push: fix segfault when HEAD points nowhere

After a push of a branch other than the current branch fails in
a no-ff error and if you are still on an unborn branch, the code
recently added to report the failure dereferenced a null pointer
while checking the name of the current branch.

Signed-off-by: Fraser Tweedale <frase@frase.id.au>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
docs: clarify git-branch --list behavior

It was not clear from the "description" section of
git-branch(1) that using a <pattern> meant that you _had_ to
use the --list option. Let's clarify that, and while we're
at it, reword some clunky and ambiguous sentences.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
branch: let branch filters imply --list

Currently, a branch filter like `--contains`, `--merged`, or
`--no-merged` is ignored when we are not in listing mode.
For example:

  git branch --contains=foo bar

will create the branch "bar" from the current HEAD, ignoring
the `--contains` argument entirely. This is not very
helpful. There are two reasonable behaviors for git here:

  1. Flag an error; the arguments do not make sense.

  2. Implicitly go into `--list` mode

This patch chooses the latter, as it is more convenient, and
there should not be any ambiguity with attempting to create
a branch; using `--contains` and not wanting to list is
nonsensical.

That leaves the case where an explicit modification option
like `-d` is given.  We already catch the case where
`--list` is given alongside `-d` and flag an error. With
this patch, we will also catch the use of `--contains` and
other filter options alongside `-d`.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Merge branch 'jc/custom-comment-char' into jch

An illustration to show codepaths that need to be touched to change
the hint lines in the edited text to begin with something other
than '#'.

This is half my work and half by Ralf Thielow.  There may still be
leftover '#' lurking around, though.  My "git grep" says C code
should be already fine, but git-rebase--interactive.sh could be
converted (it should not matter, as the file is not really a
free-form text).

Will merge to 'master'.

* jc/custom-comment-char:
  Allow custom "comment char"
Merge branch 'jc/push-2.0-default-to-simple' into jch

Will cook in 'next' until Git 2.0 ;-).

* jc/push-2.0-default-to-simple:
  t5570: do not assume the "matching" push is the default
  t5551: do not assume the "matching" push is the default
  t5550: do not assume the "matching" push is the default
  doc: push.default is no longer "matching"
  push: switch default from "matching" to "simple"
  t9401: do not assume the "matching" push is the default
  t9400: do not assume the "matching" push is the default
  t7406: do not assume the "matching" push is the default
  t5531: do not assume the "matching" push is the default
  t5519: do not assume the "matching" push is the default
  t5517: do not assume the "matching" push is the default
  t5516: do not assume the "matching" push is the default
  t5505: do not assume the "matching" push is the default
  t5404: do not assume the "matching" push is the default

Conflicts:
	builtin/push.c
Merge branch 'nd/fetch-depth-is-broken' into jch

"git fetch --depth" was broken in at least three ways.  The
resulting history was deeper than specified by one commit, it was
unclear how to wipe the shallowness of the repository with the
command, and documentation was misleading.

Will merge to 'master'.

* nd/fetch-depth-is-broken:
  fetch: elaborate --depth action
  upload-pack: fix off-by-one depth calculation in shallow clone
  fetch: add --unshallow for turning shallow repo into complete one
Merge branch 'jc/no-git-config-in-clone' into jch

We stopped paying attention to $GIT_CONFIG environment that points
at a single configuration file from any command other than "git config"
quite a while ago, but "git clone" internally set, exported, and
then unexported the variable during its operation unnecessarily.

Will merge to 'master'.

* jc/no-git-config-in-clone:
  clone: do not export and unexport GIT_CONFIG
Merge branch 'jk/config-parsing-cleanup' into jch

Configuration parsing for tar.* configuration variables were
broken. Introduce a new config-keyname parser API to make the
callers much less error prone.

Will merge to 'master'.

* jk/config-parsing-cleanup:
  reflog: use parse_config_key in config callback
  help: use parse_config_key for man config
  submodule: simplify memory handling in config parsing
  submodule: use parse_config_key when parsing config
  userdiff: drop parse_driver function
  convert some config callbacks to parse_config_key
  archive-tar: use parse_config_key when parsing config
  config: add helper function for parsing key names
Merge branch 'as/test-cleanup' into jch

Will merge to 'master'.

* as/test-cleanup:
  t7102 (reset): don't hardcode SHA-1 in expected outputs
Merge branch 'jc/do-not-let-random-file-interfere-with-completion-tests' into jch

Scripts to test bash completion was inherently flaky as it was
affected by whatever random things the user may have on $PATH.

Will merge to 'master'.

* jc/do-not-let-random-file-interfere-with-completion-tests:
  t9902: protect test from stray build artifacts
Merge branch 'jc/push-reject-reasons' into jch

Improve error and advice messages given locally when "git push"
refuses when it cannot compute fast-forwardness by separating these
cases from the normal "not a fast-forward; merge first and push
again" case.

Will merge to 'master'.

* jc/push-reject-reasons:
  push: finishing touches to explain REJECT_ALREADY_EXISTS better
  push: introduce REJECT_FETCH_FIRST and REJECT_NEEDS_FORCE
  push: further simplify the logic to assign rejection reason
  push: further clean up fields of "struct ref"
Merge branch 'jk/cvsimport-does-not-work-with-cvsps3' into jch

Warn people that other tools are more recommendable over
cvsimport+cvsps2 combo when doing a one-shot import, and cvsimport
will not work with cvsps3.

Will merge to 'master'.

* jk/cvsimport-does-not-work-with-cvsps3:
  git-cvsimport.txt: cvsps-2 is deprecated
Merge branch 'jn/do-not-drop-username-when-reading-from-etc-mailname' into jch

We used to stuff "user@" and then append what we read from
/etc/mailname to come up with a default e-mail ident, but a bug
lost the "user@" part.  This is to fix it.

Will merge to 'master'.

* jn/do-not-drop-username-when-reading-from-etc-mailname:
  ident: do not drop username when reading from /etc/mailname
Merge branch 'mm/add-u-A-sans-pathspec' into jch

Forbid "git add -u" and "git add -A" without pathspec run from a
subdirectory, to train people to type "." (or ":/") to make the
choice of default does not matter.

Will merge to 'master'.

* mm/add-u-A-sans-pathspec:
  add: warn when -u or -A is used without pathspec
Merge branch 'jk/remote-helpers-in-python-3' into jch

Prepare remote-helper test written in Python to be run with Python3.

Will merge to 'master'.

* jk/remote-helpers-in-python-3:
  git_remote_helpers: remove GIT-PYTHON-VERSION upon "clean"
  git-remote-testpy: fix path hashing on Python 3
  git-remote-testpy: call print as a function
  git-remote-testpy: don't do unbuffered text I/O
  git-remote-testpy: hash bytes explicitly
  svn-fe: allow svnrdump_sim.py to run with Python 3
  git_remote_helpers: use 2to3 if building with Python 3
  git_remote_helpers: force rebuild if python version changes
  git_remote_helpers: fix input when running under Python 3
  git_remote_helpers: allow building with Python 3
Merge branch 'jc/remove-treesame-parent-in-simplify-merges' into jch

The --simplify-merges logic did not cull irrelevant parents from a
merge that is otherwise not interesting with respect to the paths
we are following.

This touches a fairly core part of the revision traversal
infrastructure; even though I think this change is correct, please
report immediately if you find any unintended side effect.

Will merge to 'next'.

* jc/remove-treesame-parent-in-simplify-merges:
  simplify-merges: drop merge from irrelevant side branch

Conflicts:
	revision.c
Merge branch 'jk/gc-auto-after-fetch' into jch

This is to resolve merge conflicts early for the same topic to
recent codebase.

Will merge to 'master'.

* jk/gc-auto-after-fetch:
  fetch-pack: avoid repeatedly re-scanning pack directory
  fetch: run gc --auto after fetching
Merge branch 'jk/read-commit-buffer-data-after-free' into jch

Clarify the ownership rule for commit->buffer field, which some
callers incorrectly accessed without making sure it is populated.

Will merge to 'master'.

* jk/read-commit-buffer-data-after-free:
  logmsg_reencode: lazily load missing commit buffers
  logmsg_reencode: never return NULL
  commit: drop useless xstrdup of commit message
Merge branch 'bc/git-p4-for-python-2.4' into jch

With small updates to remove dependency on newer features of
Python, keep git-p4 usable with older Python.

Will merge to 'master'.

* bc/git-p4-for-python-2.4:
  INSTALL: git-p4 does not support Python 3
  git-p4.py: support Python 2.4
  git-p4.py: support Python 2.5
Merge branch 'nd/edit-branch-desc-while-detached' into jch

Attempt to "branch --edit-description" an existing branch, while
being on a detached HEAD, errored out.

Will merge to 'master'.

* nd/edit-branch-desc-while-detached:
  branch: no detached HEAD check when editing another branch's description