OSDN Git Service

git-core/git.git
6 years agot2020: test variations that matter
Junio C Hamano [Wed, 6 Dec 2017 16:10:07 +0000 (08:10 -0800)]
t2020: test variations that matter

Because our test suite is not about validating the working of the
shell, it is pointless to test variations of how a literal string
'yes' is quoted when assigned to an environment variable.

Instead, test various ways to spell 'yes' (we use strcasecmp() so
uppercased and capitalized variant should work just like 'yes'
spelled in all lowercase) and make sure we take them as 'yes'.  That
is more relevant in testing Git.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot4013: test new output from diff --abbrev --raw
Ann T Ropea [Sun, 3 Dec 2017 21:27:43 +0000 (22:27 +0100)]
t4013: test new output from diff --abbrev --raw

Use newly-introduced finely-grained control to teach the diff-family to
honor the new environment GIT_PRINT_SHA1_ELLIPSIS and remove the
ellipses when it is not set.

Mentored-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Ann T Ropea <bedhanger@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agodiff: diff_aligned_abbrev: remove ellipsis after abbreviated SHA-1 value
Ann T Ropea [Sun, 3 Dec 2017 21:27:42 +0000 (22:27 +0100)]
diff: diff_aligned_abbrev: remove ellipsis after abbreviated SHA-1 value

Neither Git nor the user are in need of this (visual) aid anymore, but
we must offer a transition period.

A follow-up patch (series) will rectify the situation by covering the
new output format as well as the backward compatible one.

Also, fix a typo: "abbbreviated" ---> "abbreviated".

Signed-off-by: Ann T Ropea <bedhanger@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot4013: prepare for upcoming "diff --raw --abbrev" output format change
Ann T Ropea [Sun, 3 Dec 2017 21:27:41 +0000 (22:27 +0100)]
t4013: prepare for upcoming "diff --raw --abbrev" output format change

Most of the t4013 tests go through a list of sample command lines,
and each of them is executed and its output compared with an
expected one stored in t4013/ directory.  Allow these lines to begin
with a colon followed by magic word(s) so that test conditions can
easily be tweaked.

The expected use that will happen in later steps of this is to run
tests expecting the traditional output and run the same test without
the GIT_PRINT_SHA1_ELLIPSIS=yes environment exported for (perhaps
some of) them, which will have to expect different output.  Since
all of the existing tests are meant to run with the environment,
use the magic word "noellipses" to cause the variable not to be set
and exported.

As this step does not add any new test with the magic word, all
tests still run with the environment variable, expecting the
traditional output, but it will change soon.

Based-on-patch-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Ann T Ropea <bedhanger@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agocheckout: describe_detached_head: remove ellipsis after committish
Ann T Ropea [Wed, 6 Dec 2017 00:20:42 +0000 (01:20 +0100)]
checkout: describe_detached_head: remove ellipsis after committish

We do not want an ellipsis displayed following an (abbreviated) SHA-1
value.

The days when this was necessary to indicate the truncation to
lower-level Git commands and/or the user are bygone.

However, to ease the transition, the ellipsis will still be printed if
the user sets the environment variable GIT_PRINT_SHA1_ELLIPSIS to "yes".

Correct documentation with respect to what describe_detached_head prints
when GIT_PRINT_SHA1_ELLIPSIS is not set as indicated above.

Add tests for the old and new behaviour.

Signed-off-by: Ann T Ropea <bedhanger@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoprint_sha1_ellipsis: introduce helper
Ann T Ropea [Sun, 3 Dec 2017 21:27:39 +0000 (22:27 +0100)]
print_sha1_ellipsis: introduce helper

Introduce a helper print_sha1_ellipsis() that pays attention to the
GIT_PRINT_SHA1_ELLIPSIS environment variable, and prepare the tests to
unconditionally set it for the test pieces that will be broken once the code
stops showing the extra dots by default.

The removal of these dots is merely a plan at this step and has not happened
yet but soon will.

Document GIT_PRINT_SHA1_ELLIPSIS.

Signed-off-by: Ann T Ropea <bedhanger@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoDocumentation: user-manual: limit usage of ellipsis
Ann T Ropea [Sun, 3 Dec 2017 21:27:38 +0000 (22:27 +0100)]
Documentation: user-manual: limit usage of ellipsis

There is no need to use full 40-hex to identify the object names like
the examples hint at by omitting the tail part of an object name as if
that has to be spelled out but the example omits them only for brevity.
Give examples using abbreviated object names without ellipses just like
how people do in real life.

Signed-off-by: Ann T Ropea <bedhanger@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoDocumentation: revisions: fix typo: "three dot" ---> "three-dot" (in line with "two...
Ann T Ropea [Sun, 3 Dec 2017 21:27:37 +0000 (22:27 +0100)]
Documentation: revisions: fix typo: "three dot" ---> "three-dot" (in line with "two-dot").

Signed-off-by: Ann T Ropea <bedhanger@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoRelNotes: the second batch post 2.15 comes
Junio C Hamano [Mon, 6 Nov 2017 05:31:16 +0000 (14:31 +0900)]
RelNotes: the second batch post 2.15 comes

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoMerge branch 'tg/deprecate-stash-save'
Junio C Hamano [Mon, 6 Nov 2017 05:24:32 +0000 (14:24 +0900)]
Merge branch 'tg/deprecate-stash-save'

"git stash save" has been deprecated in favour of "git stash push".

* tg/deprecate-stash-save:
  stash: remove now superfluos help for "stash push"
  stash: mark "git stash save" deprecated in the man page
  stash: replace "git stash save" with "git stash push" in the documentation

6 years agoMerge branch 'tb/complete-checkout'
Junio C Hamano [Mon, 6 Nov 2017 05:24:31 +0000 (14:24 +0900)]
Merge branch 'tb/complete-checkout'

Command line completion (in contrib/) update.

* tb/complete-checkout:
  completion: add remaining flags to checkout

6 years agoMerge branch 'gc/gitweb-filetest-acl'
Junio C Hamano [Mon, 6 Nov 2017 05:24:30 +0000 (14:24 +0900)]
Merge branch 'gc/gitweb-filetest-acl'

"gitweb" checks if a directory is searchable with Perl's "-x"
operator, which can be enhanced by using "filetest 'access'"
pragma, which now we do.

* gc/gitweb-filetest-acl:
  gitweb: use filetest to allow ACLs

6 years agoMerge branch 'mp/push-pushoption-config'
Junio C Hamano [Mon, 6 Nov 2017 05:24:30 +0000 (14:24 +0900)]
Merge branch 'mp/push-pushoption-config'

The "--push-option=<string>" option to "git push" now defaults to a
list of strings configured via push.pushOption variable.

* mp/push-pushoption-config:
  builtin/push.c: add push.pushOption config

6 years agoMerge branch 'hv/fetch-moved-submodules-on-demand'
Junio C Hamano [Mon, 6 Nov 2017 05:24:29 +0000 (14:24 +0900)]
Merge branch 'hv/fetch-moved-submodules-on-demand'

"git fetch --recurse-submodules" now knows that submodules can be
moved around in the superproject in addition to getting updated,
and finds the ones that need to be fetched accordingly.

* hv/fetch-moved-submodules-on-demand:
  submodule: simplify decision tree whether to or not to fetch
  implement fetching of moved submodules
  fetch: add test to make sure we stay backwards compatible

6 years agoMerge branch 'jc/check-ref-format-oor'
Junio C Hamano [Mon, 6 Nov 2017 05:24:28 +0000 (14:24 +0900)]
Merge branch 'jc/check-ref-format-oor'

"git check-ref-format --branch @{-1}" bit a "BUG()" when run
outside a repository for obvious reasons; clarify the documentation
and make sure we do not even try to expand the at-mark magic in
such a case, but still call the validation logic for branch names.

* jc/check-ref-format-oor:
  check-ref-format doc: --branch validates and expands <branch>
  check-ref-format --branch: strip refs/heads/ using skip_prefix
  check-ref-format --branch: do not expand @{...} outside repository

6 years agoMerge branch 'jc/t5601-copy-workaround'
Junio C Hamano [Mon, 6 Nov 2017 05:24:27 +0000 (14:24 +0900)]
Merge branch 'jc/t5601-copy-workaround'

A (possibly flakey) test fix.

* jc/t5601-copy-workaround:
  t5601: rm the target file of cp that could still be executing

6 years agoMerge branch 'bc/object-id'
Junio C Hamano [Mon, 6 Nov 2017 05:24:27 +0000 (14:24 +0900)]
Merge branch 'bc/object-id'

Conversion from uchar[20] to struct object_id continues.

* bc/object-id: (25 commits)
  refs/files-backend: convert static functions to object_id
  refs: convert read_raw_ref backends to struct object_id
  refs: convert peel_object to struct object_id
  refs: convert resolve_ref_unsafe to struct object_id
  worktree: convert struct worktree to object_id
  refs: convert resolve_gitlink_ref to struct object_id
  Convert remaining callers of resolve_gitlink_ref to object_id
  sha1_file: convert index_path and index_fd to struct object_id
  refs: convert reflog_expire parameter to struct object_id
  refs: convert read_ref_at to struct object_id
  refs: convert peel_ref to struct object_id
  builtin/pack-objects: convert to struct object_id
  pack-bitmap: convert traverse_bitmap_commit_list to object_id
  refs: convert dwim_log to struct object_id
  builtin/reflog: convert remaining unsigned char uses to object_id
  refs: convert dwim_ref and expand_ref to struct object_id
  refs: convert read_ref and read_ref_full to object_id
  refs: convert resolve_refdup and refs_resolve_refdup to struct object_id
  Convert check_connected to use struct object_id
  refs: update ref transactions to use struct object_id
  ...

6 years agoMerge branch 'jk/revision-pruning-optim'
Junio C Hamano [Mon, 6 Nov 2017 05:24:26 +0000 (14:24 +0900)]
Merge branch 'jk/revision-pruning-optim'

Pathspec-limited revision traversal was taught not to keep finding
unneeded differences once it knows two trees are different inside
given pathspec.

* jk/revision-pruning-optim:
  revision: quit pruning diff more quickly when possible

6 years agoMerge branch 'ds/find-unique-abbrev-optim'
Junio C Hamano [Mon, 6 Nov 2017 05:24:25 +0000 (14:24 +0900)]
Merge branch 'ds/find-unique-abbrev-optim'

Optimize the code to find shortest unique prefix of object names.

* ds/find-unique-abbrev-optim:
  sha1_name: minimize OID comparisons during disambiguation
  sha1_name: parse less while finding common prefix
  sha1_name: unroll len loop in find_unique_abbrev_r()
  p4211-line-log.sh: add log --online --raw --parents perf test

6 years agoMerge branch 'wk/pull-signoff'
Junio C Hamano [Mon, 6 Nov 2017 05:24:24 +0000 (14:24 +0900)]
Merge branch 'wk/pull-signoff'

"git pull" has been taught to accept "--[no-]signoff" option and
pass it down to "git merge".

* wk/pull-signoff:
  pull: pass --signoff/--no-signoff to "git merge"

6 years agoMerge branch 'pc/submodule-helper'
Junio C Hamano [Mon, 6 Nov 2017 05:24:23 +0000 (14:24 +0900)]
Merge branch 'pc/submodule-helper'

GSoC.

* pc/submodule-helper:
  submodule: port submodule subcommand 'status' from shell to C
  submodule--helper: introduce for_each_listed_submodule()
  submodule--helper: introduce get_submodule_displaypath()

6 years agoMerge branch 'pb/bisect-helper'
Junio C Hamano [Mon, 6 Nov 2017 05:24:23 +0000 (14:24 +0900)]
Merge branch 'pb/bisect-helper'

An early part of piece-by-piece rewrite of "git bisect".

* pb/bisect-helper:
  bisect--helper: `is_expected_rev` & `check_expected_revs` shell function in C
  t6030: explicitly test for bisection cleanup
  bisect--helper: `bisect_clean_state` shell function in C
  bisect--helper: `write_terms` shell function in C
  bisect--helper: rewrite `check_term_format` shell function in C
  bisect--helper: use OPT_CMDMODE instead of OPT_BOOL

6 years agoMerge branch 'dm/run-command-ignored-hook-advise'
Junio C Hamano [Mon, 6 Nov 2017 05:24:22 +0000 (14:24 +0900)]
Merge branch 'dm/run-command-ignored-hook-advise'

A hook script that is set unexecutable is simply ignored.  Git
notifies when such a file is ignored, unless the message is
squelched via advice.ignoredHook configuration.

* dm/run-command-ignored-hook-advise:
  run-command: add hint when a hook is ignored

6 years agoThe first batch for 2.16
Junio C Hamano [Mon, 6 Nov 2017 04:18:22 +0000 (13:18 +0900)]
The first batch for 2.16

The most notable change is that we no longer take "git add ''" and
add everything.  An empty string is now an error when used as a
pathspec element.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoMerge branch 'ex/deprecate-empty-pathspec-as-match-all'
Junio C Hamano [Mon, 6 Nov 2017 04:11:29 +0000 (13:11 +0900)]
Merge branch 'ex/deprecate-empty-pathspec-as-match-all'

The final step to make an empty string as a pathspec element
illegal.  We started this by first deprecating and warning a
pathspec that has such an element in 2.11 (Nov 2016).

Hopefully we can merge this down to the 'master' by the end of the
year?  A deprecation warning period that is about 1 year does not
sound too bad.

* ex/deprecate-empty-pathspec-as-match-all:
  pathspec: die on empty strings as pathspec
  t0027: do not use an empty string as a pathspec element

6 years agoMerge branch 'jk/rebase-i-exec-gitdir-fix'
Junio C Hamano [Mon, 6 Nov 2017 04:11:28 +0000 (13:11 +0900)]
Merge branch 'jk/rebase-i-exec-gitdir-fix'

A recent regression in "git rebase -i" that broke execution of git
commands from subdirectories via "exec" insn has been fixed.

* jk/rebase-i-exec-gitdir-fix:
  sequencer: pass absolute GIT_DIR to exec commands

6 years agoMerge branch 'cn/diff-indent-no-longer-is-experimental'
Junio C Hamano [Mon, 6 Nov 2017 04:11:27 +0000 (13:11 +0900)]
Merge branch 'cn/diff-indent-no-longer-is-experimental'

Doc update.

* cn/diff-indent-no-longer-is-experimental:
  diff: --indent-heuristic is no longer experimental

6 years agoMerge branch 'bw/grep-recurse-submodules'
Junio C Hamano [Mon, 6 Nov 2017 04:11:27 +0000 (13:11 +0900)]
Merge branch 'bw/grep-recurse-submodules'

A broken access to object databases in recent update to "git grep
--recurse-submodules" has been fixed.

* bw/grep-recurse-submodules:
  grep: take the read-lock when adding a submodule

6 years agoMerge branch 'mh/test-local-canary'
Junio C Hamano [Mon, 6 Nov 2017 04:11:26 +0000 (13:11 +0900)]
Merge branch 'mh/test-local-canary'

We try to see if somebody runs our test suite with a shell that
does not support "local" like bash/dash does.

* mh/test-local-canary:
  t0000: check whether the shell supports the "local" keyword

6 years agoMerge branch 'js/submodule-in-excluded'
Junio C Hamano [Mon, 6 Nov 2017 04:11:26 +0000 (13:11 +0900)]
Merge branch 'js/submodule-in-excluded'

"git status --ignored -u" did not stop at a working tree of a
separate project that is embedded in an ignored directory and
listed files in that other project, instead of just showing the
directory itself as ignored.

* js/submodule-in-excluded:
  status: do not get confused by submodules in excluded directories

6 years agoMerge branch 'ao/check-resolve-ref-unsafe-result'
Junio C Hamano [Mon, 6 Nov 2017 04:11:25 +0000 (13:11 +0900)]
Merge branch 'ao/check-resolve-ref-unsafe-result'

"git commit", after making a commit, did not check for errors when
asking on what branch it made the commit, which has been correted.

* ao/check-resolve-ref-unsafe-result:
  commit: check result of resolve_ref_unsafe

6 years agoMerge branch 'jk/misc-resolve-ref-unsafe-fixes'
Junio C Hamano [Mon, 6 Nov 2017 04:11:24 +0000 (13:11 +0900)]
Merge branch 'jk/misc-resolve-ref-unsafe-fixes'

Some codepaths did not check for errors when asking what branch the
HEAD points at, which have been fixed.

* jk/misc-resolve-ref-unsafe-fixes:
  worktree: handle broken symrefs in find_shared_symref()
  log: handle broken HEAD in decoration check
  remote: handle broken symrefs
  test-ref-store: avoid passing NULL to printf

6 years agoMerge branch 'sb/diff-color-moved-use-xdl-recmatch'
Junio C Hamano [Mon, 6 Nov 2017 04:11:24 +0000 (13:11 +0900)]
Merge branch 'sb/diff-color-moved-use-xdl-recmatch'

Instead of using custom line comparison and hashing functions to
implement "moved lines" coloring in the diff output, use the pair
of these functions from lower-layer xdiff/ code.

* sb/diff-color-moved-use-xdl-recmatch:
  diff.c: get rid of duplicate implementation
  xdiff-interface: export comparing and hashing strings

6 years agoMerge branch 'jk/diff-color-moved-fix'
Junio C Hamano [Mon, 6 Nov 2017 04:11:23 +0000 (13:11 +0900)]
Merge branch 'jk/diff-color-moved-fix'

The experimental "color moved lines differently in diff output"
feature was buggy around "ignore whitespace changes" edges, whihch
has been corrected.

* jk/diff-color-moved-fix:
  diff: handle NULs in get_string_hash()
  diff: fix whitespace-skipping with --color-moved
  t4015: test the output of "diff --color-moved -b"
  t4015: check "negative" case for "-w --color-moved"
  t4015: refactor --color-moved whitespace test

6 years agoMerge branch 'kd/auto-col-with-pager-fix'
Junio C Hamano [Mon, 6 Nov 2017 04:11:22 +0000 (13:11 +0900)]
Merge branch 'kd/auto-col-with-pager-fix'

"auto" as a value for the columnar output configuration ought to
judge "is the output consumed by humans?" with the same criteria as
"auto" for coloured output configuration, i.e. either the standard
output stream is going to tty, or a pager is in use.  We forgot the
latter, which has been fixed.

* kd/auto-col-with-pager-fix:
  column: do not include pager.c
  column: show auto columns when pager is active

6 years agoMerge branch 'jc/no-cmd-as-subroutine'
Junio C Hamano [Mon, 6 Nov 2017 04:11:21 +0000 (13:11 +0900)]
Merge branch 'jc/no-cmd-as-subroutine'

Calling cmd_foo() as if it is a general purpose helper function is
a no-no.  Correct two instances of such to set an example.

* jc/no-cmd-as-subroutine:
  merge-ours: do not use cmd_*() as a subroutine
  describe: do not use cmd_*() as a subroutine

6 years agoMerge branch 'ma/lockfile-fixes'
Junio C Hamano [Mon, 6 Nov 2017 04:11:21 +0000 (13:11 +0900)]
Merge branch 'ma/lockfile-fixes'

An earlier update made it possible to use an on-stack in-core
lockfile structure (as opposed to having to deliberately leak an
on-heap one).  Many codepaths have been updated to take advantage
of this new facility.

* ma/lockfile-fixes:
  read_cache: roll back lock in `update_index_if_able()`
  read-cache: leave lock in right state in `write_locked_index()`
  read-cache: drop explicit `CLOSE_LOCK`-flag
  cache.h: document `write_locked_index()`
  apply: remove `newfd` from `struct apply_state`
  apply: move lockfile into `apply_state`
  cache-tree: simplify locking logic
  checkout-index: simplify locking logic
  tempfile: fix documentation on `delete_tempfile()`
  lockfile: fix documentation on `close_lock_file_gently()`
  treewide: prefer lockfiles on the stack
  sha1_file: do not leak `lock_file`

6 years agodiff: --indent-heuristic is no longer experimental
Carlos Martín Nieto [Sun, 29 Oct 2017 15:12:28 +0000 (16:12 +0100)]
diff: --indent-heuristic is no longer experimental

This heuristic has been the default since 2.14 so we should not confuse our
users by saying that it's experimental and off by default.

Signed-off-by: Carlos Martín Nieto <cmn@dwim.me>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agogrep: take the read-lock when adding a submodule
Martin Ågren [Wed, 1 Nov 2017 20:45:06 +0000 (21:45 +0100)]
grep: take the read-lock when adding a submodule

With --recurse-submodules, we add each submodule that we encounter to
the list of alternate object databases. With threading, our changes to
the list are not protected against races. Indeed, ThreadSanitizer
reports a race when we call `add_to_alternates_memory()` around the same
time that another thread is reading in the list through
`read_sha1_file()`.

Take the grep read-lock while adding the submodule. The lock is used to
serialize uses of non-thread-safe parts of Git's API, including
`read_sha1_file()`.

Helped-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Acked-by: Brandon Williams <bmwill@google.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agosequencer: pass absolute GIT_DIR to exec commands
Jacob Keller [Tue, 31 Oct 2017 23:07:33 +0000 (16:07 -0700)]
sequencer: pass absolute GIT_DIR to exec commands

When we replaced the old shell script based interactive rebase in
commmit 18633e1a22a6 ("rebase -i: use the rebase--helper builtin",
2017-02-09) we introduced a regression of functionality in that the
GIT_DIR would be sent to the environment of the exec command as-is.

This generally meant that it would be passed as "GIT_DIR=.git", which
causes problems for any exec command that wants to run git commands in
a subdirectory.

This isn't a very large regression, since it is not that likely that the
exec command will run a git command, and even less likely that it will
need to do so in a subdir. This regression was discovered by a build
system which uses git-describe to find the current version of the build
system, and happened to do so from the src/ sub directory of the
project.

Fix this by passing in the absolute path of the git directory into the
child environment.

Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
Acked-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot0000: check whether the shell supports the "local" keyword
Michael Haggerty [Thu, 26 Oct 2017 08:18:53 +0000 (10:18 +0200)]
t0000: check whether the shell supports the "local" keyword

Add a test balloon to see if we get complaints from anybody who is
using a shell that doesn't support the "local" keyword. If so, this
test can be reverted. If not, we might want to consider using "local"
in shell code throughout the git code base.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoGit 2.15 v2.15.0
Junio C Hamano [Mon, 30 Oct 2017 05:00:44 +0000 (14:00 +0900)]
Git 2.15

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoMerge tag 'l10n-2.15.0-rnd2.1' of git://github.com/git-l10n/git-po
Junio C Hamano [Mon, 30 Oct 2017 00:32:54 +0000 (09:32 +0900)]
Merge tag 'l10n-2.15.0-rnd2.1' of git://github.com/git-l10n/git-po

l10n for Git 2.15.0 round 2 with Catalan updates

* tag 'l10n-2.15.0-rnd2.1' of git://github.com/git-l10n/git-po:
  l10n: Update Catalan translation

6 years agol10n: Update Catalan translation
Jordi Mas [Wed, 25 Oct 2017 17:50:59 +0000 (19:50 +0200)]
l10n: Update Catalan translation

Signed-off-by: Jordi Mas <jmas@softcatala.org>
6 years agoHopefully final batch before 2.15
Junio C Hamano [Sat, 28 Oct 2017 01:20:30 +0000 (10:20 +0900)]
Hopefully final batch before 2.15

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoMerge branch 'sg/rev-list-doc-reorder-fix'
Junio C Hamano [Sat, 28 Oct 2017 01:18:42 +0000 (10:18 +0900)]
Merge branch 'sg/rev-list-doc-reorder-fix'

Doc flow fix.

* sg/rev-list-doc-reorder-fix:
  rev-list-options.txt: use correct directional reference

6 years agoMerge branch 'sb/rev-parse-show-superproject-root'
Junio C Hamano [Sat, 28 Oct 2017 01:18:40 +0000 (10:18 +0900)]
Merge branch 'sb/rev-parse-show-superproject-root'

Doc markup fix.

* sb/rev-parse-show-superproject-root:
  docs: fix formatting of rev-parse's --show-superproject-working-tree

6 years agoMerge branch 'ao/path-use-xmalloc'
Junio C Hamano [Sat, 28 Oct 2017 01:18:39 +0000 (10:18 +0900)]
Merge branch 'ao/path-use-xmalloc'

A possible oom error is now caught as a fatal error, instead of
continuing and dereferencing NULL.

* ao/path-use-xmalloc:
  path.c: use xmalloc() in add_to_trie()

6 years agoMerge branch 'np/config-path-doc'
Junio C Hamano [Sat, 28 Oct 2017 01:18:39 +0000 (10:18 +0900)]
Merge branch 'np/config-path-doc'

Doc update.

* np/config-path-doc:
  config doc: clarify "git config --path" example

6 years agodocs: fix formatting of rev-parse's --show-superproject-working-tree
Sebastian Schuberth [Thu, 26 Oct 2017 11:53:37 +0000 (11:53 +0000)]
docs: fix formatting of rev-parse's --show-superproject-working-tree

Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agorev-list-options.txt: use correct directional reference
SZEDER Gábor [Thu, 26 Oct 2017 15:26:37 +0000 (17:26 +0200)]
rev-list-options.txt: use correct directional reference

The descriptions of the options '--parents', '--children' and
'--graph' say "see 'History Simplification' below", although the
referred section is in fact above the description of these options.

Send readers in the right direction by saying "above" instead of
"below".

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agostash: remove now superfluos help for "stash push"
Thomas Gummerer [Sun, 22 Oct 2017 17:04:09 +0000 (18:04 +0100)]
stash: remove now superfluos help for "stash push"

With the 'git stash save' interface, it was easily possible for users to
try to add a message which would start with "-", which 'git stash save'
would interpret as a command line argument, and fail.  For this case we
added some extra help on how to create a stash with a message starting
with "-".

For 'stash push', messages are passed with the -m flag, avoiding this
potential pitfall.  Now only pathspecs starting with "-" would have to
be distinguished from command line parameters by using
"-- --<pathspec>".  This is fairly common in the git command line
interface, and we don't try to guess what the users wanted in the other
cases.

Because this way of passing pathspecs is quite common in other git
commands, and we don't provide any extra help there, do the same in the
error message for 'git stash push'.

Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agostash: mark "git stash save" deprecated in the man page
Thomas Gummerer [Sun, 22 Oct 2017 17:04:08 +0000 (18:04 +0100)]
stash: mark "git stash save" deprecated in the man page

'git stash push' fixes a historical wart in the interface of 'git stash
save'.  As 'git stash push' has all functionality of 'git stash save',
with a nicer, more consistent user interface deprecate 'git stash
save'.  To do this, remove it from the synopsis of the man page, and
move it to a separate section, stating that it is deprecated.

Helped-by: Robert P. J. Day <rpjday@crashcourse.ca>
Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agostash: replace "git stash save" with "git stash push" in the documentation
Thomas Gummerer [Sun, 22 Oct 2017 17:04:07 +0000 (18:04 +0100)]
stash: replace "git stash save" with "git stash push" in the documentation

"git stash push" is the newer interface for creating a stash.  While we
are still keeping "git stash save" around for the time being, it's better
to point new users of "git stash" to the more modern (and more feature
rich) interface, instead of teaching them the older version that we
might want to phase out in the future.

Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoMerge branch 'mh/ref-locking-fix'
Junio C Hamano [Thu, 26 Oct 2017 03:29:23 +0000 (12:29 +0900)]
Merge branch 'mh/ref-locking-fix'

Transactions to update multiple references that involves a deletion
was quite broken in an error codepath and did not abort everything
correctly.

* mh/ref-locking-fix:
  files_transaction_prepare(): fix handling of ref lock failure
  t1404: add a bunch of tests of D/F conflicts

6 years agostatus: do not get confused by submodules in excluded directories
Johannes Schindelin [Wed, 25 Oct 2017 20:40:40 +0000 (22:40 +0200)]
status: do not get confused by submodules in excluded directories

We meticulously pass the `exclude` flag to the `treat_directory()`
function so that we can indicate that files in it are excluded rather
than untracked when recursing.

But we did not yet treat submodules the same way.

Because of that, `git status --ignored --untracked` with a submodule
`submodule` in a gitignored `tracked/` would show the submodule in the
"Untracked files" section, e.g.

On branch master
Untracked files:
  (use "git add <file>..." to include in what will be committed)

tracked/submodule/

Ignored files:
  (use "git add -f <file>..." to include in what will be committed)

tracked/submodule/initial.t

Instead, we would want it to show the submodule in the "Ignored files"
section:

On branch master
Ignored files:
  (use "git add -f <file>..." to include in what will be committed)

tracked/submodule/

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agodiff.c: get rid of duplicate implementation
Stefan Beller [Wed, 25 Oct 2017 18:49:12 +0000 (11:49 -0700)]
diff.c: get rid of duplicate implementation

The implementations in diff.c to detect moved lines needs to compare
strings and hash strings, which is implemented in that file, as well
as in the xdiff library.

Remove the rather recent implementation in diff.c and rely on the well
exercised code in the xdiff lib.

With this change the hash used for bucketing the strings for the moved
line detection changes from FNV32 (that is provided via the hashmaps
memhash) to DJB2 (which is used internally in xdiff).  Benchmarks found
on the web[1] do not indicate that these hashes are different in
performance for readable strings.

[1] https://softwareengineering.stackexchange.com/questions/49550/which-hashing-algorithm-is-best-for-uniqueness-and-speed

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoxdiff-interface: export comparing and hashing strings
Stefan Beller [Wed, 25 Oct 2017 18:49:11 +0000 (11:49 -0700)]
xdiff-interface: export comparing and hashing strings

This will turn out to be useful in a later patch.

xdl_recmatch is exported in xdiff/xutils.h, to be used by various
xdiff/*.c files, but not outside of xdiff/. This one makes it available
to the outside, too.

While at it, add documentation.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agopath.c: use xmalloc() in add_to_trie()
Andrey Okoshkin [Tue, 24 Oct 2017 15:15:05 +0000 (18:15 +0300)]
path.c: use xmalloc() in add_to_trie()

Add usage of xmalloc() instead of malloc() in add_to_trie() as xmalloc wraps
and checks memory allocation result.

Signed-off-by: Andrey Okoshkin <a.okoshkin@samsung.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agocompletion: add remaining flags to checkout
Thomas Braun [Tue, 24 Oct 2017 13:19:31 +0000 (15:19 +0200)]
completion: add remaining flags to checkout

In the commits 1fc458d9 (builtin/checkout: add --recurse-submodules
switch, 2017-03-14), 08d595dc (checkout: add --ignore-skip-worktree-bits
in sparse checkout mode, 2013-04-13) and 32669671 (checkout: introduce
--detach synonym for "git checkout foo^{commit}", 2011-02-08) checkout
gained new flags but the completion was not updated, although these flags
are useful completions. Add them.

The flags --force and --ignore-other-worktrees are not added as they are
potentially dangerous.

The flags --progress and --no-progress are only useful for scripting and are
therefore also not included.

Signed-off-by: Thomas Braun <thomas.braun@virtuell-zuhause.de>
Reviewed-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agofiles_transaction_prepare(): fix handling of ref lock failure
Michael Haggerty [Tue, 24 Oct 2017 15:16:25 +0000 (17:16 +0200)]
files_transaction_prepare(): fix handling of ref lock failure

Since dc39e09942 (files_ref_store: use a transaction to update packed
refs, 2017-09-08), failure to lock a reference has been handled
incorrectly by `files_transaction_prepare()`. If
`lock_ref_for_update()` fails in the lock-acquisition loop of that
function, it sets `ret` then breaks out of that loop. Prior to
dc39e09942, that was OK, because the only thing following the loop was
the cleanup code. But dc39e09942 added another blurb of code between
the loop and the cleanup. That blurb sometimes resets `ret` to zero,
making the cleanup code think that the locking was successful.

Specifically, whenever

* One or more reference deletions have been processed successfully in
  the lock-acquisition loop. (Processing the first such reference
  causes a packed-ref transaction to be initialized.)

* Then `lock_ref_for_update()` fails for a subsequent reference. Such
  a failure can happen for a number of reasons, such as the old SHA-1
  not being correct, lock contention, etc. This causes a `break` out
  of the lock-acquisition loop.

* The `packed-refs` lock is acquired successfully and
  `ref_transaction_prepare()` succeeds for the packed-ref transaction.
  This has the effect of resetting `ret` back to 0, and making the
  cleanup code think that lock acquisition was successful.

In that case, any reference updates that were processed prior to
breaking out of the loop would be carried out (loose and packed), but
the reference that couldn't be locked and any subsequent references
would silently be ignored.

This can easily cause data loss if, for example, the user was trying
to push a new name for an existing branch while deleting the old name.
After the push, the branch could be left unreachable, and could even
subsequently be garbage-collected.

This problem was noticed in the context of deleting one reference and
creating another in a single transaction, when the two references D/F
conflict with each other, like

    git update-ref --stdin <<EOF
    delete refs/foo
    create refs/foo/bar HEAD
    EOF

This triggers the above bug because the deletion is processed
successfully for `refs/foo`, then the D/F conflict causes
`lock_ref_for_update()` to fail when `refs/foo/bar` is processed. In
this case the transaction *should* fail, but instead it causes
`refs/foo` to be deleted without creating `refs/foo`. This could
easily result in data loss.

The fix is simple: instead of just breaking out of the loop, jump
directly to the cleanup code. This fixes some tests in t1404 that were
added in the previous commit.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot1404: add a bunch of tests of D/F conflicts
Michael Haggerty [Tue, 24 Oct 2017 15:16:24 +0000 (17:16 +0200)]
t1404: add a bunch of tests of D/F conflicts

It is currently not allowed, in a single transaction, to add one
reference and delete another reference if the two reference names D/F
conflict with each other (e.g., like `refs/foo/bar` and `refs/foo`).
The reason is that the code would need to take locks

    $GIT_DIR/refs/foo.lock
    $GIT_DIR/refs/foo/bar.lock

But the latter lock couldn't coexist with the loose reference file

    $GIT_DIR/refs/foo

, because `$GIT_DIR/refs/foo` cannot be both a directory and a file at
the same time (hence the name "D/F conflict).

Add a bunch of tests that we cleanly reject such transactions.

In fact, many of the new tests currently fail. They will be fixed in
the next commit along with an explanation.

Reported-by: Jeff King <peff@peff.net>
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoMerge tag 'l10n-2.15.0-rnd2' of git://github.com/git-l10n/git-po
Junio C Hamano [Tue, 24 Oct 2017 02:44:52 +0000 (11:44 +0900)]
Merge tag 'l10n-2.15.0-rnd2' of git://github.com/git-l10n/git-po

l10n for Git 2.15.0 round 2

* tag 'l10n-2.15.0-rnd2' of git://github.com/git-l10n/git-po: (22 commits)
  l10n: zh_CN: review for git v2.15.0 l10n round 2
  l10n: zh_CN: for git v2.15.0 l10n round 2
  l10n: de.po: fix typos
  l10n: de.po: translate 70 new messages
  l10n: ru.po: update Russian translation
  l10n: vi.po(3245t): Updated Vietnamese translation for v2.15.0 round 2
  l10n: sv.po: Update Swedish translation (3245t0f0u)
  l10n: fr.po: v2.15.0 round 2
  l10n: fr.po change translation of "First, rewinding"
  l10n: fr.po fix some mistakes
  l10n: Update Catalan translation
  l10n: ko.po: Update Korean translation
  l10n: es.po: v2.15.0 round 2
  l10n: git.pot: v2.15.0 round 2 (2 new, 2 removed)
  l10n: ru.po: update Russian translation
  l10n: bg.po: Updated Bulgarian translation (3245t)
  l10n: sv.po: Update Swedish translation (3245t0f0u)
  l10n: vi.po(3245t): Updated Vietnamese translation for v2.15.0
  l10n: es.po: Update translation v2.15.0 round 1
  l10n: git.pot: v2.15.0 round 1 (68 new, 36 removed)
  ...

6 years agoMerge branch 'jx/zh_CN-proposed' of github.com:jiangxin/git
Jiang Xin [Tue, 24 Oct 2017 02:11:48 +0000 (10:11 +0800)]
Merge branch 'jx/zh_CN-proposed' of github.com:jiangxin/git

* 'jx/zh_CN-proposed' of github.com:jiangxin/git:
  l10n: zh_CN: review for git v2.15.0 l10n round 2
  l10n: zh_CN: for git v2.15.0 l10n round 2

6 years agol10n: zh_CN: review for git v2.15.0 l10n round 2
Ray Chen [Mon, 23 Oct 2017 16:17:59 +0000 (00:17 +0800)]
l10n: zh_CN: review for git v2.15.0 l10n round 2

Signed-off-by: Ray Chen <oldsharp@gmail.com>
6 years agol10n: zh_CN: for git v2.15.0 l10n round 2
Jiang Xin [Sun, 8 Oct 2017 07:29:11 +0000 (15:29 +0800)]
l10n: zh_CN: for git v2.15.0 l10n round 2

Translate 69 messages (3245t0f0u) for git v2.15.0-rc2.

Signed-off-by: Jiang Xin <worldhello.net@gmail.com>
Reviewed-by: 依云 <lilydjwg@gmail.com>
6 years agoMerge branch 'master' of https://github.com/ralfth/git-po-de
Jiang Xin [Tue, 24 Oct 2017 01:56:09 +0000 (09:56 +0800)]
Merge branch 'master' of https://github.com/ralfth/git-po-de

* 'master' of https://github.com/ralfth/git-po-de:
  l10n: de.po: fix typos
  l10n: de.po: translate 70 new messages

6 years agocolumn: do not include pager.c
Junio C Hamano [Tue, 24 Oct 2017 01:11:18 +0000 (10:11 +0900)]
column: do not include pager.c

Everything this file needs from the pager API (e.g. term_columns(),
pager_in_use()) is already declared in the header file it includes.

Noticed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agogitweb: use filetest to allow ACLs
Guillaume Castagnino [Thu, 19 Oct 2017 07:32:46 +0000 (09:32 +0200)]
gitweb: use filetest to allow ACLs

In commit 46a1385 (gitweb: skip unreadable subdirectories, 2017-07-18)
we forgot to handle non-unix ACLs as well. Fix this.

Signed-off-by: Guillaume Castagnino <casta@xwing.info>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agobuiltin/push.c: add push.pushOption config
Marius Paliga [Mon, 23 Oct 2017 11:44:49 +0000 (13:44 +0200)]
builtin/push.c: add push.pushOption config

Push options need to be given explicitly, via the command line as "git
push --push-option <option>".  Add the config option push.pushOption,
which is a multi-valued option, containing push options that are sent
by default.

When push options are set in the lower-priority configulation file
(e.g. /etc/gitconfig, or $HOME/.gitconfig), they can be unset later in
the more specific repository config by the empty string.

Add tests and update documentation as well.

Signed-off-by: Marius Paliga <marius.paliga@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agol10n: de.po: fix typos
Andre Hinrichs [Thu, 19 Oct 2017 06:25:25 +0000 (08:25 +0200)]
l10n: de.po: fix typos

Signed-off-by: Andre Hinrichs <andre.hinrichs@gmx.de>
Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com>
6 years agol10n: de.po: translate 70 new messages
Ralf Thielow [Wed, 11 Oct 2017 10:48:48 +0000 (12:48 +0200)]
l10n: de.po: translate 70 new messages

Translate 70 new messages came from git.pot update in 25eab542b
(l10n: git.pot: v2.15.0 round 1 (68 new, 36 removed)) and 9c07fab78
(l10n: git.pot: v2.15.0 round 2 (2 new, 2 removed)).

Signed-off-by: Ralf Thielow <ralf.thielow@gmail.com>
6 years agoSync with 2.14.3
Junio C Hamano [Mon, 23 Oct 2017 05:54:30 +0000 (14:54 +0900)]
Sync with 2.14.3

6 years agoGit 2.14.3 v2.14.3
Junio C Hamano [Mon, 23 Oct 2017 05:44:17 +0000 (14:44 +0900)]
Git 2.14.3

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoMerge branch 'jk/info-alternates-fix' into maint
Junio C Hamano [Mon, 23 Oct 2017 05:40:00 +0000 (14:40 +0900)]
Merge branch 'jk/info-alternates-fix' into maint

A regression fix for 2.11 that made the code to read the list of
alternate object stores overrun the end of the string.

* jk/info-alternates-fix:
  read_info_alternates: warn on non-trivial errors
  read_info_alternates: read contents into strbuf

6 years agoMerge branch 'jc/fetch-refspec-doc-update' into maint
Junio C Hamano [Mon, 23 Oct 2017 05:39:08 +0000 (14:39 +0900)]
Merge branch 'jc/fetch-refspec-doc-update' into maint

"git fetch <there> <src>:<dst>" allows an object name on the <src>
side when the other side accepts such a request since Git v2.5, but
the documentation was left stale.

* jc/fetch-refspec-doc-update:
  fetch doc: src side of refspec could be full SHA-1

6 years agoMerge branch 'jk/write-in-full-fix' into maint
Junio C Hamano [Mon, 23 Oct 2017 05:37:21 +0000 (14:37 +0900)]
Merge branch 'jk/write-in-full-fix' into maint

Many codepaths did not diagnose write failures correctly when disks
go full, due to their misuse of write_in_full() helper function,
which have been corrected.

* jk/write-in-full-fix:
  read_pack_header: handle signed/unsigned comparison in read result
  config: flip return value of store_write_*()
  notes-merge: use ssize_t for write_in_full() return value
  pkt-line: check write_in_full() errors against "< 0"
  convert less-trivial versions of "write_in_full() != len"
  avoid "write_in_full(fd, buf, len) != len" pattern
  get-tar-commit-id: check write_in_full() return against 0
  config: avoid "write_in_full(fd, buf, len) < len" pattern

6 years agoMerge branch 'rj/no-sign-compare' into maint
Junio C Hamano [Mon, 23 Oct 2017 05:20:18 +0000 (14:20 +0900)]
Merge branch 'rj/no-sign-compare' into maint

Many codepaths have been updated to squelch -Wsign-compare
warnings.

* rj/no-sign-compare:
  ALLOC_GROW: avoid -Wsign-compare warnings
  cache.h: hex2chr() - avoid -Wsign-compare warnings
  commit-slab.h: avoid -Wsign-compare warnings
  git-compat-util.h: xsize_t() - avoid -Wsign-compare warnings

6 years agoMerge branch 'ma/ts-cleanups' into maint
Junio C Hamano [Mon, 23 Oct 2017 05:19:02 +0000 (14:19 +0900)]
Merge branch 'ma/ts-cleanups' into maint

Assorted bugfixes and clean-ups.

* ma/ts-cleanups:
  ThreadSanitizer: add suppressions
  strbuf_setlen: don't write to strbuf_slopbuf
  pack-objects: take lock before accessing `remaining`
  convert: always initialize attr_action in convert_attrs

6 years agoMerge branch 'ls/travis-scriptify' into maint
Junio C Hamano [Mon, 23 Oct 2017 05:17:53 +0000 (14:17 +0900)]
Merge branch 'ls/travis-scriptify' into maint

The scripts to drive TravisCI has been reorganized and then an
optimization to avoid spending cycles on a branch whose tip is
tagged has been implemented.

* ls/travis-scriptify:
  travis-ci: fix "skip_branch_tip_with_tag()" string comparison
  travis: dedent a few scripts that are indented overly deeply
  travis-ci: skip a branch build if equal tag is present
  travis-ci: move Travis CI code into dedicated scripts

6 years agoMerge branch 'er/fast-import-dump-refs-on-checkpoint' into maint
Junio C Hamano [Mon, 23 Oct 2017 05:17:27 +0000 (14:17 +0900)]
Merge branch 'er/fast-import-dump-refs-on-checkpoint' into maint

The checkpoint command "git fast-import" did not flush updates to
refs and marks unless at least one object was created since the
last checkpoint, which has been corrected, as these things can
happen without any new object getting created.

* er/fast-import-dump-refs-on-checkpoint:
  fast-import: checkpoint: dump branches/tags/marks even if object_count==0

6 years agoMerge branch 'jt/fast-export-copy-modify-fix' into maint
Junio C Hamano [Mon, 23 Oct 2017 05:14:51 +0000 (14:14 +0900)]
Merge branch 'jt/fast-export-copy-modify-fix' into maint

"git fast-export" with -M/-C option issued "copy" instruction on a
path that is simultaneously modified, which was incorrect.

* jt/fast-export-copy-modify-fix:
  fast-export: do not copy from modified file

6 years agoMerge branch 'nd/worktree-kill-parse-ref' into maint
Junio C Hamano [Mon, 23 Oct 2017 05:14:16 +0000 (14:14 +0900)]
Merge branch 'nd/worktree-kill-parse-ref' into maint

"git branch -M a b" while on a branch that is completely unrelated
to either branch a or branch b misbehaved when multiple worktree
was in use.  This has been fixed.

* nd/worktree-kill-parse-ref:
  branch: fix branch renaming not updating HEADs correctly

6 years agol10n: ru.po: update Russian translation
Dimitriy Ryazantcev [Sun, 22 Oct 2017 17:35:13 +0000 (20:35 +0300)]
l10n: ru.po: update Russian translation

Signed-off-by: Dimitriy Ryazantcev <dimitriy.ryazantcev@gmail.com>
6 years agoMerge branch 'master' of https://github.com/vnwildman/git
Jiang Xin [Sun, 22 Oct 2017 11:01:07 +0000 (19:01 +0800)]
Merge branch 'master' of https://github.com/vnwildman/git

* 'master' of https://github.com/vnwildman/git:
  l10n: vi.po(3245t): Updated Vietnamese translation for v2.15.0 round 2

6 years agoworktree: handle broken symrefs in find_shared_symref()
Jeff King [Thu, 19 Oct 2017 17:49:36 +0000 (13:49 -0400)]
worktree: handle broken symrefs in find_shared_symref()

The refs_resolve_ref_unsafe() function may return NULL even
with a REF_ISSYMREF flag if a symref points to a broken ref.
As a result, it's possible for find_shared_symref() to
segfault when it passes NULL to strcmp().

This is hard to trigger for most code paths. We typically
pass HEAD to the function as the symref to resolve, and
programs like "git branch" will bail much earlier if HEAD
isn't valid.

I did manage to trigger it through one very obscure
sequence:

  # You have multiple notes refs which conflict.
  git notes add -m base
  git notes --ref refs/notes/foo add -m foo

  # There's left-over cruft in NOTES_MERGE_REF that
  # makes it a broken symref (in this case we point
  # to a syntactically invalid ref).
  echo "ref: refs/heads/master.lock" >.git/NOTES_MERGE_REF

  # You try to merge the notes. We read the broken value in
  # order to complain that another notes-merge is
  # in-progress, but we segfault in find_shared_symref().
  git notes merge refs/notes/foo

This is obviously silly and almost certainly impossible to
trigger accidentally, but it does show that the bug is
triggerable from at least one code path. In addition, it
would trigger if we saw a transient filesystem error when
resolving the pointed-to ref.

We can fix this by treating NULL the same as a non-matching
symref. Arguably we'd prefer to know if a symref points to
"refs/heads/foo", but "refs/heads/foo" is broken. But
refs_resolve_ref_unsafe() isn't capable of giving us that
information, so this is the best we can do.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agolog: handle broken HEAD in decoration check
Jeff King [Thu, 19 Oct 2017 17:49:01 +0000 (13:49 -0400)]
log: handle broken HEAD in decoration check

The resolve_ref_unsafe() function may return NULL even with
a REF_ISSYMREF flag if a symref points to a broken ref. As a
result, it's possible for the decoration code's "is this
branch the current HEAD" check to segfault when it passes
the NULL to starts_with().

This is unlikely in practice, since we can only reach this
code if we already resolved HEAD to a matching sha1 earlier.
But it's possible if HEAD racily becomes broken, or if
there's a transient filesystem error.

We can fix this by returning early in the broken case, since
NULL could not possibly match any of our branch names.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoremote: handle broken symrefs
Jeff King [Thu, 19 Oct 2017 17:47:30 +0000 (13:47 -0400)]
remote: handle broken symrefs

It's possible for resolve_ref_unsafe() to return NULL with a
REF_ISSYMREF flag if a symref points to a broken ref.  In
this case, the read_remote_branches() function will segfault
passing the name to xstrdup().

This is hard to trigger in practice, since this function is
used as a callback to for_each_ref(), which will skip broken
refs in the first place (so it would have to be broken
racily, or for us to see a transient filesystem error).

If we see such a racy broken outcome let's treat it as "not
a symref". This is exactly the same thing that would happen
in the non-racy case (our function would not be called at
all, as for_each_ref would skip the broken symref).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agotest-ref-store: avoid passing NULL to printf
Jeff King [Thu, 19 Oct 2017 17:46:21 +0000 (13:46 -0400)]
test-ref-store: avoid passing NULL to printf

It's possible for resolve_ref_unsafe() to return NULL (e.g.,
if we are reading and the ref does not exist), in which case
we'll pass NULL to printf. On glibc systems this produces
"(null)", but on others it may segfault.

The tests don't expect any such case, but if we ever did
trigger this, we would prefer to cleanly fail the test with
unexpected input rather than segfault. Let's manually
replace NULL with "(null)". The exact value doesn't matter,
as it won't match any possible ref the caller could expect
(and anyway, the exit code of the program will tell whether
"ref" is valid or not).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agocommit: check result of resolve_ref_unsafe
Andrey Okoshkin [Fri, 20 Oct 2017 11:03:28 +0000 (14:03 +0300)]
commit: check result of resolve_ref_unsafe

Add check of the resolved HEAD reference while printing of a commit summary.
resolve_ref_unsafe() may return NULL pointer if underlying calls of lstat() or
open() fail in files_read_raw_ref().
Such situation can be caused by race: file becomes inaccessible to this moment.

Signed-off-by: Andrey Okoshkin <a.okoshkin@samsung.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agodiff: handle NULs in get_string_hash()
Jeff King [Thu, 19 Oct 2017 20:31:20 +0000 (16:31 -0400)]
diff: handle NULs in get_string_hash()

For computing moved lines, we feed the characters of each
line into a hash. When we've been asked to ignore
whitespace, then we pick each character using next_byte(),
which returns -1 on end-of-string, which it determines using
the start/end pointers we feed it.

However our check of its return value treats "0" the same as
"-1", meaning we'd quit if the string has an embedded NUL.
This is unlikely to ever come up in practice since our line
boundaries generally come from calling strlen() in the first
place.

But it was a bit surprising to me as a reader of the
next_byte() code. And it's possible that we may one day feed
this function with more exotic input, which otherwise works
with arbitrary ptr/len pairs.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agodiff: fix whitespace-skipping with --color-moved
Jeff King [Thu, 19 Oct 2017 20:29:26 +0000 (16:29 -0400)]
diff: fix whitespace-skipping with --color-moved

The code for handling whitespace with --color-moved
represents partial strings as a pair of pointers. There are
two possible conventions for the end pointer:

  1. It points to the byte right after the end of the
     string.

  2. It points to the final byte of the string.

But we seem to use both conventions in the code:

  a. we assign the initial pointers from the NUL-terminated
     string using (1)

  b. we eat trailing whitespace by checking the second
     pointer for isspace(), which needs (2)

  c. the next_byte() function checks for end-of-string with
     "if (cp > endp)", which is (2)

  d. in next_byte() we skip past internal whitespace with
     "while (cp < end)", which is (1)

This creates fewer bugs than you might think, because there
are some subtle interactions. Because of (a) and (c), we
always return the NUL-terminator from next_byte(). But all
of the callers of next_byte() happen to handle that
gracefully.

Because of the mismatch between (d) and (c), next_byte()
could accidentally return a whitespace character right at
endp. But because of the interaction of (a) and (b), we fail
to actually chomp trailing whitespace, meaning our endp
_always_ points to a NUL, canceling out the problem.

But that does leave (b) as a real bug: when ignoring
whitespace only at the end-of-line, we don't correctly trim
it, and fail to match up lines.

We can fix the whole thing by moving consistently to one
convention. Since convention (1) is idiomatic in our code
base, we'll pick that one.

The existing "-w" and "-b" tests continue to pass, and a new
"--ignore-space-at-eol" shows off the breakage we're fixing.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot4015: test the output of "diff --color-moved -b"
Jeff King [Thu, 19 Oct 2017 20:26:31 +0000 (16:26 -0400)]
t4015: test the output of "diff --color-moved -b"

Commit fa5ba2c1dd (diff: fix infinite loop with
--color-moved --ignore-space-change, 2017-10-12) added a
test to make sure that "--color-moved -b" doesn't run
forever, but the test in question doesn't actually have any
moved lines in it.

Let's scrap that test and add a variant of the existing
"--color-moved -w" test, but this time we'll check that we
find the move with whitespace changes, but not arbitrary
whitespace additions.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot4015: check "negative" case for "-w --color-moved"
Jeff King [Thu, 19 Oct 2017 20:25:57 +0000 (16:25 -0400)]
t4015: check "negative" case for "-w --color-moved"

We test that lines with whitespace changes are not found by
"--color-moved" by default, but are found if "-w" is added.
Let's add one more twist: a line that has non-whitespace
changes should not be marked as a pure move.

This is perhaps an obvious case for us to get right (and we
do), but as we add more whitespace tests, they will form a
pattern of "make sure this case is a move and this other
case is not".

Note that we have to add a line to our moved block, since
having a too-small block doesn't trigger the "moved"
heuristics.  And we also add a line of context to ensure
that there's more context lines than moved lines (so the
diff shows us moving the lines up, rather than moving the
context down).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agot4015: refactor --color-moved whitespace test
Jeff King [Thu, 19 Oct 2017 20:24:03 +0000 (16:24 -0400)]
t4015: refactor --color-moved whitespace test

In preparation for testing several different whitespace
options, let's split out the setup and cleanup steps of the
whitespace test.

While we're here, let's also switch to using "<<-" to indent
our here-documents properly, and use q_to_tab to more
explicitly mark where we expect whitespace to appear.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoGit 2.15-rc2 v2.15.0-rc2
Junio C Hamano [Thu, 19 Oct 2017 05:49:17 +0000 (14:49 +0900)]
Git 2.15-rc2

Signed-off-by: Junio C Hamano <gitster@pobox.com>
6 years agoMerge branch 'jc/branch-force-doc-readability-fix'
Junio C Hamano [Thu, 19 Oct 2017 05:45:45 +0000 (14:45 +0900)]
Merge branch 'jc/branch-force-doc-readability-fix'

Doc update.

* jc/branch-force-doc-readability-fix:
  branch doc: sprinkle a few commas for readability

6 years agoMerge branch 'dg/filter-branch-filter-order-doc'
Junio C Hamano [Thu, 19 Oct 2017 05:45:45 +0000 (14:45 +0900)]
Merge branch 'dg/filter-branch-filter-order-doc'

Update the documentation for "git filter-branch" so that the filter
options are listed in the same order as they are applied, as
described in an earlier part of the doc.

* dg/filter-branch-filter-order-doc:
  doc: list filter-branch subdirectory-filter first

6 years agoMerge branch 'jc/fetch-refspec-doc-update'
Junio C Hamano [Thu, 19 Oct 2017 05:45:44 +0000 (14:45 +0900)]
Merge branch 'jc/fetch-refspec-doc-update'

"git fetch <there> <src>:<dst>" allows an object name on the <src>
side when the other side accepts such a request since Git v2.5, but
the documentation was left stale.

* jc/fetch-refspec-doc-update:
  fetch doc: src side of refspec could be full SHA-1

6 years agoMerge branch 'wk/merge-options-gpg-sign-doc'
Junio C Hamano [Thu, 19 Oct 2017 05:45:43 +0000 (14:45 +0900)]
Merge branch 'wk/merge-options-gpg-sign-doc'

Doc updates.

* wk/merge-options-gpg-sign-doc:
  Documentation/merge-options.txt: describe -S/--gpg-sign for 'pull'