git
7 years agorebase: pass --[no-]signoff option to git am oblomov/rebase-signoff
Giuseppe Bilotta [Thu, 16 Sep 2010 08:59:21 +0000 (10:59 +0200)] 
rebase: pass --[no-]signoff option to git am

This makes it easy to sign off a whole patchset before submission.

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
7 years agobuiltin/am: fold am_signoff() into am_append_signoff()
Giuseppe Bilotta [Sat, 15 Apr 2017 13:15:22 +0000 (15:15 +0200)] 
builtin/am: fold am_signoff() into am_append_signoff()

There are no more direct calls to am_signoff(), so we can fold its
logic  in am_append_signoff().

(This is done in a separate commit rather than in the previous one, to
make it easier to revert this specific change if additional calls are
ever introduced.)

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
7 years agobuiltin/am: obey --signoff also when --rebasing
Giuseppe Bilotta [Thu, 16 Sep 2010 08:59:21 +0000 (10:59 +0200)] 
builtin/am: obey --signoff also when --rebasing

Signoff is handled in parse_mail(), but not in parse_mail_rebasing(),
since the latter is only used when git-rebase calls git-am with the
--rebasing option, and --signoff is never passed in this case.

In order to introduce (in the upcoming commits) support for `git-rebase
--signoff`, we must make gi-am obey it also in the rebase case. This is
trivially fixed by moving the conditional addition of the signoff from
parse_mail() to the caller am_run(), after either of the parse_mail*()
functions were called.

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
7 years agoSync with master
Junio C Hamano [Mon, 17 Apr 2017 06:38:53 +0000 (23:38 -0700)] 
Sync with master

* master:
  Twelfth batch for 2.13

7 years agoMerge branch 'lt/mailinfo-in-body-header-continuation' into next
Junio C Hamano [Mon, 17 Apr 2017 06:38:27 +0000 (23:38 -0700)] 
Merge branch 'lt/mailinfo-in-body-header-continuation' into next

If a patch e-mail had its first paragraph after an in-body header
indented (even after a blank line after the in-body header line),
the indented line was mistook as a continuation of the in-body
header.  This has been fixed.

* lt/mailinfo-in-body-header-continuation:
  mailinfo: fix in-body header continuations

7 years agoMerge branch 'bw/push-options-recursively-to-submodules' into next
Junio C Hamano [Mon, 17 Apr 2017 06:38:26 +0000 (23:38 -0700)] 
Merge branch 'bw/push-options-recursively-to-submodules' into next

"git push --recurse-submodules --push-option=<string>" learned to
propagate the push option recursively down to pushes in submodules.

* bw/push-options-recursively-to-submodules:
  push: propagate remote and refspec with --recurse-submodules
  submodule--helper: add push-check subcommand
  remote: expose parse_push_refspec function
  push: propagate push-options with --recurse-submodules
  push: unmark a local variable as static

7 years agoMerge branch 'bc/object-id' into next
Junio C Hamano [Mon, 17 Apr 2017 06:38:24 +0000 (23:38 -0700)] 
Merge branch 'bc/object-id' into next

Conversion from unsigned char [40] to struct object_id continues.

* bc/object-id:
  Documentation: update and rename api-sha1-array.txt
  Rename sha1_array to oid_array
  Convert sha1_array_for_each_unique and for_each_abbrev to object_id
  Convert sha1_array_lookup to take struct object_id
  Convert remaining callers of sha1_array_lookup to object_id
  Make sha1_array_append take a struct object_id *
  sha1-array: convert internal storage for struct sha1_array to object_id
  builtin/pull: convert to struct object_id
  submodule: convert check_for_new_submodule_commits to object_id
  sha1_name: convert disambiguate_hint_fn to take object_id
  sha1_name: convert struct disambiguate_state to object_id
  test-sha1-array: convert most code to struct object_id
  parse-options-cb: convert sha1_array_append caller to struct object_id
  fsck: convert init_skiplist to struct object_id
  builtin/receive-pack: convert portions to struct object_id
  builtin/pull: convert portions to struct object_id
  builtin/diff: convert to struct object_id
  Convert GIT_SHA1_RAWSZ used for allocation to GIT_MAX_RAWSZ
  Convert GIT_SHA1_HEXSZ used for allocation to GIT_MAX_HEXSZ
  Define new hash-size constants for allocating memory

7 years agoMerge branch 'sb/submodule-short-status' into next
Junio C Hamano [Mon, 17 Apr 2017 06:38:23 +0000 (23:38 -0700)] 
Merge branch 'sb/submodule-short-status' into next

The output from "git status --short" has been extended to show
various kinds of dirtyness in submodules differently; instead of to
"M" for modified, 'm' and '?' can be shown to signal changes only
to the working tree of the submodule but not the commit that is
checked out.

* sb/submodule-short-status:
  submodule.c: correctly handle nested submodules in is_submodule_modified
  short status: improve reporting for submodule changes
  submodule.c: stricter checking for submodules in is_submodule_modified
  submodule.c: port is_submodule_modified to use porcelain 2
  submodule.c: convert is_submodule_modified to use strbuf_getwholeline
  submodule.c: factor out early loop termination in is_submodule_modified
  submodule.c: use argv_array in is_submodule_modified

7 years agoTwelfth batch for 2.13
Junio C Hamano [Mon, 17 Apr 2017 06:30:49 +0000 (23:30 -0700)] 
Twelfth batch for 2.13

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMerge branch 'js/difftool-builtin'
Junio C Hamano [Mon, 17 Apr 2017 06:29:34 +0000 (23:29 -0700)] 
Merge branch 'js/difftool-builtin'

Code cleanup.

* js/difftool-builtin:
  difftool: fix use-after-free
  difftool: avoid strcpy

7 years agoMerge branch 'sb/unpack-trees-would-lose-submodule-message-update'
Junio C Hamano [Mon, 17 Apr 2017 06:29:34 +0000 (23:29 -0700)] 
Merge branch 'sb/unpack-trees-would-lose-submodule-message-update'

Update an error message.

* sb/unpack-trees-would-lose-submodule-message-update:
  unpack-trees.c: align submodule error message to the other error messages

7 years agoMerge branch 'ab/regen-perl-mak-with-different-perl'
Junio C Hamano [Mon, 17 Apr 2017 06:29:33 +0000 (23:29 -0700)] 
Merge branch 'ab/regen-perl-mak-with-different-perl'

Update the build dependency so that an update to /usr/bin/perl
etc. result in recomputation of perl.mak file.

* ab/regen-perl-mak-with-different-perl:
  perl: regenerate perl.mak if perl -V changes

7 years agoMerge branch 'sb/show-diff-for-submodule-in-diff-fix'
Junio C Hamano [Mon, 17 Apr 2017 06:29:32 +0000 (23:29 -0700)] 
Merge branch 'sb/show-diff-for-submodule-in-diff-fix'

"git diff --submodule=diff" learned to work better in a project
with a submodule that in turn has its own submodules.

* sb/show-diff-for-submodule-in-diff-fix:
  diff: submodule inline diff to initialize env array.

7 years agoMerge branch 'qp/bisect-docfix'
Junio C Hamano [Mon, 17 Apr 2017 06:29:31 +0000 (23:29 -0700)] 
Merge branch 'qp/bisect-docfix'

Doc update.

* qp/bisect-docfix:
  git-bisect.txt: add missing word

7 years agoMerge branch 'mm/ls-files-s-doc'
Junio C Hamano [Mon, 17 Apr 2017 06:29:30 +0000 (23:29 -0700)] 
Merge branch 'mm/ls-files-s-doc'

Doc update.

* mm/ls-files-s-doc:
  Documentation: document elements in "ls-files -s" output in order

7 years agoMerge branch 'jk/loose-object-info-report-error'
Junio C Hamano [Mon, 17 Apr 2017 06:29:30 +0000 (23:29 -0700)] 
Merge branch 'jk/loose-object-info-report-error'

Update error handling for codepath that deals with corrupt loose
objects.

* jk/loose-object-info-report-error:
  index-pack: detect local corruption in collision check
  sha1_loose_object_info: return error for corrupted objects

7 years agoMerge branch 'jc/bs-t-is-not-a-tab-for-sed'
Junio C Hamano [Mon, 17 Apr 2017 06:29:28 +0000 (23:29 -0700)] 
Merge branch 'jc/bs-t-is-not-a-tab-for-sed'

Code cleanup.

* jc/bs-t-is-not-a-tab-for-sed:
  contrib/git-resurrect.sh: do not write \t for HT in sed scripts

7 years agoMerge branch 'jc/unused-symbols'
Junio C Hamano [Mon, 17 Apr 2017 06:29:27 +0000 (23:29 -0700)] 
Merge branch 'jc/unused-symbols'

Code cleanup.

* jc/unused-symbols:
  remote.[ch]: parse_push_cas_option() can be static

7 years agoMerge branch 'jk/snprintf-cleanups'
Junio C Hamano [Mon, 17 Apr 2017 06:29:26 +0000 (23:29 -0700)] 
Merge branch 'jk/snprintf-cleanups'

Code clean-up.

* jk/snprintf-cleanups:
  daemon: use an argv_array to exec children
  gc: replace local buffer with git_path
  transport-helper: replace checked snprintf with xsnprintf
  convert unchecked snprintf into xsnprintf
  combine-diff: replace malloc/snprintf with xstrfmt
  replace unchecked snprintf calls with heap buffers
  receive-pack: print --pack-header directly into argv array
  name-rev: replace static buffer with strbuf
  create_branch: use xstrfmt for reflog message
  create_branch: move msg setup closer to point of use
  avoid using mksnpath for refs
  avoid using fixed PATH_MAX buffers for refs
  fetch: use heap buffer to format reflog
  tag: use strbuf to format tag header
  diff: avoid fixed-size buffer for patch-ids
  odb_mkstemp: use git_path_buf
  odb_mkstemp: write filename into strbuf
  do not check odb_mkstemp return value for errors

7 years agoMerge branch 'js/difftool-builtin' into next
Junio C Hamano [Sat, 15 Apr 2017 08:31:52 +0000 (01:31 -0700)] 
Merge branch 'js/difftool-builtin' into next

Code cleanup.

* js/difftool-builtin:
  difftool: fix use-after-free

7 years agoMerge branch 'jh/memihash-opt' into next
Junio C Hamano [Sat, 15 Apr 2017 08:31:51 +0000 (01:31 -0700)] 
Merge branch 'jh/memihash-opt' into next

Hotfix for a topic that is already in 'master'.

* jh/memihash-opt:
  t3008: skip lazy-init test on a single-core box
  test-online-cpus: helper to return cpu count

7 years agodifftool: fix use-after-free
Johannes Schindelin [Thu, 13 Apr 2017 19:21:58 +0000 (21:21 +0200)] 
difftool: fix use-after-free

The left and right base directories were pointed to the buf field of
two strbufs, which were subject to change.

A contrived test case shows the problem where a file with a long enough
name to force the strbuf to grow is up-to-date (hence the code path is
used where the work tree's version of the file is reused), and then a
file that is not up-to-date needs to be written (hence the code path is
used where checkout_entry() uses the previously recorded base_dir that
is invalid by now).

Let's just copy the base_dir strings for use with checkout_entry(),
never touch them until the end, and release them then. This is an easily
verifiable fix (as opposed to the next-obvious alternative: to re-set
base_dir after every loop iteration).

This fixes https://github.com/git-for-windows/git/issues/1124

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agot3008: skip lazy-init test on a single-core box
Kevin Willford [Mon, 3 Apr 2017 15:16:42 +0000 (15:16 +0000)] 
t3008: skip lazy-init test on a single-core box

The lazy-init codepath will not be exercised uniless threaded.  Skip
the entire test on a single-core box.  Also replace a hard-coded
constant of 2000 (number of cache entries to manifacture for tests)
with a variable with a human readable name.

Signed-off-by: Kevin Willford <kewillf@microsoft.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agotest-online-cpus: helper to return cpu count
Jeff Hostetler [Mon, 3 Apr 2017 15:16:41 +0000 (15:16 +0000)] 
test-online-cpus: helper to return cpu count

Created helper executable to print the value of online_cpus()
allowing multi-threaded tests to be skipped when appropriate.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoSync with master
Junio C Hamano [Tue, 11 Apr 2017 07:55:18 +0000 (00:55 -0700)] 
Sync with master

* master:
  Eleventh batch for 2.13
  travis-ci: build and test Git on Windows

7 years agoMerge branch 'sb/unpack-trees-would-lose-submodule-message-update' into next
Junio C Hamano [Tue, 11 Apr 2017 07:55:13 +0000 (00:55 -0700)] 
Merge branch 'sb/unpack-trees-would-lose-submodule-message-update' into next

Update an error message.

* sb/unpack-trees-would-lose-submodule-message-update:
  unpack-trees.c: align submodule error message to the other error messages

7 years agoMerge branch 'ab/regen-perl-mak-with-different-perl' into next
Junio C Hamano [Tue, 11 Apr 2017 07:55:12 +0000 (00:55 -0700)] 
Merge branch 'ab/regen-perl-mak-with-different-perl' into next

Update the build dependency so that an update to /usr/bin/perl
etc. result in recomputation of perl.mak file.

* ab/regen-perl-mak-with-different-perl:
  perl: regenerate perl.mak if perl -V changes

7 years agoMerge branch 'sb/show-diff-for-submodule-in-diff-fix' into next
Junio C Hamano [Tue, 11 Apr 2017 07:55:11 +0000 (00:55 -0700)] 
Merge branch 'sb/show-diff-for-submodule-in-diff-fix' into next

"git diff --submodule=diff" learned to work better in a project
with a submodule that in turn has its own submodules.

* sb/show-diff-for-submodule-in-diff-fix:
  diff: submodule inline diff to initialize env array.

7 years agoMerge branch 'qp/bisect-docfix' into next
Junio C Hamano [Tue, 11 Apr 2017 07:55:10 +0000 (00:55 -0700)] 
Merge branch 'qp/bisect-docfix' into next

Doc update.

* qp/bisect-docfix:
  git-bisect.txt: add missing word

7 years agoMerge branch 'mm/ls-files-s-doc' into next
Junio C Hamano [Tue, 11 Apr 2017 07:55:09 +0000 (00:55 -0700)] 
Merge branch 'mm/ls-files-s-doc' into next

Doc update.

* mm/ls-files-s-doc:
  Documentation: document elements in "ls-files -s" output in order

7 years agoMerge branch 'jk/loose-object-info-report-error' into next
Junio C Hamano [Tue, 11 Apr 2017 07:55:08 +0000 (00:55 -0700)] 
Merge branch 'jk/loose-object-info-report-error' into next

Update error handling for codepath that deals with corrupt loose
objects.

* jk/loose-object-info-report-error:
  index-pack: detect local corruption in collision check
  sha1_loose_object_info: return error for corrupted objects

7 years agoMerge branch 'jc/bs-t-is-not-a-tab-for-sed' into next
Junio C Hamano [Tue, 11 Apr 2017 07:55:07 +0000 (00:55 -0700)] 
Merge branch 'jc/bs-t-is-not-a-tab-for-sed' into next

Code cleanup.

* jc/bs-t-is-not-a-tab-for-sed:
  contrib/git-resurrect.sh: do not write \t for HT in sed scripts

7 years agoMerge branch 'jc/unused-symbols' into next
Junio C Hamano [Tue, 11 Apr 2017 07:55:06 +0000 (00:55 -0700)] 
Merge branch 'jc/unused-symbols' into next

Code cleanup.

* jc/unused-symbols:
  remote.[ch]: parse_push_cas_option() can be static

7 years agoMerge branch 'js/difftool-builtin' into next
Junio C Hamano [Tue, 11 Apr 2017 07:55:05 +0000 (00:55 -0700)] 
Merge branch 'js/difftool-builtin' into next

Code cleanup.

* js/difftool-builtin:
  difftool: avoid strcpy

7 years agoMerge branch 'jh/memihash-opt' into next
Junio C Hamano [Tue, 11 Apr 2017 07:55:05 +0000 (00:55 -0700)] 
Merge branch 'jh/memihash-opt' into next

Hotfix for a topic that is already in 'master'.

* jh/memihash-opt:
  name-hash: fix buffer overrun

7 years agoMerge branch 'jk/snprintf-cleanups' into next
Junio C Hamano [Tue, 11 Apr 2017 07:55:04 +0000 (00:55 -0700)] 
Merge branch 'jk/snprintf-cleanups' into next

Code clean-up.

* jk/snprintf-cleanups:
  daemon: use an argv_array to exec children
  gc: replace local buffer with git_path
  transport-helper: replace checked snprintf with xsnprintf
  convert unchecked snprintf into xsnprintf
  combine-diff: replace malloc/snprintf with xstrfmt
  replace unchecked snprintf calls with heap buffers
  receive-pack: print --pack-header directly into argv array
  name-rev: replace static buffer with strbuf
  create_branch: use xstrfmt for reflog message
  create_branch: move msg setup closer to point of use
  avoid using mksnpath for refs
  avoid using fixed PATH_MAX buffers for refs
  fetch: use heap buffer to format reflog
  tag: use strbuf to format tag header
  diff: avoid fixed-size buffer for patch-ids
  odb_mkstemp: use git_path_buf
  odb_mkstemp: write filename into strbuf
  do not check odb_mkstemp return value for errors

7 years agomailinfo: fix in-body header continuations
Linus Torvalds [Sat, 1 Apr 2017 19:14:39 +0000 (12:14 -0700)] 
mailinfo: fix in-body header continuations

An empty line should stop any pending in-body headers, and start the
actual body parsing.

This also modifies the original test for the in-body headers to actually
have a real commit body that starts with spaces, and changes the test to
check that the long line matches _exactly_, and doesn't get extra data
from the body.

Fixes:6b4b013f1884 ("mailinfo: handle in-body header continuations")
Cc: Jonathan Tan <jonathantanmy@google.com>
Cc: Jeff King <peff@peff.net>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agopush: propagate remote and refspec with --recurse-submodules
Brandon Williams [Wed, 5 Apr 2017 17:47:19 +0000 (10:47 -0700)] 
push: propagate remote and refspec with --recurse-submodules

Teach "push --recurse-submodules" to propagate, if given a name as remote, the
provided remote and refspec recursively to the pushes performed in the
submodules. The push will therefore only succeed if all submodules have a
remote with such a name configured.

Note that "push --recurse-submodules" with a path or URL as remote will not
propagate the remote or refspec and instead use the default remote and refspec
configured in the submodule, preserving the current behavior.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agosubmodule--helper: add push-check subcommand
Brandon Williams [Wed, 5 Apr 2017 17:47:18 +0000 (10:47 -0700)] 
submodule--helper: add push-check subcommand

Add the 'push-check' subcommand to submodule--helper which is used to
check if the provided remote and refspec can be used as part of a push
operation in the submodule.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoremote: expose parse_push_refspec function
Brandon Williams [Wed, 5 Apr 2017 17:47:17 +0000 (10:47 -0700)] 
remote: expose parse_push_refspec function

A future patch needs access to the 'parse_push_refspec()' function so
let's export the function so other modules can use it.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agopush: propagate push-options with --recurse-submodules
Brandon Williams [Wed, 5 Apr 2017 17:47:16 +0000 (10:47 -0700)] 
push: propagate push-options with --recurse-submodules

Teach push --recurse-submodules to propagate push-options recursively to
the pushes performed in the submodules.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoEleventh batch for 2.13
Junio C Hamano [Tue, 11 Apr 2017 07:27:05 +0000 (00:27 -0700)] 
Eleventh batch for 2.13

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMerge branch 'ls/travis-relays-for-windows-ci'
Junio C Hamano [Tue, 11 Apr 2017 07:21:52 +0000 (00:21 -0700)] 
Merge branch 'ls/travis-relays-for-windows-ci'

Define a new task in .travis.yml that triggers a test session on
Windows run elsewhere.

* ls/travis-relays-for-windows-ci:
  travis-ci: build and test Git on Windows

7 years agoMerge branch 'cc/untracked'
Junio C Hamano [Tue, 11 Apr 2017 07:21:51 +0000 (00:21 -0700)] 
Merge branch 'cc/untracked'

Code cleanup.

* cc/untracked:
  update-index: fix xgetcwd() related memory leak

7 years agoMerge branch 'ah/log-decorate-default-to-auto'
Junio C Hamano [Tue, 11 Apr 2017 07:21:51 +0000 (00:21 -0700)] 
Merge branch 'ah/log-decorate-default-to-auto'

The default behaviour of "git log" in an interactive session has
been changed to enable "--decorate".

* ah/log-decorate-default-to-auto:
  log: if --decorate is not given, default to --decorate=auto

7 years agoMerge branch 'ab/ref-filter-no-contains'
Junio C Hamano [Tue, 11 Apr 2017 07:21:50 +0000 (00:21 -0700)] 
Merge branch 'ab/ref-filter-no-contains'

"git tag/branch/for-each-ref" family of commands long allowed to
filter the refs by "--contains X" (show only the refs that are
descendants of X), "--merged X" (show only the refs that are
ancestors of X), "--no-merged X" (show only the refs that are not
ancestors of X).  One curious omission, "--no-contains X" (show
only the refs that are not descendants of X) has been added to
them.

* ab/ref-filter-no-contains:
  tag: add tests for --with and --without
  ref-filter: reflow recently changed branch/tag/for-each-ref docs
  ref-filter: add --no-contains option to tag/branch/for-each-ref
  tag: change --point-at to default to HEAD
  tag: implicitly supply --list given another list-like option
  tag: change misleading --list <pattern> documentation
  parse-options: add OPT_NONEG to the "contains" option
  tag: add more incompatibles mode tests
  for-each-ref: partly change <object> to <commit> in help
  tag tests: fix a typo in a test description
  tag: remove a TODO item from the test suite
  ref-filter: add test for --contains on a non-commit
  ref-filter: make combining --merged & --no-merged an error
  tag doc: reword --[no-]merged to talk about commits, not tips
  tag doc: split up the --[no-]merged documentation
  tag doc: move the description of --[no-]merged earlier

7 years agodiff: submodule inline diff to initialize env array.
Stefan Beller [Fri, 31 Mar 2017 23:17:32 +0000 (16:17 -0700)] 
diff: submodule inline diff to initialize env array.

David reported:
> When I try to run `git diff --submodule=diff` in a submodule which has
> it's own submodules that have changes I get the error: fatal: bad
> object.

This happens, because we do not properly initialize the environment
in which the diff is run in the submodule. That means we inherit the
environment from the main process, which sets environment variables.
(Apparently we do set environment variables which we do not set
when not in a submodules, i.e. the .git directory is linked)

This commit, just like fd47ae6a5b (diff: teach diff to display
submodule difference with an inline diff, 2016-08-31) introduces bad
test code (i.e. hard coded hash values), which will be cleanup up in
a later patch.

Reported-by: David Parrish <daveparrish@gmail.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agopush: unmark a local variable as static
Brandon Williams [Fri, 31 Mar 2017 23:56:22 +0000 (16:56 -0700)] 
push: unmark a local variable as static

There isn't any obvious reason for the 'struct string_list push_options'
and 'struct string_list_item *item' to be marked as static, so unmark
them as being static.  Also, clear the push_options string_list to
prevent memory leaking.

Signed-off-by: Brandon Williams <bmwill@google.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agogit-bisect.txt: add missing word
Quentin Pradet [Sat, 1 Apr 2017 06:40:56 +0000 (10:40 +0400)] 
git-bisect.txt: add missing word

Signed-off-by: Quentin Pradet <quentin.pradet@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoDocumentation: document elements in "ls-files -s" output in order
Mostyn Bramley-Moore [Sat, 1 Apr 2017 07:08:25 +0000 (09:08 +0200)] 
Documentation: document elements in "ls-files -s" output in order

List the fields in order of appearance in the command output.

Signed-off-by: Mostyn Bramley-Moore <mostyn@antipode.se>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoindex-pack: detect local corruption in collision check
Jeff King [Sat, 1 Apr 2017 08:09:32 +0000 (04:09 -0400)] 
index-pack: detect local corruption in collision check

When we notice that we have a local copy of an incoming
object, we compare the two objects to make sure we haven't
found a collision. Before we get to the actual object
bytes, though, we compare the type and size from
sha1_object_info().

If our local object is corrupted, then the type will be
OBJ_BAD, which obviously will not match the incoming type,
and we'll report "SHA1 COLLISION FOUND" (with capital
letters and everything). This is confusing, as the problem
is not a collision but rather local corruption. We should
report that instead (just like we do if reading the rest of
the object content fails a few lines later).

Note that we _could_ just ignore the error and mark it as a
non-collision. That would let you "git fetch" to replace a
corrupted object. But it's not a very reliable method for
repairing a repository. The earlier want/have negotiation
tries to get the other side to omit objects we already have,
and it would not realize that we are "missing" this
corrupted object. So we're better off complaining loudly
when we see corruption, and letting the user take more
drastic measures to repair (like making a full clone
elsewhere and copying the pack into place).

Note that the test sets transfer.unpackLimit in the
receiving repository so that we use index-pack (which is
what does the collision check). Normally for such a small
push we'd use unpack-objects, which would simply try to
write the loose object, and discard the new one when we see
that there's already an old one.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agosha1_loose_object_info: return error for corrupted objects
Jeff King [Sat, 1 Apr 2017 08:05:21 +0000 (04:05 -0400)] 
sha1_loose_object_info: return error for corrupted objects

When sha1_loose_object_info() finds that a loose object file
cannot be stat(2)ed or mmap(2)ed, it returns -1 to signal an
error to the caller.  However, if it found that the loose
object file is corrupt and the object data cannot be used
from it, it stuffs OBJ_BAD into "type" field of the
object_info, but returns zero (i.e., success), which can
confuse callers.

This is due to 052fe5eac (sha1_loose_object_info: make type
lookup optional, 2013-07-12), which switched the return to a
strict success/error, rather than returning the type (but
botched the return).

Callers of regular sha1_object_info() don't notice the
difference, as that function returns the type (which is
OBJ_BAD in this case). However, direct callers of
sha1_object_info_extended() see the function return success,
but without setting any meaningful values in the object_info
struct, leading them to access potentially uninitialized
memory.

The easiest way to see the bug is via "cat-file -s", which
will happily ignore the corruption and report whatever
value happened to be in the "size" variable.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agocontrib/git-resurrect.sh: do not write \t for HT in sed scripts
Junio C Hamano [Sat, 1 Apr 2017 04:08:30 +0000 (21:08 -0700)] 
contrib/git-resurrect.sh: do not write \t for HT in sed scripts

Just like we did in 0d1d6e50 ("t/t7003: replace \t with literal tab
in sed expression", 2010-08-12), avoid writing "\t" for HT in sed
scripts, which is not portable.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoname-hash: fix buffer overrun
Kevin Willford [Fri, 31 Mar 2017 17:32:14 +0000 (17:32 +0000)] 
name-hash: fix buffer overrun

Add check for the end of the entries for the thread partition.
Add test for lazy init name hash with specific directory structure

The lazy init hash name was causing a buffer overflow when the last
entry in the index was multiple folder deep with parent folders that
did not have any files in them.

This adds a test for the boundary condition of the thread partitions
with the folder structure that was triggering the buffer overflow.

The fix was to check if it is the last entry for the thread partition
in the handle_range_dir and not try to use the next entry in the cache.

Signed-off-by: Kevin Willford <kewillf@microsoft.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoremote.[ch]: parse_push_cas_option() can be static
Junio C Hamano [Fri, 31 Mar 2017 20:20:48 +0000 (13:20 -0700)] 
remote.[ch]: parse_push_cas_option() can be static

Since 068c77a5 ("builtin/send-pack.c: use parse_options API",
2015-08-19), there is no external user of this helper function.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoDocumentation: update and rename api-sha1-array.txt
brian m. carlson [Fri, 31 Mar 2017 01:40:01 +0000 (01:40 +0000)] 
Documentation: update and rename api-sha1-array.txt

Since the structure and functions have changed names, update the code
examples and the documentation.  Rename the file to match the new name
of the API.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoRename sha1_array to oid_array
brian m. carlson [Fri, 31 Mar 2017 01:40:00 +0000 (01:40 +0000)] 
Rename sha1_array to oid_array

Since this structure handles an array of object IDs, rename it to struct
oid_array.  Also rename the accessor functions and the initialization
constant.

This commit was produced mechanically by providing non-Documentation
files to the following Perl one-liners:

    perl -pi -E 's/struct sha1_array/struct oid_array/g'
    perl -pi -E 's/\bsha1_array_/oid_array_/g'
    perl -pi -E 's/SHA1_ARRAY_INIT/OID_ARRAY_INIT/g'

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoConvert sha1_array_for_each_unique and for_each_abbrev to object_id
brian m. carlson [Fri, 31 Mar 2017 01:39:59 +0000 (01:39 +0000)] 
Convert sha1_array_for_each_unique and for_each_abbrev to object_id

Make sha1_array_for_each_unique take a callback using struct object_id.
Since one of these callbacks is an argument to for_each_abbrev, convert
those as well.  Rename various functions, replacing "sha1" with "oid".

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoConvert sha1_array_lookup to take struct object_id
brian m. carlson [Fri, 31 Mar 2017 01:39:58 +0000 (01:39 +0000)] 
Convert sha1_array_lookup to take struct object_id

Convert this function by changing the declaration and definition and
applying the following semantic patch to update the callers:

@@
expression E1, E2;
@@
- sha1_array_lookup(E1, E2.hash)
+ sha1_array_lookup(E1, &E2)

@@
expression E1, E2;
@@
- sha1_array_lookup(E1, E2->hash)
+ sha1_array_lookup(E1, E2)

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoConvert remaining callers of sha1_array_lookup to object_id
brian m. carlson [Fri, 31 Mar 2017 01:39:57 +0000 (01:39 +0000)] 
Convert remaining callers of sha1_array_lookup to object_id

There are a very small number of callers which don't already use struct
object_id.  Convert them.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMake sha1_array_append take a struct object_id *
brian m. carlson [Fri, 31 Mar 2017 01:39:56 +0000 (01:39 +0000)] 
Make sha1_array_append take a struct object_id *

Convert the callers to pass struct object_id by changing the function
declaration and definition and applying the following semantic patch:

@@
expression E1, E2;
@@
- sha1_array_append(E1, E2.hash)
+ sha1_array_append(E1, &E2)

@@
expression E1, E2;
@@
- sha1_array_append(E1, E2->hash)
+ sha1_array_append(E1, E2)

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agodaemon: use an argv_array to exec children
Jeff King [Tue, 28 Mar 2017 19:48:10 +0000 (15:48 -0400)] 
daemon: use an argv_array to exec children

Our struct child_process already has its own argv_array.
Let's use that to avoid having to format options into
separate buffers.

Note that we'll need to declare the child process outside of
the run_service_command() helper to do this. But that opens
up a further simplification, which is that the helper can
append to our argument list, saving each caller from
specifying "." manually.

Signed-off-by: Jeff King <peff@peff.net>
7 years agogc: replace local buffer with git_path
Jeff King [Tue, 28 Mar 2017 19:47:03 +0000 (15:47 -0400)] 
gc: replace local buffer with git_path

We probe the "17/" loose object directory for auto-gc, and
use a local buffer to format the path. We can just use
git_path() for this. It handles paths of any length
(reducing our error handling). And because we feed the
result straight to a system call, we can just use the static
variant.

Note that git_path also knows the string "objects/" is
special, and will replace it with git_object_directory()
when necessary.

Another alternative would be to use sha1_file_name() for the
pretend object "170000...", but that ends up being more
hassle for no gain, as we have to truncate the final path
component.

Signed-off-by: Jeff King <peff@peff.net>
7 years agotransport-helper: replace checked snprintf with xsnprintf
Jeff King [Tue, 28 Mar 2017 19:47:00 +0000 (15:47 -0400)] 
transport-helper: replace checked snprintf with xsnprintf

We can use xsnprintf to do our truncation check with less
code. The error message isn't as specific, but the point is
that this isn't supposed to trigger in the first place
(because our buffer is big enough to handle any int).

Signed-off-by: Jeff King <peff@peff.net>
7 years agoconvert unchecked snprintf into xsnprintf
Jeff King [Tue, 28 Mar 2017 19:46:56 +0000 (15:46 -0400)] 
convert unchecked snprintf into xsnprintf

These calls to snprintf should always succeed, because their
input is small and fixed. Let's use xsnprintf to make sure
this is the case (and to make auditing for actual truncation
easier).

These could be candidates for turning into heap buffers, but
they fall into a few broad categories that make it not worth
doing:

  - formatting single numbers is simple enough that we can
    see the result should fit

  - the size of a sha1 is likewise well-known, and I didn't
    want to cause unnecessary conflicts with the ongoing
    process to convert these constants to GIT_MAX_HEXSZ

  - the interface for curl_errorstr is dictated by curl

Signed-off-by: Jeff King <peff@peff.net>
7 years agocombine-diff: replace malloc/snprintf with xstrfmt
Jeff King [Tue, 28 Mar 2017 19:46:53 +0000 (15:46 -0400)] 
combine-diff: replace malloc/snprintf with xstrfmt

There's no need to use the magic "100" when a strbuf can do
it for us.

Signed-off-by: Jeff King <peff@peff.net>
7 years agoreplace unchecked snprintf calls with heap buffers
Jeff King [Tue, 28 Mar 2017 19:46:50 +0000 (15:46 -0400)] 
replace unchecked snprintf calls with heap buffers

We'd prefer to avoid unchecked snprintf calls because
truncation can lead to unexpected results.

These are all cases where truncation shouldn't ever happen,
because the input to snprintf is fixed in size. That makes
them candidates for xsnprintf(), but it's simpler still to
just use the heap, and then nobody has to wonder if "100" is
big enough.

We'll use xstrfmt() where possible, and a strbuf when we need
the resulting size or to reuse the same buffer in a loop.

Signed-off-by: Jeff King <peff@peff.net>
7 years agoreceive-pack: print --pack-header directly into argv array
Jeff King [Tue, 28 Mar 2017 19:46:47 +0000 (15:46 -0400)] 
receive-pack: print --pack-header directly into argv array

After receive-pack reads the pack header from the client, it
feeds the already-read part to index-pack and unpack-objects
via their --pack-header command-line options.  To do so, we
format it into a fixed buffer, then duplicate it into the
child's argv_array.

Our buffer is long enough to handle any possible input, so
this isn't wrong. But it's more complicated than it needs to
be; we can just argv_array_pushf() the final value and avoid
the intermediate copy. This drops the magic number and is
more efficient, too.

Note that we need to push to the argv_array in order, which
means we can't do the push until we are in the "unpack-objects
versus index-pack" conditional.  Rather than duplicate the
slightly complicated format specifier, I pushed it into a
helper function.

Signed-off-by: Jeff King <peff@peff.net>
7 years agoname-rev: replace static buffer with strbuf
Jeff King [Tue, 28 Mar 2017 19:46:44 +0000 (15:46 -0400)] 
name-rev: replace static buffer with strbuf

When name-rev needs to format an actual name, we do so into
a fixed-size buffer. That includes the actual ref tip, as
well as any traversal information. Since refs can exceed
1024 bytes, this means you can get a bogus result. E.g.,
doing:

   git tag $(perl -e 'print join("/", 1..1024)')
   git describe --contains HEAD^

results in ".../282/283", when it should be
".../1023/1024~1".

We can solve this by using a heap buffer. We'll use a
strbuf, which lets us write into the same buffer from our
loop without having to reallocate.

Signed-off-by: Jeff King <peff@peff.net>
7 years agocreate_branch: use xstrfmt for reflog message
Jeff King [Tue, 28 Mar 2017 19:46:40 +0000 (15:46 -0400)] 
create_branch: use xstrfmt for reflog message

We generate a reflog message that contains some fixed text
plus a branch name, and use a buffer of size PATH_MAX + 20.
This mostly works if you assume that refnames are shorter
than PATH_MAX, but:

  1. That's not necessarily true. PATH_MAX is not always the
     filesystem's limit.

  2. The "20" is not sufficiently large for the fixed text
     anyway.

Let's just switch to a heap buffer so we don't have to even
care.

Signed-off-by: Jeff King <peff@peff.net>
7 years agocreate_branch: move msg setup closer to point of use
Jeff King [Tue, 28 Mar 2017 19:46:36 +0000 (15:46 -0400)] 
create_branch: move msg setup closer to point of use

In create_branch() we write the reflog msg into a buffer in
the main function, but then use it only inside a
conditional. If you carefully follow the logic, you can
confirm that we never use the buffer uninitialized nor write
when it would not be used. But we can make this a lot more
obvious by simply moving the write step inside the
conditional.

Signed-off-by: Jeff King <peff@peff.net>
7 years agoavoid using mksnpath for refs
Jeff King [Tue, 28 Mar 2017 19:46:33 +0000 (15:46 -0400)] 
avoid using mksnpath for refs

Like the previous commit, we'd like to avoid the assumption
that refs fit into PATH_MAX-sized buffers. These callsites
have an extra twist, though: they write the refnames using
mksnpath. This does two things beyond a regular snprintf:

  1. It quietly writes "/bad-path/" when truncation occurs.
     This saves the caller having to check the error code,
     but if you aren't actually feeding the result to a
     system call (and we aren't here), it's questionable.

  2. It calls cleanup_path(), which removes leading
     instances of "./".  That's questionable when dealing
     with refnames, as we could silently canonicalize a
     syntactically bogus refname into a valid one.

Let's convert each case to use a strbuf. This is preferable
to xstrfmt() because we can reuse the same buffer as we
loop.

Signed-off-by: Jeff King <peff@peff.net>
7 years agoavoid using fixed PATH_MAX buffers for refs
Jeff King [Tue, 28 Mar 2017 19:46:30 +0000 (15:46 -0400)] 
avoid using fixed PATH_MAX buffers for refs

Many functions which handle refs use a PATH_MAX-sized buffer
to do so. This is mostly reasonable as we have to write
loose refs into the filesystem, and at least on Linux the 4K
PATH_MAX is big enough that nobody would care. But:

  1. The static PATH_MAX is not always the filesystem limit.

  2. On other platforms, PATH_MAX may be much smaller.

  3. As we move to alternate ref storage, we won't be bound
     by filesystem limits.

Let's convert these to heap buffers so we don't have to
worry about truncation or size limits.

We may want to eventually constrain ref lengths for sanity
and to prevent malicious names, but we should do so
consistently across all platforms, and in a central place
(like the ref code).

Signed-off-by: Jeff King <peff@peff.net>
7 years agofetch: use heap buffer to format reflog
Jeff King [Tue, 28 Mar 2017 19:46:26 +0000 (15:46 -0400)] 
fetch: use heap buffer to format reflog

Part of the reflog content comes from the environment, which
can be much larger than our fixed buffer. Let's use a heap
buffer so we avoid truncating it.

Signed-off-by: Jeff King <peff@peff.net>
7 years agotag: use strbuf to format tag header
Jeff King [Tue, 28 Mar 2017 19:46:23 +0000 (15:46 -0400)] 
tag: use strbuf to format tag header

We format the tag header into a fixed 1024-byte buffer. But
since the tag-name and tagger ident can be arbitrarily
large, we may unceremoniously die with "tag header too big".
Let's just use a strbuf instead.

Note that it looks at first glance like we can just format
this directly into the "buf" strbuf where it will ultimately
go. But that buffer may already contain the tag message, and
we have no easy way to prepend formatted data to a strbuf
(we can only splice in an already-generated buffer). This
isn't a performance-critical path, so going through an extra
buffer isn't a big deal.

Signed-off-by: Jeff King <peff@peff.net>
7 years agodiff: avoid fixed-size buffer for patch-ids
Jeff King [Thu, 30 Mar 2017 18:26:05 +0000 (14:26 -0400)] 
diff: avoid fixed-size buffer for patch-ids

To generate a patch id, we format the diff header into a
fixed-size buffer, and then feed the result to our sha1
computation. The fixed buffer has size '4*PATH_MAX + 20',
which in theory accommodates the four filenames plus some
extra data. Except:

  1. The filenames may not be constrained to PATH_MAX. The
     static value may not be a real limit on the current
     filesystem. Moreover, we may compute patch-ids for
     names stored only in git, without touching the current
     filesystem at all.

  2. The 20 bytes is not nearly enough to cover the
     extra content we put in the buffer.

As a result, the data we feed to the sha1 computation may be
truncated, and it's possible that a commit with a very long
filename could erroneously collide in the patch-id space
with another commit. For instance, if one commit modified
"really-long-filename/foo" and another modified "bar" in the
same directory.

In practice this is unlikely. Because the filenames are
repeated, and because there's a single cutoff at the end of
the buffer, the offending filename would have to be on the
order of four times larger than PATH_MAX.

We could fix this by moving to a strbuf. However, we can
observe that the purpose of formatting this in the first
place is to feed it to git_SHA1_Update(). So instead, let's
just feed each part of the formatted string directly. This
actually ends up more readable, and we can even factor out
some duplicated bits from the various conditional branches.

Technically this may change the output of patch-id for very
long filenames, but it's not worth making an exception for
this in the --stable output. It was a bug, and one that only
affected an unlikely set of paths.  And anyway, the exact
value would have varied from platform to platform depending
on the value of PATH_MAX, so there is no "stable" value.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoSync with master
Junio C Hamano [Thu, 30 Mar 2017 21:26:03 +0000 (14:26 -0700)] 
Sync with master

* master:
  Tenth batch for 2.13

7 years agoMerge branch 'cc/untracked' into next
Junio C Hamano [Thu, 30 Mar 2017 21:25:56 +0000 (14:25 -0700)] 
Merge branch 'cc/untracked' into next

* cc/untracked:
  update-index: fix xgetcwd() related memory leak

7 years agoMerge branch 'jk/make-coccicheck-detect-errors' into next
Junio C Hamano [Thu, 30 Mar 2017 21:25:55 +0000 (14:25 -0700)] 
Merge branch 'jk/make-coccicheck-detect-errors' into next

Build fix.

* jk/make-coccicheck-detect-errors:
  Makefile: detect errors in running spatch

7 years agoMerge branch 'bc/push-cert-receive-fix' into next
Junio C Hamano [Thu, 30 Mar 2017 21:25:55 +0000 (14:25 -0700)] 
Merge branch 'bc/push-cert-receive-fix' into next

"git receive-pack" could have been forced to die by attempting
allocate an unreasonably large amount of memory with a crafted push
certificate; this has been fixed.

* bc/push-cert-receive-fix:
  builtin/receive-pack: fix incorrect pointer arithmetic

7 years agoMerge branch 'mh/notes-tree-consolidate-fix' into next
Junio C Hamano [Thu, 30 Mar 2017 21:25:54 +0000 (14:25 -0700)] 
Merge branch 'mh/notes-tree-consolidate-fix' into next

Removing an entry from a notes tree and then looking another note
entry from the resulting tree using the internal notes API
functions did not work as expected.  No in-tree users of the API
has such access pattern, but it still is worth fixing.

* mh/notes-tree-consolidate-fix:
  notes: do not break note_tree structure in note_tree_consolidate()

7 years agoTenth batch for 2.13
Junio C Hamano [Thu, 30 Mar 2017 21:14:32 +0000 (14:14 -0700)] 
Tenth batch for 2.13

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMerge branch 'jk/make-coccicheck-detect-errors'
Junio C Hamano [Thu, 30 Mar 2017 21:07:19 +0000 (14:07 -0700)] 
Merge branch 'jk/make-coccicheck-detect-errors'

Build fix.

* jk/make-coccicheck-detect-errors:
  Makefile: detect errors in running spatch

7 years agoMerge branch 'bc/push-cert-receive-fix'
Junio C Hamano [Thu, 30 Mar 2017 21:07:18 +0000 (14:07 -0700)] 
Merge branch 'bc/push-cert-receive-fix'

"git receive-pack" could have been forced to die by attempting
allocate an unreasonably large amount of memory with a crafted push
certificate; this has been fixed.

* bc/push-cert-receive-fix:
  builtin/receive-pack: fix incorrect pointer arithmetic

7 years agoMerge branch 'mh/notes-tree-consolidate-fix'
Junio C Hamano [Thu, 30 Mar 2017 21:07:17 +0000 (14:07 -0700)] 
Merge branch 'mh/notes-tree-consolidate-fix'

Removing an entry from a notes tree and then looking another note
entry from the resulting tree using the internal notes API
functions did not work as expected.  No in-tree users of the API
has such access pattern, but it still is worth fixing.

* mh/notes-tree-consolidate-fix:
  notes: do not break note_tree structure in note_tree_consolidate()

7 years agoMerge branch 'js/rebase-i-reword-to-run-hooks'
Junio C Hamano [Thu, 30 Mar 2017 21:07:17 +0000 (14:07 -0700)] 
Merge branch 'js/rebase-i-reword-to-run-hooks'

A recent update to "rebase -i" stopped running hooks for the "git
commit" command during "reword" action, which has been fixed.

* js/rebase-i-reword-to-run-hooks:
  sequencer: allow the commit-msg hooks to run during a `reword`
  sequencer: make commit options more extensible
  t7504: document regression: reword no longer calls commit-msg

7 years agoMerge branch 'mg/describe-debug-l10n'
Junio C Hamano [Thu, 30 Mar 2017 21:07:17 +0000 (14:07 -0700)] 
Merge branch 'mg/describe-debug-l10n'

Some debugging output from "git describe" were marked for l10n,
but some weren't.  Mark missing ones for l10n.

* mg/describe-debug-l10n:
  l10n: de: translate describe debug terms
  describe: localize debug output fully

7 years agoMerge branch 'ab/case-insensitive-upstream-and-push-marker'
Junio C Hamano [Thu, 30 Mar 2017 21:07:16 +0000 (14:07 -0700)] 
Merge branch 'ab/case-insensitive-upstream-and-push-marker'

On many keyboards, typing "@{" involves holding down SHIFT key and
one can easily end up with "@{Up..." when typing "@{upstream}".  As
the upstream/push keywords do not appear anywhere else in the syntax,
we can safely accept them case insensitively without introducing
ambiguity or confusion  to solve this.

* ab/case-insensitive-upstream-and-push-marker:
  rev-parse: match @{upstream}, @{u} and @{push} case-insensitively

7 years agoMerge branch 'ab/doc-submitting'
Junio C Hamano [Thu, 30 Mar 2017 21:07:16 +0000 (14:07 -0700)] 
Merge branch 'ab/doc-submitting'

Doc update.

* ab/doc-submitting:
  doc/SubmittingPatches: show how to get a CLI commit summary
  doc/SubmittingPatches: clarify the casing convention for "area: change..."

7 years agoMerge branch 'ab/test-readme-updates'
Junio C Hamano [Thu, 30 Mar 2017 21:07:16 +0000 (14:07 -0700)] 
Merge branch 'ab/test-readme-updates'

Doc updates.

* ab/test-readme-updates:
  t/README: clarify the test_have_prereq documentation
  t/README: change "Inside <X> part" to "Inside the <X> part"
  t/README: link to metacpan.org, not search.cpan.org

7 years agoMerge branch 'rs/freebsd-getcwd-workaround'
Junio C Hamano [Thu, 30 Mar 2017 21:07:15 +0000 (14:07 -0700)] 
Merge branch 'rs/freebsd-getcwd-workaround'

FreeBSD implementation of getcwd(3) behaved differently when an
intermediate directory is unreadable/unsearchable depending on the
length of the buffer provided, which our strbuf_getcwd() was not
aware of.  strbuf_getcwd() has been taught to cope with it better.

* rs/freebsd-getcwd-workaround:
  strbuf: support long paths w/o read rights in strbuf_getcwd() on FreeBSD

7 years agoMerge branch 'bw/recurse-submodules-relative-fix'
Junio C Hamano [Thu, 30 Mar 2017 21:07:15 +0000 (14:07 -0700)] 
Merge branch 'bw/recurse-submodules-relative-fix'

A few commands that recently learned the "--recurse-submodule"
option misbehaved when started from a subdirectory of the
superproject.

* bw/recurse-submodules-relative-fix:
  ls-files: fix bug when recursing with relative pathspec
  ls-files: fix typo in variable name
  grep: fix bug when recursing with relative pathspec
  setup: allow for prefix to be passed to git commands
  grep: fix help text typo

7 years agoMerge branch 'sg/completion-ctags'
Junio C Hamano [Thu, 30 Mar 2017 21:07:15 +0000 (14:07 -0700)] 
Merge branch 'sg/completion-ctags'

Command line completion updates.

* sg/completion-ctags:
  completion: offer ctags symbol names for 'git log -S', '-G' and '-L:'
  completion: extract completing ctags symbol names into helper function
  completion: put matching ctags symbol names directly into COMPREPLY

7 years agoMerge branch 'sg/completion-refs-speedup'
Junio C Hamano [Thu, 30 Mar 2017 21:07:14 +0000 (14:07 -0700)] 
Merge branch 'sg/completion-refs-speedup'

The refs completion for large number of refs has been sped up,
partly by giving up disambiguating ambiguous refs and partly by
eliminating most of the shell processing between 'git for-each-ref'
and 'ls-remote' and Bash's completion facility.

* sg/completion-refs-speedup:
  completion: speed up branch and tag completion
  completion: fill COMPREPLY directly when completing fetch refspecs
  completion: fill COMPREPLY directly when completing refs
  completion: let 'for-each-ref' sort remote branches for 'checkout' DWIMery
  completion: let 'for-each-ref' filter remote branches for 'checkout' DWIMery
  completion: let 'for-each-ref' strip the remote name from remote branches
  completion: let 'for-each-ref' and 'ls-remote' filter matching refs
  completion: don't disambiguate short refs
  completion: don't disambiguate tags and branches
  completion: support excluding full refs
  completion: support completing fully qualified non-fast-forward refspecs
  completion: support completing full refs after '--option=refs/<TAB>'
  completion: wrap __git_refs() for better option parsing
  completion: remove redundant __gitcomp_nl() options from _git_commit()

7 years agoMerge branch 'bw/submodule-is-active'
Junio C Hamano [Thu, 30 Mar 2017 21:07:14 +0000 (14:07 -0700)] 
Merge branch 'bw/submodule-is-active'

"what URL do we want to update this submodule?" and "are we
interested in this submodule?" are split into two distinct
concepts, and then the way used to express the latter got extended,
paving a way to make it easier to manage a project with many
submodules and make it possible to later extend use of multiple
worktrees for a project with submodules.

* bw/submodule-is-active:
  submodule add: respect submodule.active and submodule.<name>.active
  submodule--helper init: set submodule.<name>.active
  clone: teach --recurse-submodules to optionally take a pathspec
  submodule init: initialize active submodules
  submodule: decouple url and submodule interest
  submodule--helper clone: check for configured submodules using helper
  submodule sync: use submodule--helper is-active
  submodule sync: skip work for inactive submodules
  submodule status: use submodule--helper is-active
  submodule--helper: add is-active subcommand

7 years agoMerge branch 'jk/no-looking-at-dotgit-outside-repo-final'
Junio C Hamano [Thu, 30 Mar 2017 21:07:13 +0000 (14:07 -0700)] 
Merge branch 'jk/no-looking-at-dotgit-outside-repo-final'

This is the endgame of the topic to avoid blindly falling back to
".git" when the setup sequence said we are _not_ in Git repository.
A corner case that happens to work right now may be broken by a
call to die("BUG").

* jk/no-looking-at-dotgit-outside-repo-final:
  setup_git_env: avoid blind fall-back to ".git"

7 years agoMerge branch 'jc/merge-drop-old-syntax'
Junio C Hamano [Thu, 30 Mar 2017 21:07:13 +0000 (14:07 -0700)] 
Merge branch 'jc/merge-drop-old-syntax'

Stop supporting "git merge <message> HEAD <commit>" syntax that has
been deprecated since October 2007, and issues a deprecation
warning message since v2.5.0.

* jc/merge-drop-old-syntax:
  merge: drop 'git merge <message> HEAD <commit>' syntax

7 years agodifftool: avoid strcpy
Jeff King [Thu, 30 Mar 2017 10:35:50 +0000 (06:35 -0400)] 
difftool: avoid strcpy

In order to checkout files, difftool reads "diff --raw"
output and feeds the names to checkout_entry(). That
function requires us to have a "struct cache_entry". And
because that struct uses a FLEX_ARRAY for the name field, we
have to actually copy in our new name.

The current code allocates a single re-usable cache_entry
that can hold a name up to PATH_MAX, and then copies
filenames into it using strcpy(). But there's no guarantee
that incoming names are smaller than PATH_MAX. They've come
from "diff --raw" output which might be diffing between two
trees (and hence we'd be subject to the PATH_MAX of some
other system, or even none at all if they were created
directly via "update-index").

We can fix this by using make_cache_entry() to create a
correctly-sized cache_entry for each name. This incurs an
extra allocation per file, but this is negligible compared
to actually writing out the file contents.

To make this simpler, we can push this procedure into a new
helper function. Note that we can also get rid of the "len"
variables for src_path and dst_path (and in fact we must, as
the compiler complains that they are unused).

Signed-off-by: Jeff King <peff@peff.net>
Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoupdate-index: fix xgetcwd() related memory leak
Christian Couder [Thu, 30 Mar 2017 06:22:08 +0000 (08:22 +0200)] 
update-index: fix xgetcwd() related memory leak

As xgetcwd() returns an allocated buffer, we should free this
buffer when we don't need it any more.

This was found by Coverity.

Reported-by: Jeff King <peff@peff.net>
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agosubmodule.c: correctly handle nested submodules in is_submodule_modified
Stefan Beller [Wed, 29 Mar 2017 22:26:16 +0000 (15:26 -0700)] 
submodule.c: correctly handle nested submodules in is_submodule_modified

Suppose I have a superproject 'super', with two submodules 'super/sub'
and 'super/sub1'. 'super/sub' itself contains a submodule
'super/sub/subsub'. Now suppose I run, from within 'super':

    echo hi >sub/subsub/stray-file
    echo hi >sub1/stray-file

Currently we get would see the following output in git-status:

    git status --short
     m sub
     ? sub1

With this patch applied, the untracked file in the nested submodule is
displayed as an untracked file on the 'super' level as well.

    git status --short
     ? sub
     ? sub1

This doesn't change the output of 'git status --porcelain=1' for nested
submodules, because its output is always ' M' for either untracked files
or local modifications no matter the nesting level of the submodule.

'git status --porcelain=2' is affected by this change in a nested
submodule, though. Without this patch it would report the direct submodule
as modified and having no untracked files. With this patch it would report
untracked files. Chalk this up as a bug fix.

This bug fix also affects the default output (non-short, non-porcelain)
of git-status, which is not tested here.

Signed-off-by: Stefan Beller <sbeller@google.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>