git
5 years agoMerge branch 'es/want-color-fd-defensive'
Junio C Hamano [Fri, 17 Aug 2018 20:09:56 +0000 (13:09 -0700)] 
Merge branch 'es/want-color-fd-defensive'

Futureproofing a helper function that can easily be misused.

* es/want-color-fd-defensive:
  color: protect against out-of-bounds reads and writes

5 years agoMerge branch 'ab/sha1dc'
Junio C Hamano [Fri, 17 Aug 2018 20:09:56 +0000 (13:09 -0700)] 
Merge branch 'ab/sha1dc'

AIX portability update for the SHA1DC hash, imported from upstream.

* ab/sha1dc:
  sha1dc: update from upstream

5 years agoMerge branch 'rs/parse-opt-lithelp'
Junio C Hamano [Fri, 17 Aug 2018 20:09:56 +0000 (13:09 -0700)] 
Merge branch 'rs/parse-opt-lithelp'

The parse-options machinery learned to refrain from enclosing
placeholder string inside a "<bra" and "ket>" pair automatically
without PARSE_OPT_LITERAL_ARGHELP.  Existing help text for option
arguments that are not formatted correctly have been identified and
fixed.

* rs/parse-opt-lithelp:
  parse-options: automatically infer PARSE_OPT_LITERAL_ARGHELP
  shortlog: correct option help for -w
  send-pack: specify --force-with-lease argument help explicitly
  pack-objects: specify --index-version argument help explicitly
  difftool: remove angular brackets from argument help
  add, update-index: fix --chmod argument help
  push: use PARSE_OPT_LITERAL_ARGHELP instead of unbalanced brackets

5 years agoMerge branch 'ab/fetch-nego'
Junio C Hamano [Fri, 17 Aug 2018 20:09:55 +0000 (13:09 -0700)] 
Merge branch 'ab/fetch-nego'

Update to a few other topics around 'git fetch'.

* ab/fetch-nego:
  fetch doc: cross-link two new negotiation options
  negotiator: unknown fetch.negotiationAlgorithm should error out

5 years agoMerge branch 'jt/refspec-dwim-precedence-fix'
Junio C Hamano [Fri, 17 Aug 2018 20:09:55 +0000 (13:09 -0700)] 
Merge branch 'jt/refspec-dwim-precedence-fix'

"git fetch $there refs/heads/s" ought to fetch the tip of the
branch 's', but when "refs/heads/refs/heads/s", i.e. a branch whose
name is "refs/heads/s" exists at the same time, fetched that one
instead by mistake.  This has been corrected to honor the usual
disambiguation rules for abbreviated refnames.

* jt/refspec-dwim-precedence-fix:
  remote: make refspec follow the same disambiguation rule as local refs

5 years agoMerge branch 'jk/merge-subtree-heuristics'
Junio C Hamano [Fri, 17 Aug 2018 20:09:55 +0000 (13:09 -0700)] 
Merge branch 'jk/merge-subtree-heuristics'

The automatic tree-matching in "git merge -s subtree" was broken 5
years ago and nobody has noticed since then, which is now fixed.

* jk/merge-subtree-heuristics:
  score_trees(): fix iteration over trees with missing entries

5 years agoMerge branch 'ab/test-must-be-empty'
Junio C Hamano [Fri, 17 Aug 2018 20:09:54 +0000 (13:09 -0700)] 
Merge branch 'ab/test-must-be-empty'

Test updates.

* ab/test-must-be-empty:
  tests: make use of the test_must_be_empty function

5 years agoMerge branch 'es/rebase-i-author-script-fix'
Junio C Hamano [Fri, 17 Aug 2018 20:09:54 +0000 (13:09 -0700)] 
Merge branch 'es/rebase-i-author-script-fix'

The "author-script" file "git rebase -i" creates got broken when
we started to move the command away from shell script, which is
getting fixed now.

* es/rebase-i-author-script-fix:
  sequencer: don't die() on bogus user-edited timestamp
  sequencer: fix "rebase -i --root" corrupting author header timestamp
  sequencer: fix "rebase -i --root" corrupting author header timezone
  sequencer: fix "rebase -i --root" corrupting author header

5 years agoMerge branch 'ab/fsck-transfer-updates'
Junio C Hamano [Fri, 17 Aug 2018 20:09:54 +0000 (13:09 -0700)] 
Merge branch 'ab/fsck-transfer-updates'

The test performed at the receiving end of "git push" to prevent
bad objects from entering repository can be customized via
receive.fsck.* configuration variables; we now have gained a
counterpart to do the same on the "git fetch" side, with
fetch.fsck.* configuration variables.

* ab/fsck-transfer-updates:
  fsck: test and document unknown fsck.<msg-id> values
  fsck: add stress tests for fsck.skipList
  fsck: test & document {fetch,receive}.fsck.* config fallback
  fetch: implement fetch.fsck.*
  transfer.fsckObjects tests: untangle confusing setup
  config doc: elaborate on fetch.fsckObjects security
  config doc: elaborate on what transfer.fsckObjects does
  config doc: unify the description of fsck.* and receive.fsck.*
  config doc: don't describe *.fetchObjects twice
  receive.fsck.<msg-id> tests: remove dead code

5 years agoSixth batch for 2.19 cycle
Junio C Hamano [Wed, 15 Aug 2018 22:13:39 +0000 (15:13 -0700)] 
Sixth batch for 2.19 cycle

Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agoMerge branch 'jt/connectivity-check-after-unshallow'
Junio C Hamano [Wed, 15 Aug 2018 22:08:28 +0000 (15:08 -0700)] 
Merge branch 'jt/connectivity-check-after-unshallow'

"git fetch" sometimes failed to update the remote-tracking refs,
which has been corrected.

* jt/connectivity-check-after-unshallow:
  fetch-pack: unify ref in and out param

5 years agoMerge branch 'sg/travis-retrieve-trash-upon-failure'
Junio C Hamano [Wed, 15 Aug 2018 22:08:28 +0000 (15:08 -0700)] 
Merge branch 'sg/travis-retrieve-trash-upon-failure'

The Travis CI scripts were taught to ship back the test data from
failed tests.

* sg/travis-retrieve-trash-upon-failure:
  travis-ci: include the trash directories of failed tests in the trace log

5 years agoMerge branch 'rs/remote-mv-leakfix'
Junio C Hamano [Wed, 15 Aug 2018 22:08:28 +0000 (15:08 -0700)] 
Merge branch 'rs/remote-mv-leakfix'

Leakfix.

* rs/remote-mv-leakfix:
  remote: clear string_list after use in mv()

5 years agoMerge branch 'es/mw-to-git-chain-fix'
Junio C Hamano [Wed, 15 Aug 2018 22:08:27 +0000 (15:08 -0700)] 
Merge branch 'es/mw-to-git-chain-fix'

Test fix.

* es/mw-to-git-chain-fix:
  mw-to-git/t9360: fix broken &&-chain

5 years agoMerge branch 'ms/http-proto-doc'
Junio C Hamano [Wed, 15 Aug 2018 22:08:27 +0000 (15:08 -0700)] 
Merge branch 'ms/http-proto-doc'

Doc fix.

* ms/http-proto-doc:
  doc: fix want-capability separator

5 years agoMerge branch 'nd/pack-objects-threading-doc'
Junio C Hamano [Wed, 15 Aug 2018 22:08:27 +0000 (15:08 -0700)] 
Merge branch 'nd/pack-objects-threading-doc'

Doc fix.

* nd/pack-objects-threading-doc:
  pack-objects: document about thread synchronization

5 years agoMerge branch 'jn/subtree-test-fixes'
Junio C Hamano [Wed, 15 Aug 2018 22:08:27 +0000 (15:08 -0700)] 
Merge branch 'jn/subtree-test-fixes'

Test fix.

* jn/subtree-test-fixes:
  subtree test: simplify preparation of expected results
  subtree test: add missing && to &&-chain

5 years agoMerge branch 'cb/p4-pre-submit-hook'
Junio C Hamano [Wed, 15 Aug 2018 22:08:27 +0000 (15:08 -0700)] 
Merge branch 'cb/p4-pre-submit-hook'

"git p4 submit" learns to ask its own pre-submit hook if it should
continue with submitting.

* cb/p4-pre-submit-hook:
  git-p4: add the `p4-pre-submit` hook

5 years agoMerge branch 'js/vscode'
Junio C Hamano [Wed, 15 Aug 2018 22:08:26 +0000 (15:08 -0700)] 
Merge branch 'js/vscode'

Add a script (in contrib/) to help users of VSCode work better with
our codebase.

* js/vscode:
  vscode: let cSpell work on commit messages, too
  vscode: add a dictionary for cSpell
  vscode: use 8-space tabs, no trailing ws, etc for Git's source code
  vscode: wrap commit messages at column 72 by default
  vscode: only overwrite C/C++ settings
  mingw: define WIN32 explicitly
  cache.h: extract enum declaration from inside a struct declaration
  vscode: hard-code a couple defines
  contrib: add a script to initialize VS Code configuration

5 years agoMerge branch 'bb/redecl-enum-fix'
Junio C Hamano [Wed, 15 Aug 2018 22:08:26 +0000 (15:08 -0700)] 
Merge branch 'bb/redecl-enum-fix'

Compilation fix.

* bb/redecl-enum-fix:
  packfile: ensure that enum object_type is defined

5 years agoMerge branch 'jk/banned-function'
Junio C Hamano [Wed, 15 Aug 2018 22:08:26 +0000 (15:08 -0700)] 
Merge branch 'jk/banned-function'

It is too easy to misuse system API functions such as strcat();
these selected functions are now forbidden in this codebase and
will cause a compilation failure.

* jk/banned-function:
  banned.h: mark strncpy() as banned
  banned.h: mark sprintf() as banned
  banned.h: mark strcat() as banned
  automatically ban strcpy()

5 years agoMerge branch 'en/merge-recursive-skip-fix'
Junio C Hamano [Wed, 15 Aug 2018 22:08:25 +0000 (15:08 -0700)] 
Merge branch 'en/merge-recursive-skip-fix'

When the sparse checkout feature is in use, "git cherry-pick" and
other mergy operations lost the skip_worktree bit when a path that
is excluded from checkout requires content level merge, which is
resolved as the same as the HEAD version, without materializing the
merge result in the working tree, which made the path appear as
deleted.  This has been corrected by preserving the skip_worktree
bit (and not materializing the file in the working tree).

* en/merge-recursive-skip-fix:
  merge-recursive: preserve skip_worktree bit when necessary
  t3507: add a testcase showing failure with sparse checkout

5 years agoMerge branch 'jt/tag-following-with-proto-v2-fix'
Junio C Hamano [Wed, 15 Aug 2018 22:08:25 +0000 (15:08 -0700)] 
Merge branch 'jt/tag-following-with-proto-v2-fix'

The wire-protocol v2 relies on the client to send "ref prefixes" to
limit the bandwidth spent on the initial ref advertisement.  "git
fetch $remote branch:branch" that asks tags that point into the
history leading to the "branch" automatically followed sent to
narrow prefix and broke the tag following, which has been fixed.

* jt/tag-following-with-proto-v2-fix:
  fetch: send "refs/tags/" prefix upon CLI refspecs
  t5702: test fetch with multiple refspecs at a time

5 years agoMerge branch 'jk/size-t'
Junio C Hamano [Wed, 15 Aug 2018 22:08:25 +0000 (15:08 -0700)] 
Merge branch 'jk/size-t'

Code clean-up to use size_t/ssize_t when they are the right type.

* jk/size-t:
  strbuf_humanise: use unsigned variables
  pass st.st_size as hint for strbuf_readlink()
  strbuf_readlink: use ssize_t
  strbuf: use size_t for length in intermediate variables
  reencode_string: use size_t for string lengths
  reencode_string: use st_add/st_mult helpers

5 years agoMerge branch 'sg/coccicheck-updates'
Junio C Hamano [Wed, 15 Aug 2018 22:08:25 +0000 (15:08 -0700)] 
Merge branch 'sg/coccicheck-updates'

Update the way we use Coccinelle to find out-of-style code that
need to be modernised.

* sg/coccicheck-updates:
  coccinelle: extract dedicated make target to clean Coccinelle's results
  coccinelle: put sane filenames into output patches
  coccinelle: exclude sha1dc source files from static analysis
  coccinelle: use $(addsuffix) in 'coccicheck' make target
  coccinelle: mark the 'coccicheck' make target as .PHONY

5 years agoMerge branch 'sb/histogram-less-memory'
Junio C Hamano [Wed, 15 Aug 2018 22:08:25 +0000 (15:08 -0700)] 
Merge branch 'sb/histogram-less-memory'

"git diff --histogram" had a bad memory usage pattern, which has
been rearranged to reduce the peak usage.

* sb/histogram-less-memory:
  xdiff/histogram: remove tail recursion
  xdiff/xhistogram: move index allocation into find_lcs
  xdiff/xhistogram: factor out memory cleanup into free_index()
  xdiff/xhistogram: pass arguments directly to fall_back_to_classic_diff

5 years agoMerge branch 'nd/i18n'
Junio C Hamano [Wed, 15 Aug 2018 22:08:23 +0000 (15:08 -0700)] 
Merge branch 'nd/i18n'

Many more strings are prepared for l10n.

* nd/i18n: (23 commits)
  transport-helper.c: mark more strings for translation
  transport.c: mark more strings for translation
  sha1-file.c: mark more strings for translation
  sequencer.c: mark more strings for translation
  replace-object.c: mark more strings for translation
  refspec.c: mark more strings for translation
  refs.c: mark more strings for translation
  pkt-line.c: mark more strings for translation
  object.c: mark more strings for translation
  exec-cmd.c: mark more strings for translation
  environment.c: mark more strings for translation
  dir.c: mark more strings for translation
  convert.c: mark more strings for translation
  connect.c: mark more strings for translation
  config.c: mark more strings for translation
  commit-graph.c: mark more strings for translation
  builtin/replace.c: mark more strings for translation
  builtin/pack-objects.c: mark more strings for translation
  builtin/grep.c: mark strings for translation
  builtin/config.c: mark more strings for translation
  ...

5 years agoMerge branch 'hs/gpgsm'
Junio C Hamano [Wed, 15 Aug 2018 22:08:23 +0000 (15:08 -0700)] 
Merge branch 'hs/gpgsm'

Teach "git tag -s" etc. a few configuration variables (gpg.format
that can be set to "openpgp" or "x509", and gpg.<format>.program
that is used to specify what program to use to deal with the format)
to allow x.509 certs with CMS via "gpgsm" to be used instead of
openpgp via "gnupg".

* hs/gpgsm:
  gpg-interface t: extend the existing GPG tests with GPGSM
  gpg-interface: introduce new signature format "x509" using gpgsm
  gpg-interface: introduce new config to select per gpg format program
  gpg-interface: do not hardcode the key string len anymore
  gpg-interface: introduce an abstraction for multiple gpg formats
  t/t7510: check the validation of the new config gpg.format
  gpg-interface: add new config to select how to sign a commit

5 years agoMerge branch 'bw/clone-ref-prefixes'
Junio C Hamano [Wed, 15 Aug 2018 22:08:23 +0000 (15:08 -0700)] 
Merge branch 'bw/clone-ref-prefixes'

The wire-protocol v2 relies on the client to send "ref prefixes" to
limit the bandwidth spent on the initial ref advertisement.  "git
clone" when learned to speak v2 forgot to do so, which has been
corrected.

* bw/clone-ref-prefixes:
  clone: send ref-prefixes when using protocol v2

5 years agoMerge branch 'jk/core-use-replace-refs'
Junio C Hamano [Wed, 15 Aug 2018 22:08:22 +0000 (15:08 -0700)] 
Merge branch 'jk/core-use-replace-refs'

A new configuration variable core.usereplacerefs has been added,
primarily to help server installations that want to ignore the
replace mechanism altogether.

* jk/core-use-replace-refs:
  add core.usereplacerefs config option
  check_replace_refs: rename to read_replace_refs
  check_replace_refs: fix outdated comment

5 years agoMerge branch 'jh/json-writer'
Junio C Hamano [Wed, 15 Aug 2018 22:08:22 +0000 (15:08 -0700)] 
Merge branch 'jh/json-writer'

Preparatory code to later add json output for telemetry data.

* jh/json-writer:
  json_writer: new routines to create JSON data

5 years agoMerge branch 'bb/make-developer-pedantic'
Junio C Hamano [Wed, 15 Aug 2018 22:08:22 +0000 (15:08 -0700)] 
Merge branch 'bb/make-developer-pedantic'

"make DEVELOPER=1 DEVOPTS=pedantic" allows developers to compile
with -pedantic option, which may catch more problematic program
constructs and potential bugs.

* bb/make-developer-pedantic:
  Makefile: add a DEVOPTS flag to get pedantic compilation

5 years agoMerge branch 'es/diff-color-moved-fix'
Junio C Hamano [Wed, 15 Aug 2018 22:08:22 +0000 (15:08 -0700)] 
Merge branch 'es/diff-color-moved-fix'

One of the "diff --color-moved" mode "dimmed_zebra" that was named
in an unusual way has been deprecated and replaced by
"dimmed-zebra".

* es/diff-color-moved-fix:
  diff: --color-moved: rename "dimmed_zebra" to "dimmed-zebra"

5 years agoMerge branch 'bw/protocol-v2'
Junio C Hamano [Wed, 15 Aug 2018 22:08:21 +0000 (15:08 -0700)] 
Merge branch 'bw/protocol-v2'

Doc update.

* bw/protocol-v2:
  pack-protocol: mention and point to docs for protocol v2

5 years agoMerge branch 'sg/travis-cocci-diagnose-failure'
Junio C Hamano [Wed, 15 Aug 2018 22:08:21 +0000 (15:08 -0700)] 
Merge branch 'sg/travis-cocci-diagnose-failure'

Update the way we run static analysis tool at TravisCI to make it
easier to use its findings.

* sg/travis-cocci-diagnose-failure:
  travis-ci: fail if Coccinelle static analysis found something to transform
  travis-ci: run Coccinelle static analysis with two parallel jobs

5 years agoMerge branch 'js/t7406-recursive-submodule-update-order-fix'
Junio C Hamano [Wed, 15 Aug 2018 22:08:21 +0000 (15:08 -0700)] 
Merge branch 'js/t7406-recursive-submodule-update-order-fix'

Test fix.

* js/t7406-recursive-submodule-update-order-fix:
  t7406: avoid failures solely due to timing issues

5 years agoMerge branch 'bw/fetch-pack-i18n'
Junio C Hamano [Wed, 15 Aug 2018 22:08:20 +0000 (15:08 -0700)] 
Merge branch 'bw/fetch-pack-i18n'

i18n updates.

* bw/fetch-pack-i18n:
  fetch-pack: mark die strings for translation

5 years agoMerge branch 'sg/fast-import-dump-refs-on-checkpoint-fix'
Junio C Hamano [Wed, 15 Aug 2018 22:08:20 +0000 (15:08 -0700)] 
Merge branch 'sg/fast-import-dump-refs-on-checkpoint-fix'

Test update.

* sg/fast-import-dump-refs-on-checkpoint-fix:
  t9300: wait for background fast-import process to die after killing it

5 years agoMerge branch 'sb/trailers-docfix'
Junio C Hamano [Wed, 15 Aug 2018 22:08:19 +0000 (15:08 -0700)] 
Merge branch 'sb/trailers-docfix'

Doc update.

* sb/trailers-docfix:
  Documentation/git-interpret-trailers: explain possible values

5 years agoMerge branch 'jk/ui-color-always-to-auto'
Junio C Hamano [Wed, 15 Aug 2018 22:08:19 +0000 (15:08 -0700)] 
Merge branch 'jk/ui-color-always-to-auto'

Doc formatting fix.

* jk/ui-color-always-to-auto:
  Documentation: fix --color option formatting

5 years agocolor: protect against out-of-bounds reads and writes
Eric Sunshine [Fri, 3 Aug 2018 06:07:49 +0000 (23:07 -0700)] 
color: protect against out-of-bounds reads and writes

want_color_fd() is designed to work only with standard output and
error file descriptors and stores information about each descriptor in
an array. However, it doesn't verify that the passed-in descriptor
lives within that set, which, with a buggy caller, could lead to
access or assignment outside the array bounds.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Acked-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agoparse-options: automatically infer PARSE_OPT_LITERAL_ARGHELP
René Scharfe [Thu, 2 Aug 2018 19:18:14 +0000 (21:18 +0200)] 
parse-options: automatically infer PARSE_OPT_LITERAL_ARGHELP

Parseopt wraps argument help strings in a pair of angular brackets by
default, to tell users that they need to replace it with an actual
value.  This is useful in most cases, because most option arguments
are indeed single values of a certain type.  The option
PARSE_OPT_LITERAL_ARGHELP needs to be used in option definitions with
arguments that have multiple parts or are literal strings.

Stop adding these angular brackets if special characters are present,
as they indicate that we don't deal with a simple placeholder.  This
simplifies the code a bit and makes defining special options slightly
easier.

Remove the flag PARSE_OPT_LITERAL_ARGHELP in the cases where the new
and more cautious handling suffices.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agoshortlog: correct option help for -w
René Scharfe [Thu, 2 Aug 2018 19:18:06 +0000 (21:18 +0200)] 
shortlog: correct option help for -w

Wrap the placeholders in the option help string for -w in pairs of
angular brackets to document that users need to replace them with actual
numbers.  Use the flag PARSE_OPT_LITERAL_ARGHELP to prevent parseopt
from adding another pair.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agosend-pack: specify --force-with-lease argument help explicitly
René Scharfe [Thu, 2 Aug 2018 19:17:58 +0000 (21:17 +0200)] 
send-pack: specify --force-with-lease argument help explicitly

Wrap each part of the argument help string in angular brackets to show
that users need to replace them with actual values.  Do that explicitly
to balance the pairs nicely in the code and avoid confusing casual
readers.  Add the flag PARSE_OPT_LITERAL_ARGHELP to keep parseopt from
adding another pair.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agopack-objects: specify --index-version argument help explicitly
René Scharfe [Thu, 2 Aug 2018 19:17:50 +0000 (21:17 +0200)] 
pack-objects: specify --index-version argument help explicitly

Wrap both placeholders in the argument help string in angular brackets
to signal that users needs replace them with some actual value.  Use the
flag PARSE_OPT_LITERAL_ARGHELP to prevent parseopt from adding another
pair.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agodifftool: remove angular brackets from argument help
René Scharfe [Thu, 2 Aug 2018 19:17:43 +0000 (21:17 +0200)] 
difftool: remove angular brackets from argument help

Parseopt wraps arguments in a pair of angular brackets by default,
signifying that the user needs to replace it with a value of the
documented type.  Remove the pairs from the option definitions to
duplication and confusion.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agoadd, update-index: fix --chmod argument help
René Scharfe [Thu, 2 Aug 2018 19:17:35 +0000 (21:17 +0200)] 
add, update-index: fix --chmod argument help

Don't translate the argument specification for --chmod; "+x" and "-x"
are the literal strings that the commands accept.

Separate alternatives using a pipe character instead of a slash, for
consistency.

Use the flag PARSE_OPT_LITERAL_ARGHELP to prevent parseopt from adding a
pair of angular brackets around the argument help string, as that would
wrongly indicate that users need to replace the literal strings with
some kind of value.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agopush: use PARSE_OPT_LITERAL_ARGHELP instead of unbalanced brackets
Ævar Arnfjörð Bjarmason [Wed, 1 Aug 2018 22:31:33 +0000 (00:31 +0200)] 
push: use PARSE_OPT_LITERAL_ARGHELP instead of unbalanced brackets

The option help text for the force-with-lease option to "git push"
reads like this:

    $ git push -h 2>&1 | grep -e force-with-lease
       --force-with-lease[=<refname>:<expect>]

which comes from having N_("refname>:<expect") as the argument help
text in the source code, with an aparent lack of "<" and ">" at both
ends.

It turns out that parse-options machinery takes the whole string and
encloses it inside a pair of "<>", to make it easier for majority
cases that uses a single token placeholder.

The help string was written in a funnily unbalanced way knowing that
the end result would balance out, by somebody who forgot the
presence of PARSE_OPT_LITERAL_ARGHELP, which is the escape hatch
mechanism designed to help such a case.  We just should use the
official escape hatch instead.

Because ":<expect>" part can be omitted to ask Git to guess, it may
be more correct to spell it as "<refname>[:<expect>]", but that is
not the focus of this topic.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Helped-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agoFifth batch for 2.19 cycle
Junio C Hamano [Thu, 2 Aug 2018 22:38:09 +0000 (15:38 -0700)] 
Fifth batch for 2.19 cycle

Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agoMerge branch 'jt/commit-graph-per-object-store'
Junio C Hamano [Thu, 2 Aug 2018 22:30:47 +0000 (15:30 -0700)] 
Merge branch 'jt/commit-graph-per-object-store'

The singleton commit-graph in-core instance is made per in-core
repository instance.

* jt/commit-graph-per-object-store:
  commit-graph: add repo arg to graph readers
  commit-graph: store graph in struct object_store
  commit-graph: add free_commit_graph
  commit-graph: add missing forward declaration
  object-store: add missing include
  commit-graph: refactor preparing commit graph

5 years agoMerge branch 'es/chain-lint-in-subshell'
Junio C Hamano [Thu, 2 Aug 2018 22:30:46 +0000 (15:30 -0700)] 
Merge branch 'es/chain-lint-in-subshell'

Look for broken "&&" chains that are hidden in subshell, many of
which have been found and corrected.

* es/chain-lint-in-subshell:
  t/chainlint.sed: drop extra spaces from regex character class
  t/chainlint: add chainlint "specialized" test cases
  t/chainlint: add chainlint "complex" test cases
  t/chainlint: add chainlint "cuddled" test cases
  t/chainlint: add chainlint "loop" and "conditional" test cases
  t/chainlint: add chainlint "nested subshell" test cases
  t/chainlint: add chainlint "one-liner" test cases
  t/chainlint: add chainlint "whitespace" test cases
  t/chainlint: add chainlint "basic" test cases
  t/Makefile: add machinery to check correctness of chainlint.sed
  t/test-lib: teach --chain-lint to detect broken &&-chains in subshells

5 years agoMerge branch 'jt/tags-to-promised-blobs-fix'
Junio C Hamano [Thu, 2 Aug 2018 22:30:46 +0000 (15:30 -0700)] 
Merge branch 'jt/tags-to-promised-blobs-fix'

The lazy clone support had a few places where missing but promised
objects were not correctly tolerated, which have been fixed.

* jt/tags-to-promised-blobs-fix:
  tag: don't warn if target is missing but promised
  revision: tolerate promised targets of tags

5 years agoMerge branch 'jt/fetch-negotiator-skipping'
Junio C Hamano [Thu, 2 Aug 2018 22:30:46 +0000 (15:30 -0700)] 
Merge branch 'jt/fetch-negotiator-skipping'

Add a server-side knob to skip commits in exponential/fibbonacci
stride in an attempt to cover wider swath of history with a smaller
number of iterations, potentially accepting a larger packfile
transfer, instead of going back one commit a time during common
ancestor discovery during the "git fetch" transaction.

* jt/fetch-negotiator-skipping:
  negotiator/skipping: skip commits during fetch

5 years agoMerge branch 'jm/send-email-tls-auth-on-batch'
Junio C Hamano [Thu, 2 Aug 2018 22:30:46 +0000 (15:30 -0700)] 
Merge branch 'jm/send-email-tls-auth-on-batch'

"git send-email" when using in a batched mode that limits the
number of messages sent in a single SMTP session lost the contents
of the variable used to choose between tls/ssl, unable to send the
second and later batches, which has been fixed.

* jm/send-email-tls-auth-on-batch:
  send-email: fix tls AUTH when sending batch

5 years agoMerge branch 'bc/sequencer-export-work-tree-as-well'
Junio C Hamano [Thu, 2 Aug 2018 22:30:45 +0000 (15:30 -0700)] 
Merge branch 'bc/sequencer-export-work-tree-as-well'

"git rebase" started exporting GIT_DIR environment variable and
exposing it to hook scripts when part of it got rewritten in C.
Instead of matching the old scripted Porcelains' behaviour,
compensate by also exporting GIT_WORK_TREE environment as well to
lessen the damage.  This can harm existing hooks that want to
operate on different repository, but the current behaviour is
already broken for them anyway.

* bc/sequencer-export-work-tree-as-well:
  sequencer: pass absolute GIT_WORK_TREE to exec commands

5 years agoMerge branch 'en/t7405-recursive-submodule-conflicts'
Junio C Hamano [Thu, 2 Aug 2018 22:30:45 +0000 (15:30 -0700)] 
Merge branch 'en/t7405-recursive-submodule-conflicts'

Tests to cover conflict cases that involve submodules have been
added for merge-recursive.

* en/t7405-recursive-submodule-conflicts:
  t7405: verify 'merge --abort' works after submodule/path conflicts
  t7405: add a directory/submodule conflict
  t7405: add a file/submodule conflict

5 years agoMerge branch 'en/t6036-merge-recursive-tests'
Junio C Hamano [Thu, 2 Aug 2018 22:30:45 +0000 (15:30 -0700)] 
Merge branch 'en/t6036-merge-recursive-tests'

Tests to cover various conflicting cases have been added for
merge-recursive.

* en/t6036-merge-recursive-tests:
  t6036: add a failed conflict detection case: regular files, different modes
  t6036: add a failed conflict detection case with conflicting types
  t6036: add a failed conflict detection case with submodule add/add
  t6036: add a failed conflict detection case with submodule modify/modify
  t6036: add a failed conflict detection case with symlink add/add
  t6036: add a failed conflict detection case with symlink modify/modify

5 years agoMerge branch 'en/dirty-merge-fixes'
Junio C Hamano [Thu, 2 Aug 2018 22:30:44 +0000 (15:30 -0700)] 
Merge branch 'en/dirty-merge-fixes'

The recursive merge strategy did not properly ensure there was no
change between HEAD and the index before performing its operation,
which has been corrected.

* en/dirty-merge-fixes:
  merge: fix misleading pre-merge check documentation
  merge-recursive: enforce rule that index matches head before merging
  t6044: add more testcases with staged changes before a merge is invoked
  merge-recursive: fix assumption that head tree being merged is HEAD
  merge-recursive: make sure when we say we abort that we actually abort
  t6044: add a testcase for index matching head, when head doesn't match HEAD
  t6044: verify that merges expected to abort actually abort
  index_has_changes(): avoid assuming operating on the_index
  read-cache.c: move index_has_changes() from merge.c

5 years agoMerge branch 'js/rebase-merge-octopus'
Junio C Hamano [Thu, 2 Aug 2018 22:30:44 +0000 (15:30 -0700)] 
Merge branch 'js/rebase-merge-octopus'

"git rebase --rebase-merges" mode now handles octopus merges as
well.

* js/rebase-merge-octopus:
  rebase --rebase-merges: adjust man page for octopus support
  rebase --rebase-merges: add support for octopus merges
  merge: allow reading the merge commit message from a file

5 years agoMerge branch 'tb/grep-only-matching'
Junio C Hamano [Thu, 2 Aug 2018 22:30:44 +0000 (15:30 -0700)] 
Merge branch 'tb/grep-only-matching'

"git grep" learned the "--only-matching" option.

* tb/grep-only-matching:
  grep.c: teach 'git grep --only-matching'
  grep.c: extract show_line_header()

5 years agoMerge branch 'kg/gc-auto-windows-workaround'
Junio C Hamano [Thu, 2 Aug 2018 22:30:43 +0000 (15:30 -0700)] 
Merge branch 'kg/gc-auto-windows-workaround'

"git gc --auto" opens file descriptors for the packfiles before
spawning "git repack/prune", which would upset Windows that does
not want a process to work on a file that is open by another
process.  The issue has been worked around.

* kg/gc-auto-windows-workaround:
  gc --auto: release pack files before auto packing

5 years agoMerge branch 'jm/cache-entry-from-mem-pool'
Junio C Hamano [Thu, 2 Aug 2018 22:30:43 +0000 (15:30 -0700)] 
Merge branch 'jm/cache-entry-from-mem-pool'

For a large tree, the index needs to hold many cache entries
allocated on heap.  These cache entries are now allocated out of a
dedicated memory pool to amortize malloc(3) overhead.

* jm/cache-entry-from-mem-pool:
  block alloc: add validations around cache_entry lifecyle
  block alloc: allocate cache entries from mem_pool
  mem-pool: fill out functionality
  mem-pool: add life cycle management functions
  mem-pool: only search head block for available space
  block alloc: add lifecycle APIs for cache_entry structs
  read-cache: teach make_cache_entry to take object_id
  read-cache: teach refresh_cache_entry to take istate

5 years agoMerge branch 'jt/fetch-nego-tip'
Junio C Hamano [Thu, 2 Aug 2018 22:30:43 +0000 (15:30 -0700)] 
Merge branch 'jt/fetch-nego-tip'

"git fetch" learned a new option "--negotiation-tip" to limit the
set of commits it tells the other end as "have", to reduce wasted
bandwidth and cycles, which would be helpful when the receiving
repository has a lot of refs that have little to do with the
history at the remote it is fetching from.

* jt/fetch-nego-tip:
  fetch-pack: support negotiation tip whitelist

5 years agoMerge branch 'en/t6042-insane-merge-rename-testcases'
Junio C Hamano [Thu, 2 Aug 2018 22:30:42 +0000 (15:30 -0700)] 
Merge branch 'en/t6042-insane-merge-rename-testcases'

Various glitches in the heuristics of merge-recursive strategy have
been documented in new tests.

* en/t6042-insane-merge-rename-testcases:
  t6042: add testcase covering long chains of rename conflicts
  t6042: add testcase covering rename/rename(2to1)/delete/delete conflict
  t6042: add testcase covering rename/add/delete conflict type

5 years agoMerge branch 'sb/object-store-lookup'
Junio C Hamano [Thu, 2 Aug 2018 22:30:42 +0000 (15:30 -0700)] 
Merge branch 'sb/object-store-lookup'

lookup_commit_reference() and friends have been updated to find
in-core object for a specific in-core repository instance.

* sb/object-store-lookup: (32 commits)
  commit.c: allow lookup_commit_reference to handle arbitrary repositories
  commit.c: allow lookup_commit_reference_gently to handle arbitrary repositories
  tag.c: allow deref_tag to handle arbitrary repositories
  object.c: allow parse_object to handle arbitrary repositories
  object.c: allow parse_object_buffer to handle arbitrary repositories
  commit.c: allow get_cached_commit_buffer to handle arbitrary repositories
  commit.c: allow set_commit_buffer to handle arbitrary repositories
  commit.c: migrate the commit buffer to the parsed object store
  commit-slabs: remove realloc counter outside of slab struct
  commit.c: allow parse_commit_buffer to handle arbitrary repositories
  tag: allow parse_tag_buffer to handle arbitrary repositories
  tag: allow lookup_tag to handle arbitrary repositories
  commit: allow lookup_commit to handle arbitrary repositories
  tree: allow lookup_tree to handle arbitrary repositories
  blob: allow lookup_blob to handle arbitrary repositories
  object: allow lookup_object to handle arbitrary repositories
  object: allow object_as_type to handle arbitrary repositories
  tag: add repository argument to deref_tag
  tag: add repository argument to parse_tag_buffer
  tag: add repository argument to lookup_tag
  ...

5 years agoMerge branch 'is/parsing-line-range'
Junio C Hamano [Thu, 2 Aug 2018 22:30:41 +0000 (15:30 -0700)] 
Merge branch 'is/parsing-line-range'

Parsing of -L[<N>][,[<M>]] parameters "git blame" and "git log"
take has been tweaked.

* is/parsing-line-range:
  log: prevent error if line range ends past end of file
  blame: prevent error if range ends past end of file

5 years agoMerge branch 'jt/fetch-pack-negotiator'
Junio C Hamano [Thu, 2 Aug 2018 22:30:41 +0000 (15:30 -0700)] 
Merge branch 'jt/fetch-pack-negotiator'

Code restructuring and a small fix to transport protocol v2 during
fetching.

* jt/fetch-pack-negotiator:
  fetch-pack: introduce negotiator API
  fetch-pack: move common check and marking together
  fetch-pack: make negotiation-related vars local
  fetch-pack: use ref adv. to prune "have" sent
  fetch-pack: directly end negotiation if ACK ready
  fetch-pack: clear marks before re-marking
  fetch-pack: split up everything_local()

5 years agoMerge branch 'ab/checkout-default-remote'
Junio C Hamano [Thu, 2 Aug 2018 22:30:41 +0000 (15:30 -0700)] 
Merge branch 'ab/checkout-default-remote'

"git checkout" and "git worktree add" learned to honor
checkout.defaultRemote when auto-vivifying a local branch out of a
remote tracking branch in a repository with multiple remotes that
have tracking branches that share the same names.

* ab/checkout-default-remote:
  checkout & worktree: introduce checkout.defaultRemote
  checkout: add advice for ambiguous "checkout <branch>"
  builtin/checkout.c: use "ret" variable for return
  checkout: pass the "num_matches" up to callers
  checkout.c: change "unique" member to "num_matches"
  checkout.c: introduce an *_INIT macro
  checkout.h: wrap the arguments to unique_tracking_name()
  checkout tests: index should be clean after dwim checkout

5 years agoMerge branch 'sb/diff-color-move-more'
Junio C Hamano [Thu, 2 Aug 2018 22:30:40 +0000 (15:30 -0700)] 
Merge branch 'sb/diff-color-move-more'

"git diff --color-moved" feature has further been tweaked.

* sb/diff-color-move-more:
  diff.c: offer config option to control ws handling in move detection
  diff.c: add white space mode to move detection that allows indent changes
  diff.c: factor advance_or_nullify out of mark_color_as_moved
  diff.c: decouple white space treatment from move detection algorithm
  diff.c: add a blocks mode for moved code detection
  diff.c: adjust hash function signature to match hashmap expectation
  diff.c: do not pass diff options as keydata to hashmap
  t4015: avoid git as a pipe input
  xdiff/xdiffi.c: remove unneeded function declarations
  xdiff/xdiff.h: remove unused flags

5 years agoMerge branch 'es/test-fixes'
Junio C Hamano [Thu, 2 Aug 2018 22:30:40 +0000 (15:30 -0700)] 
Merge branch 'es/test-fixes'

Test clean-up and corrections.

* es/test-fixes: (26 commits)
  t5608: fix broken &&-chain
  t9119: fix broken &&-chains
  t9000-t9999: fix broken &&-chains
  t7000-t7999: fix broken &&-chains
  t6000-t6999: fix broken &&-chains
  t5000-t5999: fix broken &&-chains
  t4000-t4999: fix broken &&-chains
  t3030: fix broken &&-chains
  t3000-t3999: fix broken &&-chains
  t2000-t2999: fix broken &&-chains
  t1000-t1999: fix broken &&-chains
  t0000-t0999: fix broken &&-chains
  t9814: simplify convoluted check that command correctly errors out
  t9001: fix broken "invoke hook" test
  t7810: use test_expect_code() instead of hand-rolled comparison
  t7400: fix broken "submodule add/reconfigure --force" test
  t7201: drop pointless "exit 0" at end of subshell
  t6036: fix broken "merge fails but has appropriate contents" tests
  t5505: modernize and simplify hard-to-digest test
  t5406: use write_script() instead of birthing shell script manually
  ...

5 years agoMerge branch 'ds/commit-graph-fsck'
Junio C Hamano [Thu, 2 Aug 2018 22:30:39 +0000 (15:30 -0700)] 
Merge branch 'ds/commit-graph-fsck'

"git fsck" learns to make sure the optional commit-graph file is in
a sane state.

* ds/commit-graph-fsck: (23 commits)
  coccinelle: update commit.cocci
  commit-graph: update design document
  gc: automatically write commit-graph files
  commit-graph: add '--reachable' option
  commit-graph: use string-list API for input
  fsck: verify commit-graph
  commit-graph: verify contents match checksum
  commit-graph: test for corrupted octopus edge
  commit-graph: verify commit date
  commit-graph: verify generation number
  commit-graph: verify parent list
  commit-graph: verify root tree OIDs
  commit-graph: verify objects exist
  commit-graph: verify corrupt OID fanout and lookup
  commit-graph: verify required chunks are present
  commit-graph: verify catches corrupt signature
  commit-graph: add 'verify' subcommand
  commit-graph: load a root tree from specific graph
  commit: force commit to parse from object database
  commit-graph: parse commit from chosen graph
  ...

5 years agoMerge branch 'jk/fsck-gitmodules-gently'
Junio C Hamano [Thu, 2 Aug 2018 22:30:39 +0000 (15:30 -0700)] 
Merge branch 'jk/fsck-gitmodules-gently'

Recent "security fix" to pay attention to contents of ".gitmodules"
while accepting "git push" was a bit overly strict than necessary,
which has been adjusted.

* jk/fsck-gitmodules-gently:
  fsck: downgrade gitmodulesParse default to "info"
  fsck: split ".gitmodules too large" error from parse failure
  fsck: silence stderr when parsing .gitmodules
  config: add options parameter to git_config_from_mem
  config: add CONFIG_ERROR_SILENT handler
  config: turn die_on_error into caller-facing enum

5 years agoMerge branch 'bc/object-id'
Junio C Hamano [Thu, 2 Aug 2018 22:30:39 +0000 (15:30 -0700)] 
Merge branch 'bc/object-id'

Conversion from uchar[40] to struct object_id continues.

* bc/object-id:
  pretty: switch hard-coded constants to the_hash_algo
  sha1-file: convert constants to uses of the_hash_algo
  log-tree: switch GIT_SHA1_HEXSZ to the_hash_algo->hexsz
  diff: switch GIT_SHA1_HEXSZ to use the_hash_algo
  builtin/merge-recursive: make hash independent
  builtin/merge: switch to use the_hash_algo
  builtin/fmt-merge-msg: make hash independent
  builtin/update-index: simplify parsing of cacheinfo
  builtin/update-index: convert to using the_hash_algo
  refs/files-backend: use the_hash_algo for writing refs
  sha1-name: use the_hash_algo when parsing object names
  strbuf: allocate space with GIT_MAX_HEXSZ
  commit: express tree entry constants in terms of the_hash_algo
  hex: switch to using the_hash_algo
  tree-walk: replace hard-coded constants with the_hash_algo
  cache: update object ID functions for the_hash_algo

5 years agoMerge branch 'en/t6036-recursive-corner-cases'
Junio C Hamano [Thu, 2 Aug 2018 22:30:39 +0000 (15:30 -0700)] 
Merge branch 'en/t6036-recursive-corner-cases'

Tests to cover more D/F conflict cases have been added for
merge-recursive.

* en/t6036-recursive-corner-cases:
  t6036: fix broken && chain in sub-shell
  t6036: add lots of detail for directory/file conflicts in recursive case

5 years agoMerge branch 'sg/httpd-test-unflake'
Junio C Hamano [Thu, 2 Aug 2018 22:30:39 +0000 (15:30 -0700)] 
Merge branch 'sg/httpd-test-unflake'

httpd tests saw occasional breakage due to the way its access log
gets inspected by the tests, which has been updated to make them
less flaky.

* sg/httpd-test-unflake:
  t/lib-httpd: avoid occasional failures when checking access.log
  t/lib-httpd: add the strip_access_log() helper function
  t5541: clean up truncating access log

5 years agoMerge branch 'bp/test-drop-caches-for-windows'
Junio C Hamano [Thu, 2 Aug 2018 22:30:38 +0000 (15:30 -0700)] 
Merge branch 'bp/test-drop-caches-for-windows'

A test helper update for Windows.

* bp/test-drop-caches-for-windows:
  handle lower case drive letters on Windows

5 years agoMerge branch 'jk/has-uncommitted-changes-fix'
Junio C Hamano [Thu, 2 Aug 2018 22:30:37 +0000 (15:30 -0700)] 
Merge branch 'jk/has-uncommitted-changes-fix'

"git pull --rebase" on a corrupt HEAD caused a segfault.  In
general we substitute an empty tree object when running the in-core
equivalent of the diff-index command, and the codepath has been
corrected to do so as well to fix this issue.

* jk/has-uncommitted-changes-fix:
  has_uncommitted_changes(): fall back to empty tree

5 years agosha1dc: update from upstream
Ævar Arnfjörð Bjarmason [Thu, 2 Aug 2018 20:50:44 +0000 (20:50 +0000)] 
sha1dc: update from upstream

Update sha1dc from the latest version by the upstream
maintainer[1]. See 2db87328ef ("Merge branch 'ab/sha1dc'", 2017-07-10)
for the last update.

This fixes an issue where AIX was wrongly detected as a Little-endian
instead of a Big-endian system. See [2][3][4].

1. https://github.com/cr-marcstevens/sha1collisiondetection/commit/232357eb2ea0397388254a4b188333a227bf5b10
2. https://github.com/cr-marcstevens/sha1collisiondetection/pull/45
3. https://github.com/cr-marcstevens/sha1collisiondetection/pull/42
4. https://public-inbox.org/git/20180729200623.GF945730@genre.crustytoothpaste.net/

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agoscore_trees(): fix iteration over trees with missing entries
Jeff King [Thu, 2 Aug 2018 18:58:21 +0000 (14:58 -0400)] 
score_trees(): fix iteration over trees with missing entries

In score_trees(), we walk over two sorted trees to find
which entries are missing or have different content between
the two.  So if we have two trees with these entries:

  one   two
  ---   ---
  a     a
  b     c
  c     d

we'd expect the loop to:

  - compare "a" to "a"

  - compare "b" to "c"; because these are sorted lists, we
    know that the second tree does not have "b"

  - compare "c" to "c"

  - compare "d" to end-of-list; we know that the first tree
    does not have "d"

And prior to d8febde370 (match-trees: simplify score_trees()
using tree_entry(), 2013-03-24) that worked. But after that
commit, we mistakenly increment the tree pointers for every
loop iteration, even when we've processed the entry for only
one side. As a result, we end up doing this:

  - compare "a" to "a"

  - compare "b" to "c"; we know that we do not have "b", but
    we still increment both tree pointers; at this point
    we're out of sync and all further comparisons are wrong

  - compare "c" to "d" and mistakenly claim that the second
    tree does not have "c"

  - exit the loop, mistakenly not realizing that the first
    tree does not have "d"

So contrary to the claim in d8febde370, we really do need to
manually use update_tree_entry(), because advancing the tree
pointer depends on the entry comparison.

That means we must stop using tree_entry() to access each
entry, since it auto-advances the pointer. Instead:

  - we'll use tree_desc.size directly to know if there's
    anything left to look at (which is what tree_entry() was
    doing under the hood)

  - rather than do an extra struct assignment to "e1" and
    "e2", we can just access the "entry" field of tree_desc
    directly

That makes us a little more intimate with the tree_desc
code, but that's not uncommon for its callers.

The included test shows off the bug by adding a new entry
"bar.t", which sorts early in the tree and de-syncs the
comparison for "foo.t", which comes after.

Reported-by: George Shammas <georgyo@gmail.com>
Helped-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agoremote: make refspec follow the same disambiguation rule as local refs
Junio C Hamano [Wed, 1 Aug 2018 16:22:37 +0000 (09:22 -0700)] 
remote: make refspec follow the same disambiguation rule as local refs

When matching a non-wildcard LHS of a refspec against a list of
refs, find_ref_by_name_abbrev() returns the first ref that matches
using any DWIM rules used by refname_match() in refs.c, even if a
better match occurs later in the list of refs.

This causes unexpected behavior when (for example) fetching using
the refspec "refs/heads/s:<something>" from a remote with both
"refs/heads/refs/heads/s" and "refs/heads/s"; even if the former was
inadvertently created, one would still expect the latter to be
fetched.  Similarly, when both a tag T and a branch T exist,
fetching T should favor the tag, just like how local refname
disambiguation rule works.  But because the code walks over
ls-remote output from the remote, which happens to be sorted in
alphabetical order and has refs/heads/T before refs/tags/T, a
request to fetch T is (mis)interpreted as fetching refs/heads/T.

Update refname_match(), all of whose current callers care only if it
returns non-zero (i.e. matches) to see if an abbreviated name can
mean the full name being tested, so that it returns a positive
integer whose magnitude can be used to tell the precedence, and fix
the find_ref_by_name_abbrev() function not to stop at the first
match but find the match with the highest precedence.

This is based on an earlier work, which special cased only the exact
matches, by Jonathan Tan.

Helped-by: Jonathan Tan <jonathantanmy@google.com>
Helped-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agofetch-pack: unify ref in and out param
Jonathan Tan [Wed, 1 Aug 2018 20:13:20 +0000 (13:13 -0700)] 
fetch-pack: unify ref in and out param

When a user fetches:
 - at least one up-to-date ref and at least one non-up-to-date ref,
 - using HTTP with protocol v0 (or something else that uses the fetch
   command of a remote helper)
some refs might not be updated after the fetch.

This bug was introduced in commit 989b8c4452 ("fetch-pack: put shallow
info in output parameter", 2018-06-28) which allowed transports to
report the refs that they have fetched in a new out-parameter
"fetched_refs". If they do so, transport_fetch_refs() makes this
information available to its caller.

Users of "fetched_refs" rely on the following 3 properties:
 (1) it is the complete list of refs that was passed to
     transport_fetch_refs(),
 (2) it has shallow information (REF_STATUS_REJECT_SHALLOW set if
     relevant), and
 (3) it has updated OIDs if ref-in-want was used (introduced after
     989b8c4452).

In an effort to satisfy (1), whenever transport_fetch_refs()
filters the refs sent to the transport, it re-adds the filtered refs to
whatever the transport supplies before returning it to the user.
However, the implementation in 989b8c4452 unconditionally re-adds the
filtered refs without checking if the transport refrained from reporting
anything in "fetched_refs" (which it is allowed to do), resulting in an
incomplete list, no longer satisfying (1).

An earlier effort to resolve this [1] solved the issue by readding the
filtered refs only if the transport did not refrain from reporting in
"fetched_refs", but after further discussion, it seems that the better
solution is to revert the API change that introduced "fetched_refs".
This API change was first suggested as part of a ref-in-want
implementation that allowed for ref patterns and, thus, there could be
drastic differences between the input refs and the refs actually fetched
[2]; we eventually decided to only allow exact ref names, but this API
change remained even though its necessity was decreased.

Therefore, revert this API change by reverting commit 989b8c4452, and
make receive_wanted_refs() update the OIDs in the sought array (like how
update_shallow() updates shallow information in the sought array)
instead. A test is also included to show that the user-visible bug
discussed at the beginning of this commit message no longer exists.

[1] https://public-inbox.org/git/20180801171806.GA122458@google.com/
[2] https://public-inbox.org/git/86a128c5fb710a41791e7183207c4d64889f9307.1485381677.git.jonathantanmy@google.com/

Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agogit-p4: add the `p4-pre-submit` hook
Chen Bin [Fri, 27 Jul 2018 11:22:22 +0000 (21:22 +1000)] 
git-p4: add the `p4-pre-submit` hook

The `p4-pre-submit` hook is executed before git-p4 submits code.
If the hook exits with non-zero value, submit process not start.

Signed-off-by: Chen Bin <chenbin.sh@gmail.com>
Reviewed-by: Luke Diamand <luke@diamand.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agofetch doc: cross-link two new negotiation options
Ævar Arnfjörð Bjarmason [Wed, 1 Aug 2018 15:18:35 +0000 (15:18 +0000)] 
fetch doc: cross-link two new negotiation options

Users interested in the fetch.negotiationAlgorithm variable added in
42cc7485a2 ("negotiator/skipping: skip commits during fetch",
2018-07-16) are probably interested in the related --negotiation-tip
option added in 3390e42adb ("fetch-pack: support negotiation tip
whitelist", 2018-07-02).

Change the documentation for those two to reference one another to
point readers in the right direction.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agonegotiator: unknown fetch.negotiationAlgorithm should error out
Ævar Arnfjörð Bjarmason [Wed, 1 Aug 2018 15:18:34 +0000 (15:18 +0000)] 
negotiator: unknown fetch.negotiationAlgorithm should error out

Change the handling of fetch.negotiationAlgorithm=<str> to error out
on unknown strings, i.e. everything except "default" or "skipping".

This changes the behavior added in 42cc7485a2 ("negotiator/skipping:
skip commits during fetch", 2018-07-16) which would ignore all unknown
values and silently fall back to the "default" value.

For a feature like this it's much better to produce an error than
proceed. We don't want users to debug some amazingly slow fetch that
should benefit from "skipping", only to find that they'd forgotten to
deploy the new git version on that particular machine.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agoMerge branch 'jt/fetch-nego-tip' into ab/fetch-nego
Junio C Hamano [Wed, 1 Aug 2018 18:07:35 +0000 (11:07 -0700)] 
Merge branch 'jt/fetch-nego-tip' into ab/fetch-nego

* jt/fetch-nego-tip:
  fetch-pack: support negotiation tip whitelist

5 years agotravis-ci: include the trash directories of failed tests in the trace log
SZEDER Gábor [Tue, 31 Jul 2018 22:56:12 +0000 (00:56 +0200)] 
travis-ci: include the trash directories of failed tests in the trace log

The trash directory of a failed test might contain invaluable
information about the cause of the failure, but we have no access to
the trash directories of Travis CI build jobs.  The only feedback we
get from there is the build job's trace log, so...

Modify 'ci/print-test-failures.sh' to create a tar.gz archive of the
trash directory of each failed test, encode that archive with base64,
and print the resulting block of ASCII text, so it gets embedded in
the trace log.  Furthermore, run tests with '--immediate' to
faithfully preserve the failed state.

Extracting the trash directories from the trace log turned out to be a
bit of a hassle, partly because of the size of these logs (usually
resulting in several hundreds or even thousands of lines of
base64-encoded text), and partly because these logs have CRLF, CRCRLF
and occasionally even CRCRCRLF line endings, which cause 'base64 -d'
from coreutils to complain about "invalid input".  For convenience add
a small script 'ci/util/extract-trash-dirs.sh', which will extract and
unpack all base64-encoded trash directories embedded in the log fed to
its standard input, and include an example command to be copy-pasted
into a terminal to do it all at the end of the failure report.

A few of our tests create sizeable trash directories, so limit the
size of each included base64-encoded block, let's say, to 1MB.  And
just in case something fundamental gets broken and a lot of tests fail
at once, don't include trash directories when the combined size of the
included base64-encoded blocks would exceed 1MB.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agoremote: clear string_list after use in mv()
René Scharfe [Wed, 1 Aug 2018 10:19:07 +0000 (12:19 +0200)] 
remote: clear string_list after use in mv()

Switch to the _DUP variant of string_list for remote_branches to allow
string_list_clear() to release the allocated memory at the end, and
actually call that function.  Free the util pointer as well; it is
allocated in read_remote_branches().

NB: This string_list is empty until read_remote_branches() is called
via for_each_ref(), so there is no need to clean it up when returning
before that point.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agosequencer: don't die() on bogus user-edited timestamp
Eric Sunshine [Tue, 31 Jul 2018 07:33:31 +0000 (03:33 -0400)] 
sequencer: don't die() on bogus user-edited timestamp

read_author_ident() is careful to handle errors "gently" when parsing
"rebase-merge/author-script" by printing a suitable warning and
returning NULL; it never die()'s. One possible reason that parsing might
fail is that "rebase-merge/author-script" has been hand-edited in such a
way which corrupts it or the information it contains.

However, read_author_ident() invokes fmt_ident() which is not so careful
about failing "gently". It will die() if it encounters a malformed
timestamp. Since read_author_ident() doesn't want to die() and since
it's dealing with possibly hand-edited data, take care to avoid passing
a bogus timestamp to fmt_ident().

A more "correctly engineered" fix would be to add a "gentle" version of
fmt_ident(), however, such a change it outside the scope of the bug-fix
series. If fmt_ident() ever does grow a "gentle" cousin, then the manual
timestamp check added here can be retired.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agosequencer: fix "rebase -i --root" corrupting author header timestamp
Eric Sunshine [Tue, 31 Jul 2018 07:33:30 +0000 (03:33 -0400)] 
sequencer: fix "rebase -i --root" corrupting author header timestamp

When "git rebase -i --root" creates a new root commit, it corrupts the
"author" header's timestamp by prepending a "@":

    author A U Thor <author@example.com> @1112912773 -0700

The commit parser is very strict about the format of the "author"
header, and does not allow a "@" in that position.

The "@" comes from GIT_AUTHOR_DATE in "rebase-merge/author-script",
signifying a Unix epoch-based timestamp, however, read_author_ident()
incorrectly allows it to slip into the commit's "author" header, thus
corrupting it.

One possible fix would be simply to filter out the "@" when constructing
the "author" header timestamp, however, a more correct fix is to parse
the GIT_AUTHOR_DATE date (via parse_date()) and format the parsed result
into the "author" header. Since "rebase-merge/author-script" may be
edited by the user, this approach has the extra benefit of catching
other potential timestamp corruption due to hand-editing.

We can do better than calling parse_date() ourselves and constructing
the "author" header manually, however, by instead taking advantage of
fmt_ident() which does this work for us.

The benefits of using fmt_ident() are twofold. First, it simplifies the
logic considerably by allowing us to avoid the complexity of building
the "author" header in parallel with and in the same buffer from which
"rebase-merge/author-script" is being parsed. Instead, fmt_ident() is
invoked to compose the header after parsing is complete.

Second, fmt_ident() is careful to prevent "crud" from polluting the
composed ident. As with validating GIT_AUTHOR_DATE, this "crud"
avoidance prevents other (possibly hand-edited) bogus author information
from "rebase-merge/author-script" from corrupting the commit object.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agosequencer: fix "rebase -i --root" corrupting author header timezone
Eric Sunshine [Tue, 31 Jul 2018 07:33:29 +0000 (03:33 -0400)] 
sequencer: fix "rebase -i --root" corrupting author header timezone

When "git rebase -i --root" creates a new root commit, it corrupts the
"author" header's timezone by repeating the last digit:

    author A U Thor <author@example.com> @1112912773 -07000

This is due to two bugs.

First, write_author_script() neglects to add the closing quote to the
value of GIT_AUTHOR_DATE when generating "rebase-merge/author-script".

Second, although sq_dequote() correctly diagnoses the missing closing
quote, read_author_ident() ignores sq_dequote()'s return value and
blindly uses the result of the aborted dequote.

sq_dequote() performs dequoting in-place by removing quoting and
shifting content downward. When it detects misquoting (lack of closing
quote, in this case), it gives up and returns an error without inserting
a NUL-terminator at the end of the shifted content, which explains the
duplicated last digit in the timezone.

(Note that the "@" preceding the timestamp is a separate bug which
will be fixed subsequently.)

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agosequencer: fix "rebase -i --root" corrupting author header
Eric Sunshine [Tue, 31 Jul 2018 07:33:28 +0000 (03:33 -0400)] 
sequencer: fix "rebase -i --root" corrupting author header

When "git rebase -i --root" creates a new root commit (say, by swapping
in a different commit for the root), it corrupts the commit's "author"
header with trailing garbage:

    author A U Thor <author@example.com> @1112912773 -07000or@example.com

This is a result of read_author_ident() neglecting to NUL-terminate the
buffer into which it composes the "author" header.

(Note that the "@" preceding the timestamp and the extra "0" in the
timezone are separate bugs which will be fixed subsequently.)

Security considerations: Construction of the "author" header by
read_author_ident() happens in-place and in parallel with parsing the
content of "rebase-merge/author-script" which occupies the same buffer.
This is possible because the constructed "author" header is always
smaller than the content of "rebase-merge/author-script". Despite
neglecting to NUL-terminate the constructed "author" header, memory is
never accessed (either by read_author_ident() or its caller) beyond the
allocated buffer since a NUL-terminator is present at the end of the
loaded "rebase-merge/author-script" content, and additional NUL's are
inserted as part of the parsing process.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agot/chainlint.sed: drop extra spaces from regex character class
Eric Sunshine [Tue, 31 Jul 2018 05:03:20 +0000 (01:03 -0400)] 
t/chainlint.sed: drop extra spaces from regex character class

This character class, like many others in this script, matches
horizontal whitespace consisting of spaces and tabs, however, a few
extra, entirely harmless, spaces somehow slipped into the expression.
Removing them is purely a cosmetic fix.

While at it, re-indent three lines with a single TAB each which were
incorrectly indented with six spaces. Also, a purely cosmetic fix.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agomw-to-git/t9360: fix broken &&-chain
Eric Sunshine [Mon, 30 Jul 2018 20:46:46 +0000 (16:46 -0400)] 
mw-to-git/t9360: fix broken &&-chain

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agosubtree test: simplify preparation of expected results
Jonathan Nieder [Mon, 30 Jul 2018 19:07:38 +0000 (12:07 -0700)] 
subtree test: simplify preparation of expected results

This mixture of quoting, pipes, and here-docs to produce expected
results in shell variables is difficult to follow.  Simplify by using
simpler constructs that write output to files instead.

Noticed because without this patch, t/chainlint is not able to
understand the script in order to validate that its subshells use an
unbroken &&-chain, causing "make -C contrib/subtree test" to fail with

error: bug in the test script: broken &&-chain or run-away HERE-DOC:

in t7900.21.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agosubtree test: add missing && to &&-chain
Jonathan Nieder [Mon, 30 Jul 2018 19:07:02 +0000 (12:07 -0700)] 
subtree test: add missing && to &&-chain

Detected using t/chainlint.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agovscode: let cSpell work on commit messages, too
Johannes Schindelin [Mon, 30 Jul 2018 15:42:58 +0000 (08:42 -0700)] 
vscode: let cSpell work on commit messages, too

By default, the cSpell extension ignores all files under .git/. That
includes, unfortunately, COMMIT_EDITMSG, i.e. commit messages. However,
spell checking is *quite* useful when writing commit messages... And
since the user hardly ever opens any file inside .git (apart from commit
messages, the config, and sometimes interactive rebase's todo lists),
there is really not much harm in *not* ignoring .git/.

The default also ignores `node_modules/`, but that does not apply to
Git, so let's skip ignoring that, too.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agovscode: add a dictionary for cSpell
Johannes Schindelin [Mon, 30 Jul 2018 15:42:57 +0000 (08:42 -0700)] 
vscode: add a dictionary for cSpell

The quite useful cSpell extension allows VS Code to have "squiggly"
lines under spelling mistakes. By default, this would add too much
clutter, though, because so much of Git's source code uses words that
would trigger cSpell.

Let's add a few words to make the spell checking more useful by reducing
the number of false positives.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agovscode: use 8-space tabs, no trailing ws, etc for Git's source code
Johannes Schindelin [Mon, 30 Jul 2018 15:42:55 +0000 (08:42 -0700)] 
vscode: use 8-space tabs, no trailing ws, etc for Git's source code

This adds a couple settings for the .c/.h files so that it is easier to
conform to Git's conventions while editing the source code.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agovscode: wrap commit messages at column 72 by default
Johannes Schindelin [Mon, 30 Jul 2018 15:42:54 +0000 (08:42 -0700)] 
vscode: wrap commit messages at column 72 by default

When configuring VS Code as core.editor (via `code --wait`), we really
want to adhere to the Git conventions of wrapping commit messages.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
5 years agovscode: only overwrite C/C++ settings
Johannes Schindelin [Mon, 30 Jul 2018 15:42:52 +0000 (08:42 -0700)] 
vscode: only overwrite C/C++ settings

The C/C++ settings are special, as they are the only generated VS Code
configurations that *will* change over the course of Git's development,
e.g. when a new constant is defined.

Therefore, let's only update the C/C++ settings, also to prevent user
modifications from being overwritten.

Ideally, we would keep user modifications in the C/C++ settings, but
that would require parsing JSON, a task for which a Unix shell script is
distinctly unsuited. So we write out .new files instead, and warn the
user if they may want to reconcile their changes.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>