add global --literal-pathspecs option

Git takes pathspec arguments in many places to limit the
scope of an operation. These pathspecs are treated not as
literal paths, but as glob patterns that can be fed to
fnmatch. When a user is giving a specific pattern, this is a
nice feature.

However, when programatically providing pathspecs, it can be
a nuisance. For example, to find the latest revision which
modified "$foo", one can use "git rev-list -- $foo". But if
"$foo" contains glob characters (e.g., "f*"), it will
erroneously match more entries than desired. The caller
needs to quote the characters in $foo, and even then, the
results may not be exactly the same as with a literal
pathspec. For instance, the depth checks in
match_pathspec_depth do not kick in if we match via fnmatch.

This patch introduces a global command-line option (i.e.,
one for "git" itself, not for specific commands) to turn
this behavior off. It also has a matching environment
variable, which can make it easier if you are a script or
porcelain interface that is going to issue many such
commands.

This option cannot turn off globbing for particular
pathspecs. That could eventually be done with a ":(noglob)"
magic pathspec prefix. However, that level of granularity is
more cumbersome to use for many cases, and doing ":(noglob)"
right would mean converting the whole codebase to use
"struct pathspec", as the usual "const char **pathspec"
cannot represent extra per-item flags.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-compat-util.h: do not #include <sys/param.h> by default

Earlier we allowed platforms that lack <sys/param.h> not to include
the header file from git-compat-util.h; we have included this header
file since the early days back when we used MAXPATHLEN (which we no
longer use) and also depended on it slurping ULONG_MAX (which we get
by including stdint.h or inttypes.h these days).

It turns out that we can compile our modern codebase just file
without including it on many platforms (so far, Fedora, Debian,
Ubuntu, MinGW, Mac OS X, Cygwin, HP-Nonstop, QNX and z/OS are
reported to be OK).

Let's stop including it by default, and on platforms that need it to
be included, leave "make NEEDS_SYS_PARAM_H=YesPlease" as an escape
hatch and ask them to report to us, so that we can find out about
the real dependency and fix it in a more platform agnostic way.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
Make lock local to fetch_pack

lock is only used by fetch_pack, so move it into that function.

Signed-off-by: Matt Kraai <matt.kraai@amo.abbott.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Port to QNX

Signed-off-by: Matt Kraai <matt.kraai@amo.abbott.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Merge branch 'dm/port' into jch

Will merge to 'next'.

* dm/port:
  git-compat-util.h: do not #include <sys/param.h> by default
  Generalize the inclusion of strings.h
  Detect when the passwd struct is missing pw_gecos
  Support builds when sys/param.h is missing
Merge branch 'mk/qnx' into jch

Port to QNX; we may want to rebase this on top of dm/port topic as
it also wants to use the HAVE_STRINGS_H mechanism it introduces.

Will merge to 'next'.

* mk/qnx:
  Port to QNX
  Make lock local to fetch_pack

Conflicts:
	builtin/fetch-pack.c
Merge branch 'jc/blame-no-follow' into jch

Teaches "--no-follow" option to "git blame" to disable its
whole-file rename detection.

Stalled mostly due to lack of responses.

* jc/blame-no-follow:
  blame: pay attention to --no-follow
  diff: accept --no-follow option
Merge branch 'jk/error-const-return' into jch

Help compilers' flow analysis by making it more explicit that
error() always returns -1, to reduce false "variable used
uninitialized" warnings.  Looks somewhat ugly but not too much.

Will merge to 'next'.

* jk/error-const-return:
  silence some -Wuninitialized false positives
  make error()'s constant return value more visible
Merge branch 'ap/log-mailmap' into jch

Clean up various codepaths around mailmap and teach the "log"
machinery to use it.

Will merge to 'next' after reading it over once again.

* ap/log-mailmap:
  test: Add test for --use-mailmap option
  log: Add --use-mailmap option
  pretty: Use mailmap to display username and email
  mailmap: Add mailmap structure to rev_info and pp
  mailmap: Simplify map_user() interface
  mailmap: Remove buffer length limit in map_user
  Use split_ident_line to parse author and committer

Conflicts:
	commit.h
	log-tree.c
Merge branch 'cc/no-gitk-build-dependency' into jch

Remove leftover bits from an earlier change to move gitk in its own
subdirectory.  Reimplementing the dependency tracking rules needs
to be done in gitk history separately.

* cc/no-gitk-build-dependency:
  Makefile: replace "echo 1>..." with "echo >..."
  Makefile: detect when PYTHON_PATH changes
  Makefile: remove tracking of TCLTK_PATH
Merge branch 'ss/svn-prompt' into jch

Waiting for an Ack from the area export.

* 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' into jch

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

Anybody who worked on "--graph" wants to comment?
Stalled mostly due to lack of responses.

* mk/maint-graph-infinity-loop:
  graph.c: infinite loop in git whatchanged --graph -m
Merge branch 'jc/mkstemp-more-careful-error-reporting' into jch

An earlier patch to save original arguments to mkstemp() away and
use it to report what filename we failed to create incorrectly used
the buffer munged by failing mkstemp().

* jc/mkstemp-more-careful-error-reporting:
  xmkstemp(): avoid showing truncated template more carefully
Merge branch 'jc/maint-test-portability' into jch

Minor test fixes noticed while running our tests on OpenBSD 5.2,
applicable to 'maint'.

* jc/maint-test-portability:
  t4014: fix arguments to grep
  t9502: do not assume GNU tar
  t0200: "locale" may not exist
Merge branch 'jc/test-portability' into jch

The remainder of jc/maint-test-portability, applicable to 'master'.

* jc/test-portability:
  t9020: use configured Python to run the test helper
  t3600: Avoid "cp -a", which is a GNUism
Merge branch 'jc/maint-fnmatch-old-style-definition' into jch

Update old-style function definition "int foo(bar) int bar; {}"
to "int foo(int bar) {}".

* jc/maint-fnmatch-old-style-definition:
  compat/fnmatch: update old-style definition to ANSI
Merge branch 'bc/append-signed-off-by' into jch

Expecting a re-roll after a review.

* bc/append-signed-off-by:
  Unify appending signoff in format-patch, commit and sequencer
  format-patch: update append_signoff prototype
  format-patch: stricter S-o-b detection
  t4014: more tests about appending s-o-b lines
  sequencer.c: teach append_signoff to avoid adding a duplicate newline
  sequencer.c: teach append_signoff how to detect duplicate s-o-b
  sequencer.c: always separate "(cherry picked from" from commit body
  sequencer.c: recognize "(cherry picked from ..." as part of s-o-b footer
  t/t3511: add some tests of 'cherry-pick -s' functionality
  t/test-lib-functions.sh: allow to specify the tag name to test_commit
  sequencer.c: remove broken support for rfc2822 continuation in footer
Merge branch 'wk/submodule-update-remote' into jch

The beginning of 'integrate with the tip of the remote branch, not
the commit recorded in the superproject gitlink' support.

* wk/submodule-update-remote:
  submodule add: If --branch is given, record it in .gitmodules
  submodule update: add --remote for submodule's upstream changes
  submodule: add get_submodule_config helper funtion

Conflicts:
	Documentation/git-submodule.txt
	git-submodule.sh
Merge branch 'jc/add-delete-default' into pu

"git add dir/" updated modified files and added new files, but does
not notice removed files, which may be "Huh?" to some users.  They
can of course use "git add -A dir/", but why should they?

Resurrected from graveyard, as I thought it was a worthwhile thing
to do in the longer term.

Waiting for comments.

* jc/add-delete-default:
  git add: notice removal of tracked paths by default
Merge branch 'jc/maint-name-rev' into pu

"git name-rev" names the given revision based on a ref that can be
reached in the smallest number of steps from the rev, but that is
not useful when the caller wants to know which tag is the oldest one
that contains the rev.  This teaches a new mode to the command that
uses the oldest ref among those which contain the rev.

I am not sure if this is worth it; for one thing, even with the help
from notes-cache, it seems to make the "describe --contains" even
slower. Also the command will be unusably slow for a user who does
not have a write access (hence unable to create or update the
notes-cache).

Stalled mostly due to lack of responses.

* jc/maint-name-rev:
  describe --contains: use "name-rev --algorithm=weight"
  name-rev --algorithm=weight: tests and documentation
  name-rev --algorithm=weight: cache the computed weight in notes
  name-rev --algorithm=weight: trivial optimization
  name-rev: --algorithm option
  name_rev: clarify the logic to assign a new tip-name to a commit
  name-rev: lose unnecessary typedef

Conflicts:
	builtin/name-rev.c