git/git.git
2 years agoMerge branch 'rs/strbuf-read-file-or-whine'
Junio C Hamano [Tue, 6 Mar 2018 22:54:07 +0000 (14:54 -0800)]
Merge branch 'rs/strbuf-read-file-or-whine'

Code clean-up.

* rs/strbuf-read-file-or-whine:
  sequencer: factor out strbuf_read_file_or_whine()

2 years agoMerge branch 'ms/non-ascii-ticks'
Junio C Hamano [Tue, 6 Mar 2018 22:54:06 +0000 (14:54 -0800)]
Merge branch 'ms/non-ascii-ticks'

Doc markup fix.

* ms/non-ascii-ticks:
  Documentation/gitsubmodules.txt: avoid non-ASCII apostrophes

2 years agoMerge branch 'jk/test-helper-v-output-fix'
Junio C Hamano [Tue, 6 Mar 2018 22:54:05 +0000 (14:54 -0800)]
Merge branch 'jk/test-helper-v-output-fix'

Test framework update.

* jk/test-helper-v-output-fix:
  t: send verbose test-helper output to fd 4

2 years agoMerge branch 'jk/cached-commit-buffer'
Junio C Hamano [Tue, 6 Mar 2018 22:54:05 +0000 (14:54 -0800)]
Merge branch 'jk/cached-commit-buffer'

Code clean-up.

* jk/cached-commit-buffer:
  revision: drop --show-all option
  commit: drop uses of get_cached_commit_buffer()

2 years agoMerge branch 'bw/doc-submodule-recurse-config-with-clone'
Junio C Hamano [Tue, 6 Mar 2018 22:54:05 +0000 (14:54 -0800)]
Merge branch 'bw/doc-submodule-recurse-config-with-clone'

Doc update.

* bw/doc-submodule-recurse-config-with-clone:
  submodule: indicate that 'submodule.recurse' doesn't apply to clone

2 years agoMerge branch 'jc/allow-ff-merging-kept-tags'
Junio C Hamano [Tue, 6 Mar 2018 22:54:04 +0000 (14:54 -0800)]
Merge branch 'jc/allow-ff-merging-kept-tags'

Since Git 1.7.9, "git merge" defaulted to --no-ff (i.e. even when
the side branch being merged is a descendant of the current commit,
create a merge commit instead of fast-forwarding) when merging a
tag object.  This was appropriate default for integrators who pull
signed tags from their downstream contributors, but caused an
unnecessary merges when used by downstream contributors who
habitually "catch up" their topic branches with tagged releases
from the upstream.  Update "git merge" to default to --no-ff only
when merging a tag object that does *not* sit at its usual place in
refs/tags/ hierarchy, and allow fast-forwarding otherwise, to
mitigate the problem.

* jc/allow-ff-merging-kept-tags:
  merge: allow fast-forward when merging a tracked tag

2 years agoMerge branch 'ab/simplify-perl-makefile'
Junio C Hamano [Tue, 6 Mar 2018 22:54:04 +0000 (14:54 -0800)]
Merge branch 'ab/simplify-perl-makefile'

Hotfix for a topic already in 'master'.

* ab/simplify-perl-makefile:
  Makefile: generate Git(3pm) as dependency of the 'doc' and 'man' targets

2 years agoMerge branch 'pw/add-p-single'
Junio C Hamano [Tue, 6 Mar 2018 22:54:03 +0000 (14:54 -0800)]
Merge branch 'pw/add-p-single'

"git add -p" used to offer "/" (look for a matching hunk) as a
choice, even there was only one hunk, which has been corrected.
Also the single-key help is now given only for keys that are
enabled (e.g. help for '/' won't be shown when there is only one
hunk).

* pw/add-p-single:
  add -p: improve error messages
  add -p: only bind search key if there's more than one hunk
  add -p: only display help for active keys

2 years agoMerge branch 'sg/t6300-modernize'
Junio C Hamano [Tue, 6 Mar 2018 22:54:03 +0000 (14:54 -0800)]
Merge branch 'sg/t6300-modernize'

Test update.

* sg/t6300-modernize:
  t6300-for-each-ref: fix "more than one quoting style" tests

2 years agoMerge branch 'sb/color-h-cleanup'
Junio C Hamano [Tue, 6 Mar 2018 22:54:02 +0000 (14:54 -0800)]
Merge branch 'sb/color-h-cleanup'

Devdoc update.

* sb/color-h-cleanup:
  color.h: document and modernize header

2 years agoMerge branch 'nd/rebase-show-current-patch'
Junio C Hamano [Tue, 6 Mar 2018 22:54:02 +0000 (14:54 -0800)]
Merge branch 'nd/rebase-show-current-patch'

The new "--show-current-patch" option gives an end-user facing way
to get the diff being applied when "git rebase" (and "git am")
stops with a conflict.

* nd/rebase-show-current-patch:
  rebase: introduce and use pseudo-ref REBASE_HEAD
  rebase: add --show-current-patch
  am: add --show-current-patch

2 years agoMerge branch 'xz/send-email-batch-size'
Junio C Hamano [Tue, 6 Mar 2018 22:54:02 +0000 (14:54 -0800)]
Merge branch 'xz/send-email-batch-size'

"git send-email" learned to complain when the batch-size option is
not defined when the relogin-delay option is, since these two are
mutually required.

* xz/send-email-batch-size:
  send-email: error out when relogin delay is missing

2 years agoMerge branch 'ab/fetch-prune'
Junio C Hamano [Tue, 6 Mar 2018 22:54:01 +0000 (14:54 -0800)]
Merge branch 'ab/fetch-prune'

Clarify how configured fetch refspecs interact with the "--prune"
option of "git fetch", and also add a handy short-hand for getting
rid of stale tags that are locally held.

* ab/fetch-prune:
  fetch: make the --prune-tags work with <url>
  fetch: add a --prune-tags option and fetch.pruneTags config
  fetch tests: add scaffolding for the new fetch.pruneTags
  git-fetch & config doc: link to the new PRUNING section
  git remote doc: correct dangerous lies about what prune does
  git fetch doc: add a new section to explain the ins & outs of pruning
  fetch tests: fetch <url> <spec> as well as fetch [<remote>]
  fetch tests: expand case/esac for later change
  fetch tests: double quote a variable for interpolation
  fetch tests: test --prune and refspec interaction
  fetch tests: add a tag to be deleted to the pruning tests
  fetch tests: re-arrange arguments for future readability
  fetch tests: refactor in preparation for testing tag pruning
  remote: add a macro for "refs/tags/*:refs/tags/*"
  fetch: stop accessing "remote" variable indirectly
  fetch: trivially refactor assignment to ref_nr
  fetch: don't redundantly NULL something calloc() gave us

2 years agoMerge branch 'sm/mv-dry-run-update'
Junio C Hamano [Tue, 6 Mar 2018 22:54:00 +0000 (14:54 -0800)]
Merge branch 'sm/mv-dry-run-update'

Code clean-up.

* sm/mv-dry-run-update:
  mv: remove unneeded 'if (!show_only)'
  t7001: add test case for --dry-run

2 years agoMerge branch 'nm/tag-edit'
Junio C Hamano [Tue, 6 Mar 2018 22:53:59 +0000 (14:53 -0800)]
Merge branch 'nm/tag-edit'

"git tag" learned an explicit "--edit" option that allows the
message given via "-m" and "-F" to be further edited.

* nm/tag-edit:
  tag: add --edit option

3 years agoSixth batch for 2.17
Junio C Hamano [Wed, 28 Feb 2018 21:39:24 +0000 (13:39 -0800)]
Sixth batch for 2.17

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'jk/push-options-via-transport-fix'
Junio C Hamano [Wed, 28 Feb 2018 21:37:58 +0000 (13:37 -0800)]
Merge branch 'jk/push-options-via-transport-fix'

"git push" over http transport did not unquote the push-options
correctly.

* jk/push-options-via-transport-fix:
  remote-curl: unquote incoming push-options
  t5545: factor out http repository setup

3 years agoMerge branch 'tz/do-not-clean-spec-file'
Junio C Hamano [Wed, 28 Feb 2018 21:37:58 +0000 (13:37 -0800)]
Merge branch 'tz/do-not-clean-spec-file'

We no longer create any *.spec file, so "make clean" should not
remove it.

* tz/do-not-clean-spec-file:
  Makefile: remove *.spec from clean target

3 years agoMerge branch 'tg/worktree-create-tracking'
Junio C Hamano [Wed, 28 Feb 2018 21:37:56 +0000 (13:37 -0800)]
Merge branch 'tg/worktree-create-tracking'

Hotfix for a recent topic.

* tg/worktree-create-tracking:
  git-worktree.txt: fix indentation of example and text of 'add' command
  git-worktree.txt: fix missing ")" typo

3 years agoMerge branch 'gs/test-unset-xdg-cache-home'
Junio C Hamano [Wed, 28 Feb 2018 21:37:56 +0000 (13:37 -0800)]
Merge branch 'gs/test-unset-xdg-cache-home'

Test update.

* gs/test-unset-xdg-cache-home:
  test-lib.sh: unset XDG_CACHE_HOME

3 years agoMerge branch 'tk/apply-dev-null-verify-name-fix'
Junio C Hamano [Wed, 28 Feb 2018 21:37:55 +0000 (13:37 -0800)]
Merge branch 'tk/apply-dev-null-verify-name-fix'

Many places in "git apply" knew that "/dev/null" that signals
"there is no such file on this side of the diff" can be followed by
whitespace and garbage when parsing a patch, except for one, which
made an otherwise valid patch (e.g. ones from subversion) rejected.

* tk/apply-dev-null-verify-name-fix:
  apply: handle Subversion diffs with /dev/null gracefully
  apply: demonstrate a problem applying svn diffs

3 years agoMerge branch 'sb/status-doc-fix'
Junio C Hamano [Wed, 28 Feb 2018 21:37:54 +0000 (13:37 -0800)]
Merge branch 'sb/status-doc-fix'

Docfix.

* sb/status-doc-fix:
  Documentation/git-status: clarify status table for porcelain mode

3 years agoMerge branch 'es/worktree-add-post-checkout-hook'
Junio C Hamano [Wed, 28 Feb 2018 21:37:53 +0000 (13:37 -0800)]
Merge branch 'es/worktree-add-post-checkout-hook'

"git worktree add" learned to run the post-checkout hook, just like
"git clone" runs it upon the initial checkout.

* es/worktree-add-post-checkout-hook:
  worktree: add: fix 'post-checkout' not knowing new worktree location

3 years agoMerge branch 'nd/am-quit'
Junio C Hamano [Wed, 28 Feb 2018 21:37:52 +0000 (13:37 -0800)]
Merge branch 'nd/am-quit'

"git am" has learned the "--quit" option, in addition to the existing
"--abort" option; having the pair mirrors a few other commands like
"rebase" and "cherry-pick".

* nd/am-quit:
  am: support --quit

3 years agoFifth batch for 2.17
Junio C Hamano [Tue, 27 Feb 2018 18:35:18 +0000 (10:35 -0800)]
Fifth batch for 2.17

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoSync with maint
Junio C Hamano [Tue, 27 Feb 2018 18:53:19 +0000 (10:53 -0800)]
Sync with maint

3 years agoMerge branch 'ys/bisect-object-id-missing-conversion-fix' into maint
Junio C Hamano [Tue, 27 Feb 2018 18:43:55 +0000 (10:43 -0800)]
Merge branch 'ys/bisect-object-id-missing-conversion-fix' into maint

Fix for a commented-out code to adjust it to a rather old API change.

* ys/bisect-object-id-missing-conversion-fix:
  bisect: debug: convert struct object to object_id

3 years agoMerge branch 'sb/submodule-update-reset-fix' into maint
Junio C Hamano [Tue, 27 Feb 2018 18:43:54 +0000 (10:43 -0800)]
Merge branch 'sb/submodule-update-reset-fix' into maint

When resetting the working tree files recursively, the working tree
of submodules are now also reset to match.

* sb/submodule-update-reset-fix:
  submodule: submodule_move_head omits old argument in forced case
  unpack-trees: oneway_merge to update submodules
  t/lib-submodule-update.sh: fix test ignoring ignored files in submodules
  t/lib-submodule-update.sh: clarify test

3 years agoMerge branch 'ab/commit-m-with-fixup' into maint
Junio C Hamano [Tue, 27 Feb 2018 18:43:54 +0000 (10:43 -0800)]
Merge branch 'ab/commit-m-with-fixup' into maint

"git commit --fixup" did not allow "-m<message>" option to be used
at the same time; allow it to annotate resulting commit with more
text.

* ab/commit-m-with-fixup:
  commit: add support for --fixup <commit> -m"<extra message>"
  commit doc: document that -c, -C, -F and --fixup with -m error

3 years agoMerge branch 'nd/ita-wt-renames-in-status' into maint
Junio C Hamano [Tue, 27 Feb 2018 18:39:34 +0000 (10:39 -0800)]
Merge branch 'nd/ita-wt-renames-in-status' into maint

"git status" after moving a path in the working tree (hence making
it appear "removed") and then adding with the -N option (hence
making that appear "added") detected it as a rename, but did not
report the  old and new pathnames correctly.

* nd/ita-wt-renames-in-status:
  wt-status.c: handle worktree renames
  wt-status.c: rename rename-related fields in wt_status_change_data
  wt-status.c: catch unhandled diff status codes
  wt-status.c: coding style fix
  Use DIFF_DETECT_RENAME for detect_rename assignments
  t2203: test status output with porcelain v2 format

3 years agoMerge branch 'jt/binsearch-with-fanout'
Junio C Hamano [Tue, 27 Feb 2018 18:34:03 +0000 (10:34 -0800)]
Merge branch 'jt/binsearch-with-fanout'

Refactor the code to binary search starting from a fan-out table
(which is how the packfile is indexed with object names) into a
reusable helper.

* jt/binsearch-with-fanout:
  packfile: refactor hash search with fanout table
  packfile: remove GIT_DEBUG_LOOKUP log statements

3 years agoMerge branch 'rd/typofix'
Junio C Hamano [Tue, 27 Feb 2018 18:34:03 +0000 (10:34 -0800)]
Merge branch 'rd/typofix'

Typofix.

* rd/typofix:
  Correct mispellings of ".gitmodule" to ".gitmodules"
  t/: correct obvious typo "detahced"

3 years agoMerge branch 'jk/test-hashmap-updates'
Junio C Hamano [Tue, 27 Feb 2018 18:34:02 +0000 (10:34 -0800)]
Merge branch 'jk/test-hashmap-updates'

Code clean-up.

* jk/test-hashmap-updates:
  test-hashmap: use "unsigned int" for hash storage
  test-hashmap: simplify alloc_test_entry
  test-hashmap: use strbuf_getline rather than fgets
  test-hashmap: use xsnprintf rather than snprintf
  test-hashmap: check allocation computation for overflow
  test-hashmap: use ALLOC_ARRAY rather than bare malloc

3 years agoMerge branch 'jk/sq-dequote-on-bogus-input'
Junio C Hamano [Tue, 27 Feb 2018 18:34:02 +0000 (10:34 -0800)]
Merge branch 'jk/sq-dequote-on-bogus-input'

Code to unquote single-quoted string (used in the parser for
configuration files, etc.) did not diagnose bogus input correctly
and produced bogus results instead.

* jk/sq-dequote-on-bogus-input:
  sq_dequote: fix extra consumption of source string

3 years agoMerge branch 'bp/fsmonitor'
Junio C Hamano [Tue, 27 Feb 2018 18:34:01 +0000 (10:34 -0800)]
Merge branch 'bp/fsmonitor'

Doc update for a recently added feature.

* bp/fsmonitor:
  fsmonitor: update documentation to remove reference to invalid config settings

3 years agoMerge branch 'bc/doc-interpret-trailers-grammofix'
Junio C Hamano [Tue, 27 Feb 2018 18:34:00 +0000 (10:34 -0800)]
Merge branch 'bc/doc-interpret-trailers-grammofix'

Docfix.

* bc/doc-interpret-trailers-grammofix:
  docs/interpret-trailers: fix agreement error

3 years agoMerge branch 'as/ll-i18n'
Junio C Hamano [Tue, 27 Feb 2018 18:33:58 +0000 (10:33 -0800)]
Merge branch 'as/ll-i18n'

Some messages in low level start-up codepath have been i18n-ized.

* as/ll-i18n:
  Mark messages for translations

3 years agoMerge branch 'sg/doc-test-must-fail-args'
Junio C Hamano [Tue, 27 Feb 2018 18:33:58 +0000 (10:33 -0800)]
Merge branch 'sg/doc-test-must-fail-args'

Devdoc update.

* sg/doc-test-must-fail-args:
  t: document 'test_must_fail ok=<signal-name>'

3 years agoMerge branch 'sb/describe-blob'
Junio C Hamano [Tue, 27 Feb 2018 18:33:57 +0000 (10:33 -0800)]
Merge branch 'sb/describe-blob'

"git describe $garbage" stopped giving any errors when the garbage
happens to be a string with 40 hexadecimal letters.

* sb/describe-blob:
  describe: confirm that blobs actually exist

3 years agoMerge branch 'rs/check-ignore-multi'
Junio C Hamano [Tue, 27 Feb 2018 18:33:56 +0000 (10:33 -0800)]
Merge branch 'rs/check-ignore-multi'

"git check-ignore" with multiple paths got confused when one is a
file and the other is a directory, which has been fixed.

* rs/check-ignore-multi:
  check-ignore: fix mix of directories and other file types

3 years agoMerge branch 'rj/sparse-updates'
Junio C Hamano [Tue, 27 Feb 2018 18:33:55 +0000 (10:33 -0800)]
Merge branch 'rj/sparse-updates'

Devtool update.

* rj/sparse-updates:
  Makefile: suppress a sparse warning for pack-revindex.c
  config.mak.uname: remove SPARSE_FLAGS setting for cygwin

3 years agoMerge branch 'jk/t0002-simplify'
Junio C Hamano [Tue, 27 Feb 2018 18:33:55 +0000 (10:33 -0800)]
Merge branch 'jk/t0002-simplify'

Code cleanup.

* jk/t0002-simplify:
  t0002: simplify error checking

3 years agoMerge branch 'js/packet-read-line-check-null'
Junio C Hamano [Tue, 27 Feb 2018 18:33:54 +0000 (10:33 -0800)]
Merge branch 'js/packet-read-line-check-null'

Some low level protocol codepath could crash when they get an
unexpected flush packet, which is now fixed.

* js/packet-read-line-check-null:
  always check for NULL return from packet_read_line()
  correct error messages for NULL packet_read_line()

3 years agoMerge branch 'js/fix-merge-arg-quoting-in-rebase-p'
Junio C Hamano [Tue, 27 Feb 2018 18:33:54 +0000 (10:33 -0800)]
Merge branch 'js/fix-merge-arg-quoting-in-rebase-p'

"git rebase -p" mangled log messages of a merge commit, which is
now fixed.

* js/fix-merge-arg-quoting-in-rebase-p:
  rebase -p: fix incorrect commit message when calling `git merge`.

3 years agoMerge branch 'jk/gettext-poison'
Junio C Hamano [Tue, 27 Feb 2018 18:33:54 +0000 (10:33 -0800)]
Merge branch 'jk/gettext-poison'

Test updates.

* jk/gettext-poison:
  git-sh-i18n: check GETTEXT_POISON before USE_GETTEXT_SCHEME
  t0205: drop redundant test

3 years agoMerge branch 'jk/doc-do-not-write-extern'
Junio C Hamano [Tue, 27 Feb 2018 18:33:53 +0000 (10:33 -0800)]
Merge branch 'jk/doc-do-not-write-extern'

Devdoc update.

* jk/doc-do-not-write-extern:
  CodingGuidelines: mention "static" and "extern"

3 years agoMerge branch 'bp/name-hash-dirname-fix'
Junio C Hamano [Tue, 27 Feb 2018 18:33:53 +0000 (10:33 -0800)]
Merge branch 'bp/name-hash-dirname-fix'

"git add" files in the same directory, but spelling the directory
path in different cases on case insensitive filesystem, corrupted
the name hash data structure and led to unexpected results.  This
has been corrected.

* bp/name-hash-dirname-fix:
  name-hash: properly fold directory names in adjust_dirname_case()

3 years agoMerge branch 'jc/blame-missing-path'
Junio C Hamano [Tue, 27 Feb 2018 18:33:50 +0000 (10:33 -0800)]
Merge branch 'jc/blame-missing-path'

"git blame HEAD COPYING" in a bare repository failed to run, while
"git blame HEAD -- COPYING" run just fine.  This has been corrected.

* jc/blame-missing-path:
  blame: tighten command line parser

3 years agoMerge branch 'ab/untracked-cache-invalidation-docs'
Junio C Hamano [Tue, 27 Feb 2018 18:33:50 +0000 (10:33 -0800)]
Merge branch 'ab/untracked-cache-invalidation-docs'

Doc update to warn against remaining bugs in untracked cache.

* ab/untracked-cache-invalidation-docs:
  update-index doc: note the caveat with "could not open..."
  update-index doc: note a fixed bug in the untracked cache

3 years agoMerge branch 'nd/fix-untracked-cache-invalidation'
Junio C Hamano [Tue, 27 Feb 2018 18:33:49 +0000 (10:33 -0800)]
Merge branch 'nd/fix-untracked-cache-invalidation'

Some bugs around "untracked cache" feature have been fixed.

* nd/fix-untracked-cache-invalidation:
  dir.c: ignore paths containing .git when invalidating untracked cache
  dir.c: stop ignoring opendir() error in open_cached_dir()
  dir.c: fix missing dir invalidation in untracked code
  dir.c: avoid stat() in valid_cached_dir()
  status: add a failing test showing a core.untrackedCache bug

3 years agoDocumentation/gitsubmodules.txt: avoid non-ASCII apostrophes
Motoki Seki [Thu, 22 Feb 2018 08:52:25 +0000 (08:52 +0000)]
Documentation/gitsubmodules.txt: avoid non-ASCII apostrophes

In gitsubmodules.txt, a few non-ASCII apostrophes are used to spell
possessive, e.g. "submodule's".  These unfortunately are not
rendered at https://git-scm.com/docs/gitsubmodules correctly by the
renderer used there.

Use ASCII apostrophes instead to work around the problem.  It also
is good to be consistent, as there are possessives spelled with
ASCII apostrophes.

Signed-off-by: Motoki Seki <marmot.motoki@gmail.com>
Acked-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agosequencer: factor out strbuf_read_file_or_whine()
René Scharfe [Thu, 22 Feb 2018 19:29:25 +0000 (20:29 +0100)]
sequencer: factor out strbuf_read_file_or_whine()

Reduce code duplication by factoring out a function that reads an entire
file into a strbuf, or reports errors on stderr if something goes wrong.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agot: send verbose test-helper output to fd 4
Jeff King [Thu, 22 Feb 2018 06:48:37 +0000 (01:48 -0500)]
t: send verbose test-helper output to fd 4

Test helper functions like test_must_fail may produce
messages to stderr when they see a problem. When the tests
are run with "--verbose", this ends up on the test script's
stderr, and the user can read it.

But there's a problem. Some tests record stderr as part of
the test, like:

  test_must_fail git foo 2>output &&
  test_i18ngrep expected.message output

In this case the error text goes into "output". This makes
the --verbose output less useful (it also means we might
accidentally match it in the second, though in practice we
tend to produce these messages only on error, so we'd abort
the test when the first command fails).

Let's instead send this user-facing output directly to
descriptor 4, which always points to the original stderr (or
/dev/null in non-verbose mode). And it's already forbidden
to redirect descriptor 4, since we use it for BASH_XTRACEFD,
as explained in 9be795fbce (t5615: avoid re-using descriptor
4, 2017-12-08).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agorevision: drop --show-all option
Jeff King [Wed, 21 Feb 2018 23:27:24 +0000 (18:27 -0500)]
revision: drop --show-all option

This was an undocumented debugging aid that does not seem to
have come in handy in the past decade, judging from its lack
of mentions on the mailing list.

Let's drop it in the name of simplicity. This is morally a
revert of 3131b71301 (Add "--show-all" revision walker flag
for debugging, 2008-02-09), but note that I did leave in the
mapping of UNINTERESTING to "^" in get_revision_mark(). I
don't think this would be possible to trigger with the
current code, but it's the only sensible marker.

We'll skip the usual deprecation period because this was
explicitly a debugging aid that was never documented.

Signed-off-by: Jeff King <peff@peff.net>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agocommit: drop uses of get_cached_commit_buffer()
Jeff King [Wed, 21 Feb 2018 23:13:38 +0000 (18:13 -0500)]
commit: drop uses of get_cached_commit_buffer()

The "--show-all" revision option shows UNINTERESTING
commits. Some of these commits may be unparsed when we try
to show them (since we may or may not need to walk their
parents to fulfill the request).

Commit 3131b71301 (Add "--show-all" revision walker flag for
debugging, 2008-02-09) resolved this by just skipping
pretty-printing for commits without their object contents
cached, saying:

  Because we now end up listing commits we may not even have been parsed
  at all "show_log" and "show_commit" need to protect against commits
  that don't have a commit buffer entry.

That was the easy fix to avoid the pretty-printer segfaulting,
but:

  1. It doesn't work for all formats. E.g., --oneline
     prints the oid for each such commit but not a trailing
     newline, leading to jumbled output.

  2. It only affects some commits, depending on whether we
     happened to parse them or not (so if they were at the
     tip of an UNINTERESTING starting point, or if we
     happened to traverse over them, you'd see more data).

  3. It unncessarily ties the decision to show the verbose
     header to whether the commit buffer was cached. That
     makes it harder to change the logic around caching
     (e.g., if we could traverse without actually loading
     the full commit objects).

These days it's safe to feed such a commit to the
pretty-print code. Since be5c9fb904 (logmsg_reencode: lazily
load missing commit buffers, 2013-01-26), we'll load it on
demand in such a case. So let's just always show the verbose
headers.

This does change the behavior of plumbing, but:

  a. The --show-all option was explicitly introduced as a
     debugging aid, and was never documented (and has rarely
     even been mentioned on the list by git devs).

  b. Avoiding the commits was already not deterministic due
     to (2) above. So the caller might have seen full
     headers for these commits anyway, and would need to be
     prepared for it.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoFourth batch for 2.17
Junio C Hamano [Wed, 21 Feb 2018 20:45:35 +0000 (12:45 -0800)]
Fourth batch for 2.17

3 years agoMerge branch 'sg/test-i18ngrep'
Junio C Hamano [Wed, 21 Feb 2018 20:45:05 +0000 (12:45 -0800)]
Merge branch 'sg/test-i18ngrep'

Test fixes.

* sg/test-i18ngrep:
  t: make 'test_i18ngrep' more informative on failure
  t: validate 'test_i18ngrep's parameters
  t: move 'test_i18ncmp' and 'test_i18ngrep' to 'test-lib-functions.sh'
  t5536: let 'test_i18ngrep' read the file without redirection
  t5510: consolidate 'grep' and 'test_i18ngrep' patterns
  t4001: don't run 'git status' upstream of a pipe
  t6022: don't run 'git merge' upstream of a pipe
  t5812: add 'test_i18ngrep's missing filename parameter
  t5541: add 'test_i18ngrep's missing filename parameter

3 years agoMerge branch 'gs/rebase-allow-empty-message'
Junio C Hamano [Wed, 21 Feb 2018 20:45:04 +0000 (12:45 -0800)]
Merge branch 'gs/rebase-allow-empty-message'

"git rebase" learned to take "--allow-empty-message" option.

* gs/rebase-allow-empty-message:
  rebase: add --allow-empty-message option

3 years agoMerge branch 'lw/daemon-log-destination'
Junio C Hamano [Wed, 21 Feb 2018 20:45:04 +0000 (12:45 -0800)]
Merge branch 'lw/daemon-log-destination'

The log from "git daemon" can be redirected with a new option; one
relevant use case is to send the log to standard error (instead of
syslog) when running it from inetd.

* lw/daemon-log-destination:
  daemon: add --log-destination=(stderr|syslog|none)

3 years agoMerge branch 'nd/format-patch-stat-width'
Junio C Hamano [Wed, 21 Feb 2018 20:45:04 +0000 (12:45 -0800)]
Merge branch 'nd/format-patch-stat-width'

"git format-patch" learned to give 72-cols to diffstat, which is
consistent with other line length limits the subcommand uses for
its output meant for e-mails.

* nd/format-patch-stat-width:
  format-patch: reduce patch diffstat width to 72
  format-patch: keep cover-letter diffstat wrapped in 72 columns

3 years agosubmodule: indicate that 'submodule.recurse' doesn't apply to clone
Brandon Williams [Tue, 20 Feb 2018 20:29:22 +0000 (12:29 -0800)]
submodule: indicate that 'submodule.recurse' doesn't apply to clone

Update the documentation for the 'submodule.recurse' config to identify
that the clone command does not respect it.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoremote-curl: unquote incoming push-options
Jeff King [Mon, 19 Feb 2018 19:50:14 +0000 (14:50 -0500)]
remote-curl: unquote incoming push-options

The transport-helper protocol c-style quotes the value of
any options passed to the helper via the "option <key> <value>"
directive. However, remote-curl doesn't actually unquote the
push-option values, meaning that we will send the quoted
version to the other side (whereas git-over-ssh would send
the raw value).

The pack-protocol.txt documentation defines the push-options
as a series of VCHARs, which excludes most characters that
would need quoting. But:

  1. You can still see the bug with a valid push-option that
     starts with a double-quote (since that triggers
     quoting).

  2. We do currently handle any non-NUL characters correctly
     in git-over-ssh. So even though the spec does not say
     that we need to handle most quoted characters, it's
     nice if our behavior is consistent between protocols.

There are two new tests: the "direct" one shows that this
already works in the non-http case, and the http one covers
this bugfix.

Reported-by: Jon Simons <jon@jonsimons.org>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agot5545: factor out http repository setup
Jeff King [Mon, 19 Feb 2018 19:48:44 +0000 (14:48 -0500)]
t5545: factor out http repository setup

We repeat many lines of setup code in the two http tests,
and further tests would need to repeat it again.  Let's
factor this out into a function.

Incidentally, this also fixes an unlikely bug: if the httpd
root path contains a double-quote, our test_when_finished
would barf due to improper quoting (we escape the embedded
quotes, but not the $, meaning we expand the variable before
the eval).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMakefile: remove *.spec from clean target
Todd Zullinger [Sat, 17 Feb 2018 03:06:24 +0000 (22:06 -0500)]
Makefile: remove *.spec from clean target

Support for generating an rpm was dropped in ab214331cf ("Makefile: stop
pretending to support rpmbuild", 2016-04-04).  We don't generate any
*.spec files so there is no need to clean them up.

Signed-off-by: Todd Zullinger <tmz@pobox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agogit-worktree.txt: fix indentation of example and text of 'add' command
Eric Sunshine [Fri, 16 Feb 2018 20:44:52 +0000 (15:44 -0500)]
git-worktree.txt: fix indentation of example and text of 'add' command

When 4e85333197 (worktree: make add <path> <branch> dwim, 2017-11-26)
added an example command in a literal code block, it neglected to
insert a mandatory "+" line before the block. This omission resulted
in both the literal code block and the (existing) paragraph following
the block to be outdented, even though they should be indented under
the 'add' sub-command along with the rest of the text pertaining to
that command. Furthermore, the mandatory "+" line separating the code
block from the following text got rendered as a leading character on
the line ("+ If <commit-ish>...") rather than being treated as a
formatting directive.

Fix these problems by adding the missing "+" line before the example
code block.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agogit-worktree.txt: fix missing ")" typo
Eric Sunshine [Fri, 16 Feb 2018 20:44:51 +0000 (15:44 -0500)]
git-worktree.txt: fix missing ")" typo

Add the closing ")" to a parenthetical phrase introduced by 4e85333197
(worktree: make add <path> <branch> dwim, 2017-11-26).

While at it, add a missing ":" at the end of the same sentence since
it precedes an example literal command block.

Reported-by: Mike Nordell <tamlin.thefirst@gmail.com>
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agotest-lib.sh: unset XDG_CACHE_HOME
Genki Sky [Fri, 16 Feb 2018 02:46:04 +0000 (21:46 -0500)]
test-lib.sh: unset XDG_CACHE_HOME

git respects XDG_CACHE_HOME for the credential cache. So, we should
unset XDG_CACHE_HOME for the test environment, lest a user's custom one
cause failure in the test.

For example, t/t0301-credential-cache.sh expects a default directory
to be used if it hasn't explicitly set XDG_CACHE_HOME.

Signed-off-by: Genki Sky <sky@genki.is>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agomerge: allow fast-forward when merging a tracked tag
Junio C Hamano [Wed, 14 Feb 2018 18:18:55 +0000 (10:18 -0800)]
merge: allow fast-forward when merging a tracked tag

Long time ago at fab47d05 ("merge: force edit and no-ff mode when
merging a tag object", 2011-11-07), "git merge" was made to always
create a merge commit when merging a tag, even when the side branch
being merged is a descendant of the current branch.

This default is good for merges made by upstream maintainers to
integrate work signed by downstream contributors, but will leave
pointless no-ff merges when downstream contributors pull a newer
release tag to make their long-running topic branches catch up with
the upstream.  When there is no local work left on the topic, such a
merge should simply fast-forward to the commit pointed at by the
release tag.

Update the default (again) for "git merge" that merges a tag object
to (1) --no-ff (i.e. create a merge commit even when side branch
fast forwards) if the tag being merged is not at its expected place
in refs/tags/ hierarchy and (2) --ff (i.e. allow fast-forward update
when able) otherwise.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoSync with 2.16.2 454/head
Junio C Hamano [Thu, 15 Feb 2018 23:24:55 +0000 (15:24 -0800)]
Sync with 2.16.2

* tag 'v2.16.2':
  Git 2.16.2

3 years agoGit 2.16.2 v2.16.2
Junio C Hamano [Thu, 15 Feb 2018 23:21:23 +0000 (15:21 -0800)]
Git 2.16.2

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'ab/doc-cat-file-e-still-shows-errors' into maint
Junio C Hamano [Thu, 15 Feb 2018 23:18:15 +0000 (15:18 -0800)]
Merge branch 'ab/doc-cat-file-e-still-shows-errors' into maint

Doc update.

* ab/doc-cat-file-e-still-shows-errors:
  cat-file doc: document that -e will return some output

3 years agoMerge branch 'as/read-tree-prefix-doc-fix' into maint
Junio C Hamano [Thu, 15 Feb 2018 23:18:14 +0000 (15:18 -0800)]
Merge branch 'as/read-tree-prefix-doc-fix' into maint

Doc update.

* as/read-tree-prefix-doc-fix:
  doc/read-tree: remove obsolete remark

3 years agoMerge branch 'nd/add-i-ignore-submodules' into maint
Junio C Hamano [Thu, 15 Feb 2018 23:18:13 +0000 (15:18 -0800)]
Merge branch 'nd/add-i-ignore-submodules' into maint

"git add -p" was taught to ignore local changes to submodules as
they do not interfere with the partial addition of regular changes
anyway.

* nd/add-i-ignore-submodules:
  add--interactive: ignore submodule changes except HEAD

3 years agoMerge branch 'tg/stash-with-pathspec-fix' into maint
Junio C Hamano [Thu, 15 Feb 2018 23:18:13 +0000 (15:18 -0800)]
Merge branch 'tg/stash-with-pathspec-fix' into maint

"git stash -- <pathspec>" incorrectly blew away untracked files in
the directory that matched the pathspec, which has been corrected.

* tg/stash-with-pathspec-fix:
  stash: don't delete untracked files that match pathspec

3 years agoMerge branch 'jk/abort-clone-with-existing-dest' into maint
Junio C Hamano [Thu, 15 Feb 2018 23:18:12 +0000 (15:18 -0800)]
Merge branch 'jk/abort-clone-with-existing-dest' into maint

"git clone $there $here" is allowed even when here directory exists
as long as it is an empty directory, but the command incorrectly
removed it upon a failure of the operation.

* jk/abort-clone-with-existing-dest:
  clone: do not clean up directories we didn't create
  clone: factor out dir_exists() helper
  t5600: modernize style
  t5600: fix outdated comment about unborn HEAD

3 years agoMerge branch 'jc/merge-symlink-ours-theirs' into maint
Junio C Hamano [Thu, 15 Feb 2018 23:18:12 +0000 (15:18 -0800)]
Merge branch 'jc/merge-symlink-ours-theirs' into maint

"git merge -Xours/-Xtheirs" learned to use our/their version when
resolving a conflicting updates to a symbolic link.

* jc/merge-symlink-ours-theirs:
  merge: teach -Xours/-Xtheirs to symbolic link merge

3 years agoMerge branch 'rs/lose-leak-pending' into maint
Junio C Hamano [Thu, 15 Feb 2018 23:18:11 +0000 (15:18 -0800)]
Merge branch 'rs/lose-leak-pending' into maint

API clean-up around revision traversal.

* rs/lose-leak-pending:
  commit: remove unused function clear_commit_marks_for_object_array()
  revision: remove the unused flag leak_pending
  checkout: avoid using the rev_info flag leak_pending
  bundle: avoid using the rev_info flag leak_pending
  bisect: avoid using the rev_info flag leak_pending
  object: add clear_commit_marks_all()
  ref-filter: use clear_commit_marks_many() in do_merge_filter()
  commit: use clear_commit_marks_many() in remove_redundant()
  commit: avoid allocation in clear_commit_marks_many()

3 years agoMerge branch 'jm/svn-pushmergeinfo-fix' into maint
Junio C Hamano [Thu, 15 Feb 2018 23:18:11 +0000 (15:18 -0800)]
Merge branch 'jm/svn-pushmergeinfo-fix' into maint

"git svn dcommit" did not take into account the fact that a
svn+ssh:// URL with a username@ (typically used for pushing) refers
to the same SVN repository without the username@ and failed when
svn.pushmergeinfo option is set.

* jm/svn-pushmergeinfo-fix:
  git-svn: fix svn.pushmergeinfo handling of svn+ssh usernames.

3 years agoMerge branch 'dk/describe-all-output-fix' into maint
Junio C Hamano [Thu, 15 Feb 2018 23:18:10 +0000 (15:18 -0800)]
Merge branch 'dk/describe-all-output-fix' into maint

An old regression in "git describe --all $annotated_tag^0" has been
fixed.

* dk/describe-all-output-fix:
  describe: prepend "tags/" when describing tags with embedded name

3 years agoMerge branch 'ab/perf-grep-threads' into maint
Junio C Hamano [Thu, 15 Feb 2018 23:18:09 +0000 (15:18 -0800)]
Merge branch 'ab/perf-grep-threads' into maint

More perf tests for threaded grep

* ab/perf-grep-threads:
  perf: amend the grep tests to test grep.threads

3 years agoThird batch for 2.17
Junio C Hamano [Thu, 15 Feb 2018 22:56:49 +0000 (14:56 -0800)]
Third batch for 2.17

Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoMerge branch 'bc/hash-algo'
Junio C Hamano [Thu, 15 Feb 2018 22:55:47 +0000 (14:55 -0800)]
Merge branch 'bc/hash-algo'

More abstraction of hash function from the codepath.

* bc/hash-algo:
  hash: update obsolete reference to SHA1_HEADER
  bulk-checkin: abstract SHA-1 usage
  csum-file: abstract uses of SHA-1
  csum-file: rename sha1file to hashfile
  read-cache: abstract away uses of SHA-1
  pack-write: switch various SHA-1 values to abstract forms
  pack-check: convert various uses of SHA-1 to abstract forms
  fast-import: switch various uses of SHA-1 to the_hash_algo
  sha1_file: switch uses of SHA-1 to the_hash_algo
  builtin/unpack-objects: switch uses of SHA-1 to the_hash_algo
  builtin/index-pack: improve hash function abstraction
  hash: create union for hash context allocation
  hash: move SHA-1 macros to hash.h

3 years agoMerge branch 'nd/ignore-glob-doc-update'
Junio C Hamano [Thu, 15 Feb 2018 22:55:46 +0000 (14:55 -0800)]
Merge branch 'nd/ignore-glob-doc-update'

Doc update.

* nd/ignore-glob-doc-update:
  gitignore.txt: elaborate shell glob syntax

3 years agoMerge branch 'tg/reset-hard-show-head-with-pretty'
Junio C Hamano [Thu, 15 Feb 2018 22:55:45 +0000 (14:55 -0800)]
Merge branch 'tg/reset-hard-show-head-with-pretty'

The way "git reset --hard" reports the commit the updated HEAD
points at is made consistent with the way how the commit title is
generated by the other parts of the system.  This matters when the
title is spread across physically multiple lines.

* tg/reset-hard-show-head-with-pretty:
  reset --hard: make use of the pretty machinery

3 years agoMerge branch 'rs/cocci-strbuf-addf-to-addstr'
Junio C Hamano [Thu, 15 Feb 2018 22:55:44 +0000 (14:55 -0800)]
Merge branch 'rs/cocci-strbuf-addf-to-addstr'

* rs/cocci-strbuf-addf-to-addstr:
  cocci: simplify check for trivial format strings

3 years agoMerge branch 'nd/trace-index-ops'
Junio C Hamano [Thu, 15 Feb 2018 22:55:44 +0000 (14:55 -0800)]
Merge branch 'nd/trace-index-ops'

* nd/trace-index-ops:
  trace: measure where the time is spent in the index-heavy operations

3 years agoMerge branch 'cc/perf-aggregate'
Junio C Hamano [Thu, 15 Feb 2018 22:55:44 +0000 (14:55 -0800)]
Merge branch 'cc/perf-aggregate'

"make perf" enhancement.

* cc/perf-aggregate:
  perf/aggregate: sort JSON fields in output
  perf/aggregate: add --reponame option
  perf/aggregate: add --subsection option

3 years agoMerge branch 'ab/wildmatch-tests'
Junio C Hamano [Thu, 15 Feb 2018 22:55:44 +0000 (14:55 -0800)]
Merge branch 'ab/wildmatch-tests'

More tests for wildmatch functions.

* ab/wildmatch-tests:
  wildmatch test: mark test as EXPENSIVE_ON_WINDOWS
  test-lib: add an EXPENSIVE_ON_WINDOWS prerequisite
  wildmatch test: create & test files on disk in addition to in-memory
  wildmatch test: perform all tests under all wildmatch() modes
  wildmatch test: use test_must_fail, not ! for test-wildmatch
  wildmatch test: remove dead fnmatch() test code
  wildmatch test: use a paranoia pattern from nul_match()
  wildmatch test: don't try to vertically align our output
  wildmatch test: use more standard shell style
  wildmatch test: indent with tabs, not spaces

3 years agoMerge branch 'po/object-id'
Junio C Hamano [Thu, 15 Feb 2018 22:55:43 +0000 (14:55 -0800)]
Merge branch 'po/object-id'

Conversion from uchar[20] to struct object_id continues.

* po/object-id:
  sha1_file: rename hash_sha1_file_literally
  sha1_file: convert write_loose_object to object_id
  sha1_file: convert force_object_loose to object_id
  sha1_file: convert write_sha1_file to object_id
  notes: convert write_notes_tree to object_id
  notes: convert combine_notes_* to object_id
  commit: convert commit_tree* to object_id
  match-trees: convert splice_tree to object_id
  cache: clear whole hash buffer with oidclr
  sha1_file: convert hash_sha1_file to object_id
  dir: convert struct sha1_stat to use object_id
  sha1_file: convert pretend_sha1_file to object_id

3 years agoMerge branch 'sb/pull-rebase-submodule'
Junio C Hamano [Thu, 15 Feb 2018 22:55:43 +0000 (14:55 -0800)]
Merge branch 'sb/pull-rebase-submodule'

"git pull --rebase" did not pass verbosity setting down when
recursing into a submodule.

* sb/pull-rebase-submodule:
  builtin/pull: respect verbosity settings in submodules

3 years agoMerge branch 'kg/packed-ref-cache-fix'
Junio C Hamano [Thu, 15 Feb 2018 22:55:42 +0000 (14:55 -0800)]
Merge branch 'kg/packed-ref-cache-fix'

Avoid mmapping small files while using packed refs (especially ones
with zero size, which would cause later munmap() to fail).

* kg/packed-ref-cache-fix:
  packed_ref_cache: don't use mmap() for small files
  load_contents(): don't try to mmap an empty file
  packed_ref_iterator_begin(): make optimization more general
  find_reference_location(): make function safe for empty snapshots
  create_snapshot(): use `xmemdupz()` rather than a strbuf
  struct snapshot: store `start` rather than `header_len`

3 years agoMerge branch 'jt/fsck-code-cleanup'
Junio C Hamano [Thu, 15 Feb 2018 22:55:41 +0000 (14:55 -0800)]
Merge branch 'jt/fsck-code-cleanup'

Plug recently introduced leaks in fsck.

* jt/fsck-code-cleanup:
  fsck: fix leak when traversing trees

3 years agoMerge branch 'en/merge-recursive-fixes'
Junio C Hamano [Thu, 15 Feb 2018 22:55:40 +0000 (14:55 -0800)]
Merge branch 'en/merge-recursive-fixes'

* en/merge-recursive-fixes:
  merge-recursive: add explanation for src_entry and dst_entry
  merge-recursive: fix logic ordering issue
  Tighten and correct a few testcases for merging and cherry-picking

3 years agoMerge branch 'jc/worktree-add-short-help'
Junio C Hamano [Thu, 15 Feb 2018 22:55:40 +0000 (14:55 -0800)]
Merge branch 'jc/worktree-add-short-help'

Error message fix.

* jc/worktree-add-short-help:
  worktree: say that "add" takes an arbitrary commit in short-help

3 years agoMerge branch 'ab/sha1dc-build'
Junio C Hamano [Thu, 15 Feb 2018 22:55:40 +0000 (14:55 -0800)]
Merge branch 'ab/sha1dc-build'

Push the submodule version of collision-detecting SHA-1 hash
implementation a bit harder on builders.

* ab/sha1dc-build:
  sha1dc_git.h: re-arrange an ifdef chain for a subsequent change
  Makefile: under "make dist", include the sha1collisiondetection submodule
  Makefile: don't error out under DC_SHA1_EXTERNAL if DC_SHA1_SUBMODULE=auto

3 years agoworktree: add: fix 'post-checkout' not knowing new worktree location
Eric Sunshine [Thu, 15 Feb 2018 19:18:41 +0000 (14:18 -0500)]
worktree: add: fix 'post-checkout' not knowing new worktree location

Although "git worktree add" learned to run the 'post-checkout' hook in
ade546be47 (worktree: invoke post-checkout hook, 2017-12-07), it
neglected to change to the directory of the newly-created worktree
before running the hook. Instead, the hook runs within the directory
from which the "git worktree add" command itself was invoked, which
effectively neuters the hook since it knows nothing about the new
worktree directory.

Further, ade546be47 failed to sanitize the environment before running
the hook, which means that user-assigned values of GIT_DIR and
GIT_WORK_TREE could mislead the hook about the location of the new
worktree. In the case of "git worktree add" being run from a bare
repository, the GIT_DIR="." assigned by Git itself leaks into the hook's
environment and breaks Git commands; this is so even when the working
directory is correctly changed to the new worktree before the hook runs
since ".", relative to the new worktree directory, does not point at the
bare repository.

Fix these problems by (1) changing to the new worktree's directory
before running the hook, and (2) sanitizing the environment of GIT_DIR
and GIT_WORK_TREE so hooks can't be confused by misleading values.

Enhance the t2025 'post-checkout' tests to verify that the hook is
indeed run within the correct directory and that Git commands invoked by
the hook compute Git-dir and top-level worktree locations correctly.

While at it, also add two new tests: (1) verify that the hook is run
within the correct directory even when the new worktree is created from
a sibling worktree (as opposed to the main worktree); (2) verify that
the hook is provided with correct context when the new worktree is
created from a bare repository (test provided by Lars Schneider).

Implementation Notes:

Rather than sanitizing the environment of GIT_DIR and GIT_WORK_TREE, an
alternative would be to set them explicitly, as is already done for
other Git commands run internally by "git worktree add". This patch opts
instead to sanitize the environment in order to clearly document that
the worktree is fully functional by the time the hook is run, thus does
not require special environmental overrides.

The hook is run manually, rather than via run_hook_le(), since it needs
to change the working directory to that of the worktree, and
run_hook_le() does not provide such functionality. As this is a one-off
case, adding 'run_hook' overloads which allow the directory to be set
does not seem warranted at this time.

Reported-by: Lars Schneider <larsxschneider@gmail.com>
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agopackfile: refactor hash search with fanout table
Jonathan Tan [Tue, 13 Feb 2018 18:39:39 +0000 (10:39 -0800)]
packfile: refactor hash search with fanout table

Subsequent patches will introduce file formats that make use of a fanout
array and a sorted table containing hashes, just like packfiles.
Refactor the hash search in packfile.c into its own function, so that
those patches can make use of it as well.

Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agopackfile: remove GIT_DEBUG_LOOKUP log statements
Jonathan Tan [Tue, 13 Feb 2018 18:39:38 +0000 (10:39 -0800)]
packfile: remove GIT_DEBUG_LOOKUP log statements

In commit 628522ec1439 ("sha1-lookup: more memory efficient search in
sorted list of SHA-1", 2008-04-09), a different algorithm for searching
a sorted list was introduced, together with a set of log statements
guarded by GIT_DEBUG_LOOKUP that are invoked both when using that
algorithm and when using the existing binary search. Those log
statements was meant for experiments and debugging, but with the removal
of the aforementioned different algorithm in commit f1068efefe6d
("sha1_file: drop experimental GIT_USE_LOOKUP search", 2017-08-09),
those log statements are probably no longer necessary.

Remove those statements.

Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoapply: handle Subversion diffs with /dev/null gracefully
Tatyana Krasnukha [Thu, 15 Feb 2018 00:29:34 +0000 (01:29 +0100)]
apply: handle Subversion diffs with /dev/null gracefully

Subversion generates diffs that can contain lines like this one:

--- /dev/null  (nonexistent)

Let's teach Git's apply machinery to handle such a line gracefully.

This fixes https://github.com/git-for-windows/git/isues/1489

Signed-off-by: Tatyana Krasnukha <tatyana@synopsys.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 years agoapply: demonstrate a problem applying svn diffs
Johannes Schindelin [Thu, 15 Feb 2018 00:29:27 +0000 (01:29 +0100)]
apply: demonstrate a problem applying svn diffs

Subversion generates diffs that contain funny ---/+++ lines containing
more than just the file names. Example:

--- a/trunk/README (revision 4711)
+++ /dev/null (nonexistent)

Let's add a test case demonstrating that apply cannot handle the
/dev/null line (although it can handle the trunk/README line just fine).

Reported in https://github.com/git-for-windows/git/issues/1489

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