log --use-mailmap: optimize for cases without --author/--committer search

When we taught the commit_match() mechanism to pay attention to the
new --use-mailmap option, we started to unconditionally copy the
commit object to a temporary buffer, just in case we need the author
and committer lines updated via the mailmap mechanism, and rewrite
author and committer using the mailmap.

It turns out that this has a rather unpleasant performance
implications.  In the linux kernel repository, running

  $ git log --author='Junio C Hamano' --pretty=short >/dev/null

under /usr/bin/time, with and without --use-mailmap (the .mailmap
file is 118 entries long, the particular author does not appear in
it), cost (with warm cache):

  [without --use-mailmap]
  5.42user 0.26system 0:05.70elapsed 99%CPU (0avgtext+0avgdata 2005936maxresident)k
  0inputs+0outputs (0major+137669minor)pagefaults 0swaps

  [with --use-mailmap]
  6.47user 0.30system 0:06.78elapsed 99%CPU (0avgtext+0avgdata 2006288maxresident)k
  0inputs+0outputs (0major+137692minor)pagefaults 0swaps

which incurs about 20% overhead.  The command is doing extra work,
so the extra cost may be justified.

But it is inexcusable to pay the cost when we do not need
author/committer match.  In the same repository,

  $ git log --grep='fix menuconfig on debian lenny' --pretty=short >/dev/null

shows very similar numbers as the above:

  [without --use-mailmap]
  5.32user 0.30system 0:05.63elapsed 99%CPU (0avgtext+0avgdata 2005984maxresident)k
  0inputs+0outputs (0major+137672minor)pagefaults 0swaps

  [with --use-mailmap]
  6.64user 0.24system 0:06.89elapsed 99%CPU (0avgtext+0avgdata 2006320maxresident)k
  0inputs+0outputs (0major+137694minor)pagefaults 0swaps

The latter case is an unnecessary performance regression.  We may
want to _show_ the result with mailmap applied, but we do not have
to copy and rewrite the author/committer of all commits we try to
match if we do not query for these fields.

Trivially optimize this performace regression by limiting the
rewrites for only when we are matching with author/committer fields.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
upload-pack: only accept commits from "shallow" line

We only allow cuts at commits, not arbitrary objects. upload-pack will
fail eventually in register_shallow if a non-commit is given with a
generic error "Object %s is a %s, not a commit". Check it early and
give a more accurate error.

This should never show up in an ordinary session. It's for buggy
clients, or when the user manually edits .git/shallow.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t7900: remove test number comments

Delete the comments indicating test numbers as it causes maintenance
headaches.  "t7900.sh -i" will help us find any broken tests anyway.

Signed-off-by: David A. Greene <greened@obbligato.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/subtree: use %B for split Subject/Body

Use %B to format the commit message and body to avoid an extra newline
if a commit only has a subject line.

Signed-off-by: Techlive Zheng <techlivezheng@gmail.com>
Signed-off-by: David A. Greene <greened@obbligato.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/subtree: add --unannotate option

Teach git-subtree about --unannotate.  This option strips a prefix
from a commit message when doing a subtree split.

Signed-off-by: James Nylen <jnylen@gmail.com>
Signed-off-by: David A. Greene <greened@obbligato.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/subtree: better error handling for "add"

Check refspecs for validity before passing them on to other commands.
This lets us generate more helpful error messages.

Signed-off-by: David A. Greene <greened@obbligato.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/subtree: fix synopsis and command help

Fix the documentation of add to show that a repository can be
specified along with a commit.

Suggested by Yann Dirson <dirson@bertin.fr>.

Signed-off-by: David A. Greene <greened@obbligato.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/subtree: honor $(DESTDIR)

Teach git-subtree's Makefile to honor DESTDIR.

Signed-off-by: Adam Tkac <atkac@redhat.com>
Signed-off-by: David A. Greene <greened@obbligato.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/subtree: mkdir the manual directory if needed

Before install git-subtree documentation, make sure the manpage
directory exists.

Signed-off-by: Jesper L. Nielsen <lyager@gmail.com>
Signed-off-by: David A. Greene <greened@obbligato.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Merge branch 'jc/maint-fmt-merge-msg-no-edit-lose-credit' into jch

Originally merged to 'next' on 2013-01-02

Stop spending cycles to compute information to be placed on
commented lines in "merge --no-edit".

Will merge to 'master'.

* jc/maint-fmt-merge-msg-no-edit-lose-credit:
  merge --no-edit: do not credit people involved in the side branch
Merge branch 'er/python-version-requirements' into jch

Originally merged to 'next' on 2013-01-02

Some python scripts we ship cannot be run with old versions of the
interpreter.

Will merge to 'master'.

* er/python-version-requirements:
  Add checks to Python scripts for version dependencies.
Merge branch 'jn/less-reconfigure' into jch

Originally merged to 'next' on 2013-01-02

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

Will merge to 'master'.

* jn/less-reconfigure:
  build: do not automatically reconfigure unless configure.ac changed
Merge branch 'os/gitweb-highlight-uncaptured' into jch

Originally merged to 'next' on 2013-01-04

The code to sanitize control characters before passing it to
"highlight" filter lost known-to-be-safe control characters by
mistake.

Will merge to 'master'.

* os/gitweb-highlight-uncaptured:
  gitweb: fix error in sanitize when highlight is enabled
Merge branch 'jc/submittingpatches' into jch

Originally merged to 'next' on 2013-01-04

Streamline the document and update with a few e-mail addresses the
patches should be sent to.

Will merge to 'master'.

* jc/submittingpatches:
  SubmittingPatches: give list and maintainer addresses
  SubmittingPatches: remove overlong checklist
  SubmittingPatches: mention subsystems with dedicated repositories
  SubmittingPatches: who am I and who cares?
Merge branch 'jk/enable-test-lint-by-default' into jch

Originally merged to 'next' on 2013-01-04

We had two simple and quick tests to catch common mistakes when
writing test scripts, but they weren't run by default when running
tests.

Will merge to 'master'.

* jk/enable-test-lint-by-default:
  tests: turn on test-lint by default
Merge branch 'nd/maint-branch-desc-doc' into jch

Originally merged to 'next' on 2013-01-04

Teach various forms of "format-patch" command line to identify what
branch the patches are taken from, so that the branch description
is picked up in more cases.

Will merge to 'master'.

* nd/maint-branch-desc-doc:
  format-patch: pick up branch description when no ref is specified
  format-patch: pick up correct branch name from symbolic ref
  t4014: a few more tests on cover letter using branch description
  branch: delete branch description if it's empty
  config.txt: a few lines about branch.<name>.description
Merge branch 'jc/format-patch-reroll' into jch

Originally merged to 'next' on 2013-01-04

Teach "format-patch" to prefix v4- to its output files for the
fourth iteration of a patch series, to make it easier for the
submitter to keep separate copies for iterations.

Will merge to 'master'.

* jc/format-patch-reroll:
  format-patch: give --reroll-count a short synonym -v
  format-patch: document and test --reroll-count
  format-patch: add --reroll-count=$N option
  get_patch_filename(): split into two functions
  get_patch_filename(): drop "just-numbers" hack
  get_patch_filename(): simplify function signature
  builtin/log.c: stop using global patch_suffix
  builtin/log.c: drop redundant "numbered_files" parameter from make_cover_letter()
  builtin/log.c: drop unused "numbered" parameter from make_cover_letter()
Merge branch 'ap/merge-stop-at-prepare-commit-msg-failure' into jch

Originally merged to 'next' on 2013-01-04

"git merge" started calling prepare-commit-msg hook like "git
commit" does some time ago, but forgot to pay attention to the exit
status of the hook.  t7505 may want a general clean-up but that is
a different topic.

Will merge to 'master'.

* ap/merge-stop-at-prepare-commit-msg-failure:
  merge: Honor prepare-commit-msg return code
Merge branch 'aw/rebase-am-failure-detection' into jch

Originally merged to 'next' on 2013-01-02

Save output from format-patch command in a temporary file, just in
case it aborts, to give a better failure-case behaviour.

* aw/rebase-am-failure-detection:
  rebase: Handle cases where format-patch fails
Merge branch 'mz/pick-unborn' into jch

Originally merged to 'next' on 2013-01-02

Allows "git cherry-pick $commit" when you do not have any history
behind HEAD yet.

* mz/pick-unborn:
  learn to pick/revert into unborn branch
  tests: move test_cmp_rev to test-lib-functions