for-each-ref: introduce %(upstream:track[short])

Introduce %(upstream:track) to display "[ahead M, behind N]" and
%(upstream:trackshort) to display "=", ">", "<", or "<>"
appropriately (inspired by contrib/completion/git-prompt.sh).

Now you can use the following format in for-each-ref:

  %(refname:short)%(upstream:trackshort)

to display refs with terse tracking information.

Note that :track and :trackshort only work with "upstream", and error
out when used with anything else.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
for-each-ref: introduce %(color:...) for color

Enhance 'git for-each-ref' with color formatting options.  You can now
use the following format in for-each-ref:

  %(color:green)%(refname:short)%(color:reset)

where color names are described in color.branch.*.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
for-each-ref: avoid color leakage

To make sure that an invocation like the following doesn't leak color,

  $ git for-each-ref --format='%(subject)%(color:green)'

auto-reset at the end of the format string when the last color token
seen in the format string isn't a color-reset.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
commit -v: strip diffs and submodule shortlogs from the commit message

When using the '-v' option of "git commit", the diff added to the commit
message temporarily for editing is stripped off after the user exited the
editor by searching for "\ndiff --git " and truncating the commmit message
there if it is found.

But this approach has two problems.

 - when the commit message itself contains a line starting with
   "diff --git" it will be truncated there prematurely; and

  - when the "diff.submodule" setting is set to "log", the diff may
    start with "Submodule <hash1>..<hash2>", which will be left in
    the commit message while it shouldn't.

Fix that by introducing a special scissor separator line starting
with the comment character '#' followed by a line describing what it
is for.  The scissor line - which will not be translated - is used
to reliably detect the start of the diff so it can be chopped off
from the commit message, no matter what the user enters there.

Turn a known test failure fixed by this change into a successful
test and add another one for a diff starting with a submodule log.

Reported-by: Ari Pollak <ari@debian.org>
Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Merge branch 'jk/robustify-parse-commit' into jch

* jk/robustify-parse-commit:
  checkout: do not die when leaving broken detached HEAD
  use parse_commit_or_die instead of custom message
  use parse_commit_or_die instead of segfaulting
  assume parse_commit checks for NULL commit
  assume parse_commit checks commit->object.parsed
  log_tree_diff: die when we fail to parse a commit
Merge branch 'jh/loose-object-dirs-creation-race' into jch

* jh/loose-object-dirs-creation-race:
  sha1_file.c:create_tmpfile(): Fix race when creating loose object dirs
Merge branch 'jk/replace-perl-in-built-scripts' into jch

Can wait in 'next'.

* jk/replace-perl-in-built-scripts:
  use @@PERL@@ in built scripts
Merge branch 'jc/merge-base-reflog' into jch

Code the logic in "pull --rebase" that figures out a fork point
from reflog entries in C.

* jc/merge-base-reflog:
  merge-base: teach "--fork-point" mode
  merge-base: use OPT_CMDMODE and clarify the command line parsing
Merge branch 'bc/http-100-continue' into jch

Issue "100 Continue" responses to help use of GSS-Negotiate
authentication scheme over HTTP transport when needed.

* bc/http-100-continue:
  remote-curl: fix large pushes with GSSAPI
  remote-curl: pass curl slot_results back through run_slot
  http: return curl's AUTHAVAIL via slot_results

# Conflicts:
# 	remote-curl.c
Merge branch 'nv/parseopt-opt-arg' into jch

Enhance "rev-parse --parseopt" mode to help parsing options with
an optional parameter.

* nv/parseopt-opt-arg:
  rev-parse --parseopt: add the --stuck-long mode
  Use the word 'stuck' instead of 'sticked'
Merge branch 'jc/ref-excludes' into jch

People often wished a way to tell "git log --branches" (and "git
log --remotes --not --branches") to exclude some local branches
from the expansion of "--branches" (similarly for "--tags", "--all"
and "--glob=<pattern>").  Now they have one.

Can wait in 'next'.

* jc/ref-excludes:
  rev-parse: introduce --exclude=<glob> to tame wildcards
  rev-list --exclude: export add/clear-ref-exclusion and ref-excluded API
  rev-list --exclude: tests
  document --exclude option
  revision: introduce --exclude=<glob> to tame wildcards

# Conflicts:
# 	Documentation/git-rev-parse.txt
# 	builtin/rev-parse.c
Merge branch 'jk/two-way-merge-corner-case-fix' into jch

Fix a rather longstanding corner-case bug in twoway "reset to
there" merge, which is most often seen in "git am --abort".

* jk/two-way-merge-corner-case-fix:
  t1005: add test for "read-tree --reset -u A B"
  t1005: reindent
  unpack-trees: fix "read-tree -u --reset A B" with conflicted index
Merge branch 'cc/remote-remove-redundant-postfixcmp' into jch

Minor code clean-up.

Can wait in 'next'.

* cc/remote-remove-redundant-postfixcmp:
  Rename suffixcmp() to has_suffix() and invert its result
  builtin/remote: remove postfixcmp() and use suffixcmp() instead
Merge branch 'th/reflog-annotated-tag' into jch

"git log -g $annotated_tag", when there is no reflog history, should
have produced a single output entry (i.e. the ref creation event),
but instead showed the history leading to the tag.

Broken at the design level.  Any reflog entry that points at a non
commit needs to be handled with new code that does not exist yet,
and lifting the "this code handles only commits" without adding
such code does not solve anything.

* th/reflog-annotated-tag:
  reflog: handle lightweight and annotated tags equally
Merge branch 'mh/fetch-tags-in-addition-to-normal-refs' into jch

The "-tags" option to "git fetch" used to be literally a synonym to
a "refs/tags/*:refs/tags/*" refspec, which meant that (1) as an
explicit refspec given from the command line, it silenced the lazy
"git fetch" default that is configured, and (2) also as an explicit
refspec given from the command line, it interacted with "--prune"
to remove any tag that the remote we are fetching from does not
have.

This demotes it to an option; with it, we fetch all tags in
addition to what would be fetched without the option, and it does
not interact with the decision "--prune" makes to see what
remote-tracking refs the local has are missing the remote
counterpart.

* mh/fetch-tags-in-addition-to-normal-refs: (23 commits)
  fetch: improve the error messages emitted for conflicting refspecs
  handle_duplicate(): mark error message for translation
  ref_remote_duplicates(): extract a function handle_duplicate()
  ref_remove_duplicates(): simplify loop logic
  t5536: new test of refspec conflicts when fetching
  ref_remove_duplicates(): avoid redundant bisection
  git-fetch.txt: improve description of tag auto-following
  fetch-options.txt: simplify ifdef/ifndef/endif usage
  fetch, remote: properly convey --no-prune options to subprocesses
  builtin/remote.c:update(): use struct argv_array
  builtin/remote.c: reorder function definitions
  query_refspecs(): move some constants out of the loop
  fetch --prune: prune only based on explicit refspecs
  fetch --tags: fetch tags *in addition to* other stuff
  fetch: only opportunistically update references based on command line
  get_expanded_map(): avoid memory leak
  get_expanded_map(): add docstring
  builtin/fetch.c: reorder function definitions
  get_ref_map(): rename local variables
  api-remote.txt: correct section "struct refspec"
  ...

# Conflicts:
# 	builtin/fetch.c
# 	builtin/remote.c
Merge branch 'sb/sha1-loose-object-info-check-existence' into jch

"git cat-file --batch-check=ok" did not check the existence of the
named object.

* sb/sha1-loose-object-info-check-existence:
  sha1_loose_object_info(): do not return success on missing object
Merge branch 'tb/doc-fetch-pack-url' into jch

Can wait in 'next'.

* tb/doc-fetch-pack-url:
  git-fetch-pack uses URLs like git-fetch
Merge branch 'jn/mediawiki-makefile-updates' into jch

Build and Installation procedure clean-up.

Can wait in 'next'.

* jn/mediawiki-makefile-updates:
  git-remote-mediawiki build: handle DESTDIR/INSTLIBDIR with whitespace
  git-remote-mediawiki build: make 'install' command configurable
  git-remote-mediawiki: honor DESTDIR in "make install"
  git-remote-mediawiki: do not remove installed files in "clean" target
Merge branch 'kb/doc-exclude-directory-semantics' into jch

Can wait in 'next'.

* kb/doc-exclude-directory-semantics:
  gitignore.txt: clarify recursive nature of excluded directories
Merge branch 'nd/wt-status-align-i18n' into jch

An attempt to automatically align the names in the "git status"
output, taking the display width of (translated) section labels
into account.

Can wait in 'next'.

* nd/wt-status-align-i18n:
  wt-status: take the alignment burden off translators