git
7 years agoSync with maint
Junio C Hamano [Wed, 18 Oct 2017 05:26:53 +0000 (14:26 +0900)] 
Sync with maint

* maint:
  Prepare for 2.14.3

7 years agoPrepare for 2.14.3
Junio C Hamano [Wed, 18 Oct 2017 05:24:09 +0000 (14:24 +0900)] 
Prepare for 2.14.3

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMerge branch 'jk/ref-filter-colors-fix' into maint
Junio C Hamano [Wed, 18 Oct 2017 05:20:43 +0000 (14:20 +0900)] 
Merge branch 'jk/ref-filter-colors-fix' into maint

This is the "theoretically more correct" approach of simply
stepping back to the state before plumbing commands started paying
attention to "color.ui" configuration variable.

* jk/ref-filter-colors-fix:
  tag: respect color.ui config
  Revert "color: check color.ui in git_default_config()"
  Revert "t6006: drop "always" color config tests"
  Revert "color: make "always" the same as "auto" in config"
  color: make "always" the same as "auto" in config
  provide --color option for all ref-filter users
  t3205: use --color instead of color.branch=always
  t3203: drop "always" color test
  t6006: drop "always" color config tests
  t7502: use diff.noprefix for --verbose test
  t7508: use test_terminal for color output
  t3701: use test-terminal to collect color output
  t4015: prefer --color to -c color.diff=always
  test-terminal: set TERM=vt100

7 years agoMerge branch 'jc/doc-checkout' into maint
Junio C Hamano [Wed, 18 Oct 2017 05:19:14 +0000 (14:19 +0900)] 
Merge branch 'jc/doc-checkout' into maint

Doc update.

* jc/doc-checkout:
  checkout doc: clarify command line args for "checkout paths" mode

7 years agoMerge branch 'tb/complete-describe' into maint
Junio C Hamano [Wed, 18 Oct 2017 05:19:14 +0000 (14:19 +0900)] 
Merge branch 'tb/complete-describe' into maint

Docfix.

* tb/complete-describe:
  completion: add --broken and --dirty to describe

7 years agoMerge branch 'rs/rs-mailmap' into maint
Junio C Hamano [Wed, 18 Oct 2017 05:19:14 +0000 (14:19 +0900)] 
Merge branch 'rs/rs-mailmap' into maint

* rs/rs-mailmap:
  .mailmap: normalize name for RenĂ© Scharfe

7 years agoMerge branch 'rs/fsck-null-return-from-lookup' into maint
Junio C Hamano [Wed, 18 Oct 2017 05:19:14 +0000 (14:19 +0900)] 
Merge branch 'rs/fsck-null-return-from-lookup' into maint

Improve behaviour of "git fsck" upon finding a missing object.

* rs/fsck-null-return-from-lookup:
  fsck: handle NULL return of lookup_blob() and lookup_tree()

7 years agoMerge branch 'jk/sha1-loose-object-info-fix' into maint
Junio C Hamano [Wed, 18 Oct 2017 05:19:14 +0000 (14:19 +0900)] 
Merge branch 'jk/sha1-loose-object-info-fix' into maint

Leakfix and futureproofing.

* jk/sha1-loose-object-info-fix:
  sha1_loose_object_info: handle errors from unpack_sha1_rest

7 years agoMerge branch 'sb/branch-avoid-repeated-strbuf-release' into maint
Junio C Hamano [Wed, 18 Oct 2017 05:19:14 +0000 (14:19 +0900)] 
Merge branch 'sb/branch-avoid-repeated-strbuf-release' into maint

* sb/branch-avoid-repeated-strbuf-release:
  branch: reset instead of release a strbuf

7 years agoMerge branch 'rs/qsort-s' into maint
Junio C Hamano [Wed, 18 Oct 2017 05:19:14 +0000 (14:19 +0900)] 
Merge branch 'rs/qsort-s' into maint

* rs/qsort-s:
  test-stringlist: avoid buffer underrun when sorting nothing

7 years agoMerge branch 'jn/strbuf-doc-re-reuse' into maint
Junio C Hamano [Wed, 18 Oct 2017 05:19:13 +0000 (14:19 +0900)] 
Merge branch 'jn/strbuf-doc-re-reuse' into maint

* jn/strbuf-doc-re-reuse:
  strbuf doc: reuse after strbuf_release is fine

7 years agoMerge branch 'rs/run-command-use-alloc-array' into maint
Junio C Hamano [Wed, 18 Oct 2017 05:19:13 +0000 (14:19 +0900)] 
Merge branch 'rs/run-command-use-alloc-array' into maint

Code clean-up.

* rs/run-command-use-alloc-array:
  run-command: use ALLOC_ARRAY

7 years agoMerge branch 'rs/tag-null-pointer-arith-fix' into maint
Junio C Hamano [Wed, 18 Oct 2017 05:19:12 +0000 (14:19 +0900)] 
Merge branch 'rs/tag-null-pointer-arith-fix' into maint

Code clean-up.

* rs/tag-null-pointer-arith-fix:
  tag: avoid NULL pointer arithmetic

7 years agoMerge branch 'rs/cocci-de-paren-call-params' into maint
Junio C Hamano [Wed, 18 Oct 2017 05:19:12 +0000 (14:19 +0900)] 
Merge branch 'rs/cocci-de-paren-call-params' into maint

Code clean-up.

* rs/cocci-de-paren-call-params:
  coccinelle: remove parentheses that become unnecessary

7 years agoMerge branch 'ad/doc-markup-fix' into maint
Junio C Hamano [Wed, 18 Oct 2017 05:19:12 +0000 (14:19 +0900)] 
Merge branch 'ad/doc-markup-fix' into maint

Docfix.

* ad/doc-markup-fix:
  doc: correct command formatting

7 years agoMerge branch 'mr/doc-negative-pathspec' into maint
Junio C Hamano [Wed, 18 Oct 2017 05:19:12 +0000 (14:19 +0900)] 
Merge branch 'mr/doc-negative-pathspec' into maint

Doc updates.

* mr/doc-negative-pathspec:
  docs: improve discoverability of exclude pathspec

7 years agoMerge branch 'jk/validate-headref-fix' into maint
Junio C Hamano [Wed, 18 Oct 2017 05:19:12 +0000 (14:19 +0900)] 
Merge branch 'jk/validate-headref-fix' into maint

Code clean-up.

* jk/validate-headref-fix:
  validate_headref: use get_oid_hex for detached HEADs
  validate_headref: use skip_prefix for symref parsing
  validate_headref: NUL-terminate HEAD buffer

7 years agoMerge branch 'ks/doc-use-camelcase-for-config-name' into maint
Junio C Hamano [Wed, 18 Oct 2017 05:19:12 +0000 (14:19 +0900)] 
Merge branch 'ks/doc-use-camelcase-for-config-name' into maint

Doc update.

* ks/doc-use-camelcase-for-config-name:
  doc: camelCase the config variables to improve readability

7 years agoMerge branch 'jk/doc-read-tree-table-asciidoctor-fix' into maint
Junio C Hamano [Wed, 18 Oct 2017 05:19:11 +0000 (14:19 +0900)] 
Merge branch 'jk/doc-read-tree-table-asciidoctor-fix' into maint

A docfix.

* jk/doc-read-tree-table-asciidoctor-fix:
  doc: put literal block delimiter around table

7 years agoMerge branch 'hn/typofix' into maint
Junio C Hamano [Wed, 18 Oct 2017 05:19:11 +0000 (14:19 +0900)] 
Merge branch 'hn/typofix' into maint

* hn/typofix:
  submodule.h: typofix

7 years agoMerge branch 'ks/test-readme-phrasofix' into maint
Junio C Hamano [Wed, 18 Oct 2017 05:19:10 +0000 (14:19 +0900)] 
Merge branch 'ks/test-readme-phrasofix' into maint

Doc updates.

* ks/test-readme-phrasofix:
  t/README: fix typo and grammatically improve a sentence

7 years agoMerge branch 'ez/doc-duplicated-words-fix' into maint
Junio C Hamano [Wed, 18 Oct 2017 05:19:10 +0000 (14:19 +0900)] 
Merge branch 'ez/doc-duplicated-words-fix' into maint

Typofix.

* ez/doc-duplicated-words-fix:
  doc: fix minor typos (extra/duplicated words)

7 years agoMerge branch 'kd/doc-for-each-ref' into maint
Junio C Hamano [Wed, 18 Oct 2017 05:19:10 +0000 (14:19 +0900)] 
Merge branch 'kd/doc-for-each-ref' into maint

Doc update.

* kd/doc-for-each-ref:
  doc/for-each-ref: explicitly specify option names
  doc/for-each-ref: consistently use '=' to between argument names and values

7 years agoMerge branch 'cc/subprocess-handshake-missing-capabilities' into maint
Junio C Hamano [Wed, 18 Oct 2017 05:19:10 +0000 (14:19 +0900)] 
Merge branch 'cc/subprocess-handshake-missing-capabilities' into maint

Finishing touches to a topic already in 'master'.

* cc/subprocess-handshake-missing-capabilities:
  subprocess: loudly die when subprocess asks for an unsupported capability

7 years agoMerge branch 'jk/system-path-cleanup' into maint
Junio C Hamano [Wed, 18 Oct 2017 05:19:10 +0000 (14:19 +0900)] 
Merge branch 'jk/system-path-cleanup' into maint

Code clean-up.

* jk/system-path-cleanup:
  git_extract_argv0_path: do nothing without RUNTIME_PREFIX
  system_path: move RUNTIME_PREFIX to a sub-function

7 years agoMerge branch 'bb/doc-eol-dirty' into maint
Junio C Hamano [Wed, 18 Oct 2017 05:19:09 +0000 (14:19 +0900)] 
Merge branch 'bb/doc-eol-dirty' into maint

Doc update.

* bb/doc-eol-dirty:
  Documentation: mention that `eol` can change the dirty status of paths

7 years agoMerge branch 'mg/timestamp-t-fix' into maint
Junio C Hamano [Wed, 18 Oct 2017 05:19:09 +0000 (14:19 +0900)] 
Merge branch 'mg/timestamp-t-fix' into maint

A mismerge fix.

* mg/timestamp-t-fix:
  name-rev: change ULONG_MAX to TIME_MAX

7 years agoMerge branch 'ma/pkt-line-leakfix' into maint
Junio C Hamano [Wed, 18 Oct 2017 05:19:08 +0000 (14:19 +0900)] 
Merge branch 'ma/pkt-line-leakfix' into maint

A leakfix.

* ma/pkt-line-leakfix:
  pkt-line: re-'static'-ify buffer in packet_write_fmt_1()

7 years agoMerge branch 'jk/config-lockfile-leak-fix' into maint
Junio C Hamano [Wed, 18 Oct 2017 05:19:07 +0000 (14:19 +0900)] 
Merge branch 'jk/config-lockfile-leak-fix' into maint

A leakfix.

* jk/config-lockfile-leak-fix:
  config: use a static lock_file struct

7 years agoMerge branch 'dw/diff-highlight-makefile-fix' into maint
Junio C Hamano [Wed, 18 Oct 2017 05:19:07 +0000 (14:19 +0900)] 
Merge branch 'dw/diff-highlight-makefile-fix' into maint

Build clean-up.

* dw/diff-highlight-makefile-fix:
  diff-highlight: add clean target to Makefile

7 years agoMerge branch 'jk/drop-sha1-entry-pos' into maint
Junio C Hamano [Wed, 18 Oct 2017 05:19:06 +0000 (14:19 +0900)] 
Merge branch 'jk/drop-sha1-entry-pos' into maint

Code clean-up.

* jk/drop-sha1-entry-pos:
  sha1-lookup: remove sha1_entry_pos() from header file
  sha1_file: drop experimental GIT_USE_LOOKUP search

7 years agoMerge branch 'tb/ref-filter-empty-modifier' into maint
Junio C Hamano [Wed, 18 Oct 2017 05:19:06 +0000 (14:19 +0900)] 
Merge branch 'tb/ref-filter-empty-modifier' into maint

In the "--format=..." option of the "git for-each-ref" command (and
its friends, i.e. the listing mode of "git branch/tag"), "%(atom:)"
(e.g. "%(refname:)", "%(body:)" used to error out.  Instead, treat
them as if the colon and an empty string that follows it were not
there.

* tb/ref-filter-empty-modifier:
  ref-filter.c: pass empty-string as NULL to atom parsers

7 years agoMerge branch 'rb/compat-poll-fix' into maint
Junio C Hamano [Wed, 18 Oct 2017 05:19:05 +0000 (14:19 +0900)] 
Merge branch 'rb/compat-poll-fix' into maint

Backports a moral equivalent of 2015 fix to the poll emulation from
the upstream gnulib to fix occasional breakages on HPE NonStop.

* rb/compat-poll-fix:
  poll.c: always set revents, even if to zero

7 years agoMerge branch 'tg/memfixes' into maint
Junio C Hamano [Wed, 18 Oct 2017 05:19:04 +0000 (14:19 +0900)] 
Merge branch 'tg/memfixes' into maint

Fixes for a handful memory access issues identified by valgrind.

* tg/memfixes:
  sub-process: use child_process.args instead of child_process.argv
  http-push: fix construction of hex value from path
  path.c: fix uninitialized memory access

7 years agoMerge branch 'ar/request-pull-phrasofix' into maint
Junio C Hamano [Wed, 18 Oct 2017 05:19:04 +0000 (14:19 +0900)] 
Merge branch 'ar/request-pull-phrasofix' into maint

Spell the name of our system as "Git" in the output from
request-pull script.

* ar/request-pull-phrasofix:
  request-pull: capitalise "Git" to make it a proper noun

7 years agoMerge branch 'jc/merge-x-theirs-docfix' into maint
Junio C Hamano [Wed, 18 Oct 2017 05:19:03 +0000 (14:19 +0900)] 
Merge branch 'jc/merge-x-theirs-docfix' into maint

The documentation for '-X<option>' for merges was misleadingly
written to suggest that "-s theirs" exists, which is not the case.

* jc/merge-x-theirs-docfix:
  merge-strategies: avoid implying that "-s theirs" exists

7 years agoMerge branch 'rs/mailinfo-qp-decode-fix' into maint
Junio C Hamano [Wed, 18 Oct 2017 05:19:03 +0000 (14:19 +0900)] 
Merge branch 'rs/mailinfo-qp-decode-fix' into maint

"git mailinfo" was loose in decoding quoted printable and produced
garbage when the two letters after the equal sign are not
hexadecimal.  This has been fixed.

* rs/mailinfo-qp-decode-fix:
  mailinfo: don't decode invalid =XY quoted-printable sequences

7 years agoMerge branch 'ik/userdiff-html-h-element-fix' into maint
Junio C Hamano [Wed, 18 Oct 2017 05:19:02 +0000 (14:19 +0900)] 
Merge branch 'ik/userdiff-html-h-element-fix' into maint

The built-in pattern to detect the "function header" for HTML did
not match <H1>..<H6> elements without any attributes, which has
been fixed.

* ik/userdiff-html-h-element-fix:
  userdiff: fix HTML hunk header regexp

7 years agoMerge branch 'jk/diff-blob' into maint
Junio C Hamano [Wed, 18 Oct 2017 05:19:01 +0000 (14:19 +0900)] 
Merge branch 'jk/diff-blob' into maint

"git cat-file --textconv" started segfaulting recently, which
has been corrected.

* jk/diff-blob:
  cat-file: handle NULL object_context.path

7 years agoMerge branch 'jk/describe-omit-some-refs' into maint
Junio C Hamano [Wed, 18 Oct 2017 05:19:01 +0000 (14:19 +0900)] 
Merge branch 'jk/describe-omit-some-refs' into maint

"git describe --match" learned to take multiple patterns in v2.13
series, but the feature ignored the patterns after the first one
and did not work at all.  This has been fixed.

* jk/describe-omit-some-refs:
  describe: fix matching to actually match all patterns

7 years agoMerge branch 'mh/for-each-string-list-item-empty-fix' into maint
Junio C Hamano [Wed, 18 Oct 2017 05:19:00 +0000 (14:19 +0900)] 
Merge branch 'mh/for-each-string-list-item-empty-fix' into maint

Code cmp.std.c nitpick.

* mh/for-each-string-list-item-empty-fix:
  for_each_string_list_item: avoid undefined behavior for empty list

7 years agoMerge branch 'tb/test-lint-echo-e' into maint
Junio C Hamano [Wed, 18 Oct 2017 05:18:59 +0000 (14:18 +0900)] 
Merge branch 'tb/test-lint-echo-e' into maint

The test linter has been taught that we do not like "echo -e".

* tb/test-lint-echo-e:
  test-lint: echo -e (or -E) is not portable

7 years agoMerge branch 'aw/gc-lockfile-fscanf-fix' into maint
Junio C Hamano [Wed, 18 Oct 2017 05:18:59 +0000 (14:18 +0900)] 
Merge branch 'aw/gc-lockfile-fscanf-fix' into maint

"git gc" tries to avoid running two instances at the same time by
reading and writing pid/host from and to a lock file; it used to
use an incorrect fscanf() format when reading, which has been
corrected.

* aw/gc-lockfile-fscanf-fix:
  gc: call fscanf() with %<len>s, not %<len>c, when reading hostname

7 years agoMerge branch 'tg/refs-allowed-flags' into maint
Junio C Hamano [Wed, 18 Oct 2017 05:18:58 +0000 (14:18 +0900)] 
Merge branch 'tg/refs-allowed-flags' into maint

API error-proofing which happens to also squelch warnings from GCC.

* tg/refs-allowed-flags:
  refs: strip out not allowed flags from ref_transaction_update

7 years agoMerge branch 'rs/archive-excluded-directory' into maint
Junio C Hamano [Wed, 18 Oct 2017 05:18:58 +0000 (14:18 +0900)] 
Merge branch 'rs/archive-excluded-directory' into maint

"git archive", especially when used with pathspec, stored an empty
directory in its output, even though Git itself never does so.
This has been fixed.

* rs/archive-excluded-directory:
  archive: don't add empty directories to archives

7 years agoMerge branch 'rk/commit-tree-make-F-verbatim' into maint
Junio C Hamano [Wed, 18 Oct 2017 05:18:58 +0000 (14:18 +0900)] 
Merge branch 'rk/commit-tree-make-F-verbatim' into maint

Unlike "git commit-tree < file", "git commit-tree -F file" did not
pass the contents of the file verbatim and instead completed an
incomplete line at the end, if exists.  The latter has been updated
to match the behaviour of the former.

* rk/commit-tree-make-F-verbatim:
  commit-tree: do not complete line in -F input

7 years agoMerge branch 'mh/packed-ref-store-prep' into maint
Junio C Hamano [Wed, 18 Oct 2017 05:18:58 +0000 (14:18 +0900)] 
Merge branch 'mh/packed-ref-store-prep' into maint

Fix regression to "gitk --bisect" by a recent update.

* mh/packed-ref-store-prep:
  rev-parse: don't trim bisect refnames

7 years agoMerge branch 'mm/send-email-cc-cruft' into maint
Junio C Hamano [Wed, 18 Oct 2017 05:18:58 +0000 (14:18 +0900)] 
Merge branch 'mm/send-email-cc-cruft' into maint

In addition to "cc: <a@dd.re.ss> # cruft", "cc: a@dd.re.ss # cruft"
was taught to "git send-email" as a valid way to tell it that it
needs to also send a carbon copy to <a@dd.re.ss> in the trailer
section.

* mm/send-email-cc-cruft:
  send-email: don't use Mail::Address, even if available
  send-email: fix garbage removal after address

7 years agoMerge branch 'rs/strbuf-getwholeline-fix' into maint
Junio C Hamano [Wed, 18 Oct 2017 05:18:57 +0000 (14:18 +0900)] 
Merge branch 'rs/strbuf-getwholeline-fix' into maint

A helper function to read a single whole line into strbuf
mistakenly triggered OOM error at EOF under certain conditions,
which has been fixed.

* rs/strbuf-getwholeline-fix:
  strbuf: clear errno before calling getdelim(3)

7 years agoPreparing for rc2 continues
Junio C Hamano [Wed, 18 Oct 2017 01:27:06 +0000 (10:27 +0900)] 
Preparing for rc2 continues

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMerge branch 'jk/ref-filter-colors-fix'
Junio C Hamano [Wed, 18 Oct 2017 01:19:08 +0000 (10:19 +0900)] 
Merge branch 'jk/ref-filter-colors-fix'

This is the "theoretically more correct" approach of simply
stepping back to the state before plumbing commands started paying
attention to "color.ui" configuration variable.

Let's run with this one.

* jk/ref-filter-colors-fix:
  tag: respect color.ui config
  Revert "color: check color.ui in git_default_config()"
  Revert "t6006: drop "always" color config tests"
  Revert "color: make "always" the same as "auto" in config"

7 years agoMerge branch 'js/rebase-i-final'
Junio C Hamano [Wed, 18 Oct 2017 01:19:07 +0000 (10:19 +0900)] 
Merge branch 'js/rebase-i-final'

Error message fix.

* js/rebase-i-final:
  sequencer.c: unify an error message

7 years agosequencer.c: unify an error message
Ralf Thielow [Tue, 17 Oct 2017 16:20:50 +0000 (18:20 +0200)] 
sequencer.c: unify an error message

Change an error message in sequencer.c for the case that
we could not write to a file to match other instances.

Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agotag: respect color.ui config
Jeff King [Fri, 13 Oct 2017 17:26:02 +0000 (13:26 -0400)] 
tag: respect color.ui config

Since 11b087adfd (ref-filter: consult want_color() before
emitting colors, 2017-07-13), we expect that setting
"color.ui" to "always" will enable color tag formats even
without a tty.  As that commit was built on top of
136c8c8b8f (color: check color.ui in git_default_config(),
2017-07-13) from the same series, we didn't need to touch
tag's config parsing at all.

However, since we reverted 136c8c8b8f, we now need to
explicitly call git_color_default_config() to make this
work.

Let's do so, and also restore the test dropped in 0c88bf5050
(provide --color option for all ref-filter users,
2017-10-03). That commit swapped out our "color.ui=always"
test for "--color" in preparation for "always" going away.
But since it is here to stay, we should test both cases.

Note that for-each-ref also lost its color.ui support as
part of reverting 136c8c8b8f. But as a plumbing command, it
should _not_ respect the color.ui config. Since it also
gained a --color option in 0c88bf5050, that's the correct
way to ask it for color. We'll continue to test that, and
confirm that "color.ui" is not respected.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoRevert "color: check color.ui in git_default_config()"
Jeff King [Fri, 13 Oct 2017 17:24:31 +0000 (13:24 -0400)] 
Revert "color: check color.ui in git_default_config()"

This reverts commit 136c8c8b8fa39f1315713248473dececf20f8fe7.

That commit was trying to address a bug caused by 4c7f1819b3
(make color.ui default to 'auto', 2013-06-10), in which
plumbing like diff-tree defaulted to "auto" color, but did
not respect a "color.ui" directive to disable it.

But it also meant that we started respecting "color.ui" set
to "always". This was a known problem, but 4c7f1819b3 argued
that nobody ought to be doing that. However, that turned out
to be wrong, and we got a number of bug reports related to
"add -p" regressing in v2.14.2.

Let's revert 136c8c8b8, fixing the regression to "add -p".
This leaves the problem from 4c7f1819b3 unfixed, but:

  1. It's a pretty obscure problem in the first place. I
     only noticed it while working on the color code, and we
     haven't got a single bug report or complaint about it.

  2. We can make a more moderate fix on top by respecting
     "never" but not "always" for plumbing commands. This
     is just the minimal fix to go back to the working state
     we had before v2.14.2.

Note that this isn't a pure revert. We now have a test in
t3701 which shows off the "add -p" regression. This can be
flipped to success.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoRevert "t6006: drop "always" color config tests"
Jeff King [Fri, 13 Oct 2017 17:23:41 +0000 (13:23 -0400)] 
Revert "t6006: drop "always" color config tests"

This reverts commit c5bdfe677cfab5b2e87771c35565d44d3198efda.

That commit was done primarily to prepare for the weakening
of "always" in 6be4595edb (color: make "always" the same as
"auto" in config, 2017-10-03). But since we've now reverted
6be4595edb, there's no need for us to remove "-c
color.ui=always" from the tests. And in fact it's a good
idea to restore these tests, to make sure that "always"
continues to work.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoRevert "color: make "always" the same as "auto" in config"
Jeff King [Fri, 13 Oct 2017 17:23:24 +0000 (13:23 -0400)] 
Revert "color: make "always" the same as "auto" in config"

This reverts commit 6be4595edb8e5b616c6e8b9fbc78b0f831fa2a87.

That commit weakened the "always" setting of color config so
that it acted as "auto". This was meant to solve regressions
in v2.14.2 in which setting "color.ui=always" in the on-disk
config broke scripts like add--interactive, because the
plumbing diff commands began to generate color output.

This was due to 136c8c8b8f (color: check color.ui in
git_default_config(), 2017-07-13), which was in turn trying
to fix issues caused by 4c7f1819b3 (make color.ui default to
'auto', 2013-06-10). But in weakening "always", we created
even more problems, as people expect to be able to use "git
-c color.ui=always" to force color (especially because some
commands don't have their own --color flag). We can fix that
by special-casing the command-line "-c", but now things are
getting pretty confusing.

Instead of piling hacks upon hacks, let's start peeling off
the hacks. The first step is dropping the weakening of
"always", which this revert does.

Note that we could actually revert the whole series merged
in by da15b78e52642bd45fd5513ab0000fdf2e58a6f4. Most of that
series consists of preparations to the tests to handle the
weakening of "-c color.ui=always". But it's worth keeping
for a few reasons:

  - there are some other preparatory cleanups, like
    e433749d86 (test-terminal: set TERM=vt100, 2017-10-03)

  - it adds "--color" options more consistently in
    0c88bf5050 (provide --color option for all ref-filter
    users, 2017-10-03)

  - some of the cases dropping "-c" end up being more robust
    and realistic tests, as in 01c94e9001 (t7508: use
    test_terminal for color output, 2017-10-03)

  - the preferred tool for overriding config is "--color",
    and we should be modeling that consistently

We can individually revert the few commits necessary to
restore some useful tests (which will be done on top of this
patch).

Note that this isn't a pure revert; we'll keep the test
added in t3701, but mark it as failure for now.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMerge branch 'jk/ui-color-always-to-auto-maint' (early part) into jk/ref-filter-color...
Junio C Hamano [Tue, 17 Oct 2017 06:08:31 +0000 (15:08 +0900)] 
Merge branch 'jk/ui-color-always-to-auto-maint' (early part) into jk/ref-filter-colors-fix-maint

* 'jk/ui-color-always-to-auto-maint' (early part):
  color: make "always" the same as "auto" in config
  provide --color option for all ref-filter users
  t3205: use --color instead of color.branch=always
  t3203: drop "always" color test
  t6006: drop "always" color config tests
  t7502: use diff.noprefix for --verbose test
  t7508: use test_terminal for color output
  t3701: use test-terminal to collect color output
  t4015: prefer --color to -c color.diff=always
  test-terminal: set TERM=vt100

7 years agoCrawling towards -rc2
Junio C Hamano [Tue, 17 Oct 2017 04:31:31 +0000 (13:31 +0900)] 
Crawling towards -rc2

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMerge branch 'sb/diff-color-move'
Junio C Hamano [Tue, 17 Oct 2017 04:29:19 +0000 (13:29 +0900)] 
Merge branch 'sb/diff-color-move'

A recently added "--color-moved" feature of "diff" fell into
infinite loop when ignoring whitespace changes, which has been
fixed.

* sb/diff-color-move:
  diff: fix infinite loop with --color-moved --ignore-space-change

7 years agoMerge branch 'js/rebase-i-final'
Junio C Hamano [Tue, 17 Oct 2017 04:29:19 +0000 (13:29 +0900)] 
Merge branch 'js/rebase-i-final'

Error message fix.

* js/rebase-i-final:
  sequencer.c: fix and unify error messages in rearrange_squash()

7 years agoMerge branch 'jc/doc-checkout'
Junio C Hamano [Tue, 17 Oct 2017 04:29:19 +0000 (13:29 +0900)] 
Merge branch 'jc/doc-checkout'

Doc update.

* jc/doc-checkout:
  checkout doc: clarify command line args for "checkout paths" mode

7 years agodiff: fix infinite loop with --color-moved --ignore-space-change
Jeff King [Fri, 13 Oct 2017 00:18:37 +0000 (20:18 -0400)] 
diff: fix infinite loop with --color-moved --ignore-space-change

The --color-moved code uses next_byte() to advance through
the blob contents. When the user has asked to ignore
whitespace changes, we try to collapse any whitespace change
down to a single space.

However, we enter the conditional block whenever we see the
IGNORE_WHITESPACE_CHANGE flag, even if the next byte isn't
whitespace.

This means that the combination of "--color-moved and
--ignore-space-change" was completely broken. Worse, because
we return from next_byte() without having advanced our
pointer, the function makes no forward progress in the
buffer and loops infinitely.

Fix this by entering the conditional only when we actually
see whitespace. We can apply this also to the
IGNORE_WHITESPACE change. That code path isn't buggy
(because it falls through to returning the next
non-whitespace byte), but it makes the logic more clear if
we only bother to look at whitespace flags after seeing that
the next byte is whitespace.

Reported-by: Orgad Shaneh <orgads@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agosequencer.c: fix and unify error messages in rearrange_squash()
Ralf Thielow [Sun, 15 Oct 2017 17:07:42 +0000 (19:07 +0200)] 
sequencer.c: fix and unify error messages in rearrange_squash()

When the write opertion fails, we write that we could
not read. Change the error message to match the operation
and remove the full stop at the end.

When ftruncate() fails, we write that we couldn't finish
the operation on the todo file. It is more accurate to write
that we couldn't truncate as we do in other calls of ftruncate().

Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agocheckout doc: clarify command line args for "checkout paths" mode
Junio C Hamano [Wed, 11 Oct 2017 02:21:03 +0000 (11:21 +0900)] 
checkout doc: clarify command line args for "checkout paths" mode

There are "git checkout [-p][<tree-ish>][--][<paths>...]" in the
SYNOPSIS section, and "git checkout [-p][<tree-ish>][--]<paths>..."
as the header for the section that explains the "check out paths
from index/tree-ish" mode.  It is unclear if we require at least one
path, or it is entirely optional.

Actually, both are wrong.  Without the "-p(atch)" option, you must
have <pathspec> (otherwise, with a commit that is a <tree-ish>, you
would be checking out that commit to build a new history on top of
it).  With it, it is already clear that you are checking out paths,
it is optional.  In other words, you cannot omit both.

The source of the confusion is that -p(atch) is described as if it
is just another "optional" part and its description is lumped
together with the non patch mode, even though the actual end user
experience is vastly different.

Let's split the entry into two, and describe the regular mode and
the patch mode separately.  This allows us to make it clear that the
regular mode MUST be given at least one pathspec, that the patch
mode can be invoked with either '-p' or '--patch' but one of these
must be given, and that the pathspec is entirely optional in the
patch mode.

Also, revamp the explanation of "checkout paths" by removing
extraneous description at the beginning, that says "checking out
paths is not checking out a branch".  Explaining what it is for and
when the user wants to use it upfront is the most direct way to help
the readers.

Noticed-by: Robert P J Day
Helped-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoGit 2.15-rc1 v2.15.0-rc1
Junio C Hamano [Wed, 11 Oct 2017 05:54:04 +0000 (14:54 +0900)] 
Git 2.15-rc1

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMerge branch 'ls/filter-process-delayed'
Junio C Hamano [Wed, 11 Oct 2017 05:52:24 +0000 (14:52 +0900)] 
Merge branch 'ls/filter-process-delayed'

Bugfixes to an already graduated series.

* ls/filter-process-delayed:
  write_entry: untangle symlink and regular-file cases
  write_entry: avoid reading blobs in CE_RETRY case
  write_entry: fix leak when retrying delayed filter
  entry.c: check if file exists after checkout
  entry.c: update cache entry only for existing files

7 years agoMerge branch 'ds/avoid-overflow-in-midpoint-computation'
Junio C Hamano [Wed, 11 Oct 2017 05:52:24 +0000 (14:52 +0900)] 
Merge branch 'ds/avoid-overflow-in-midpoint-computation'

Code clean-up.

* ds/avoid-overflow-in-midpoint-computation:
  cleanup: fix possible overflow errors in binary search

7 years agoMerge branch 'tb/complete-describe'
Junio C Hamano [Wed, 11 Oct 2017 05:52:23 +0000 (14:52 +0900)] 
Merge branch 'tb/complete-describe'

Docfix.

* tb/complete-describe:
  completion: add --broken and --dirty to describe

7 years agoMerge branch 'sb/test-cmp-expect-actual'
Junio C Hamano [Wed, 11 Oct 2017 05:52:23 +0000 (14:52 +0900)] 
Merge branch 'sb/test-cmp-expect-actual'

Test tweak.

* sb/test-cmp-expect-actual:
  tests: fix diff order arguments in test_cmp

7 years agoMerge branch 'jk/refs-df-conflict'
Junio C Hamano [Wed, 11 Oct 2017 05:52:23 +0000 (14:52 +0900)] 
Merge branch 'jk/refs-df-conflict'

An ancient bug that made Git misbehave with creation/renaming of
refs has been fixed.

* jk/refs-df-conflict:
  refs_resolve_ref_unsafe: handle d/f conflicts for writes
  t3308: create a real ref directory/file conflict

7 years agoMerge branch 'rs/rs-mailmap'
Junio C Hamano [Wed, 11 Oct 2017 05:52:23 +0000 (14:52 +0900)] 
Merge branch 'rs/rs-mailmap'

* rs/rs-mailmap:
  .mailmap: normalize name for RenĂ© Scharfe

7 years agoMerge branch 'rs/fsck-null-return-from-lookup'
Junio C Hamano [Wed, 11 Oct 2017 05:52:23 +0000 (14:52 +0900)] 
Merge branch 'rs/fsck-null-return-from-lookup'

Improve behaviour of "git fsck" upon finding a missing object.

* rs/fsck-null-return-from-lookup:
  fsck: handle NULL return of lookup_blob() and lookup_tree()

7 years agoMerge branch 'jk/sha1-loose-object-info-fix'
Junio C Hamano [Wed, 11 Oct 2017 05:52:22 +0000 (14:52 +0900)] 
Merge branch 'jk/sha1-loose-object-info-fix'

Leakfix and futureproofing.

* jk/sha1-loose-object-info-fix:
  sha1_loose_object_info: handle errors from unpack_sha1_rest

7 years agoMerge branch 'hn/string-list-doc'
Junio C Hamano [Wed, 11 Oct 2017 05:52:22 +0000 (14:52 +0900)] 
Merge branch 'hn/string-list-doc'

Docfix.

* hn/string-list-doc:
  api-argv-array.txt: remove broken link to string-list API

7 years agoMerge branch 'tb/show-trailers-in-ref-filter'
Junio C Hamano [Wed, 11 Oct 2017 05:52:22 +0000 (14:52 +0900)] 
Merge branch 'tb/show-trailers-in-ref-filter'

"git for-each-ref --format=..." learned a new format element,
%(trailers), to show only the commit log trailer part of the log
message.

* tb/show-trailers-in-ref-filter:
  ref-filter.c: parse trailers arguments with %(contents) atom
  ref-filter.c: use trailer_opts to format trailers
  t6300: refactor %(trailers) tests
  doc: use "`<literal>`"-style quoting for literal strings
  doc: 'trailers' is the preferred way to format trailers
  t4205: unfold across multiple lines

7 years agoMerge branch 'jt/oidmap'
Junio C Hamano [Wed, 11 Oct 2017 05:52:22 +0000 (14:52 +0900)] 
Merge branch 'jt/oidmap'

Introduce a new "oidmap" API and rewrite oidset to use it.

* jt/oidmap:
  oidmap: map with OID as key

7 years agoMerge branch 'jr/hash-migration-plan-doc'
Junio C Hamano [Wed, 11 Oct 2017 05:52:22 +0000 (14:52 +0900)] 
Merge branch 'jr/hash-migration-plan-doc'

Lay out plans for weaning us off of SHA-1.

* jr/hash-migration-plan-doc:
  technical doc: add a design doc for hash function transition

7 years agowrite_entry: untangle symlink and regular-file cases
Jeff King [Mon, 9 Oct 2017 17:50:05 +0000 (13:50 -0400)] 
write_entry: untangle symlink and regular-file cases

The write_entry() function switches on the mode of the entry
we're going to write out. The cases for S_IFLNK and S_IFREG
are lumped together. In earlier versions of the code, this
made some sense. They have a shared preamble (which reads
the blob content), a short type-specific body, and a shared
conclusion (which writes out the file contents; always for
S_IFREG and only sometimes for S_IFLNK).

But over time this has grown to make less sense. The preamble
now has conditional bits for each type, and the S_IFREG body
has grown a lot more complicated. It's hard to follow the
logic of which code is running for which mode.

Let's give each mode its own case arm. We will still share
the conclusion code, which means we now jump to it with a
goto. Ideally we'd pull that shared code into its own
function, but it touches so much internal state in the
write_entry() function that the end result is actually
harder to follow than the goto.

While we're here, we'll touch up a few bits of whitespace to
make the beginning and endings of the cases easier to read.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agowrite_entry: avoid reading blobs in CE_RETRY case
Jeff King [Mon, 9 Oct 2017 17:48:52 +0000 (13:48 -0400)] 
write_entry: avoid reading blobs in CE_RETRY case

When retrying a delayed filter-process request, we don't
need to send the blob to the filter a second time. However,
we read it unconditionally into a buffer, only to later
throw away that buffer. We can make this more efficient by
skipping the read in the first place when it isn't
necessary.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agowrite_entry: fix leak when retrying delayed filter
Jeff King [Mon, 9 Oct 2017 17:48:24 +0000 (13:48 -0400)] 
write_entry: fix leak when retrying delayed filter

When write_entry() retries a delayed filter request, we
don't need to send the blob content to the filter again, and
set the pointer to NULL. But doing so means we leak the
contents we read earlier from read_blob_entry(). Let's make
sure to free it before dropping the pointer.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agocleanup: fix possible overflow errors in binary search
Derrick Stolee [Sun, 8 Oct 2017 18:29:37 +0000 (14:29 -0400)] 
cleanup: fix possible overflow errors in binary search

A common mistake when writing binary search is to allow possible
integer overflow by using the simple average:

mid = (min + max) / 2;

Instead, use the overflow-safe version:

mid = min + (max - min) / 2;

This translation is safe since the operation occurs inside a loop
conditioned on "min < max". The included changes were found using
the following git grep:

git grep '/ *2;' '*.c'

Making this cleanup will prevent future review friction when a new
binary search is contructed based on existing code.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMerge branch 'js/rebase-i-final'
Junio C Hamano [Mon, 9 Oct 2017 09:59:16 +0000 (18:59 +0900)] 
Merge branch 'js/rebase-i-final'

* js/rebase-i-final:
  i18n: add a missing space in message

7 years agoi18n: add a missing space in message
Jean-Noel Avila [Sun, 8 Oct 2017 12:18:39 +0000 (14:18 +0200)] 
i18n: add a missing space in message

The message spans over 2 lines but the C conconcatenation does not add
the needed space between the two lines.

Signed-off-by: Jean-Noel Avila <jn.avila@free.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoPrepare for -rc1
Junio C Hamano [Sat, 7 Oct 2017 07:29:03 +0000 (16:29 +0900)] 
Prepare for -rc1

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMerge branch 'tb/ref-filter-empty-modifier'
Junio C Hamano [Sat, 7 Oct 2017 07:27:56 +0000 (16:27 +0900)] 
Merge branch 'tb/ref-filter-empty-modifier'

In the "--format=..." option of the "git for-each-ref" command (and
its friends, i.e. the listing mode of "git branch/tag"), "%(atom:)"
(e.g. "%(refname:)", "%(body:)" used to error out.  Instead, treat
them as if the colon and an empty string that follows it were not
there.

* tb/ref-filter-empty-modifier:
  ref-filter.c: pass empty-string as NULL to atom parsers

7 years agoMerge branch 'ks/verify-filename-non-option-error-message-tweak'
Junio C Hamano [Sat, 7 Oct 2017 07:27:55 +0000 (16:27 +0900)] 
Merge branch 'ks/verify-filename-non-option-error-message-tweak'

Error message tweak.

* ks/verify-filename-non-option-error-message-tweak:
  setup: update error message to be more meaningful

7 years agoMerge branch 'ks/branch-tweak-error-message-for-extra-args'
Junio C Hamano [Sat, 7 Oct 2017 07:27:55 +0000 (16:27 +0900)] 
Merge branch 'ks/branch-tweak-error-message-for-extra-args'

Error message tweak.

* ks/branch-tweak-error-message-for-extra-args:
  branch: change the error messages to be more meaningful

7 years agoMerge branch 'jk/ui-color-always-to-auto'
Junio C Hamano [Sat, 7 Oct 2017 07:27:55 +0000 (16:27 +0900)] 
Merge branch 'jk/ui-color-always-to-auto'

Fix regression of "git add -p" for users with "color.ui = always"
in their configuration, by merging the topic below and adjusting it
for the 'master' front.

* jk/ui-color-always-to-auto:
  t7301: use test_terminal to check color
  t4015: use --color with --color-moved
  color: make "always" the same as "auto" in config
  provide --color option for all ref-filter users
  t3205: use --color instead of color.branch=always
  t3203: drop "always" color test
  t6006: drop "always" color config tests
  t7502: use diff.noprefix for --verbose test
  t7508: use test_terminal for color output
  t3701: use test-terminal to collect color output
  t4015: prefer --color to -c color.diff=always
  test-terminal: set TERM=vt100

7 years agoMerge branch 'ma/builtin-unleak'
Junio C Hamano [Sat, 7 Oct 2017 07:27:55 +0000 (16:27 +0900)] 
Merge branch 'ma/builtin-unleak'

Many variables that points at a region of memory that will live
throughout the life of the program have been marked with UNLEAK
marker to help the leak checkers concentrate on real leaks..

* ma/builtin-unleak:
  builtin/: add UNLEAKs

7 years agoMerge branch 'rb/compat-poll-fix'
Junio C Hamano [Sat, 7 Oct 2017 07:27:55 +0000 (16:27 +0900)] 
Merge branch 'rb/compat-poll-fix'

Backports a moral equivalent of 2015 fix to the poll emulation from
the upstream gnulib to fix occasional breakages on HPE NonStop.

* rb/compat-poll-fix:
  poll.c: always set revents, even if to zero

7 years agoMerge branch 'tg/memfixes'
Junio C Hamano [Sat, 7 Oct 2017 07:27:54 +0000 (16:27 +0900)] 
Merge branch 'tg/memfixes'

Fixes for a handful memory access issues identified by valgrind.

* tg/memfixes:
  sub-process: use child_process.args instead of child_process.argv
  http-push: fix construction of hex value from path
  path.c: fix uninitialized memory access

7 years agoMerge branch 'sb/branch-avoid-repeated-strbuf-release'
Junio C Hamano [Sat, 7 Oct 2017 07:27:54 +0000 (16:27 +0900)] 
Merge branch 'sb/branch-avoid-repeated-strbuf-release'

* sb/branch-avoid-repeated-strbuf-release:
  branch: reset instead of release a strbuf

7 years agoMerge branch 'rs/qsort-s'
Junio C Hamano [Sat, 7 Oct 2017 07:27:53 +0000 (16:27 +0900)] 
Merge branch 'rs/qsort-s'

* rs/qsort-s:
  test-stringlist: avoid buffer underrun when sorting nothing

7 years agoMerge branch 'jn/strbuf-doc-re-reuse'
Junio C Hamano [Sat, 7 Oct 2017 07:27:53 +0000 (16:27 +0900)] 
Merge branch 'jn/strbuf-doc-re-reuse'

* jn/strbuf-doc-re-reuse:
  strbuf doc: reuse after strbuf_release is fine

7 years agoMerge branch 'tb/delimit-pretty-trailers-args-with-comma'
Junio C Hamano [Sat, 7 Oct 2017 07:27:52 +0000 (16:27 +0900)] 
Merge branch 'tb/delimit-pretty-trailers-args-with-comma'

The feature that allows --pretty='%(trailers)' to take modifiers
like "fold" and "only" used to separate these modifiers with a
comma, i.e. "%(trailers:fold:only)", but we changed our mind and
use a comma, i.e. "%(trailers:fold,only)".  Fast track this change
before this new feature becomes part of any official release.

* tb/delimit-pretty-trailers-args-with-comma:
  pretty.c: delimit "%(trailers)" arguments with ","

7 years agocompletion: add --broken and --dirty to describe
Thomas Braun [Fri, 6 Oct 2017 18:02:47 +0000 (20:02 +0200)] 
completion: add --broken and --dirty to describe

When the flags for broken and dirty were implemented in
b0176ce6b5 (builtin/describe: introduce --broken flag, 2017-03-21)
and 9f67d2e827 (Teach "git describe" --dirty option, 2009-10-21)
the completion was not updated, although these flags are useful
completions. Add them.

Signed-off-by: Thomas Braun <thomas.braun@virtuell-zuhause.de>
Helped-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agotests: fix diff order arguments in test_cmp
Stefan Beller [Fri, 6 Oct 2017 19:00:06 +0000 (12:00 -0700)] 
tests: fix diff order arguments in test_cmp

Fix the argument order for test_cmp. When given the expected
result first the diff shows the actual output with '+' and the
expectation with '-', which is the convention for our tests.

Signed-off-by: Stefan Beller <sbeller@google.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agorefs_resolve_ref_unsafe: handle d/f conflicts for writes
Jeff King [Fri, 6 Oct 2017 14:42:17 +0000 (10:42 -0400)] 
refs_resolve_ref_unsafe: handle d/f conflicts for writes

If our call to refs_read_raw_ref() fails, we check errno to
see if the ref is simply missing, or if we encountered a
more serious error. If it's just missing, then in "write"
mode (i.e., when RESOLVE_REFS_READING is not set), this is
perfectly fine.

However, checking for ENOENT isn't sufficient to catch all
missing-ref cases. In the filesystem backend, we may also
see EISDIR when we try to resolve "a" and "a/b" exists.
Likewise, we may see ENOTDIR if we try to resolve "a/b" and
"a" exists. In both of those cases, we know that our
resolved ref doesn't exist, but we return an error (rather
than reporting the refname and returning a null sha1).

This has been broken for a long time, but nobody really
noticed because the next step after resolving without the
READING flag is usually to lock the ref and write it. But in
both of those cases, the write will fail with the same
errno due to the directory/file conflict.

There are two cases where we can notice this, though:

  1. If we try to write "a" and there's a leftover directory
     already at "a", even though there is no ref "a/b". The
     actual write is smart enough to move the empty "a" out
     of the way.

     This is reasonably rare, if only because the writing
     code has to do an independent resolution before trying
     its write (because the actual update_ref() code handles
     this case fine). The notes-merge code does this, and
     before the fix in the prior commit t3308 erroneously
     expected this case to fail.

  2. When resolving symbolic refs, we typically do not use
     the READING flag because we want to resolve even
     symrefs that point to unborn refs. Even if those unborn
     refs could not actually be written because of d/f
     conflicts with existing refs.

     You can see this by asking "git symbolic-ref" to report
     the target of a symref pointing past a d/f conflict.

We can fix the problem by recognizing the other "missing"
errnos and treating them like ENOENT. This should be safe to
do even for callers who are then going to actually write the
ref, because the actual writing process will fail if the d/f
conflict is a real one (and t1404 checks these cases).

Arguably this should be the responsibility of the
files-backend to normalize all "missing ref" errors into
ENOENT (since something like EISDIR may not be meaningful at
all to a database backend). However other callers of
refs_read_raw_ref() may actually care about the distinction;
putting this into resolve_ref() is the minimal fix for now.

The new tests in t1401 use git-symbolic-ref, which is the
most direct way to check the resolution by itself.
Interestingly we actually had a test that setup this case
already, but we only used it to verify that the funny state
could be overwritten, not that it could be resolved.

We also add a new test in t3200, as "branch -m" was the
original motivation for looking into this. What happens is
this:

  0. HEAD is pointing to branch "a"

  1. The user asks to rename "a" to "a/b".

  2. We create "a/b" and delete "a".

  3. We then try to update any worktree HEADs that point to
     the renamed ref (including the main repo HEAD). To do
     that, we have to resolve each HEAD. But now our HEAD is
     pointing at "a", and we get EISDIR due to the loose
     "a/b". As a result, we think there is no HEAD, and we
     do not update it. It now points to the bogus "a".

Interestingly this case used to work, but only accidentally.
Before 31824d180d (branch: fix branch renaming not updating
HEADs correctly, 2017-08-24), we'd update any HEAD which we
couldn't resolve. That was wrong, but it papered over the
fact that we were incorrectly failing to resolve HEAD.

So while the bug demonstrated by the git-symbolic-ref is
quite old, the regression to "branch -m" is recent.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agot3308: create a real ref directory/file conflict
Jeff King [Fri, 6 Oct 2017 14:38:30 +0000 (10:38 -0400)] 
t3308: create a real ref directory/file conflict

A test in t3308 wants to make sure that we don't
accidentally merge into "refs/notes/dir" when it exists as a
directory, so it does:

  mkdir .git/refs/notes/dir
  git -c core.notesRef=refs/notes/dir merge ...

and expects the second command to fail. But that
understimates the refs code, which is smart enough to remove
useless directories in the refs hierarchy. The test
succeeded only because of a bug which prevented resolving
refs/notes/dir for writing, even though an actual ref update
would succeed.

In preparation for fixing that bug, let's switch to creating
a real ref in refs/notes/dir, which is a more realistic
situation.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>