config: add support for http.<url>.* settings

The credentials configuration values already support url-specific
configuration items in the form credential.<url>.*.  This patch
adds similar support for http configuration values.

The <url> value is considered a match to a url if the <url> value
is either an exact match or a prefix of the url which ends on a
path component boundary ('/').  So "https://example.com/test" will
match "https://example.com/test" and "https://example.com/test/too"
but not "https://example.com/testextra".

Longer matches take precedence over shorter matches with
environment variable settings taking precedence over all.

With this configuration:

[http]
        useragent = other-agent
        noEPSV = true
[http "https://example.com"]
        useragent = example-agent
        sslVerify = false
[http "https://example.com/path"]
        useragent = path-agent

The "https://other.example.com/" url will have useragent
"other-agent" and sslVerify will be on.

The "https://example.com/" url will have useragent
"example-agent" and sslVerify will be off.

The "https://example.com/path/sub" url will have useragent
"path-agent" and sslVerify will be off.

All three of the examples will have noEPSV enabled.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
config: improve support for http.<url>.* settings

Improve on the http.<url>.* url matching behavior by first
normalizing the urls before they are compared.

With this change, for example, the following configuration
section:

[http "https://example.com/path"]
        useragent = example-agent
        sslVerify = false

will properly match a "HTTPS://example.COM/p%61th" url which
is equivalent.

The normalization rules are based on RFC 3986 and should
result in any two equivalent urls being a match.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
tests: add new test for the url_normalize function

In order to perform sane URL matching for http.<url>.* options,
http.c normalizes URLs before performing matches.

A new test-url-normalize test program is introduced along with
a new t5200-url-normalize.sh script to run the tests.

Since the url_normalize function currently lives in http.c this
test will be skipped if NO_CURL is defined since http.c is skipped
in that case.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
config: allow http.<url>.* any user matching

Previously the <url> had to specify an exactly matching user name
and password if those were present in the url being matched against.

Now the password portion is always ignored and omitting the user
name from <url> allows it to match against any user name.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
pull: require choice between rebase/merge on non-fast-forward pull

Because it is so easy to let Git handle automatically a trivial
merge with "git pull", a person who is new to Git may not realize
that the project s/he is interacting with may prefer a "rebase"
workflow.

Add a safety valve to fail "git pull" that does not explicitly
specify what branch from which repository to integrate your history
with, when it is neither a fast-forward or "already up-to-date",
until/unless the user expressed her preference between the two ways
of integration.

This can be an irritating backward incompatible change for old
timers, but it can be a one time irritation by doing:

    git config --global pull.rebase false

once to say "I will always --merge", and they'd not even notice.

    http://thread.gmane.org/gmane.comp.version-control.git/225146/focus=225326

for a full discussion.

Helped-by: John Keeping <john@keeping.me.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff: deprecate -q option to diff-files

This reimplements the ancient "-q" option to "git diff-files" that
was inherited from "show-diff -q" in terms of "--diff-filter=d".  We
will be deprecating the "-q" option, so let's issue a warning when
we do so.

Incidentally this also tentatively fixes "git diff --no-index" to
honor "-q" and hide deletions; the use will get the same warning.

We should remove the support for "-q" in a future version but it is
not that urgent.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff: remove "diff-files -q" in a version of Git in a distant future

This was inherited from "show-diff -q" that was invented to tell
comparison between the index and the working tree to ignore only
removals in 2005.

These days, it is spelled as "--diff-filter=d".

Signed-off-by: Junio C Hamano <gitster@pobox.com>
traverse_trees(): clarify return value of the callback

The variable name "ret" sounds like the variable to be returned, but
since e6c111b4 we return error, and it is misleading.

As this variable tells us which trees in t[] array were used in the
callback function, so that this caller can know the entries in which
of the trees need advancing, "trees_used" is a better name.

Also the assignment to 0 was removed at the start of the function as
well after the "if (interesting)" block.  Those are unneeded as that
variable is set to the callback return value any time we enter the
"if (interesting)" block, so we'd overwrite old values anyway.

Signed-off-by: Stefan Beller <stefanbeller@googlemail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Cygwin 1.7 has trustable filemode

The current Cygwin 1.7 distribution on supported Windows versions provides
complete support for POSIX filemodes, so enable this by default. git as
distributed by the Cygwin project is configured this way. Cygwin 1.5
installations are less likely to have this support, so leave the old
default in place for those.

This fixes one testsuite failure:
t3300 test 17 (diff-index -M -p with mode change quotes funny filename)

Historical notes: Cygwin version 1.7 supports Windows-XP and newer, thus
dropped support for all OS variants that lack NTFS and/or the full win32
api, and since late 1.5 development, Cygwin maps POSIX modes to NTFS ACLs
by default.  Cygwin 1.5 supports OS variants that use FAT as the native
file system, and had optional methods for providing POSIX file modes on
top of FAT12/16 and NTFS, though not FAT32.  Also, support for POSIX modes
on top of FAT were dropped later in 1.5.  Thus, POSIX filemode support
is not expected by default on a Cygwin 1.5 installation, but is expected
by default on a 1.7 installation.

Signed-off-by: Mark Levedahl <mlevedahl@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Cygwin 1.7 needs compat/regex

Cygwin v1.7 uses the regex library from newlib which does not pass git's
tests, so don't use it. This fixes failures in t4018 and t4034.

Continue to use the platform supplied regex library for earlier versions.

Signed-off-by: Mark Levedahl <mlevedahl@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Cygwin 1.7 has thread-safe pread

Per http://cygwin.com/ml/cygwin/2012-07/msg00331.html , cygwin 1.7
was modified to explicitly support git's use of pread, so make this
the default. Do not affect earlier cygwin versions.

Signed-off-by: Mark Levedahl <mlevedahl@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Cygwin 1.7 supports mmap

git has shipped for years with MMAP enabled in the stock distribution,
there are no reports of problems / failures on the list relating to
this. Leave the default as-is on v1.5 due to lack of knowlege of this
working on earlier Cygwin.

Signed-off-by: Mark Levedahl <mlevedahl@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Merge branch 'jc/simple-add-must-be-a-no-op' into jch

* jc/simple-add-must-be-a-no-op:
  t2202: make sure "git add" (no args) stays a no-op
Merge branch 'mm/color-auto-default' into jch

A finishing touch to fix breakage to "add -e" caused by defaulting
ui.color to "auto".

* mm/color-auto-default:
  git add -e: Explicitly specify that patch should have no color
Merge branch 'jc/name-rev-exact-ref' into jch

Corrects the longstanding sloppiness in the implementation of
name-rev that conflated "we take commit-ish" and "differences
between tags and commits do not matter".

* jc/name-rev-exact-ref:
  describe: fix --contains when a tag is given as input
  name-rev: differentiate between tags and commits they point at
  describe: use argv-array
  name-rev: allow converting the exact object name at the tip of a ref
  name-ref: factor out name shortening logic from name_ref()
Merge branch 'tr/fd-gotcha-fixes' into jch

Two places we did not check return value (expected to be a file
descriptor) correctly.

* tr/fd-gotcha-fixes:
  run-command: dup_devnull(): guard against syscalls failing
  git_mkstemps: correctly test return value of open()
Merge branch 'jc/mailmap-case-insensitivity' into jch

The mailmap mechanism unnecessarily downcased the e-mail addresses
in the output, and also ignored the human name when it is a single
character name.

This now has become Eric Sunshine's series, even though it still is
under jc/ hierarchy.

* jc/mailmap-case-insensitivity:
  mailmap: style fixes
  mailmap: debug: avoid passing NULL to fprintf() '%s' conversion specification
  mailmap: debug: eliminate -Wformat field precision type warning
  mailmap: debug: fix malformed fprintf() format conversion specification
  mailmap: debug: fix out-of-order fprintf() arguments
  mailmap: do not downcase mailmap entries
  t4203: demonstrate loss of uppercase characters in canonical email
  mailmap: do not lose single-letter names
  t4203: demonstrate loss of single-character name in mailmap entry
Merge branch 'dw/request-pull-diag' into jch

* dw/request-pull-diag:
  request-pull: improve error message for invalid revision args
Merge branch 'mm/diff-no-patch-synonym-to-s' into jch

"git show -s" was less discoverable than it should be.

* mm/diff-no-patch-synonym-to-s:
  Documentation/git-log.txt: capitalize section names
  Documentation: move description of -s, --no-patch to diff-options.txt
  Documentation/git-show.txt: include common diff options, like git-log.txt
  diff: allow --patch & cie to override -s/--no-patch
  diff: allow --no-patch as synonym for -s
  t4000-diff-format.sh: modernize style
Merge branch 'tr/do-not-call-submodules-subprojects' into jch

* tr/do-not-call-submodules-subprojects:
  show-branch: fix description of --date-order
  apply, entry: speak of submodules instead of subprojects

# Conflicts:
# 	builtin/show-branch.c