git/git.git
3 years agoMerge branch 'ra/decorate-limit-refs'
Junio C Hamano [Wed, 13 Dec 2017 21:28:54 +0000 (13:28 -0800)]
Merge branch 'ra/decorate-limit-refs'

The tagnames "git log --decorate" uses to annotate the commits can
now be limited to subset of available refs with the two additional
options, --decorate-refs[-exclude]=<pattern>.

* ra/decorate-limit-refs:
  log: add option to choose which refs to decorate

3 years agoMerge branch 'bc/hash-algo'
Junio C Hamano [Wed, 13 Dec 2017 21:28:54 +0000 (13:28 -0800)]
Merge branch 'bc/hash-algo'

An infrastructure to define what hash function is used in Git is
introduced, and an effort to plumb that throughout various
codepaths has been started.

* bc/hash-algo:
  repository: fix a sparse 'using integer as NULL pointer' warning
  Switch empty tree and blob lookups to use hash abstraction
  Integrate hash algorithm support with repo setup
  Add structure representing hash algorithm
  setup: expose enumerated repo info

3 years agoRelNotes: the eighth batch
Junio C Hamano [Wed, 6 Dec 2017 17:29:50 +0000 (09:29 -0800)]
RelNotes: the eighth batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoSync with maint
Junio C Hamano [Wed, 6 Dec 2017 17:27:59 +0000 (09:27 -0800)]
Sync with maint

3 years agoMerge branch 'jn/ssh-wrappers'
Junio C Hamano [Wed, 6 Dec 2017 17:23:45 +0000 (09:23 -0800)]
Merge branch 'jn/ssh-wrappers'

The ssh-variant 'simple' introduced earlier broke existing
installations by not passing --port/-4/-6 and not diagnosing an
attempt to pass these as an error.  Instead, default to
automatically detect how compatible the GIT_SSH/GIT_SSH_COMMAND is
to OpenSSH convention and then error out an invocation to make it
easier to diagnose connection errors.

* jn/ssh-wrappers:
  connect: correct style of C-style comment
  ssh: 'simple' variant does not support --port
  ssh: 'simple' variant does not support -4/-6
  ssh: 'auto' variant to select between 'ssh' and 'simple'
  connect: split ssh option computation to its own function
  connect: split ssh command line options into separate function
  connect: split git:// setup into a separate function
  connect: move no_fork fallback to git_tcp_connect
  ssh test: make copy_ssh_wrapper_as clean up after itself

3 years agoMerge branch 'bw/protocol-v1'
Junio C Hamano [Wed, 6 Dec 2017 17:23:44 +0000 (09:23 -0800)]
Merge branch 'bw/protocol-v1'

A new mechanism to upgrade the wire protocol in place is proposed
and demonstrated that it works with the older versions of Git
without harming them.

* bw/protocol-v1:
  Documentation: document Extra Parameters
  ssh: introduce a 'simple' ssh variant
  i5700: add interop test for protocol transition
  http: tell server that the client understands v1
  connect: tell server that the client understands v1
  connect: teach client to recognize v1 server response
  upload-pack, receive-pack: introduce protocol version 1
  daemon: recognize hidden request arguments
  protocol: introduce protocol extension mechanisms
  pkt-line: add packet_write function
  connect: in ref advertisement, shallows are last

3 years agoMerge branch 'sp/doc-info-attributes'
Junio C Hamano [Wed, 6 Dec 2017 17:23:43 +0000 (09:23 -0800)]
Merge branch 'sp/doc-info-attributes'

Doc update.

* sp/doc-info-attributes:
  doc: Mention info/attributes in gitrepository-layout

3 years agoMerge branch 'ph/stash-save-m-option-fix'
Junio C Hamano [Wed, 6 Dec 2017 17:23:42 +0000 (09:23 -0800)]
Merge branch 'ph/stash-save-m-option-fix'

In addition to "git stash -m message", the command learned to
accept "git stash -mmessage" form.

* ph/stash-save-m-option-fix:
  stash: learn to parse -m/--message like commit does

3 years agoMerge branch 'jk/fewer-pack-rescan'
Junio C Hamano [Wed, 6 Dec 2017 17:23:42 +0000 (09:23 -0800)]
Merge branch 'jk/fewer-pack-rescan'

Internaly we use 0{40} as a placeholder object name to signal the
codepath that there is no such object (e.g. the fast-forward check
while "git fetch" stores a new remote-tracking ref says "we know
there is no 'old' thing pointed at by the ref, as we are creating
it anew" by passing 0{40} for the 'old' side), and expect that a
codepath to locate an in-core object to return NULL as a sign that
the object does not exist.  A look-up for an object that does not
exist however is quite costly with a repository with large number
of packfiles.  This access pattern has been optimized.

* jk/fewer-pack-rescan:
  sha1_file: fast-path null sha1 as a missing object
  everything_local: use "quick" object existence check
  p5551: add a script to test fetch pack-dir rescans
  t/perf/lib-pack: use fast-import checkpoint to create packs
  p5550: factor out nonsense-pack creation

3 years agoMerge branch 'tg/deprecate-stash-save'
Junio C Hamano [Wed, 6 Dec 2017 17:23:41 +0000 (09:23 -0800)]
Merge branch 'tg/deprecate-stash-save'

Doc update.

* tg/deprecate-stash-save:
  doc: prefer 'stash push' over 'stash save'

3 years agoMerge branch 'rd/doc-notes-prune-fix'
Junio C Hamano [Wed, 6 Dec 2017 17:23:40 +0000 (09:23 -0800)]
Merge branch 'rd/doc-notes-prune-fix'

Doc update.

* rd/doc-notes-prune-fix:
  notes: correct 'git notes prune' options to '[-n] [-v]'

3 years agoMerge branch 'rd/man-reflog-add-n'
Junio C Hamano [Wed, 6 Dec 2017 17:23:39 +0000 (09:23 -0800)]
Merge branch 'rd/man-reflog-add-n'

Doc update.

* rd/man-reflog-add-n:
  doc: add missing "-n" (dry-run) option to reflog man page

3 years agoMerge branch 'rd/man-prune-progress'
Junio C Hamano [Wed, 6 Dec 2017 17:23:39 +0000 (09:23 -0800)]
Merge branch 'rd/man-prune-progress'

Doc update.

* rd/man-prune-progress:
  prune: add "--progress" to man page and usage msg

3 years agoMerge branch 'jt/submodule-tests-cleanup'
Junio C Hamano [Wed, 6 Dec 2017 17:23:38 +0000 (09:23 -0800)]
Merge branch 'jt/submodule-tests-cleanup'

Further test clean-up.

* jt/submodule-tests-cleanup:
  Tests: clean up submodule recursive helpers

3 years agoMerge branch 'jn/reproducible-build'
Junio C Hamano [Wed, 6 Dec 2017 17:23:37 +0000 (09:23 -0800)]
Merge branch 'jn/reproducible-build'

The build procedure has been taught to avoid some unnecessary
instability in the build products.

* jn/reproducible-build:
  generate-cmdlist: avoid non-deterministic output
  git-gui: sort entries in optimized tclIndex

3 years agoMerge branch 'cc/git-packet-pm'
Junio C Hamano [Wed, 6 Dec 2017 17:23:37 +0000 (09:23 -0800)]
Merge branch 'cc/git-packet-pm'

Code clean-up.

* cc/git-packet-pm:
  Git/Packet.pm: use 'if' instead of 'unless'
  Git/Packet: clarify that packet_required_key_val_read allows EOF

3 years agoMerge branch 'ac/complete-pull-autostash'
Junio C Hamano [Wed, 6 Dec 2017 17:23:37 +0000 (09:23 -0800)]
Merge branch 'ac/complete-pull-autostash'

The shell completion (in contrib/) learned that "git pull" can take
the "--autostash" option.

* ac/complete-pull-autostash:
  completion: add --autostash and --no-autostash to pull

3 years agoMerge branch 'hm/config-parse-expiry-date'
Junio C Hamano [Wed, 6 Dec 2017 17:23:37 +0000 (09:23 -0800)]
Merge branch 'hm/config-parse-expiry-date'

"git config --expiry-date gc.reflogexpire" can read "2.weeks" from
the configuration and report it as a timestamp, just like "--int"
would read "1k" and report 1024, to help consumption by scripts.

* hm/config-parse-expiry-date:
  config: add --expiry-date

3 years agoMerge branch 'tz/branch-doc-remove-set-upstream'
Junio C Hamano [Wed, 6 Dec 2017 17:23:36 +0000 (09:23 -0800)]
Merge branch 'tz/branch-doc-remove-set-upstream'

"git branch --set-upstream" has been deprecated and (sort of)
removed, as "--set-upstream-to" is the preferred one these days.
The documentation still had "--set-upstream" listed on its
synopsys section, which has been corrected.

* tz/branch-doc-remove-set-upstream:
  branch doc: remove --set-upstream from synopsis

3 years agoMerge branch 'cc/perf-run-config'
Junio C Hamano [Wed, 6 Dec 2017 17:23:36 +0000 (09:23 -0800)]
Merge branch 'cc/perf-run-config'

* cc/perf-run-config:
  perf: store subsection results in "test-results/$GIT_PERF_SUBSECTION/"
  perf/run: show name of rev being built
  perf/run: add run_subsection()
  perf/run: update get_var_from_env_or_config() for subsections
  perf/run: add get_subsections()
  perf/run: add calls to get_var_from_env_or_config()
  perf/run: add GIT_PERF_DIRS_OR_REVS
  perf/run: add get_var_from_env_or_config()
  perf/run: add '--config' option to the 'run' script

3 years agoMerge branch 'sb/submodule-recursive-checkout-detach-head'
Junio C Hamano [Wed, 6 Dec 2017 17:23:35 +0000 (09:23 -0800)]
Merge branch 'sb/submodule-recursive-checkout-detach-head'

"git checkout --recursive" may overwrite and rewind the history of
the branch that happens to be checked out in submodule
repositories, which might not be desirable.  Detach the HEAD but
still allow the recursive checkout to succeed in such a case.

* sb/submodule-recursive-checkout-detach-head:
  Documentation/checkout: clarify submodule HEADs to be detached
  recursive submodules: detach HEAD from new state

3 years agoPrepare for 2.15.2
Junio C Hamano [Wed, 6 Dec 2017 17:10:35 +0000 (09:10 -0800)]
Prepare for 2.15.2

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'jc/merge-base-fork-point-doc' into maint
Junio C Hamano [Wed, 6 Dec 2017 17:09:05 +0000 (09:09 -0800)]
Merge branch 'jc/merge-base-fork-point-doc' into maint

Clarify and enhance documentation for "merge-base --fork-point", as
it was clear what it computed but not why/what for.

* jc/merge-base-fork-point-doc:
  merge-base --fork-point doc: clarify the example and failure modes

3 years agoMerge branch 'tz/redirect-fix' into maint
Junio C Hamano [Wed, 6 Dec 2017 17:09:04 +0000 (09:09 -0800)]
Merge branch 'tz/redirect-fix' into maint

A few scripts (both in production and tests) incorrectly redirected
their error output.  These have been corrected.

* tz/redirect-fix:
  rebase: fix stderr redirect in apply_autostash()
  t/lib-gpg: fix gpgconf stderr redirect to /dev/null

3 years agoMerge branch 'tz/notes-error-to-stderr' into maint
Junio C Hamano [Wed, 6 Dec 2017 17:09:04 +0000 (09:09 -0800)]
Merge branch 'tz/notes-error-to-stderr' into maint

"git notes" sent its error message to its standard output stream,
which was corrected.

* tz/notes-error-to-stderr:
  notes: send "Automatic notes merge failed" messages to stderr

3 years agoMerge branch 'sb/test-cherry-pick-submodule-getting-in-a-way' into maint
Junio C Hamano [Wed, 6 Dec 2017 17:09:03 +0000 (09:09 -0800)]
Merge branch 'sb/test-cherry-pick-submodule-getting-in-a-way' into maint

The three-way merge performed by "git cherry-pick" was confused
when a new submodule was added in the meantime, which has been
fixed (or "papered over").

* sb/test-cherry-pick-submodule-getting-in-a-way:
  merge-recursive: handle addition of submodule on our side of history
  t/3512: demonstrate unrelated submodule/file conflict as cherry-pick failure

3 years agoMerge branch 'pw/sequencer-recover-from-unlockable-index' into maint
Junio C Hamano [Wed, 6 Dec 2017 17:09:03 +0000 (09:09 -0800)]
Merge branch 'pw/sequencer-recover-from-unlockable-index' into maint

The sequencer machinery (used by "git cherry-pick A..B", and "git
rebase -i", among other things) would have lost a commit if stopped
due to an unlockable index file, which has been fixed.

* pw/sequencer-recover-from-unlockable-index:
  sequencer: reschedule pick if index can't be locked

3 years agoMerge branch 'rs/apply-inaccurate-eof-with-incomplete-line' into maint
Junio C Hamano [Wed, 6 Dec 2017 17:09:03 +0000 (09:09 -0800)]
Merge branch 'rs/apply-inaccurate-eof-with-incomplete-line' into maint

"git apply --inaccurate-eof" when used with "--ignore-space-change"
triggered an internal sanity check, which has been fixed.

* rs/apply-inaccurate-eof-with-incomplete-line:
  apply: update line lengths for --inaccurate-eof

3 years agoMerge branch 'tz/complete-branch-copy' into maint
Junio C Hamano [Wed, 6 Dec 2017 17:09:02 +0000 (09:09 -0800)]
Merge branch 'tz/complete-branch-copy' into maint

Command line completion (in contrib/) has been taught about the
"--copy" option of "git branch".

* tz/complete-branch-copy:
  completion: add '--copy' option to 'git branch'

3 years agoMerge branch 'ew/rebase-mboxrd' into maint
Junio C Hamano [Wed, 6 Dec 2017 17:09:01 +0000 (09:09 -0800)]
Merge branch 'ew/rebase-mboxrd' into maint

When "git rebase" prepared an mailbox of changes and fed it to "git
am" to replay them, it was confused when a stray "From " happened
to be in the log message of one of the replayed changes.  This has
been corrected.

* ew/rebase-mboxrd:
  rebase: use mboxrd format to avoid split errors

3 years agoMerge branch 'sd/branch-copy' into maint
Junio C Hamano [Wed, 6 Dec 2017 17:09:01 +0000 (09:09 -0800)]
Merge branch 'sd/branch-copy' into maint

Code clean-up.

* sd/branch-copy:
  config: avoid "write_in_full(fd, buf, len) != len" pattern

3 years agoMerge branch 'sw/pull-ipv46-passthru' into maint
Junio C Hamano [Wed, 6 Dec 2017 17:09:00 +0000 (09:09 -0800)]
Merge branch 'sw/pull-ipv46-passthru' into maint

Contrary to the documentation, "git pull -4/-6 other-args" did not
ask the underlying "git fetch" to go over IPv4/IPv6, which has been
corrected.

* sw/pull-ipv46-passthru:
  pull: pass -4/-6 option to 'git fetch'

3 years agoMerge branch 'bc/submitting-patches-in-asciidoc' into maint
Junio C Hamano [Wed, 6 Dec 2017 17:08:59 +0000 (09:08 -0800)]
Merge branch 'bc/submitting-patches-in-asciidoc' into maint

The SubmittingPatches document has been converted to produce an
HTML version via AsciiDoc/Asciidoctor.

* bc/submitting-patches-in-asciidoc:
  Documentation: convert SubmittingPatches to AsciiDoc
  Documentation: enable compat-mode for Asciidoctor

3 years agoMerge branch 'mh/avoid-rewriting-packed-refs' into maint
Junio C Hamano [Wed, 6 Dec 2017 17:08:20 +0000 (09:08 -0800)]
Merge branch 'mh/avoid-rewriting-packed-refs' into maint

Recent update to the refs infrastructure implementation started
rewriting packed-refs file more often than before; this has been
optimized again for most trivial cases.

* mh/avoid-rewriting-packed-refs:
  files-backend: don't rewrite the `packed-refs` file unnecessarily
  t1409: check that `packed-refs` is not rewritten unnecessarily

3 years agoSync with v2.15.1
Junio C Hamano [Tue, 28 Nov 2017 04:43:55 +0000 (13:43 +0900)]
Sync with v2.15.1

3 years agoRelNotes: the seventh batch
Junio C Hamano [Tue, 28 Nov 2017 04:43:32 +0000 (13:43 +0900)]
RelNotes: the seventh batch

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'rs/include-comments-before-the-function-header'
Junio C Hamano [Tue, 28 Nov 2017 04:41:50 +0000 (13:41 +0900)]
Merge branch 'rs/include-comments-before-the-function-header'

"git grep -W", "git diff -W" and their friends learned a heuristic
to extend a pre-context beyond the line that matches the "function
pattern" (aka "diff.*.xfuncname") to include a comment block, if
exists, that immediately precedes it.

* rs/include-comments-before-the-function-header:
  grep: show non-empty lines before functions with -W
  grep: update boundary variable for pre-context
  t7810: improve check of -W with user-defined function lines
  xdiff: show non-empty lines before functions with -W
  xdiff: factor out is_func_rec()
  t4051: add test for comments preceding function lines

3 years agoMerge branch 'ma/branch-list-paginate'
Junio C Hamano [Tue, 28 Nov 2017 04:41:49 +0000 (13:41 +0900)]
Merge branch 'ma/branch-list-paginate'

"git branch --list" learned to show its output through the pager by
default when the output is going to a terminal, which is controlled
by the pager.branch configuration variable.  This is similar to a
recent change to "git tag --list".

* ma/branch-list-paginate:
  branch: change default of `pager.branch` to "on"
  branch: respect `pager.branch` in list-mode only
  t7006: add tests for how git branch paginates

3 years agoMerge branch 'jc/branch-name-sanity'
Junio C Hamano [Tue, 28 Nov 2017 04:41:49 +0000 (13:41 +0900)]
Merge branch 'jc/branch-name-sanity'

"git branch" and "git checkout -b" are now forbidden from creating
a branch whose name is "HEAD".

* jc/branch-name-sanity:
  builtin/branch: remove redundant check for HEAD
  branch: correctly reject refs/heads/{-dash,HEAD}
  branch: split validate_new_branchname() into two
  branch: streamline "attr_only" handling in validate_new_branchname()

3 years agoGit 2.15.1 v2.15.1
Junio C Hamano [Tue, 28 Nov 2017 04:39:14 +0000 (13:39 +0900)]
Git 2.15.1

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'rs/config-write-section-fix' into maint
Junio C Hamano [Tue, 28 Nov 2017 04:38:33 +0000 (13:38 +0900)]
Merge branch 'rs/config-write-section-fix' into maint

There was a recent semantic mismerge in the codepath to write out a
section of a configuration section, which has been corrected.

* rs/config-write-section-fix:
  config: flip return value of write_section()

3 years agorepository: fix a sparse 'using integer as NULL pointer' warning
Ramsay Jones [Tue, 28 Nov 2017 03:01:19 +0000 (03:01 +0000)]
repository: fix a sparse 'using integer as NULL pointer' warning

Commit 78a6766802 ("Integrate hash algorithm support with repo setup",
2017-11-12) added a 'const struct git_hash_algo *hash_algo' field to the
repository structure, without modifying the initializer of the 'the_repo'
variable. This does not actually introduce a bug, since the '0' initializer
for the 'ignore_env:1' bit-field is interpreted as a NULL pointer (hence
the warning), and the final field (now with no initializer) receives a
default '0'.

Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoRelNotes: the sixth batch for 2.16
Junio C Hamano [Mon, 27 Nov 2017 02:16:50 +0000 (11:16 +0900)]
RelNotes: the sixth batch for 2.16

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoSync with maint
Junio C Hamano [Mon, 27 Nov 2017 02:15:09 +0000 (11:15 +0900)]
Sync with maint

* maint:
  A bit more fixes for 2.15.1
  RelNotes: minor typo fixes in 2.15.1 draft

3 years agoMerge branch 'sw/pull-ipv46-passthru'
Junio C Hamano [Mon, 27 Nov 2017 02:06:40 +0000 (11:06 +0900)]
Merge branch 'sw/pull-ipv46-passthru'

Contrary to the documentation, "git pull -4/-6 other-args" did not
ask the underlying "git fetch" to go over IPv4/IPv6, which has been
corrected.

* sw/pull-ipv46-passthru:
  pull: pass -4/-6 option to 'git fetch'

3 years agoMerge branch 'ks/rebase-no-git-foo'
Junio C Hamano [Mon, 27 Nov 2017 02:06:39 +0000 (11:06 +0900)]
Merge branch 'ks/rebase-no-git-foo'

Mentions of "git-rebase" and "git-am" (dashed form) still remained
in end-user visible strings emitted by the "git rebase" command;
they have been corrected.

* ks/rebase-no-git-foo:
  git-rebase: clean up dashed-usages in messages

3 years agoMerge branch 'rs/config-write-section-fix'
Junio C Hamano [Mon, 27 Nov 2017 02:06:38 +0000 (11:06 +0900)]
Merge branch 'rs/config-write-section-fix'

There was a recent semantic mismerge in the codepath to write out a
section of a configuration section, which has been corrected.

* rs/config-write-section-fix:
  config: flip return value of write_section()

3 years agoMerge branch 'ew/rebase-mboxrd'
Junio C Hamano [Mon, 27 Nov 2017 02:06:37 +0000 (11:06 +0900)]
Merge branch 'ew/rebase-mboxrd'

When "git rebase" prepared an mailbox of changes and fed it to "git
am" to replay them, it was confused when a stray "From " happened
to be in the log message of one of the replayed changes.  This has
been corrected.

* ew/rebase-mboxrd:
  rebase: use mboxrd format to avoid split errors

3 years agoMerge branch 'tb/add-renormalize'
Junio C Hamano [Mon, 27 Nov 2017 02:06:37 +0000 (11:06 +0900)]
Merge branch 'tb/add-renormalize'

"git add --renormalize ." is a new and safer way to record the fact
that you are correcting the end-of-line convention and other
"convert_to_git()" glitches in the in-repository data.

* tb/add-renormalize:
  add: introduce "--renormalize"

3 years agoMerge branch 'tz/complete-branch-copy'
Junio C Hamano [Mon, 27 Nov 2017 02:06:37 +0000 (11:06 +0900)]
Merge branch 'tz/complete-branch-copy'

Command line completion (in contrib/) has been taught about the
"--copy" option of "git branch".

* tz/complete-branch-copy:
  completion: add '--copy' option to 'git branch'

3 years agoMerge branch 'rs/apply-inaccurate-eof-with-incomplete-line'
Junio C Hamano [Mon, 27 Nov 2017 02:06:36 +0000 (11:06 +0900)]
Merge branch 'rs/apply-inaccurate-eof-with-incomplete-line'

"git apply --inaccurate-eof" when used with "--ignore-space-change"
triggered an internal sanity check, which has been fixed.

* rs/apply-inaccurate-eof-with-incomplete-line:
  apply: update line lengths for --inaccurate-eof

3 years agoMerge branch 'pw/sequencer-recover-from-unlockable-index'
Junio C Hamano [Mon, 27 Nov 2017 02:06:35 +0000 (11:06 +0900)]
Merge branch 'pw/sequencer-recover-from-unlockable-index'

The sequencer machinery (used by "git cherry-pick A..B", and "git
rebase -i", among other things) would have lost a commit if stopped
due to an unlockable index file, which has been fixed.

* pw/sequencer-recover-from-unlockable-index:
  sequencer: reschedule pick if index can't be locked

3 years agoMerge branch 'sd/branch-copy'
Junio C Hamano [Mon, 27 Nov 2017 02:06:35 +0000 (11:06 +0900)]
Merge branch 'sd/branch-copy'

Code clean-up.

* sd/branch-copy:
  config: avoid "write_in_full(fd, buf, len) != len" pattern

3 years agoMerge branch 'sb/test-cherry-pick-submodule-getting-in-a-way'
Junio C Hamano [Mon, 27 Nov 2017 02:06:34 +0000 (11:06 +0900)]
Merge branch 'sb/test-cherry-pick-submodule-getting-in-a-way'

The three-way merge performed by "git cherry-pick" was confused
when a new submodule was added in the meantime, which has been
fixed (or "papered over").

* sb/test-cherry-pick-submodule-getting-in-a-way:
  merge-recursive: handle addition of submodule on our side of history
  t/3512: demonstrate unrelated submodule/file conflict as cherry-pick failure

3 years agoMerge branch 'tz/notes-error-to-stderr'
Junio C Hamano [Mon, 27 Nov 2017 02:06:34 +0000 (11:06 +0900)]
Merge branch 'tz/notes-error-to-stderr'

"git notes" sent its error message to its standard output stream,
which was corrected.

* tz/notes-error-to-stderr:
  notes: send "Automatic notes merge failed" messages to stderr

3 years agoMerge branch 'tz/redirect-fix'
Junio C Hamano [Mon, 27 Nov 2017 02:06:33 +0000 (11:06 +0900)]
Merge branch 'tz/redirect-fix'

A few scripts (both in production and tests) incorrectly redirected
their error output.  These have been corrected.

* tz/redirect-fix:
  rebase: fix stderr redirect in apply_autostash()
  t/lib-gpg: fix gpgconf stderr redirect to /dev/null

3 years agoMerge branch 'rv/sendemail-tocmd-in-config-and-completion'
Junio C Hamano [Mon, 27 Nov 2017 02:06:32 +0000 (11:06 +0900)]
Merge branch 'rv/sendemail-tocmd-in-config-and-completion'

Teach "sendemail.tocmd" to places that know about "sendemail.to",
like documentation and shell completion (in contrib/).

* rv/sendemail-tocmd-in-config-and-completion:
  completion: add git config sendemail.tocmd
  Documentation/config: add sendemail.tocmd to list preceding "See git-send-email(1)"

3 years agoMerge branch 'jc/merge-base-fork-point-doc'
Junio C Hamano [Mon, 27 Nov 2017 02:06:32 +0000 (11:06 +0900)]
Merge branch 'jc/merge-base-fork-point-doc'

Clarify and enhance documentation for "merge-base --fork-point", as
it was clear what it computed but not why/what for.

* jc/merge-base-fork-point-doc:
  merge-base --fork-point doc: clarify the example and failure modes

3 years agoMerge branch 'jc/ignore-cr-at-eol'
Junio C Hamano [Mon, 27 Nov 2017 02:06:31 +0000 (11:06 +0900)]
Merge branch 'jc/ignore-cr-at-eol'

The "diff" family of commands learned to ignore differences in
carriage return at the end of line.

* jc/ignore-cr-at-eol:
  diff: --ignore-cr-at-eol
  xdiff: reassign xpparm_t.flags bits

3 years agoA bit more fixes for 2.15.1
Junio C Hamano [Mon, 27 Nov 2017 01:58:31 +0000 (10:58 +0900)]
A bit more fixes for 2.15.1

We've been waiting long enough, a few more would not hurt ;-)

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'ma/reduce-heads-leakfix' into maint
Junio C Hamano [Mon, 27 Nov 2017 01:57:02 +0000 (10:57 +0900)]
Merge branch 'ma/reduce-heads-leakfix' into maint

Leak fixes.

* ma/reduce-heads-leakfix:
  reduce_heads: fix memory leaks
  builtin/merge-base: free commit lists

3 years agoMerge branch 'ma/bisect-leakfix' into maint
Junio C Hamano [Mon, 27 Nov 2017 01:57:02 +0000 (10:57 +0900)]
Merge branch 'ma/bisect-leakfix' into maint

Leak fixes.

* ma/bisect-leakfix:
  bisect: fix memory leak when returning best element
  bisect: fix off-by-one error in `best_bisection_sorted()`
  bisect: fix memory leak in `find_bisection()`
  bisect: change calling-convention of `find_bisection()`

3 years agoMerge branch 'rs/apply-fuzzy-match-fix' into maint
Junio C Hamano [Mon, 27 Nov 2017 01:57:02 +0000 (10:57 +0900)]
Merge branch 'rs/apply-fuzzy-match-fix' into maint

A fix for an ancient bug in "git apply --ignore-space-change" codepath.

* rs/apply-fuzzy-match-fix:
  apply: avoid out-of-bounds access in fuzzy_matchlines()

3 years agoMerge branch 'ad/submitting-patches-title-decoration' into maint
Junio C Hamano [Mon, 27 Nov 2017 01:57:01 +0000 (10:57 +0900)]
Merge branch 'ad/submitting-patches-title-decoration' into maint

Doc update around use of "format-patch --subject-prefix" etc.

* ad/submitting-patches-title-decoration:
  doc/SubmittingPatches: correct subject guidance

3 years agoMerge branch 'rs/imap-send-next-arg-fix' into maint
Junio C Hamano [Mon, 27 Nov 2017 01:57:00 +0000 (10:57 +0900)]
Merge branch 'rs/imap-send-next-arg-fix' into maint

Error checking in "git imap-send" for empty response has been
improved.

* rs/imap-send-next-arg-fix:
  imap-send: handle missing response codes gracefully
  imap-send: handle NULL return of next_arg()

3 years agoRelNotes: minor typo fixes in 2.15.1 draft
Todd Zullinger [Sat, 25 Nov 2017 17:32:40 +0000 (12:32 -0500)]
RelNotes: minor typo fixes in 2.15.1 draft

Signed-off-by: Todd Zullinger <tmz@pobox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agodoc: Mention info/attributes in gitrepository-layout
Steffen Prohaska [Wed, 22 Nov 2017 08:58:14 +0000 (09:58 +0100)]
doc: Mention info/attributes in gitrepository-layout

Signed-off-by: Steffen Prohaska <prohaska@zib.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agostash: learn to parse -m/--message like commit does
Phil Hord [Wed, 22 Nov 2017 21:20:30 +0000 (13:20 -0800)]
stash: learn to parse -m/--message like commit does

`git stash push -m foo` uses "foo" as the message for the stash. But
`git stash push -m"foo"` does not parse successfully.  Similarly
`git stash push --message="My stash message"` also fails.  The stash
documentation doesn't suggest this syntax should work, but gitcli
does and my fingers have learned this pattern long ago for `commit`.

Teach `git stash` to parse -mFoo and --message=Foo the same as `git
commit` would do.  Even though it's an internal function, add
similar support to create_stash() for consistency.

Signed-off-by: Phil Hord <phil.hord@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agocompletion: add --autostash and --no-autostash to pull
Albert Astals Cid [Tue, 21 Nov 2017 14:39:28 +0000 (15:39 +0100)]
completion: add --autostash and --no-autostash to pull

Ideally we should only autocomplete if pull has --rebase since
they only work with it but could not figure out how to do that
and the error message of doing git pull --autostash points out
that you need --rebase so i guess it's good enough

Signed-off-by: Albert Astals Cid <albert.astals.cid@kdab.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoGit/Packet.pm: use 'if' instead of 'unless'
Christian Couder [Tue, 21 Nov 2017 16:09:39 +0000 (17:09 +0100)]
Git/Packet.pm: use 'if' instead of 'unless'

The code is more understandable with 'if' instead of 'unless'.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoGit/Packet: clarify that packet_required_key_val_read allows EOF
Christian Couder [Tue, 21 Nov 2017 16:09:38 +0000 (17:09 +0100)]
Git/Packet: clarify that packet_required_key_val_read allows EOF

The function calls itself "required", but it does not die when it
sees an unexpected EOF.

Let's rename it to "packet_key_val_read()".

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'jn/reproducible-build' of ../git-gui into jn/reproducible-build
Junio C Hamano [Wed, 22 Nov 2017 05:57:52 +0000 (14:57 +0900)]
Merge branch 'jn/reproducible-build' of ../git-gui into jn/reproducible-build

* 'jn/reproducible-build' of ../git-gui:
  git-gui: sort entries in optimized tclIndex

3 years agogenerate-cmdlist: avoid non-deterministic output
Jonathan Nieder [Sat, 2 Jul 2016 00:32:00 +0000 (17:32 -0700)]
generate-cmdlist: avoid non-deterministic output

Non-determinism makes it harder for build tools to discover when a
target needs to be rebuilt.

generate-cmdlist.sh stores the full path in a comment:

 /* Automatically generated by /build/git-agojiD/git-2.15.0/generate-cmdlist.sh */

Use the file name alone instead.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agogit-gui: sort entries in optimized tclIndex
Anders Kaseorg [Wed, 16 Nov 2016 21:37:17 +0000 (16:37 -0500)]
git-gui: sort entries in optimized tclIndex

auto_mkindex expands wildcards in directory order, which depends on
the underlying filesystem.  To improve build reproducibility, sort the
list of *.tcl files in the Makefile.

The unoptimized loading case was previously fixed in gitgui-0.21.0~14
(git-gui: sort entries in tclIndex, 2015-01-26).

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agodoc: prefer 'stash push' over 'stash save'
Phil Hord [Tue, 21 Nov 2017 23:05:23 +0000 (15:05 -0800)]
doc: prefer 'stash push' over 'stash save'

Although `git stash save` was deprecated recently, some parts of the
documentation still refer to it instead of `push`.

Signed-off-by: Phil Hord <phil.hord@gmail.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoTests: clean up submodule recursive helpers
Jonathan Tan [Tue, 21 Nov 2017 22:12:56 +0000 (14:12 -0800)]
Tests: clean up submodule recursive helpers

This continues the work in commit d3b5a49 ("Tests: clean up and document
submodule helpers", 2017-11-08).

Factor out the commonalities from
test_submodule_switch_recursing_with_args() and
test_submodule_forced_switch_recursing_with_args() in
lib-submodule-update.sh, and document their usage. Some tests differ
slightly in their test assertions; I have used the superset of those
assertions in that case.

Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agolog: add option to choose which refs to decorate
Rafael Ascensão [Tue, 21 Nov 2017 21:33:41 +0000 (21:33 +0000)]
log: add option to choose which refs to decorate

When `log --decorate` is used, git will decorate commits with all
available refs. While in most cases this may give the desired effect,
under some conditions it can lead to excessively verbose output.

Introduce two command line options, `--decorate-refs=<pattern>` and
`--decorate-refs-exclude=<pattern>` to allow the user to select which
refs are used in decoration.

When "--decorate-refs=<pattern>" is given, only the refs that match the
pattern are used in decoration. The refs that match the pattern when
"--decorate-refs-exclude=<pattern>" is given, are never used in
decoration.

These options follow the same convention for mixing negative and
positive patterns across the system, assuming that the inclusive default
is to match all refs available.

 (1) if there is no positive pattern given, pretend as if an
     inclusive default positive pattern was given;

 (2) for each candidate, reject it if it matches no positive
     pattern, or if it matches any one of the negative patterns.

The rules for what is considered a match are slightly different from the
rules used elsewhere.

Commands like `log --glob` assume a trailing '/*' when glob chars are
not present in the pattern. This makes it difficult to specify a single
ref.  On the other hand, commands like `describe --match --all` allow
specifying exact refs, but do not have the convenience of allowing
"shorthand refs" like 'refs/heads' or 'heads' to refer to
'refs/heads/*'.

The commands introduced in this patch consider a match if:

  (a) the pattern contains globs chars,
and regular pattern matching returns a match.

  (b) the pattern does not contain glob chars,
         and ref '<pattern>' exists, or if ref exists under '<pattern>/'

This allows both behaviours (allowing single refs and shorthand refs)
yet remaining compatible with existent commands.

Helped-by: Kevin Daudt <me@ikke.info>
Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Rafael Ascensão <rafa.almas@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agonotes: correct 'git notes prune' options to '[-n] [-v]'
Robert P. J. Day [Tue, 21 Nov 2017 19:17:21 +0000 (14:17 -0500)]
notes: correct 'git notes prune' options to '[-n] [-v]'

Currently, 'git notes prune' in man page and usage message
incorrectly lists options as '[-n | -v]', rather than '[-n] [-v]'.

Signed-off-by: Robert P. J. Day <rpjday@crashcourse.ca>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoprune: add "--progress" to man page and usage msg
Robert P. J. Day [Tue, 21 Nov 2017 15:51:52 +0000 (10:51 -0500)]
prune: add "--progress" to man page and usage msg

Add mention of git prune's "--progress" option to the SYNOPSIS and
DESCRIPTION sections of the man page, and to the usage message of "git
prune" itself.

While we're here, move the explanation of "--" toward the end of the
DESCRIPTION section, where it belongs.

Signed-off-by: Robert P. J. Day <rpjday@crashcourse.ca>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agodoc: add missing "-n" (dry-run) option to reflog man page
Robert P. J. Day [Tue, 21 Nov 2017 15:39:55 +0000 (10:39 -0500)]
doc: add missing "-n" (dry-run) option to reflog man page

While the "git reflog" man page supports both "--dry-run" and "-n" for
a dry run, the man page mentions only the former, not the latter.

Signed-off-by: Robert P. J. Day <rpjday@crashcourse.ca>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agosha1_file: fast-path null sha1 as a missing object
Jeff King [Tue, 21 Nov 2017 23:17:39 +0000 (18:17 -0500)]
sha1_file: fast-path null sha1 as a missing object

In theory nobody should ever ask the low-level object code
for a null sha1. It's used as a sentinel for "no such
object" in lots of places, so leaking through to this level
is a sign that the higher-level code is not being careful
about its error-checking.  In practice, though, quite a few
code paths seem to rely on the null sha1 lookup failing as a
way to quietly propagate non-existence (e.g., by feeding it
to lookup_commit_reference_gently(), which then returns
NULL).

When this happens, we do two inefficient things:

  1. We actually search for the null sha1 in packs and in
     the loose object directory.

  2. When we fail to find it, we re-scan the pack directory
     in case a simultaneous repack happened to move it from
     loose to packed. This can be very expensive if you have
     a large number of packs.

Only the second one actually causes noticeable performance
problems, so we could treat them independently. But for the
sake of simplicity (both of code and of reasoning about it),
it makes sense to just declare that the null sha1 cannot be
a real on-disk object, and looking it up will always return
"no such object".

There's no real loss of functionality to do so Its use as a
sentinel value means that anybody who is unlucky enough to
hit the 2^-160th chance of generating an object with that
sha1 is already going to find the object largely unusable.

In an ideal world, we'd simply fix all of the callers to
notice the null sha1 and avoid passing it to us. But a
simple experiment to catch this with a BUG() shows that
there are a large number of code paths that do so.

So in the meantime, let's fix the performance problem by
taking a fast exit from the object lookup when we see a null
sha1. p5551 shows off the improvement (when a fetched ref is
new, the "old" sha1 is 0{40}, which ends up being passed for
fast-forward checks, the status table abbreviations, etc):

  Test            HEAD^             HEAD
  --------------------------------------------------------
  5551.4: fetch   5.51(5.03+0.48)   0.17(0.10+0.06) -96.9%

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoSync with maint
Junio C Hamano [Tue, 21 Nov 2017 05:11:40 +0000 (14:11 +0900)]
Sync with maint

* maint:
  Almost ready for 2.15.1

3 years agoRelNotes: the fifth batch for 2.16
Junio C Hamano [Tue, 21 Nov 2017 05:11:06 +0000 (14:11 +0900)]
RelNotes: the fifth batch for 2.16

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'rs/apply-fuzzy-match-fix'
Junio C Hamano [Tue, 21 Nov 2017 05:07:52 +0000 (14:07 +0900)]
Merge branch 'rs/apply-fuzzy-match-fix'

A fix for an ancient bug in "git apply --ignore-space-change" codepath.

* rs/apply-fuzzy-match-fix:
  apply: avoid out-of-bounds access in fuzzy_matchlines()

3 years agoMerge branch 'ad/submitting-patches-title-decoration'
Junio C Hamano [Tue, 21 Nov 2017 05:07:51 +0000 (14:07 +0900)]
Merge branch 'ad/submitting-patches-title-decoration'

Doc update around use of "format-patch --subject-prefix" etc.

* ad/submitting-patches-title-decoration:
  doc/SubmittingPatches: correct subject guidance

3 years agoMerge branch 'av/fsmonitor'
Junio C Hamano [Tue, 21 Nov 2017 05:07:51 +0000 (14:07 +0900)]
Merge branch 'av/fsmonitor'

Various fixes to bp/fsmonitor topic.

* av/fsmonitor:
  fsmonitor: simplify determining the git worktree under Windows
  fsmonitor: store fsmonitor bitmap before splitting index
  fsmonitor: read from getcwd(), not the PWD environment variable
  fsmonitor: delay updating state until after split index is merged
  fsmonitor: document GIT_TRACE_FSMONITOR
  fsmonitor: don't bother pretty-printing JSON from watchman
  fsmonitor: set the PWD to the top of the working tree

3 years agoMerge branch 'bp/fsmonitor'
Junio C Hamano [Tue, 21 Nov 2017 05:07:50 +0000 (14:07 +0900)]
Merge branch 'bp/fsmonitor'

We learned to talk to watchman to speed up "git status" and other
operations that need to see which paths have been modified.

* bp/fsmonitor:
  fsmonitor: preserve utf8 filenames in fsmonitor-watchman log
  fsmonitor: read entirety of watchman output
  fsmonitor: MINGW support for watchman integration
  fsmonitor: add a performance test
  fsmonitor: add a sample integration script for Watchman
  fsmonitor: add test cases for fsmonitor extension
  split-index: disable the fsmonitor extension when running the split index test
  fsmonitor: add a test tool to dump the index extension
  update-index: add fsmonitor support to update-index
  ls-files: Add support in ls-files to display the fsmonitor valid bit
  fsmonitor: add documentation for the fsmonitor extension.
  fsmonitor: teach git to optionally utilize a file system monitor to speed up detecting new or changed files.
  update-index: add a new --force-write-index option
  preload-index: add override to enable testing preload-index
  bswap: add 64 bit endianness helper get_be64

3 years agoAlmost ready for 2.15.1
Junio C Hamano [Tue, 21 Nov 2017 05:07:08 +0000 (14:07 +0900)]
Almost ready for 2.15.1

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'rs/sequencer-rewrite-file-cleanup' into maint
Junio C Hamano [Tue, 21 Nov 2017 05:05:33 +0000 (14:05 +0900)]
Merge branch 'rs/sequencer-rewrite-file-cleanup' into maint

Code cleanup.

* rs/sequencer-rewrite-file-cleanup:
  sequencer.c: check return value of close() in rewrite_file()
  sequencer: use O_TRUNC to truncate files
  sequencer: factor out rewrite_file()

3 years agoMerge branch 'cb/t4201-robustify' into maint
Junio C Hamano [Tue, 21 Nov 2017 05:05:33 +0000 (14:05 +0900)]
Merge branch 'cb/t4201-robustify' into maint

A test update.

* cb/t4201-robustify:
  t4201: make use of abbreviation in the test more robust

3 years agoMerge branch 'tz/fsf-address-update' into maint
Junio C Hamano [Tue, 21 Nov 2017 05:05:32 +0000 (14:05 +0900)]
Merge branch 'tz/fsf-address-update' into maint

Replace the mailing address of FSF to a URL, as FSF prefers.

* tz/fsf-address-update:
  Replace Free Software Foundation address in license notices
  Replace Free Software Foundation address in license notices

3 years agoMerge branch 'ad/rebase-i-serie-typofix' into maint
Junio C Hamano [Tue, 21 Nov 2017 05:05:32 +0000 (14:05 +0900)]
Merge branch 'ad/rebase-i-serie-typofix' into maint

Typofix.

* ad/rebase-i-serie-typofix:
  rebase -i: fix comment typo

3 years agoMerge branch 'jk/info-alternates-fix' into maint
Junio C Hamano [Tue, 21 Nov 2017 05:05:31 +0000 (14:05 +0900)]
Merge branch 'jk/info-alternates-fix' into maint

We used to add an empty alternate object database to the system
that does not help anything; it has been corrected.

* jk/info-alternates-fix:
  link_alt_odb_entries: make empty input a noop

3 years agoMerge branch 'ab/pcre-v2' into maint
Junio C Hamano [Tue, 21 Nov 2017 05:05:30 +0000 (14:05 +0900)]
Merge branch 'ab/pcre-v2' into maint

Building with NO_LIBPCRE1_JIT did not disable it, which has been fixed.

* ab/pcre-v2:
  grep: fix NO_LIBPCRE1_JIT to fully disable JIT

3 years agoMerge branch 'sr/wrapper-quote-filenames' into maint
Junio C Hamano [Tue, 21 Nov 2017 05:05:29 +0000 (14:05 +0900)]
Merge branch 'sr/wrapper-quote-filenames' into maint

Some error messages did not quote filenames shown in it, which have
been fixed.

* sr/wrapper-quote-filenames:
  wrapper.c: consistently quote filenames in error messages

3 years agoMerge branch 'bw/rebase-i-ignored-submodule-fix' into maint
Junio C Hamano [Tue, 21 Nov 2017 05:05:29 +0000 (14:05 +0900)]
Merge branch 'bw/rebase-i-ignored-submodule-fix' into maint

"git rebase -i" recently started misbehaving when a submodule that
is configured with 'submodule.<name>.ignore' is dirty; this has
been corrected.

* bw/rebase-i-ignored-submodule-fix:
  wt-status: actually ignore submodules when requested

3 years agoconnect: correct style of C-style comment
Jonathan Nieder [Mon, 20 Nov 2017 22:04:58 +0000 (14:04 -0800)]
connect: correct style of C-style comment

Documentation/CodingGuidelines explains:

 - Multi-line comments include their delimiters on separate lines from
   the text.  E.g.

/*
 * A very long
 * multi-line comment.
 */

Reported-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agossh: 'simple' variant does not support --port
Jonathan Nieder [Mon, 20 Nov 2017 21:31:01 +0000 (13:31 -0800)]
ssh: 'simple' variant does not support --port

When trying to connect to an ssh:// URL with port explicitly specified
and the ssh command configured with GIT_SSH does not support such a
setting, it is less confusing to error out than to silently suppress
the port setting and continue.

This requires updating the GIT_SSH setting in t5603-clone-dirname.sh.
That test is about the directory name produced when cloning various
URLs.  It uses an ssh wrapper that ignores all its arguments but does
not declare that it supports a port argument; update it to set
GIT_SSH_VARIANT=ssh to do so.  (Real-life ssh wrappers that pass a
port argument to OpenSSH would also support -G and would not require
such an update.)

Reported-by: William Yan <wyan@google.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Acked-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agossh: 'simple' variant does not support -4/-6
Jonathan Nieder [Mon, 20 Nov 2017 21:30:30 +0000 (13:30 -0800)]
ssh: 'simple' variant does not support -4/-6

If the user passes -4/--ipv4 or -6/--ipv6 to "git fetch" or "git push"
and the ssh command configured with GIT_SSH does not support such a
setting, error out instead of ignoring the option and continuing.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Acked-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agossh: 'auto' variant to select between 'ssh' and 'simple'
Jonathan Nieder [Mon, 20 Nov 2017 21:30:04 +0000 (13:30 -0800)]
ssh: 'auto' variant to select between 'ssh' and 'simple'

Android's "repo" tool is a tool for managing a large codebase
consisting of multiple smaller repositories, similar to Git's
submodule feature.  Starting with Git 94b8ae5a (ssh: introduce a
'simple' ssh variant, 2017-10-16), users noticed that it stopped
handling the port in ssh:// URLs.

The cause: when it encounters ssh:// URLs, repo pre-connects to the
server and sets GIT_SSH to a helper ".repo/repo/git_ssh" that reuses
that connection.  Before 94b8ae5a, the helper was assumed to support
OpenSSH options for lack of a better guess and got passed a -p option
to set the port.  After that patch, it uses the new default of a
simple helper that does not accept an option to set the port.

The next release of "repo" will set GIT_SSH_VARIANT to "ssh" to avoid
that.  But users of old versions and of other similar GIT_SSH
implementations would not get the benefit of that fix.

So update the default to use OpenSSH options again, with a twist.  As
observed in 94b8ae5a, we cannot assume that $GIT_SSH always handles
OpenSSH options: common helpers such as travis-ci's dpl[*] are
configured using GIT_SSH and do not accept OpenSSH options.  So make
the default a new variant "auto", with the following behavior:

 1. First, check for a recognized basename, like today.

 2. If the basename is not recognized, check whether $GIT_SSH supports
    OpenSSH options by running

$GIT_SSH -G <options> <host>

    This returns status 0 and prints configuration in OpenSSH if it
    recognizes all <options> and returns status 255 if it encounters
    an unrecognized option.  A wrapper script like

exec ssh -- "$@"

    would fail with

ssh: Could not resolve hostname -g: Name or service not known

    , correctly reflecting that it does not support OpenSSH options.
    The command is run with stdin, stdout, and stderr redirected to
    /dev/null so even a command that expects a terminal would exit
    immediately.

 3. Based on the result from step (2), behave like "ssh" (if it
    succeeded) or "simple" (if it failed).

This way, the default ssh variant for unrecognized commands can handle
both the repo and dpl cases as intended.

This autodetection has been running on Google workstations since
2017-10-23 with no reported negative effects.

[*] https://github.com/travis-ci/dpl/blob/6c3fddfda1f2a85944c544446b068bac0a77c049/lib/dpl/provider.rb#L215

Reported-by: William Yan <wyan@google.com>
Improved-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>