git
7 years agoMerge branch 'cc/apply-am'
Junio C Hamano [Mon, 19 Sep 2016 20:47:17 +0000 (13:47 -0700)] 
Merge branch 'cc/apply-am'

"git am" has been taught to make an internal call to "git apply"'s
innards without spawning the latter as a separate process.

* cc/apply-am: (41 commits)
  builtin/am: use apply API in run_apply()
  apply: learn to use a different index file
  apply: pass apply state to build_fake_ancestor()
  apply: refactor `git apply` option parsing
  apply: change error_routine when silent
  usage: add get_error_routine() and get_warn_routine()
  usage: add set_warn_routine()
  apply: don't print on stdout in verbosity_silent mode
  apply: make it possible to silently apply
  apply: use error_errno() where possible
  apply: make some parsing functions static again
  apply: move libified code from builtin/apply.c to apply.{c,h}
  apply: rename and move opt constants to apply.h
  builtin/apply: rename option parsing functions
  builtin/apply: make create_one_file() return -1 on error
  builtin/apply: make try_create_file() return -1 on error
  builtin/apply: make write_out_results() return -1 on error
  builtin/apply: make write_out_one_result() return -1 on error
  builtin/apply: make create_file() return -1 on error
  builtin/apply: make add_index_file() return -1 on error
  ...

7 years agoSecond batch for 2.11
Junio C Hamano [Thu, 15 Sep 2016 21:13:06 +0000 (14:13 -0700)] 
Second batch for 2.11

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMerge branch 'js/git-gui-commit-gpgsign'
Junio C Hamano [Thu, 15 Sep 2016 21:11:16 +0000 (14:11 -0700)] 
Merge branch 'js/git-gui-commit-gpgsign'

"git commit-tree" stopped reading commit.gpgsign configuration
variable that was meant for Porcelain "git commit" in Git 2.9; we
forgot to update "git gui" to look at the configuration to match
this change.

* js/git-gui-commit-gpgsign:
  git-gui: respect commit.gpgsign again

7 years agoMerge branch 'js/sequencer-wo-die'
Junio C Hamano [Thu, 15 Sep 2016 21:11:16 +0000 (14:11 -0700)] 
Merge branch 'js/sequencer-wo-die'

Lifts calls to exit(2) and die() higher in the callchain in
sequencer.c files so that more helper functions in it can be used
by callers that want to handle error conditions themselves.

* js/sequencer-wo-die:
  sequencer: ensure to release the lock when we could not read the index
  sequencer: lib'ify checkout_fast_forward()
  sequencer: lib'ify fast_forward_to()
  sequencer: lib'ify save_opts()
  sequencer: lib'ify save_todo()
  sequencer: lib'ify save_head()
  sequencer: lib'ify create_seq_dir()
  sequencer: lib'ify read_populate_opts()
  sequencer: lib'ify read_populate_todo()
  sequencer: lib'ify read_and_refresh_cache()
  sequencer: lib'ify prepare_revs()
  sequencer: lib'ify walk_revs_populate_todo()
  sequencer: lib'ify do_pick_commit()
  sequencer: lib'ify do_recursive_merge()
  sequencer: lib'ify write_message()
  sequencer: do not die() in do_pick_commit()
  sequencer: lib'ify sequencer_pick_revisions()

7 years agoMerge branch 'sb/diff-cleanup'
Junio C Hamano [Thu, 15 Sep 2016 21:11:15 +0000 (14:11 -0700)] 
Merge branch 'sb/diff-cleanup'

Code cleanup.

* sb/diff-cleanup:
  diff: remove dead code
  diff: omit found pointer from emit_callback
  diff.c: use diff_options directly

7 years agoMerge branch 'jk/fix-remote-curl-url-wo-proto'
Junio C Hamano [Thu, 15 Sep 2016 21:11:15 +0000 (14:11 -0700)] 
Merge branch 'jk/fix-remote-curl-url-wo-proto'

"git fetch http::/site/path" did not die correctly and segfaulted
instead.

* jk/fix-remote-curl-url-wo-proto:
  remote-curl: handle URLs without protocol

7 years agoMerge branch 'ah/misc-message-fixes'
Junio C Hamano [Thu, 15 Sep 2016 21:11:15 +0000 (14:11 -0700)] 
Merge branch 'ah/misc-message-fixes'

Message cleanup.

* ah/misc-message-fixes:
  unpack-trees: do not capitalize "working"
  git-merge-octopus: do not capitalize "octopus"
  git-rebase--interactive: fix English grammar
  cat-file: put spaces around pipes in usage string
  am: put spaces around pipe in usage string

7 years agoMerge branch 'sy/git-gui-i18n-ja'
Junio C Hamano [Thu, 15 Sep 2016 21:11:14 +0000 (14:11 -0700)] 
Merge branch 'sy/git-gui-i18n-ja'

Update Japanese translation for "git-gui".

* sy/git-gui-i18n-ja:
  git-gui: update Japanese information
  git-gui: update Japanese translation
  git-gui: add Japanese language code
  git-gui: apply po template to Japanese translation
  git-gui: consistently use the same word for "blame" in Japanese
  git-gui: consistently use the same word for "remote" in Japanese

7 years agoMerge branch 'jk/pack-tag-of-tag'
Junio C Hamano [Thu, 15 Sep 2016 21:11:14 +0000 (14:11 -0700)] 
Merge branch 'jk/pack-tag-of-tag'

"git pack-objects --include-tag" was taught that when we know that
we are sending an object C, we want a tag B that directly points at
C but also a tag A that points at the tag B.  We used to miss the
intermediate tag B in some cases.

* jk/pack-tag-of-tag:
  pack-objects: walk tag chains for --include-tag
  t5305: simplify packname handling
  t5305: use "git -C"
  t5305: drop "dry-run" of unpack-objects
  t5305: move cleanup into test block

7 years agoSync with maint
Junio C Hamano [Mon, 12 Sep 2016 22:35:14 +0000 (15:35 -0700)] 
Sync with maint

* maint:
  l10n: zh_CN: review for git v2.10.0 l10n
  l10n: zh_CN: fixed some typos for git 2.10.0
  l10n: pt_PT: update Portuguese repository info
  l10n: pt_PT: update Portuguese translation

7 years agoFirst batch for 2.11
Junio C Hamano [Mon, 12 Sep 2016 22:35:05 +0000 (15:35 -0700)] 
First batch for 2.11

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMerge branch 'sb/transport-report-missing-submodule-on-stderr'
Junio C Hamano [Mon, 12 Sep 2016 22:34:38 +0000 (15:34 -0700)] 
Merge branch 'sb/transport-report-missing-submodule-on-stderr'

Message cleanup.

* sb/transport-report-missing-submodule-on-stderr:
  transport: report missing submodule pushes consistently on stderr

7 years agoMerge branch 'ep/use-git-trace-curl-in-tests'
Junio C Hamano [Mon, 12 Sep 2016 22:34:38 +0000 (15:34 -0700)] 
Merge branch 'ep/use-git-trace-curl-in-tests'

Update a few tests that used to use GIT_CURL_VERBOSE to use the
newer GIT_TRACE_CURL.

* ep/use-git-trace-curl-in-tests:
  t5551-http-fetch-smart.sh: use the GIT_TRACE_CURL environment var
  t5550-http-fetch-dumb.sh: use the GIT_TRACE_CURL environment var
  test-lib.sh: preserve GIT_TRACE_CURL from the environment
  t5541-http-push-smart.sh: use the GIT_TRACE_CURL environment var

7 years agoMerge branch 'sb/xdiff-remove-unused-static-decl'
Junio C Hamano [Mon, 12 Sep 2016 22:34:38 +0000 (15:34 -0700)] 
Merge branch 'sb/xdiff-remove-unused-static-decl'

Code cleanup.

* sb/xdiff-remove-unused-static-decl:
  xdiff: remove unneeded declarations

7 years agoMerge branch 'js/t6026-clean-up'
Junio C Hamano [Mon, 12 Sep 2016 22:34:37 +0000 (15:34 -0700)] 
Merge branch 'js/t6026-clean-up'

A test spawned a short-lived background process, which sometimes
prevented the test directory from getting removed at the end of the
script on some platforms.

* js/t6026-clean-up:
  t6026-merge-attr: clean up background process at end of test case

7 years agoMerge branch 'js/t9903-chaining'
Junio C Hamano [Mon, 12 Sep 2016 22:34:37 +0000 (15:34 -0700)] 
Merge branch 'js/t9903-chaining'

* js/t9903-chaining:
  t9903: fix broken && chain

7 years agoMerge branch 'rs/hex2chr'
Junio C Hamano [Mon, 12 Sep 2016 22:34:36 +0000 (15:34 -0700)] 
Merge branch 'rs/hex2chr'

* rs/hex2chr:
  introduce hex2chr() for converting two hexadecimal digits to a character

7 years agoMerge branch 'rs/compat-strdup'
Junio C Hamano [Mon, 12 Sep 2016 22:34:36 +0000 (15:34 -0700)] 
Merge branch 'rs/compat-strdup'

* rs/compat-strdup:
  compat: move strdup(3) replacement to its own file

7 years agoMerge branch 'jc/forbid-symbolic-ref-d-HEAD'
Junio C Hamano [Mon, 12 Sep 2016 22:34:35 +0000 (15:34 -0700)] 
Merge branch 'jc/forbid-symbolic-ref-d-HEAD'

"git symbolic-ref -d HEAD" happily removes the symbolic ref, but
the resulting repository becomes an invalid one.  Teach the command
to forbid removal of HEAD.

* jc/forbid-symbolic-ref-d-HEAD:
  symbolic-ref -d: do not allow removal of HEAD

7 years agoMerge branch 'jc/submodule-anchor-git-dir'
Junio C Hamano [Mon, 12 Sep 2016 22:34:34 +0000 (15:34 -0700)] 
Merge branch 'jc/submodule-anchor-git-dir'

Having a submodule whose ".git" repository is somehow corrupt
caused a few commands that recurse into submodules loop forever.

* jc/submodule-anchor-git-dir:
  submodule: avoid auto-discovery in prepare_submodule_repo_env()

7 years agoMerge branch 'jk/squelch-false-warning-from-gcc-o3'
Junio C Hamano [Mon, 12 Sep 2016 22:34:33 +0000 (15:34 -0700)] 
Merge branch 'jk/squelch-false-warning-from-gcc-o3'

* jk/squelch-false-warning-from-gcc-o3:
  color_parse_mem: initialize "struct color" temporary
  error_errno: use constant return similar to error()

7 years agoMerge branch 'jk/test-lib-drop-pid-from-results'
Junio C Hamano [Mon, 12 Sep 2016 22:34:33 +0000 (15:34 -0700)] 
Merge branch 'jk/test-lib-drop-pid-from-results'

The test framework left the number of tests and success/failure
count in the t/test-results directory, keyed by the name of the
test script plus the process ID.  The latter however turned out not
to serve any useful purpose.  The process ID part of the filename
has been removed.

* jk/test-lib-drop-pid-from-results:
  test-lib: drop PID from test-results/*.count

7 years agoMerge branch 'jc/am-read-author-file'
Junio C Hamano [Mon, 12 Sep 2016 22:34:32 +0000 (15:34 -0700)] 
Merge branch 'jc/am-read-author-file'

Extract a small helper out of the function that reads the authors
script file "git am" internally uses.

* jc/am-read-author-file:
  am: refactor read_author_script()

7 years agoMerge branch 'jk/diff-submodule-diff-inline'
Junio C Hamano [Mon, 12 Sep 2016 22:34:31 +0000 (15:34 -0700)] 
Merge branch 'jk/diff-submodule-diff-inline'

The "git diff --submodule={short,log}" mechanism has been enhanced
to allow "--submodule=diff" to show the patch between the submodule
commits bound to the superproject.

* jk/diff-submodule-diff-inline:
  diff: teach diff to display submodule difference with an inline diff
  submodule: refactor show_submodule_summary with helper function
  submodule: convert show_submodule_summary to use struct object_id *
  allow do_submodule_path to work even if submodule isn't checked out
  diff: prepare for additional submodule formats
  graph: add support for --line-prefix on all graph-aware output
  diff.c: remove output_prefix_length field
  cache: add empty_tree_oid object and helper function

7 years agoMerge tag 'l10n-2.10.0-rnd2.3' of git://github.com/git-l10n/git-po into maint
Junio C Hamano [Mon, 12 Sep 2016 22:23:42 +0000 (15:23 -0700)] 
Merge tag 'l10n-2.10.0-rnd2.3' of git://github.com/git-l10n/git-po into maint

l10n-2.10.0-rnd2.3

* tag 'l10n-2.10.0-rnd2.3' of git://github.com/git-l10n/git-po:
  l10n: zh_CN: review for git v2.10.0 l10n
  l10n: zh_CN: fixed some typos for git 2.10.0
  l10n: pt_PT: update Portuguese repository info
  l10n: pt_PT: update Portuguese translation

7 years agoMerge branch 'js/commit-gpgsign' of ../git-gui into js/git-gui-commit-gpgsign
Junio C Hamano [Sun, 11 Sep 2016 21:53:26 +0000 (14:53 -0700)] 
Merge branch 'js/commit-gpgsign' of ../git-gui into js/git-gui-commit-gpgsign

* 'js/commit-gpgsign' of ../git-gui:
  git-gui: respect commit.gpgsign again

7 years agogit-gui: respect commit.gpgsign again
Johannes Schindelin [Fri, 9 Sep 2016 12:28:24 +0000 (14:28 +0200)] 
git-gui: respect commit.gpgsign again

As of v2.9.0, `git commit-tree` no longer heeds the `commit.gpgsign`
config setting. This broke committing with GPG signature in Git GUI.

This fixes https://github.com/git-for-windows/git/issues/850

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agol10n: zh_CN: review for git v2.10.0 l10n
Ray Chen [Wed, 7 Sep 2016 10:03:04 +0000 (18:03 +0800)] 
l10n: zh_CN: review for git v2.10.0 l10n

Signed-off-by: Ray Chen <oldsharp@gmail.com>
7 years agol10n: zh_CN: fixed some typos for git 2.10.0
Jiang Xin [Mon, 5 Sep 2016 15:26:21 +0000 (23:26 +0800)] 
l10n: zh_CN: fixed some typos for git 2.10.0

Reviewed-by: Ray <tvvocold@163.com>
Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
7 years agosequencer: ensure to release the lock when we could not read the index
Johannes Schindelin [Fri, 9 Sep 2016 14:38:20 +0000 (16:38 +0200)] 
sequencer: ensure to release the lock when we could not read the index

A future caller of read_and_refresh_cache() may want to do more than just
print some helpful advice in case of failure.

Suggested by Junio Hamano.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agosequencer: lib'ify checkout_fast_forward()
Johannes Schindelin [Fri, 9 Sep 2016 14:38:00 +0000 (16:38 +0200)] 
sequencer: lib'ify checkout_fast_forward()

Instead of dying there, let the caller high up in the callchain
notice the error and handle it (by dying, still).

The only callers of checkout_fast_forward(), cmd_merge(),
pull_into_void(), cmd_pull() and sequencer's fast_forward_to(),
already check the return value and handle it appropriately. With this
step, we make it notice an error return from this function.

So this is a safe conversion to make checkout_fast_forward()
callable from new callers that want it not to die, without changing
the external behaviour of anything existing.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agosequencer: lib'ify fast_forward_to()
Johannes Schindelin [Fri, 9 Sep 2016 14:37:55 +0000 (16:37 +0200)] 
sequencer: lib'ify fast_forward_to()

Instead of dying there, let the caller high up in the callchain
notice the error and handle it (by dying, still).

The only caller of fast_forward_to(), do_pick_commit() already checks
the return value and passes it on to its callers, so its caller must
be already prepared to handle error returns, and with this step, we
make it notice an error return from this function.

So this is a safe conversion to make fast_forward_to() callable from
new callers that want it not to die, without changing the external
behaviour of anything existing.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agosequencer: lib'ify save_opts()
Johannes Schindelin [Fri, 9 Sep 2016 14:37:53 +0000 (16:37 +0200)] 
sequencer: lib'ify save_opts()

Instead of dying there, let the caller high up in the callchain notice
the error and handle it (by dying, still).

The only caller of save_opts(), sequencer_pick_revisions() can already
return errors, so its caller must be already prepared to handle error
returns, and with this step, we make it notice an error return from
this function.

So this is a safe conversion to make save_opts() callable from new
callers that want it not to die, without changing the external
behaviour of anything existing.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agosequencer: lib'ify save_todo()
Johannes Schindelin [Fri, 9 Sep 2016 14:37:50 +0000 (16:37 +0200)] 
sequencer: lib'ify save_todo()

Instead of dying there, let the caller high up in the callchain notice
the error and handle it (by dying, still).

The only caller of save_todo(), pick_commits() can already return
errors, so its caller must be already prepared to handle error
returns, and with this step, we make it notice an error return from
this function.

So this is a safe conversion to make save_todo() callable
from new callers that want it not to die, without changing the
external behaviour of anything existing.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agosequencer: lib'ify save_head()
Johannes Schindelin [Fri, 9 Sep 2016 14:37:47 +0000 (16:37 +0200)] 
sequencer: lib'ify save_head()

Instead of dying there, let the caller high up in the callchain notice
the error and handle it (by dying, still).

The only caller of save_head(), sequencer_pick_revisions() can already
return errors, so its caller must be already prepared to handle error
returns, and with this step, we make it notice an error return from
this function.

So this is a safe conversion to make save_head() callable from new
callers that want it not to die, without changing the external
behaviour of anything existing.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agosequencer: lib'ify create_seq_dir()
Johannes Schindelin [Fri, 9 Sep 2016 14:37:44 +0000 (16:37 +0200)] 
sequencer: lib'ify create_seq_dir()

Instead of dying there, let the caller high up in the callchain notice
the error and handle it (by dying, still).

The only caller of create_seq_dir(), sequencer_pick_revisions() can
already return errors, so its caller must be already prepared to
handle error returns, and with this step, we make it notice an error
return from this function.

So this is a safe conversion to make create_seq_dir() callable from
new callers that want it not to die, without changing the external
behaviour of anything existing.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agosequencer: lib'ify read_populate_opts()
Johannes Schindelin [Fri, 9 Sep 2016 14:37:27 +0000 (16:37 +0200)] 
sequencer: lib'ify read_populate_opts()

Instead of dying there, let the caller high up in the callchain notice
the error and handle it (by dying, still).

The only caller of read_populate_opts(), sequencer_continue() can
already return errors, so its caller must be already prepared to
handle error returns, and with this step, we make it notice an error
return from this function.

So this is a safe conversion to make read_populate_opts() callable
from new callers that want it not to die, without changing the
external behaviour of anything existing.

Note that the function git_config_from_file(), called from
read_populate_opts(), can currently still die() (in git_parse_source(),
because the do_config_from_file() function sets die_on_error = 1). We do
not try to fix that here, as it would have larger ramifications on the
config code, and we also assume that we write the opts file
programmatically, hence any parse errors would be bugs.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agosequencer: lib'ify read_populate_todo()
Johannes Schindelin [Fri, 9 Sep 2016 14:37:24 +0000 (16:37 +0200)] 
sequencer: lib'ify read_populate_todo()

Instead of dying there, let the caller high up in the callchain
notice the error and handle it (by dying, still).

The only caller of read_populate_todo(), sequencer_continue() can
already return errors, so its caller must be already prepared to
handle error returns, and with this step, we make it notice an
error return from this function.

So this is a safe conversion to make read_populate_todo() callable
from new callers that want it not to die, without changing the
external behaviour of anything existing.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agosequencer: lib'ify read_and_refresh_cache()
Johannes Schindelin [Fri, 9 Sep 2016 14:37:21 +0000 (16:37 +0200)] 
sequencer: lib'ify read_and_refresh_cache()

Instead of dying there, let the caller high up in the callchain
notice the error and handle it (by dying, still).

There are two call sites of read_and_refresh_cache(), one of which is
pick_commits(), whose callers were already prepared to do the right
thing given an "error" return from it by an earlier patch, so the
conversion is safe.

The other one, sequencer_pick_revisions() was also prepared to relay
an error return back to its caller in all remaining cases in an
earlier patch.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agosequencer: lib'ify prepare_revs()
Johannes Schindelin [Fri, 9 Sep 2016 14:37:18 +0000 (16:37 +0200)] 
sequencer: lib'ify prepare_revs()

Instead of dying there, let the caller high up in the callchain notice
the error and handle it (by dying, still).

The only caller of prepare_revs(), walk_revs_populate_todo() was just
taught to return errors, after verifying that its callers are prepared
to handle error returns, and with this step, we make it notice an
error return from this function.

So this is a safe conversion to make prepare_revs() callable from new
callers that want it not to die, without changing the external
behaviour of anything existing.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agosequencer: lib'ify walk_revs_populate_todo()
Johannes Schindelin [Fri, 9 Sep 2016 14:37:15 +0000 (16:37 +0200)] 
sequencer: lib'ify walk_revs_populate_todo()

Instead of dying there, let the caller high up in the callchain notice
the error and handle it (by dying, still).

The function sequencer_pick_revisions() is the only caller of
walk_revs_populate_todo(), and it already returns errors
appropriately, so its caller must be already prepared to handle error
returns, and with this step, we make it notice an error return from
this function.

So this is a safe conversion to make walk_revs_populate_todo()
callable from new callers that want it not to die, without changing
the external behaviour of anything existing.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agosequencer: lib'ify do_pick_commit()
Johannes Schindelin [Fri, 9 Sep 2016 14:37:12 +0000 (16:37 +0200)] 
sequencer: lib'ify do_pick_commit()

Instead of dying there, let the caller high up in the callchain notice
the error and handle it (by dying, still).

The only two callers of do_pick_commit(), pick_commits() and
single_pick() already check the return value and pass it on to their
callers, so their callers must be already prepared to handle error
returns, and with this step, we make it notice an error return from
this function.

So this is a safe conversion to make do_pick_commit() callable from
new callers that want it not to die, without changing the external
behaviour of anything existing.

While at it, remove the superfluous space.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agosequencer: lib'ify do_recursive_merge()
Johannes Schindelin [Fri, 9 Sep 2016 14:37:10 +0000 (16:37 +0200)] 
sequencer: lib'ify do_recursive_merge()

Instead of dying there, let the caller high up in the callchain
notice the error and handle it (by dying, still).

The only caller of do_recursive_merge(), do_pick_commit() already
checks the return value and passes it on to its callers, so its caller
must be already prepared to handle error returns, and with this step,
we make it notice an error return from this function.

So this is a safe conversion to make do_recursive_merge() callable
from new callers that want it not to die, without changing the
external behaviour of anything existing.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agosequencer: lib'ify write_message()
Johannes Schindelin [Fri, 9 Sep 2016 14:37:05 +0000 (16:37 +0200)] 
sequencer: lib'ify write_message()

Instead of dying there, let the caller high up in the callchain
notice the error and handle it (by dying, still).

The only caller of write_message(), do_pick_commit() already checks
the return value and passes it on to its callers, so its caller must
be already prepared to handle error returns, and with this step, we
make it notice an error return from this function.

So this is a safe conversion to make write_message() callable
from new callers that want it not to die, without changing the
external behaviour of anything existing.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoSync with maint
Junio C Hamano [Fri, 9 Sep 2016 05:00:53 +0000 (22:00 -0700)] 
Sync with maint

* maint:
  Prepare for 2.9.4

7 years agoStart the 2.11 cycle
Junio C Hamano [Fri, 9 Sep 2016 05:00:35 +0000 (22:00 -0700)] 
Start the 2.11 cycle

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMerge branch 'bh/diff-highlight-graph'
Junio C Hamano [Fri, 9 Sep 2016 04:49:52 +0000 (21:49 -0700)] 
Merge branch 'bh/diff-highlight-graph'

"diff-highlight" script (in contrib/) learned to work better with
"git log -p --graph" output.

* bh/diff-highlight-graph:
  diff-highlight: avoid highlighting combined diffs
  diff-highlight: add multi-byte tests
  diff-highlight: ignore test cruft
  diff-highlight: add support for --graph output
  diff-highlight: add failing test for handling --graph output
  diff-highlight: add some tests

7 years agoMerge branch 'hv/doc-commit-reference-style'
Junio C Hamano [Fri, 9 Sep 2016 04:49:51 +0000 (21:49 -0700)] 
Merge branch 'hv/doc-commit-reference-style'

A small doc update.

* hv/doc-commit-reference-style:
  SubmittingPatches: use gitk's "Copy commit summary" format

7 years agoMerge branch 'sb/submodule-clone-rr'
Junio C Hamano [Fri, 9 Sep 2016 04:49:50 +0000 (21:49 -0700)] 
Merge branch 'sb/submodule-clone-rr'

"git clone --resurse-submodules --reference $path $URL" is a way to
reduce network transfer cost by borrowing objects in an existing
$path repository when cloning the superproject from $URL; it
learned to also peek into $path for presense of corresponding
repositories of submodules and borrow objects from there when able.

* sb/submodule-clone-rr:
  clone: recursive and reference option triggers submodule alternates
  clone: implement optional references
  clone: clarify option_reference as required
  clone: factor out checking for an alternate path
  submodule--helper update-clone: allow multiple references
  submodule--helper module-clone: allow multiple references
  t7408: merge short tests, factor out testing method
  t7408: modernize style

7 years agoMerge branch 'jh/status-v2-porcelain'
Junio C Hamano [Fri, 9 Sep 2016 04:49:50 +0000 (21:49 -0700)] 
Merge branch 'jh/status-v2-porcelain'

Enhance "git status --porcelain" output by collecting more data on
the state of the index and the working tree files, which may
further be used to teach git-prompt (in contrib/) to make fewer
calls to git.

* jh/status-v2-porcelain:
  status: unit tests for --porcelain=v2
  test-lib-functions.sh: add lf_to_nul helper
  git-status.txt: describe --porcelain=v2 format
  status: print branch info with --porcelain=v2 --branch
  status: print per-file porcelain v2 status data
  status: collect per-file data for --porcelain=v2
  status: support --porcelain[=<version>]
  status: cleanup API to wt_status_print
  status: rename long-format print routines

7 years agoMerge branch 'po/range-doc'
Junio C Hamano [Fri, 9 Sep 2016 04:49:49 +0000 (21:49 -0700)] 
Merge branch 'po/range-doc'

Clarify various ways to specify the "revision ranges" in the
documentation.

* po/range-doc:
  doc: revisions: sort examples and fix alignment of the unchanged
  doc: revisions: show revision expansion in examples
  doc: revisions - clarify reachability examples
  doc: revisions - define `reachable`
  doc: gitrevisions - clarify 'latter case' is revision walk
  doc: gitrevisions - use 'reachable' in page description
  doc: revisions: single vs multi-parent notation comparison
  doc: revisions: extra clarification of <rev>^! notation effects
  doc: revisions: give headings for the two and three dot notations
  doc: show the actual left, right, and boundary marks
  doc: revisions - name the left and right sides
  doc: use 'symmetric difference' consistently

7 years agoMerge branch 'rt/help-unknown'
Junio C Hamano [Fri, 9 Sep 2016 04:49:48 +0000 (21:49 -0700)] 
Merge branch 'rt/help-unknown'

"git nosuchcommand --help" said "No manual entry for gitnosuchcommand",
which was not intuitive, given that "git nosuchcommand" said "git:
'nosuchcommand' is not a git command".

* rt/help-unknown:
  help: make option --help open man pages only for Git commands
  help: introduce option --exclude-guides

7 years agoMerge branch 'cc/receive-pack-limit'
Junio C Hamano [Fri, 9 Sep 2016 04:49:47 +0000 (21:49 -0700)] 
Merge branch 'cc/receive-pack-limit'

An incoming "git push" that attempts to push too many bytes can now
be rejected by setting a new configuration variable at the receiving
end.

* cc/receive-pack-limit:
  receive-pack: allow a maximum input size to be specified
  unpack-objects: add --max-input-size=<size> option
  index-pack: add --max-input-size=<size> option

7 years agoMerge branch 'jk/format-patch-number-singleton-patch-with-cover'
Junio C Hamano [Fri, 9 Sep 2016 04:49:47 +0000 (21:49 -0700)] 
Merge branch 'jk/format-patch-number-singleton-patch-with-cover'

"git format-patch --cover-letter HEAD^" to format a single patch
with a separate cover letter now numbers the output as [PATCH 0/1]
and [PATCH 1/1] by default.

* jk/format-patch-number-singleton-patch-with-cover:
  format-patch: show 0/1 and 1/1 for singleton patch with cover letter

7 years agoMerge branch 'jk/delta-base-cache'
Junio C Hamano [Fri, 9 Sep 2016 04:49:46 +0000 (21:49 -0700)] 
Merge branch 'jk/delta-base-cache'

The delta-base-cache mechanism has been a key to the performance in
a repository with a tightly packed packfile, but it did not scale
well even with a larger value of core.deltaBaseCacheLimit.

* jk/delta-base-cache:
  t/perf: add basic perf tests for delta base cache
  delta_base_cache: use hashmap.h
  delta_base_cache: drop special treatment of blobs
  delta_base_cache: use list.h for LRU
  release_delta_base_cache: reuse existing detach function
  clear_delta_base_cache_entry: use a more descriptive name
  cache_or_unpack_entry: drop keep_cache parameter

7 years agoStart maintenance track for 2.10.x series
Junio C Hamano [Fri, 9 Sep 2016 04:39:38 +0000 (21:39 -0700)] 
Start maintenance track for 2.10.x series

7 years agoPrepare for 2.9.4
Junio C Hamano [Fri, 9 Sep 2016 04:37:59 +0000 (21:37 -0700)] 
Prepare for 2.9.4

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMerge branch 'hv/doc-commit-reference-style' into maint
Junio C Hamano [Fri, 9 Sep 2016 04:36:03 +0000 (21:36 -0700)] 
Merge branch 'hv/doc-commit-reference-style' into maint

A small doc update.

* hv/doc-commit-reference-style:
  SubmittingPatches: use gitk's "Copy commit summary" format
  SubmittingPatches: document how to reference previous commits

7 years agoMerge branch 'sg/reflog-past-root' into maint
Junio C Hamano [Fri, 9 Sep 2016 04:36:02 +0000 (21:36 -0700)] 
Merge branch 'sg/reflog-past-root' into maint

A small test clean-up for a topic introduced in v2.9.1 and later.

* sg/reflog-past-root:
  t1410: remove superfluous 'git reflog' from the 'walk past root' test

7 years agoMerge branch 'rs/mailinfo-lib' into maint
Junio C Hamano [Fri, 9 Sep 2016 04:36:01 +0000 (21:36 -0700)] 
Merge branch 'rs/mailinfo-lib' into maint

Small code clean-up.

* rs/mailinfo-lib:
  mailinfo: recycle strbuf in check_header()

7 years agoMerge branch 'jk/tighten-alloc' into maint
Junio C Hamano [Fri, 9 Sep 2016 04:36:00 +0000 (21:36 -0700)] 
Merge branch 'jk/tighten-alloc' into maint

Small code and comment clean-up.

* jk/tighten-alloc:
  receive-pack: use FLEX_ALLOC_MEM in queue_command()
  correct FLEXPTR_* example in comment

7 years agoMerge branch 'rs/use-strbuf-add-unique-abbrev' into maint
Junio C Hamano [Fri, 9 Sep 2016 04:35:59 +0000 (21:35 -0700)] 
Merge branch 'rs/use-strbuf-add-unique-abbrev' into maint

A small code clean-up.

* rs/use-strbuf-add-unique-abbrev:
  use strbuf_add_unique_abbrev() for adding short hashes

7 years agoMerge branch 'rs/merge-recursive-string-list-init' into maint
Junio C Hamano [Fri, 9 Sep 2016 04:35:59 +0000 (21:35 -0700)] 
Merge branch 'rs/merge-recursive-string-list-init' into maint

A small code clean-up.

* rs/merge-recursive-string-list-init:
  merge-recursive: use STRING_LIST_INIT_NODUP

7 years agoMerge branch 'rs/merge-add-strategies-simplification' into maint
Junio C Hamano [Fri, 9 Sep 2016 04:35:58 +0000 (21:35 -0700)] 
Merge branch 'rs/merge-add-strategies-simplification' into maint

A small code clean-up.

* rs/merge-add-strategies-simplification:
  merge: use string_list_split() in add_strategies()

7 years agoMerge branch 'ls/packet-line-protocol-doc-fix' into maint
Junio C Hamano [Fri, 9 Sep 2016 04:35:57 +0000 (21:35 -0700)] 
Merge branch 'ls/packet-line-protocol-doc-fix' into maint

Correct an age-old calco (is that a typo-like word for calc)
in the documentation.

* ls/packet-line-protocol-doc-fix:
  pack-protocol: fix maximum pkt-line size

7 years agoMerge branch 'bw/mingw-avoid-inheriting-fd-to-lockfile' into maint
Junio C Hamano [Fri, 9 Sep 2016 04:35:56 +0000 (21:35 -0700)] 
Merge branch 'bw/mingw-avoid-inheriting-fd-to-lockfile' into maint

The tempfile (hence its user lockfile) API lets the caller to open
a file descriptor to a temporary file, write into it and then
finalize it by first closing the filehandle and then either
removing or renaming the temporary file.  When the process spawns a
subprocess after obtaining the file descriptor, and if the
subprocess has not exited when the attempt to remove or rename is
made, the last step fails on Windows, because the subprocess has
the file descriptor still open.  Open tempfile with O_CLOEXEC flag
to avoid this (on Windows, this is mapped to O_NOINHERIT).

* bw/mingw-avoid-inheriting-fd-to-lockfile:
  mingw: ensure temporary file handles are not inherited by child processes
  t6026-merge-attr: child processes must not inherit index.lock handles

7 years agoMerge branch 'dg/document-git-c-in-git-config-doc' into maint
Junio C Hamano [Fri, 9 Sep 2016 04:35:56 +0000 (21:35 -0700)] 
Merge branch 'dg/document-git-c-in-git-config-doc' into maint

The "git -c var[=val] cmd" facility to append a configuration
variable definition at the end of the search order was described in
git(1) manual page, but not in git-config(1), which was more likely
place for people to look for when they ask "can I make a one-shot
override, and if so how?"

* dg/document-git-c-in-git-config-doc:
  doc: mention `git -c` in git-config(1)

7 years agoMerge branch 'js/no-html-bypass-on-windows' into maint
Junio C Hamano [Fri, 9 Sep 2016 04:35:55 +0000 (21:35 -0700)] 
Merge branch 'js/no-html-bypass-on-windows' into maint

On Windows, help.browser configuration variable used to be ignored,
which has been corrected.

* js/no-html-bypass-on-windows:
  Revert "display HTML in default browser using Windows' shell API"

7 years agoMerge branch 'jk/difftool-command-not-found' into maint
Junio C Hamano [Fri, 9 Sep 2016 04:35:54 +0000 (21:35 -0700)] 
Merge branch 'jk/difftool-command-not-found' into maint

"git difftool" by default ignores the error exit from the backend
commands it spawns, because often they signal that they found
differences by exiting with a non-zero status code just like "diff"
does; the exit status codes 126 and above however are special in
that they are used to signal that the command is not executable,
does not exist, or killed by a signal.  "git difftool" has been
taught to notice these exit status codes.

* jk/difftool-command-not-found:
  difftool: always honor fatal error exit codes

7 years agoMerge branch 'sb/checkout-explit-detach-no-advice' into maint
Junio C Hamano [Fri, 9 Sep 2016 04:35:54 +0000 (21:35 -0700)] 
Merge branch 'sb/checkout-explit-detach-no-advice' into maint

"git checkout --detach <branch>" used to give the same advice
message as that is issued when "git checkout <tag>" (or anything
that is not a branch name) is given, but asking with "--detach" is
an explicit enough sign that the user knows what is going on.  The
advice message has been squelched in this case.

* sb/checkout-explit-detach-no-advice:
  checkout: do not mention detach advice for explicit --detach option

7 years agoMerge branch 'rs/pull-signed-tag' into maint
Junio C Hamano [Fri, 9 Sep 2016 04:35:54 +0000 (21:35 -0700)] 
Merge branch 'rs/pull-signed-tag' into maint

When "git merge-recursive" works on history with many criss-cross
merges in "verbose" mode, the names the command assigns to the
virtual merge bases could have overwritten each other by unintended
reuse of the same piece of memory.

* rs/pull-signed-tag:
  commit: use FLEX_ARRAY in struct merge_remote_desc
  merge-recursive: fix verbose output for multiple base trees
  commit: factor out set_merge_remote_desc()
  commit: use xstrdup() in get_merge_parent()

7 years agoMerge branch 'js/test-lint-pathname' into maint
Junio C Hamano [Fri, 9 Sep 2016 04:35:54 +0000 (21:35 -0700)] 
Merge branch 'js/test-lint-pathname' into maint

The "t/" hierarchy is prone to get an unusual pathname; "make test"
has been taught to make sure they do not contain paths that cannot
be checked out on Windows (and the mechanism can be reusable to
catch pathnames that are not portable to other platforms as need
arises).

* js/test-lint-pathname:
  t/Makefile: ensure that paths are valid on platforms we care

7 years agoMerge branch 'js/mv-dir-to-new-directory' into maint
Junio C Hamano [Fri, 9 Sep 2016 04:35:54 +0000 (21:35 -0700)] 
Merge branch 'js/mv-dir-to-new-directory' into maint

"git mv dir non-existing-dir/" did not work in some environments
the same way as existing mainstream platforms.  The code now moves
"dir" to "non-existing-dir", without relying on rename("A", "B/")
that strips the trailing slash of '/'.

* js/mv-dir-to-new-directory:
  git mv: do not keep slash in `git mv dir non-existing-dir/`

7 years agoMerge branch 'js/import-tars-hardlinks' into maint
Junio C Hamano [Fri, 9 Sep 2016 04:35:54 +0000 (21:35 -0700)] 
Merge branch 'js/import-tars-hardlinks' into maint

"import-tars" fast-import script (in contrib/) used to ignore a
hardlink target and replaced it with an empty file, which has been
corrected to record the same blob as the other file the hardlink is
shared with.

* js/import-tars-hardlinks:
  import-tars: support hard links

7 years agoMerge branch 'ms/document-pack-window-memory-is-per-thread' into maint
Junio C Hamano [Fri, 9 Sep 2016 04:35:53 +0000 (21:35 -0700)] 
Merge branch 'ms/document-pack-window-memory-is-per-thread' into maint

* ms/document-pack-window-memory-is-per-thread:
  document git-repack interaction of pack.threads and pack.windowMemory

7 years agoMerge branch 'jk/push-force-with-lease-creation' into maint
Junio C Hamano [Fri, 9 Sep 2016 04:35:53 +0000 (21:35 -0700)] 
Merge branch 'jk/push-force-with-lease-creation' into maint

"git push --force-with-lease" already had enough logic to allow
ensuring that such a push results in creation of a ref (i.e. the
receiving end did not have another push from sideways that would be
discarded by our force-pushing), but didn't expose this possibility
to the users.  It does so now.

* jk/push-force-with-lease-creation:
  t5533: make it pass on case-sensitive filesystems
  push: allow pushing new branches with --force-with-lease
  push: add shorthand for --force-with-lease branch creation
  Documentation/git-push: fix placeholder formatting

7 years agoMerge branch 'jk/reflog-date' into maint
Junio C Hamano [Fri, 9 Sep 2016 04:35:52 +0000 (21:35 -0700)] 
Merge branch 'jk/reflog-date' into maint

The reflog output format is documented better, and a new format
--date=unix to report the seconds-since-epoch (without timezone)
has been added.

* jk/reflog-date:
  date: clarify --date=raw description
  date: add "unix" format
  date: document and test "raw-local" mode
  doc/pretty-formats: explain shortening of %gd
  doc/pretty-formats: describe index/time formats for %gd
  doc/rev-list-options: explain "-g" output formats
  doc/rev-list-options: clarify "commit@{Nth}" for "-g" option

7 years agoMerge branch 'jc/renormalize-merge-kill-safer-crlf' into maint
Junio C Hamano [Fri, 9 Sep 2016 04:35:51 +0000 (21:35 -0700)] 
Merge branch 'jc/renormalize-merge-kill-safer-crlf' into maint

"git merge" with renormalization did not work well with
merge-recursive, due to "safer crlf" conversion kicking in when it
shouldn't.

* jc/renormalize-merge-kill-safer-crlf:
  merge: avoid "safer crlf" during recording of merge results
  convert: unify the "auto" handling of CRLF

7 years agoMerge branch 'jk/common-main' into maint
Junio C Hamano [Fri, 9 Sep 2016 04:35:50 +0000 (21:35 -0700)] 
Merge branch 'jk/common-main' into maint

There are certain house-keeping tasks that need to be performed at
the very beginning of any Git program, and programs that are not
built-in commands had to do them exactly the same way as "git"
potty does.  It was easy to make mistakes in one-off standalone
programs (like test helpers).  A common "main()" function that
calls cmd_main() of individual program has been introduced to
make it harder to make mistakes.

* jk/common-main:
  mingw: declare main()'s argv as const
  common-main: call git_setup_gettext()
  common-main: call restore_sigpipe_to_default()
  common-main: call sanitize_stdfds()
  common-main: call git_extract_argv0_path()
  add an extra level of indirection to main()

7 years agodiff: remove dead code
Stefan Beller [Wed, 7 Sep 2016 23:36:48 +0000 (16:36 -0700)] 
diff: remove dead code

When `len < 1`, len has to be 0 or negative, emit_line will then remove the
first character and by then `len` would be negative. As this doesn't
happen, it is safe to assume it is dead code.

This continues to simplify the code, which was started in b8d9c1a66b
(2009-09-03,  diff.c: the builtin_diff() deals with only two-file
comparison).

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agodiff: omit found pointer from emit_callback
Stefan Beller [Wed, 7 Sep 2016 23:36:46 +0000 (16:36 -0700)] 
diff: omit found pointer from emit_callback

We keep the actual data in the diff options, which are just as accessible.
Remove the pointer stored in struct emit_callback for readability.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agodiff.c: use diff_options directly
Stefan Beller [Wed, 7 Sep 2016 23:36:44 +0000 (16:36 -0700)] 
diff.c: use diff_options directly

The value of `ecbdata->opt` is accessible via the short variable `o`
already, so let's use that instead.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agotransport: report missing submodule pushes consistently on stderr
Stefan Beller [Tue, 23 Aug 2016 21:40:08 +0000 (14:40 -0700)] 
transport: report missing submodule pushes consistently on stderr

The surrounding advice is printed to stderr, but the list of submodules
is not. Make the report consistent by reporting everything to stderr.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agounpack-trees: do not capitalize "working"
Alex Henrie [Thu, 8 Sep 2016 04:34:53 +0000 (22:34 -0600)] 
unpack-trees: do not capitalize "working"

In English, only proper nouns are capitalized.

Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agogit-merge-octopus: do not capitalize "octopus"
Alex Henrie [Thu, 8 Sep 2016 04:34:40 +0000 (22:34 -0600)] 
git-merge-octopus: do not capitalize "octopus"

In English, only proper nouns are capitalized.

Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agogit-rebase--interactive: fix English grammar
Alex Henrie [Thu, 8 Sep 2016 04:34:17 +0000 (22:34 -0600)] 
git-rebase--interactive: fix English grammar

Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agocat-file: put spaces around pipes in usage string
Alex Henrie [Thu, 8 Sep 2016 04:34:00 +0000 (22:34 -0600)] 
cat-file: put spaces around pipes in usage string

This makes the style a little more consistent with other usage strings,
and will resolve a warning at
https://www.softcatala.org/recursos/quality/git.html

Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoam: put spaces around pipe in usage string
Alex Henrie [Thu, 8 Sep 2016 04:33:08 +0000 (22:33 -0600)] 
am: put spaces around pipe in usage string

This makes the style a little more consistent with other usage strings,
and will resolve a warning at
https://www.softcatala.org/recursos/quality/git.html

Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoremote-curl: handle URLs without protocol
Jeff King [Wed, 7 Sep 2016 20:06:42 +0000 (16:06 -0400)] 
remote-curl: handle URLs without protocol

Generally remote-curl would never see a URL that did not
have "proto:" at the beginning, as that is what tells git to
run the "git-remote-proto" helper (and git-remote-http, etc,
are aliases for git-remote-curl).

However, the special syntax "proto::something" will run
git-remote-proto with only "something" as the URL. So a
malformed URL like:

  http::/example.com/repo.git

will feed the URL "/example.com/repo.git" to
git-remote-http. The resulting URL has no protocol, but the
code added by 372370f (http: use credential API to handle
proxy authentication, 2016-01-26) does not handle this case
and segfaults.

For the purposes of this code, we don't really care what the
exact protocol; only whether or not it is https. So let's
just assume that a missing protocol is not, and curl will
handle the real error (which is that the URL is nonsense).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agobuiltin/am: use apply API in run_apply()
Christian Couder [Sun, 4 Sep 2016 20:18:33 +0000 (22:18 +0200)] 
builtin/am: use apply API in run_apply()

This replaces run_apply() implementation with a new one that
uses the apply API that has been previously prepared in
apply.c and apply.h.

This shoud improve performance a lot in certain cases.

As the previous implementation was creating a new `git apply`
process to apply each patch, it could be slow on systems like
Windows where it is costly to create new processes.

Also the new `git apply` process had to read the index from
disk, and when the process was done the calling process
discarded its own index and read back from disk the new
index that had been created by the `git apply` process.

This could be very inefficient with big repositories that
have big index files, especially when the system decided
that it was a good idea to run the `git apply` processes on
a different processor core.

Also eliminating index reads enables further performance
improvements by using:

`git update-index --split-index`

For example here is a benchmark of a multi hundred commit
rebase on the Linux kernel on a Debian laptop with SSD:

command: git rebase --onto 1993b17 52bef0c 29dde7c

Vanilla "next" without split index:                1m54.953s
Vanilla "next" with split index:                   1m22.476s
This series on top of "next" without split index:  1m12.034s
This series on top of "next" with split index:     0m15.678s

(using branch "next" from mid April 2016.)

Benchmarked-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoapply: learn to use a different index file
Christian Couder [Sun, 4 Sep 2016 20:18:32 +0000 (22:18 +0200)] 
apply: learn to use a different index file

Sometimes we want to apply in a different index file.

Before the apply functionality was libified it was possible to
use the GIT_INDEX_FILE environment variable, for this purpose.

But now, as the apply functionality has been libified, it should
be possible to do that in a libified way.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoapply: pass apply state to build_fake_ancestor()
Christian Couder [Sun, 4 Sep 2016 20:18:31 +0000 (22:18 +0200)] 
apply: pass apply state to build_fake_ancestor()

To libify git apply functionality, we will need to read from a
different index file in get_current_sha1(). This index file will be
stored in "struct apply_state", so let's pass the state to
build_fake_ancestor() which will later pass it to get_current_sha1().

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoapply: refactor `git apply` option parsing
Christian Couder [Sun, 4 Sep 2016 20:18:30 +0000 (22:18 +0200)] 
apply: refactor `git apply` option parsing

Parsing `git apply` options can be useful to other commands that
want to call the libified apply functionality, because this way
they can easily pass some options from their own command line to
the libified apply functionality.

This will be used by `git am` in a following patch.

To make this possible, let's refactor the `git apply` option
parsing code into a new libified apply_parse_options() function.

Doing that makes it possible to remove some functions definitions
from "apply.h" and make them static in "apply.c".

Helped-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoapply: change error_routine when silent
Christian Couder [Sun, 4 Sep 2016 20:18:29 +0000 (22:18 +0200)] 
apply: change error_routine when silent

To avoid printing anything when applying with
`state->apply_verbosity == verbosity_silent`, let's save the
existing warn and error routines before applying, and let's
replace them with a routine that does nothing.

Then after applying, let's restore the saved routines.

Note that, as we need to restore the saved routines in all
cases, we cannot return early any more in apply_all_patches().

Helped-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agousage: add get_error_routine() and get_warn_routine()
Christian Couder [Sun, 4 Sep 2016 20:18:28 +0000 (22:18 +0200)] 
usage: add get_error_routine() and get_warn_routine()

Let's make it possible to get the current error_routine and warn_routine,
so that we can store them before using set_error_routine() or
set_warn_routine() to use new ones.

This way we will be able put back the original routines, when we are done
with using new ones.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agousage: add set_warn_routine()
Christian Couder [Sun, 4 Sep 2016 20:18:27 +0000 (22:18 +0200)] 
usage: add set_warn_routine()

There are already set_die_routine() and set_error_routine(),
so let's add set_warn_routine() as this will be needed in a
following commit.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoapply: don't print on stdout in verbosity_silent mode
Christian Couder [Sun, 4 Sep 2016 20:18:26 +0000 (22:18 +0200)] 
apply: don't print on stdout in verbosity_silent mode

When apply_verbosity is set to verbosity_silent nothing should be
printed on both stderr and stdout.

To avoid printing on stdout, we can just skip calling the following
functions:

- stat_patch_list(),
- numstat_patch_list(),
- summary_patch_list().

It is safe to do that because the above functions have no side
effects other than printing:

- stat_patch_list() only computes some local values and then call
show_stats() and print_stat_summary(), those two functions only
compute local values and call printing functions,
- numstat_patch_list() also only computes local values and calls
printing functions,
- summary_patch_list() calls show_file_mode_name(), printf(),
show_rename_copy(), show_mode_change() that are only printing.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoapply: make it possible to silently apply
Christian Couder [Sun, 4 Sep 2016 20:18:25 +0000 (22:18 +0200)] 
apply: make it possible to silently apply

This changes 'int apply_verbosely' into 'enum apply_verbosity', and
changes the possible values of the variable from a bool to
a tristate.

The previous 'false' state is changed into 'verbosity_normal'.
The previous 'true' state is changed into 'verbosity_verbose'.

The new added state is 'verbosity_silent'. It should prevent
anything to be printed on both stderr and stdout.

This is needed because `git am` wants to first call apply
functionality silently, if it can then fall back on 3-way merge
in case of error.

Printing on stdout, and calls to warning() or error() are not
taken care of in this patch, as that will be done in following
patches.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoapply: use error_errno() where possible
Christian Couder [Sun, 4 Sep 2016 20:18:24 +0000 (22:18 +0200)] 
apply: use error_errno() where possible

To avoid possible mistakes and to uniformly show the errno
related messages, let's use error_errno() where possible.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoapply: make some parsing functions static again
Christian Couder [Sun, 4 Sep 2016 20:18:23 +0000 (22:18 +0200)] 
apply: make some parsing functions static again

Some parsing functions that were used in both "apply.c" and
"builtin/apply.c" are now only used in the former, so they
can be made static to "apply.c".

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>