wildmatch: fix "**" special case

"**" is adjusted to only be effective when surrounded by slashes, in
40bbee0 (wildmatch: adjust "**" behavior - 2012-10-15). Except that
the commit did it wrong:

1. when it checks for "the preceding slash unless ** is at the
   beginning", it compares to wrong pointer. It should have compared
   to the beginning of the pattern, not the text.

2. prev_p points to the character before "**", not the first "*". The
   correct comparison must be "prev_p < pattern" or
   "prev_p + 1 == pattern", not "prev_p == pattern".

3. The pattern must be surrounded by slashes unless it's at the
   beginning or the end of the pattern. We do two checks: one for the
   preceding slash and one the trailing slash. Both checks must be
   met. The use of "||" is wrong.

This patch fixes all above.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
compat/fnmatch: respect NO_FNMATCH* even on glibc

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
wildmatch: replace variable 'special' with better named ones

'special' is too generic and is used for two different purposes.
Replace it with 'match_slash' to indicate "**" pattern and 'negated'
for "[!...]" and "[^...]".

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Merge branch 'nd/wildmatch' into next

Allows pathname patterns in .gitignore and .gitattributes files
with double-asterisks "foo/**/bar" to match any number of directory
hierarchies.

* nd/wildmatch:
  wildmatch: replace variable 'special' with better named ones
  compat/fnmatch: respect NO_FNMATCH* even on glibc
  wildmatch: fix "**" special case
build: do not automatically reconfigure unless configure.ac changed

Starting with v1.7.12-rc0~4^2 (build: reconfigure automatically if
configure.ac changes, 2012-07-19), "config.status --recheck" is
automatically run every time the "configure" script changes.  In
particular, that means the configuration procedure repeats whenever
the version number changes (since the configure script changes to
support "./configure --version" and "./configure --help"), making
bisecting painfully slow.

The intent was to make the reconfiguration process only trigger for
changes to configure.ac's logic.  Tweak the Makefile rule to match
that intent by depending on configure.ac instead of configure.

Reported-by: Martin von Zweigbergk <martinvonz@gmail.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Reviewed-by: Jeff King <peff@peff.net>
Reviewed-by: Stefano Lattarini <stefano.lattarini@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Merge branch 'mh/ceiling'

An element on GIT_CEILING_DIRECTORIES list that does not name the
real path to a directory (i.e. a symbolic link) could have caused
the GIT_DIR discovery logic to escape the ceiling.

* mh/ceiling:
  string_list_longest_prefix(): remove function
  setup_git_directory_gently_1(): resolve symlinks in ceiling paths
  longest_ancestor_length(): require prefix list entries to be normalized
  longest_ancestor_length(): take a string_list argument for prefixes
  longest_ancestor_length(): use string_list_split()
  Introduce new function real_path_if_valid()
  real_path_internal(): add comment explaining use of cwd
  Introduce new static function real_path_internal()
Merge branch 'jc/maint-test-portability'

t4014, t9502 and t0200 tests had various portability issues that
broke on OpenBSD.

* jc/maint-test-portability:
  t4014: fix arguments to grep
  t9502: do not assume GNU tar
  t0200: "locale" may not exist
Merge branch 'jc/test-cvs-no-init-in-existing-dir'

t9200 runs "cvs init" on a directory that already exists, but a
platform can configure this fail for the current user (e.g. you need
to be in the cvsadmin group on NetBSD 6.0).

* jc/test-cvs-no-init-in-existing-dir:
  t9200: let "cvs init" create the test repository
Merge branch 'jc/mkstemp-more-careful-error-reporting'

After failing to create a temporary file using mkstemp(), failing
pathname was not reported correctly on some platforms.

* jc/mkstemp-more-careful-error-reporting:
  xmkstemp(): avoid showing truncated template more carefully
Merge branch 'ss/svn-prompt'

The way "git svn" asked for password using SSH_ASKPASS and
GIT_ASKPASS was not in line with the rest of the system.

* ss/svn-prompt:
  git-svn, perl/Git.pm: extend and use Git->prompt method for querying users
  perl/Git.pm: Honor SSH_ASKPASS as fallback if GIT_ASKPASS is not set
  git-svn, perl/Git.pm: add central method for prompting passwords
Merge branch 'mk/maint-graph-infinity-loop'

The --graph code fell into infinite loop when asked to do what the
code did not expect.

* mk/maint-graph-infinity-loop:
  graph.c: infinite loop in git whatchanged --graph -m
Merge branch 'rb/http-cert-cred-no-username-prompt'

http transport was wrong to ask for the username when the
authentication is done by certificate identity.

* rb/http-cert-cred-no-username-prompt:
  http.c: Avoid username prompt for certifcate credentials
Merge branch 'jk/repack-ref-racefix'

"git pack-refs" that ran in parallel to another process that created
new refs had a nasty race.

* jk/repack-ref-racefix:
  refs: do not use cached refs in repack_without_ref
Merge branch 'nd/invalidate-i-t-a-cache-tree'

After "git add -N" and then writing a tree object out of the
index, the cache-tree data structure got corrupted.

* nd/invalidate-i-t-a-cache-tree:
  cache-tree: invalidate i-t-a paths after generating trees
  cache-tree: fix writing cache-tree when CE_REMOVE is present
  cache-tree: replace "for" loops in update_one with "while" loops
  cache-tree: remove dead i-t-a code in verify_cache()
Merge branch 'md/gitweb-sort-by-age'

"gitweb", when sorting by age to show repositories with new
activities first, used to sort repositories with absolutely nothing
in it early, which was not very useful.

* md/gitweb-sort-by-age:
  gitweb: Sort projects with undefined ages last
Merge branch 'sp/shortlog-missing-lf'

When a line to be wrapped has a solid run of non space characters
whose length exactly is the wrap width, "git shortlog -w" failed to
add a newline after such a line.

* sp/shortlog-missing-lf:
  strbuf_add_wrapped*(): Remove unused return value
  shortlog: fix wrapping lines of wraplen
Merge branch 'jc/maint-fbsd-sh-ifs-workaround'

Some shells do not behave correctly when IFS is unset; work it
around by explicitly setting it to the default value.

* jc/maint-fbsd-sh-ifs-workaround:
  sh-setup: work around "unset IFS" bug in some shells
Merge branch 'jc/test-portability'

* jc/test-portability:
  t9020: use configured Python to run the test helper
  t3600: Avoid "cp -a", which is a GNUism
Start 1.8.2 cycle

Various fixes that have been cooking in 'next' have been merged. All
of them should go to 'maint' for 1.8.1.1 later.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
Merge branch 'jn/less-reconfigure' into next

When autoconf is used, any build on a different commit always ran
"config.status --recheck" even when unnecessary.

* jn/less-reconfigure:
  build: do not automatically reconfigure unless configure.ac changed