git
7 years agoSync with 2.13-rc0 oblomov/request-pull
Junio C Hamano [Thu, 20 Apr 2017 05:13:59 +0000 (22:13 -0700)] 
Sync with 2.13-rc0

* master:
  Git 2.13-rc0

7 years agoMerge branch 'gb/rebase-signoff' into next
Junio C Hamano [Thu, 20 Apr 2017 05:10:16 +0000 (22:10 -0700)] 
Merge branch 'gb/rebase-signoff' into next

"git rebase" learns "--signoff" option.

* gb/rebase-signoff:
  rebase: pass --[no-]signoff option to git am
  builtin/am: fold am_signoff() into am_append_signoff()
  builtin/am: honor --signoff also when --rebasing

7 years agoMerge branch 'dt/xgethostname-nul-termination' into next
Junio C Hamano [Thu, 20 Apr 2017 05:10:16 +0000 (22:10 -0700)] 
Merge branch 'dt/xgethostname-nul-termination' into next

gethostname(2) may not NUL terminate the buffer if hostname does
not fit; unfortunately there is no easy way to see if our buffer
was too small, but at least this will make sure we will not end up
using garbage past the end of the buffer.

* dt/xgethostname-nul-termination:
  xgethostname: handle long hostnames
  use HOST_NAME_MAX to size buffers for gethostname(2)

7 years agoMerge branch 'jk/ls-files-recurse-submodules-fix' into next
Junio C Hamano [Thu, 20 Apr 2017 05:10:15 +0000 (22:10 -0700)] 
Merge branch 'jk/ls-files-recurse-submodules-fix' into next

"ls-files --recurse-submodules" did not quite work well in a
project with nested submodules.

* jk/ls-files-recurse-submodules-fix:
  ls-files: fix path used when recursing into submodules
  ls-files: fix recurse-submodules with nested submodules

7 years agoMerge branch 'rs/misc-cppcheck-fixes' into next
Junio C Hamano [Thu, 20 Apr 2017 05:10:14 +0000 (22:10 -0700)] 
Merge branch 'rs/misc-cppcheck-fixes' into next

Various small fixes.

* rs/misc-cppcheck-fixes:
  server-info: avoid calling fclose(3) twice in update_info_file()
  files_for_each_reflog_ent_reverse(): close stream and free strbuf on error
  am: close stream on error, but not stdin

7 years agoMerge branch 'jk/snprintf-cleanups' into next
Junio C Hamano [Thu, 20 Apr 2017 05:10:14 +0000 (22:10 -0700)] 
Merge branch 'jk/snprintf-cleanups' into next

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

* jk/snprintf-cleanups:
  replace: plug a memory leak

7 years agoMerge branch 'xy/format-patch-base' into next
Junio C Hamano [Thu, 20 Apr 2017 05:10:13 +0000 (22:10 -0700)] 
Merge branch 'xy/format-patch-base' into next

Doc cleanup.

* xy/format-patch-base:
  doc: trivial typo in git-format-patch.txt

7 years agoMerge branch 'sb/checkout-recurse-submodules' into next
Junio C Hamano [Thu, 20 Apr 2017 05:10:12 +0000 (22:10 -0700)] 
Merge branch 'sb/checkout-recurse-submodules' into next

Code cleanup.

* sb/checkout-recurse-submodules:
  submodule: remove a superfluous second check for the "new" variable

7 years agoMerge branch 'jt/fetch-pack-error-reporting' into next
Junio C Hamano [Thu, 20 Apr 2017 05:10:11 +0000 (22:10 -0700)] 
Merge branch 'jt/fetch-pack-error-reporting' into next

"git fetch-pack" was not prepared to accept ERR packet that the
upload-pack can send with a human-readable error message.  It
showed the packet contents with ERR prefix, so there was no data
loss, but it was redundant to say "ERR" in an error message.

* jt/fetch-pack-error-reporting:
  fetch-pack: show clearer error message upon ERR

7 years agoMerge branch 'km/t1400-modernization' into next
Junio C Hamano [Thu, 20 Apr 2017 05:10:10 +0000 (22:10 -0700)] 
Merge branch 'km/t1400-modernization' into next

Code cleanup.

* km/t1400-modernization:
  t1400: use consistent style for test_expect_success calls

7 years agoMerge branch 'jk/quarantine-received-objects' into next
Junio C Hamano [Thu, 20 Apr 2017 05:10:09 +0000 (22:10 -0700)] 
Merge branch 'jk/quarantine-received-objects' into next

Add finishing touches to a recent topic.

* jk/quarantine-received-objects:
  refs: reject ref updates while GIT_QUARANTINE_PATH is set
  receive-pack: document user-visible quarantine effects
  receive-pack: drop tmp_objdir_env from run_update_hook

7 years agoMerge branch 'jk/loose-object-fsck' into next
Junio C Hamano [Thu, 20 Apr 2017 05:10:08 +0000 (22:10 -0700)] 
Merge branch 'jk/loose-object-fsck' into next

Code cleanup.

* jk/loose-object-fsck:
  sha1_file: remove an used fd variable

7 years agoMerge branch 'bw/submodule-with-bs-path' into next
Junio C Hamano [Thu, 20 Apr 2017 05:10:07 +0000 (22:10 -0700)] 
Merge branch 'bw/submodule-with-bs-path' into next

"git submodule" script does not work well with strange pathnames.
Protect it from a path with slashes in them, at least.

* bw/submodule-with-bs-path:
  submodule: prevent backslash expantion in submodule names

7 years agoMerge branch 'ls/travis-doc-asciidoctor' into next
Junio C Hamano [Thu, 20 Apr 2017 05:10:07 +0000 (22:10 -0700)] 
Merge branch 'ls/travis-doc-asciidoctor' into next

Have Travis CI format the documentation with both AsciiDoc and
AsciiDoctor.

* ls/travis-doc-asciidoctor:
  travis-ci: unset compiler for jobs that do not need one
  travis-ci: parallelize documentation build
  travis-ci: build documentation with AsciiDoc and Asciidoctor

7 years agoMerge branch 'jh/verify-index-checksum-only-in-fsck' into next
Junio C Hamano [Thu, 20 Apr 2017 05:10:06 +0000 (22:10 -0700)] 
Merge branch 'jh/verify-index-checksum-only-in-fsck' into next

The index file has a trailing SHA-1 checksum to detect file
corruption, and historically we checked it every time the index
file is used.  Omit the validation during normal use, and instead
verify only in "git fsck".

* jh/verify-index-checksum-only-in-fsck:
  read-cache: force_verify_index_checksum

7 years agoMerge branch 'jh/unpack-trees-micro-optim' into next
Junio C Hamano [Thu, 20 Apr 2017 05:10:05 +0000 (22:10 -0700)] 
Merge branch 'jh/unpack-trees-micro-optim' into next

In a 2- and 3-way merge of trees, more than one source trees often
end up sharing an identical subtree; optimize by not reading the
same tree multiple times in such a case.

* jh/unpack-trees-micro-optim:
  unpack-trees: avoid duplicate ODB lookups during checkout

7 years agoMerge branch 'jh/string-list-micro-optim' into next
Junio C Hamano [Thu, 20 Apr 2017 05:10:04 +0000 (22:10 -0700)] 
Merge branch 'jh/string-list-micro-optim' into next

The string-list API used a custom reallocation strategy that was
very inefficient, instead of using the usual ALLOC_GROW() macro,
which has been fixed.

* jh/string-list-micro-optim:
  string-list: use ALLOC_GROW macro when reallocing string_list

7 years agoMerge branch 'nd/conditional-config-include' into next
Junio C Hamano [Thu, 20 Apr 2017 05:10:03 +0000 (22:10 -0700)] 
Merge branch 'nd/conditional-config-include' into next

$GIT_DIR may in some cases be normalized with all symlinks resolved
while "gitdir" path expansion in the pattern does not receive the
same treatment, leading to incorrect mismatch.  This has been fixed.

* nd/conditional-config-include:
  config: resolve symlinks in conditional include's patterns
  path.c: and an option to call real_path() in expand_user_path()

7 years agoMerge branch 'dt/http-postbuffer-can-be-large' into next
Junio C Hamano [Thu, 20 Apr 2017 05:10:02 +0000 (22:10 -0700)] 
Merge branch 'dt/http-postbuffer-can-be-large' into next

Allow the http.postbuffer configuration variable to be set to a
size that can be expressed in size_t, which can be larger than
ulong on some platforms.

* dt/http-postbuffer-can-be-large:
  http.postbuffer: allow full range of ssize_t values

7 years agoMerge branch 'tb/doc-eol-normalization' into next
Junio C Hamano [Thu, 20 Apr 2017 05:10:01 +0000 (22:10 -0700)] 
Merge branch 'tb/doc-eol-normalization' into next

Doc update.

* tb/doc-eol-normalization:
  gitattributes.txt: document how to normalize the line endings

7 years agoMerge branch 'sr/http-proxy-configuration-fix' into next
Junio C Hamano [Thu, 20 Apr 2017 05:10:00 +0000 (22:10 -0700)] 
Merge branch 'sr/http-proxy-configuration-fix' into next

"http.proxy" set to an empty string is used to disable the usage of
proxy.  We broke this early last year.

* sr/http-proxy-configuration-fix:
  http: fix the silent ignoring of proxy misconfiguraion
  http: honor empty http.proxy option to bypass proxy

7 years agoGit 2.13-rc0 v2.13.0-rc0
Junio C Hamano [Thu, 20 Apr 2017 04:42:08 +0000 (21:42 -0700)] 
Git 2.13-rc0

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMerge branch 'jh/memihash-opt'
Junio C Hamano [Thu, 20 Apr 2017 04:37:25 +0000 (21:37 -0700)] 
Merge branch 'jh/memihash-opt'

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

* jh/memihash-opt:
  p0004: make perf test executable
  t3008: skip lazy-init test on a single-core box
  test-online-cpus: helper to return cpu count
  name-hash: fix buffer overrun

7 years agoMerge branch 'vn/revision-shorthand-for-side-branch-log'
Junio C Hamano [Thu, 20 Apr 2017 04:37:25 +0000 (21:37 -0700)] 
Merge branch 'vn/revision-shorthand-for-side-branch-log'

Doc cleanup.

* vn/revision-shorthand-for-side-branch-log:
  doc/revisions: remove brackets from rev^-n shorthand

7 years agoMerge branch 'sf/putty-w-args'
Junio C Hamano [Thu, 20 Apr 2017 04:37:24 +0000 (21:37 -0700)] 
Merge branch 'sf/putty-w-args'

* sf/putty-w-args:
  connect.c: handle errors from split_cmdline

7 years agoMerge branch 'ld/p4-current-branch-fix'
Junio C Hamano [Thu, 20 Apr 2017 04:37:23 +0000 (21:37 -0700)] 
Merge branch 'ld/p4-current-branch-fix'

"git p4" used "name-rev HEAD" when it wants to learn what branch is
checked out; it should use "symbolic-ref HEAD".

* ld/p4-current-branch-fix:
  git-p4: don't use name-rev to get current branch
  git-p4: add read_pipe_text() internal function
  git-p4: add failing test for name-rev rather than symbolic-ref

7 years agoMerge branch 'dt/gc-ignore-old-gc-logs'
Junio C Hamano [Thu, 20 Apr 2017 04:37:22 +0000 (21:37 -0700)] 
Merge branch 'dt/gc-ignore-old-gc-logs'

* dt/gc-ignore-old-gc-logs:
  t6500: wait for detached auto gc at the end of the test script

7 years agoMerge branch 'bw/attr-pathspec'
Junio C Hamano [Thu, 20 Apr 2017 04:37:21 +0000 (21:37 -0700)] 
Merge branch 'bw/attr-pathspec'

* bw/attr-pathspec:
  pathspec: fix segfault in clear_pathspec

7 years agoMerge branch 'ab/grep-plug-pathspec-leak'
Junio C Hamano [Thu, 20 Apr 2017 04:37:21 +0000 (21:37 -0700)] 
Merge branch 'ab/grep-plug-pathspec-leak'

Call clear_pathspec() to release resources immediately before the
cmd_grep() function returns.

* ab/grep-plug-pathspec-leak:
  grep: plug a trivial memory leak

7 years agoMerge branch 'jk/no-looking-at-dotgit-outside-repo'
Junio C Hamano [Thu, 20 Apr 2017 04:37:20 +0000 (21:37 -0700)] 
Merge branch 'jk/no-looking-at-dotgit-outside-repo'

Clean up fallouts from recent tightening of the set-up sequence,
where Git barfs when repository information is accessed without
first ensuring that it was started in a repository.

* jk/no-looking-at-dotgit-outside-repo:
  test-read-cache: setup git dir
  has_sha1_file: don't bother if we are not in a repository

7 years agoMerge branch 'nd/files-backend-git-dir'
Junio C Hamano [Thu, 20 Apr 2017 04:37:19 +0000 (21:37 -0700)] 
Merge branch 'nd/files-backend-git-dir'

The "submodule" specific field in the ref_store structure is
replaced with a more generic "gitdir" that can later be used also
when dealing with ref_store that represents the set of refs visible
from the other worktrees.

* nd/files-backend-git-dir: (28 commits)
  refs.h: add a note about sorting order of for_each_ref_*
  t1406: new tests for submodule ref store
  t1405: some basic tests on main ref store
  t/helper: add test-ref-store to test ref-store functions
  refs: delete pack_refs() in favor of refs_pack_refs()
  files-backend: avoid ref api targeting main ref store
  refs: new transaction related ref-store api
  refs: add new ref-store api
  refs: rename get_ref_store() to get_submodule_ref_store() and make it public
  files-backend: replace submodule_allowed check in files_downcast()
  refs: move submodule code out of files-backend.c
  path.c: move some code out of strbuf_git_path_submodule()
  refs.c: make get_main_ref_store() public and use it
  refs.c: kill register_ref_store(), add register_submodule_ref_store()
  refs.c: flatten get_ref_store() a bit
  refs: rename lookup_ref_store() to lookup_submodule_ref_store()
  refs.c: introduce get_main_ref_store()
  files-backend: remove the use of git_path()
  files-backend: add and use files_ref_path()
  files-backend: add and use files_reflog_path()
  ...

7 years agoMerge branch 'bw/submodule-is-active'
Junio C Hamano [Thu, 20 Apr 2017 04:37:18 +0000 (21:37 -0700)] 
Merge branch 'bw/submodule-is-active'

Error message fix.

* bw/submodule-is-active:
  submodule--helper: fix typo in is_active error message

7 years agoMerge branch 'va/i18n-perl-scripts'
Junio C Hamano [Thu, 20 Apr 2017 04:37:17 +0000 (21:37 -0700)] 
Merge branch 'va/i18n-perl-scripts'

Message fix.

* va/i18n-perl-scripts:
  git-add--interactive.perl: add missing dot in a message

7 years agoMerge branch 'sb/submodule-rm-absorb'
Junio C Hamano [Thu, 20 Apr 2017 04:37:17 +0000 (21:37 -0700)] 
Merge branch 'sb/submodule-rm-absorb'

Error message fix.

* sb/submodule-rm-absorb:
  submodule.c: add missing ' in error messages

7 years agoMerge branch 'ah/diff-files-ours-theirs-doc'
Junio C Hamano [Thu, 20 Apr 2017 04:37:16 +0000 (21:37 -0700)] 
Merge branch 'ah/diff-files-ours-theirs-doc'

The diff options "--ours", "--theirs" exist for quite some time.
But so far they were not documented. Now they are.

* ah/diff-files-ours-theirs-doc:
  diff-files: document --ours etc.

7 years agoMerge branch 'lt/mailinfo-in-body-header-continuation'
Junio C Hamano [Thu, 20 Apr 2017 04:37:15 +0000 (21:37 -0700)] 
Merge branch 'lt/mailinfo-in-body-header-continuation'

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'
Junio C Hamano [Thu, 20 Apr 2017 04:37:14 +0000 (21:37 -0700)] 
Merge branch 'bw/push-options-recursively-to-submodules'

"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'
Junio C Hamano [Thu, 20 Apr 2017 04:37:13 +0000 (21:37 -0700)] 
Merge branch 'bc/object-id'

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'
Junio C Hamano [Thu, 20 Apr 2017 04:37:12 +0000 (21:37 -0700)] 
Merge branch 'sb/submodule-short-status'

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 agoMerge branch 'nd/files-backend-git-dir' into next oblomov/worktree-add-existing
Junio C Hamano [Wed, 19 Apr 2017 05:36:38 +0000 (22:36 -0700)] 
Merge branch 'nd/files-backend-git-dir' into next

The "submodule" specific field in the ref_store structure is
replaced with a more generic "gitdir" that can later be used also
when dealing with ref_store that represents the set of refs visible
from the other worktrees.

* nd/files-backend-git-dir: (28 commits)
  refs.h: add a note about sorting order of for_each_ref_*
  t1406: new tests for submodule ref store
  t1405: some basic tests on main ref store
  t/helper: add test-ref-store to test ref-store functions
  refs: delete pack_refs() in favor of refs_pack_refs()
  files-backend: avoid ref api targeting main ref store
  refs: new transaction related ref-store api
  refs: add new ref-store api
  refs: rename get_ref_store() to get_submodule_ref_store() and make it public
  files-backend: replace submodule_allowed check in files_downcast()
  refs: move submodule code out of files-backend.c
  path.c: move some code out of strbuf_git_path_submodule()
  refs.c: make get_main_ref_store() public and use it
  refs.c: kill register_ref_store(), add register_submodule_ref_store()
  refs.c: flatten get_ref_store() a bit
  refs: rename lookup_ref_store() to lookup_submodule_ref_store()
  refs.c: introduce get_main_ref_store()
  files-backend: remove the use of git_path()
  files-backend: add and use files_ref_path()
  files-backend: add and use files_reflog_path()
  ...

7 years agoMerge branch 'jk/no-looking-at-dotgit-outside-repo' into next
Junio C Hamano [Wed, 19 Apr 2017 05:36:37 +0000 (22:36 -0700)] 
Merge branch 'jk/no-looking-at-dotgit-outside-repo' into next

Clean up fallouts from recent tightening of the set-up sequence,
where Git barfs when repository information is accessed without
first ensuring that it was started in a repository.

* jk/no-looking-at-dotgit-outside-repo:
  test-read-cache: setup git dir
  has_sha1_file: don't bother if we are not in a repository

7 years agoMerge branch 'vn/revision-shorthand-for-side-branch-log' into next
Junio C Hamano [Wed, 19 Apr 2017 05:36:36 +0000 (22:36 -0700)] 
Merge branch 'vn/revision-shorthand-for-side-branch-log' into next

Doc cleanup.

* vn/revision-shorthand-for-side-branch-log:
  doc/revisions: remove brackets from rev^-n shorthand

7 years agoMerge branch 'sf/putty-w-args' into next
Junio C Hamano [Wed, 19 Apr 2017 05:36:35 +0000 (22:36 -0700)] 
Merge branch 'sf/putty-w-args' into next

* sf/putty-w-args:
  connect.c: handle errors from split_cmdline

7 years agoMerge branch 'ld/p4-current-branch-fix' into next
Junio C Hamano [Wed, 19 Apr 2017 05:36:35 +0000 (22:36 -0700)] 
Merge branch 'ld/p4-current-branch-fix' into next

"git p4" used "name-rev HEAD" when it wants to learn what branch is
checked out; it should use "symbolic-ref HEAD".

* ld/p4-current-branch-fix:
  git-p4: don't use name-rev to get current branch
  git-p4: add read_pipe_text() internal function
  git-p4: add failing test for name-rev rather than symbolic-ref

7 years agoMerge branch 'dt/gc-ignore-old-gc-logs' into next
Junio C Hamano [Wed, 19 Apr 2017 05:36:34 +0000 (22:36 -0700)] 
Merge branch 'dt/gc-ignore-old-gc-logs' into next

* dt/gc-ignore-old-gc-logs:
  t6500: wait for detached auto gc at the end of the test script

7 years agoMerge branch 'bw/attr-pathspec' into next
Junio C Hamano [Wed, 19 Apr 2017 05:36:33 +0000 (22:36 -0700)] 
Merge branch 'bw/attr-pathspec' into next

* bw/attr-pathspec:
  pathspec: fix segfault in clear_pathspec

7 years agoMerge branch 'ab/grep-plug-pathspec-leak' into next
Junio C Hamano [Wed, 19 Apr 2017 05:36:32 +0000 (22:36 -0700)] 
Merge branch 'ab/grep-plug-pathspec-leak' into next

Call clear_pathspec() to release resources immediately before the
cmd_grep() function returns.

* ab/grep-plug-pathspec-leak:
  grep: plug a trivial memory leak

7 years agoMerge branch 'bw/submodule-is-active' into next
Junio C Hamano [Wed, 19 Apr 2017 05:36:31 +0000 (22:36 -0700)] 
Merge branch 'bw/submodule-is-active' into next

Error message fix.

* bw/submodule-is-active:
  submodule--helper: fix typo in is_active error message

7 years agoMerge branch 'va/i18n-perl-scripts' into next
Junio C Hamano [Wed, 19 Apr 2017 05:36:31 +0000 (22:36 -0700)] 
Merge branch 'va/i18n-perl-scripts' into next

Message fix.

* va/i18n-perl-scripts:
  git-add--interactive.perl: add missing dot in a message

7 years agoMerge branch 'sb/submodule-rm-absorb' into next
Junio C Hamano [Wed, 19 Apr 2017 05:36:30 +0000 (22:36 -0700)] 
Merge branch 'sb/submodule-rm-absorb' into next

Error message fix.

* sb/submodule-rm-absorb:
  submodule.c: add missing ' in error messages

7 years agoMerge branch 'ah/diff-files-ours-theirs-doc' into next
Junio C Hamano [Wed, 19 Apr 2017 05:36:29 +0000 (22:36 -0700)] 
Merge branch 'ah/diff-files-ours-theirs-doc' into next

The diff options "--ours", "--theirs" exist for quite some time.
But so far they were not documented. Now they are.

* ah/diff-files-ours-theirs-doc:
  diff-files: document --ours etc.

7 years agoMerge branch 'jh/memihash-opt' into next
Junio C Hamano [Wed, 19 Apr 2017 03:57:40 +0000 (20:57 -0700)] 
Merge branch 'jh/memihash-opt' into next

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

* jh/memihash-opt:
  p0004: make perf test executable

7 years agorebase: pass --[no-]signoff option to git am
Giuseppe Bilotta [Tue, 18 Apr 2017 09:29:05 +0000 (11:29 +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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoxgethostname: handle long hostnames
David Turner [Tue, 18 Apr 2017 21:57:43 +0000 (17:57 -0400)] 
xgethostname: handle long hostnames

If the full hostname doesn't fit in the buffer supplied to
gethostname, POSIX does not specify whether the buffer will be
null-terminated, so to be safe, we should do it ourselves.  Introduce
new function, xgethostname, which ensures that there is always a \0
at the end of the buffer.

Signed-off-by: David Turner <dturner@twosigma.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agouse HOST_NAME_MAX to size buffers for gethostname(2)
René Scharfe [Tue, 18 Apr 2017 21:57:42 +0000 (17:57 -0400)] 
use HOST_NAME_MAX to size buffers for gethostname(2)

POSIX limits the length of host names to HOST_NAME_MAX.  Export the
fallback definition from daemon.c and use this constant to make all
buffers used with gethostname(2) big enough for any possible result
and a terminating NUL.

Inspired-by: David Turner <dturner@twosigma.com>
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: David Turner <dturner@twosigma.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agop0004: make perf test executable
Christian Couder [Tue, 18 Apr 2017 14:24:07 +0000 (16:24 +0200)] 
p0004: make perf test executable

It looks like in 89c3b0ad43 (name-hash: add perf test for lazy_init_name_hash,
2017-03-23) p0004 was not created with the execute unix rights.
Let's fix that.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Acked-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agols-files: fix path used when recursing into submodules
Jacob Keller [Thu, 13 Apr 2017 17:12:24 +0000 (10:12 -0700)] 
ls-files: fix path used when recursing into submodules

Don't assume that the current working directory is the root of the
repository. Correctly generate the path for the recursing child
processes by building it from the work_tree() root instead. Otherwise if
we run ls-files using --git-dir or --work-tree it will not work
correctly as it attempts to change directory into a potentially invalid
location. Best case, it doesn't exist and we produce an error. Worst
case we cd into the wrong location and unknown behavior occurs.

Add a new test which highlights this possibility.

Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoreplace: plug a memory leak
Junio C Hamano [Tue, 18 Apr 2017 04:56:54 +0000 (21:56 -0700)] 
replace: plug a memory leak

Recent update to for_each_replace_name() to make it use a strbuf in
place of a fixed buffer forgot to release the memory held by the
strbuf before leaving the function.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agodoc: trivial typo in git-format-patch.txt
Giuseppe Bilotta [Mon, 17 Apr 2017 22:32:53 +0000 (00:32 +0200)] 
doc: trivial typo in git-format-patch.txt

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agols-files: fix recurse-submodules with nested submodules
Jacob Keller [Thu, 13 Apr 2017 17:12:23 +0000 (10:12 -0700)] 
ls-files: fix recurse-submodules with nested submodules

Since commit e77aa336f116 ("ls-files: optionally recurse into
submodules", 2016-10-07) ls-files has known how to recurse into
submodules when displaying files.

Unfortunately this fails for certain cases, including when nesting more
than one submodule, called from within a submodule that itself has
submodules, or when the GIT_DIR environemnt variable is set.

Prior to commit b58a68c1c187 ("setup: allow for prefix to be passed to
git commands", 2017-03-17) this resulted in an error indicating that
--prefix and --super-prefix were incompatible.

After this commit, instead, the process loops forever with a GIT_DIR set
to the parent and continuously reads the parent submodule files and
recursing forever.

Fix this by preparing the environment properly for submodules when
setting up the child process. This is similar to how other commands such
as grep behave.

This was not caught by the original tests because the scenario is
avoided if the submodules are created separately and not stored as the
standard method of putting the submodule git directory under
.git/modules/<name>. We can update the test to show the failure by the
addition of "git submodule absorbgitdirs" to the test case. However,
note that this new test would run forever without the necessary fix in
this patch.

Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agofetch-pack: show clearer error message upon ERR
Jonathan Tan [Wed, 12 Apr 2017 18:06:02 +0000 (11:06 -0700)] 
fetch-pack: show clearer error message upon ERR

Currently, fetch-pack prints a confusing error message ("expected
ACK/NAK") when the server it's communicating with sends a pkt-line
starting with "ERR".  Replace it with a less confusing error message.

Also update the documentation describing the fetch-pack/upload-pack
protocol (pack-protocol.txt) to indicate that "ERR" can be sent in the
place of "ACK" or "NAK". In practice, this has been done for quite some
time by other Git implementations (e.g. JGit sends "want $id not valid")
and by Git itself (since commit bdb31ea: "upload-pack: report "not our
ref" to client", 2017-02-23) whenever a "want" line references an object
that it does not have. (This is uncommon, but can happen if a repository
is garbage-collected during a negotiation.)

Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agosubmodule: remove a superfluous second check for the "new" variable
Sebastian Schuberth [Mon, 17 Apr 2017 07:59:47 +0000 (07:59 +0000)] 
submodule: remove a superfluous second check for the "new" variable

Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoserver-info: avoid calling fclose(3) twice in update_info_file()
René Scharfe [Sun, 16 Apr 2017 16:55:58 +0000 (18:55 +0200)] 
server-info: avoid calling fclose(3) twice in update_info_file()

If an error occurs when or after closing the stream we call fclose(3)
again in the error handler.  The second call can exhibit undefined
behavior, so make sure to call fclose(3) at most once.  Also avoid
calling close(2) after fd has been successfully associated with the
stream, as fclose(3) has become responsible for doing that beyond
this point.

Found with Cppcheck.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agofiles_for_each_reflog_ent_reverse(): close stream and free strbuf on error
René Scharfe [Sun, 16 Apr 2017 16:55:46 +0000 (18:55 +0200)] 
files_for_each_reflog_ent_reverse(): close stream and free strbuf on error

Exit the loop orderly through the cleanup code, instead of dashing out
with logfp still open and sb leaking.

Found with Cppcheck.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Reviewed-by: Jeff King <peff@peff.net>
Reviewed-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agot1400: use consistent style for test_expect_success calls
Kyle Meyer [Sun, 16 Apr 2017 02:31:02 +0000 (22:31 -0400)] 
t1400: use consistent style for test_expect_success calls

Structure calls as

    test_expect_success 'description' '
     body
    '

Use double quotes for the description if it requires parameter
expansion or contains a single quote.

Signed-off-by: Kyle Meyer <kyle@kyleam.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agodoc/revisions: remove brackets from rev^-n shorthand
Kyle Meyer [Sun, 16 Apr 2017 04:07:57 +0000 (00:07 -0400)] 
doc/revisions: remove brackets from rev^-n shorthand

Given that other instances of "{...}" in the revision documentation
represent literal characters of revision specifications, describing
the rev^-n shorthand as "<rev>^-{<n>}" incorrectly suggests that
something like "master^-{1}" is an acceptable form.

Signed-off-by: Kyle Meyer <kyle@kyleam.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.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 agosha1_file: remove an used fd variable
Sebastian Schuberth [Sun, 16 Apr 2017 19:04:01 +0000 (19:04 +0000)] 
sha1_file: remove an used fd variable

Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoam: close stream on error, but not stdin
René Scharfe [Sun, 16 Apr 2017 16:55:30 +0000 (18:55 +0200)] 
am: close stream on error, but not stdin

Avoid closing stdin, but do close an actual input file on error exit.

Found with Cppcheck.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agobuiltin/am: fold am_signoff() into am_append_signoff()
Giuseppe Bilotta [Sat, 15 Apr 2017 14:41:02 +0000 (16:41 +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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agobuiltin/am: honor --signoff also when --rebasing
Giuseppe Bilotta [Sat, 15 Apr 2017 14:41:01 +0000 (16:41 +0200)] 
builtin/am: honor --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 git-am pay attention to it also
in the rebase case. This can be done 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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agogit-p4: don't use name-rev to get current branch
Luke Diamand [Sat, 15 Apr 2017 10:36:09 +0000 (11:36 +0100)] 
git-p4: don't use name-rev to get current branch

git-p4 was using "git name-rev" to find out the current branch.

That is not safe, since if multiple branches or tags point at
the same revision, the result obtained might not be what is
expected.

Instead use "git symbolic-ref".

Signed-off-by: Luke Diamand <luke@diamand.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agogit-p4: add read_pipe_text() internal function
Luke Diamand [Sat, 15 Apr 2017 10:36:08 +0000 (11:36 +0100)] 
git-p4: add read_pipe_text() internal function

The existing read_pipe() function returns an empty string on
error, but also returns an empty string if the command returns
an empty string.

This leads to ugly constructions trying to detect error cases.

Add read_pipe_text() which just returns None on error.

Signed-off-by: Luke Diamand <luke@diamand.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agogit-p4: add failing test for name-rev rather than symbolic-ref
Luke Diamand [Sat, 15 Apr 2017 10:36:07 +0000 (11:36 +0100)] 
git-p4: add failing test for name-rev rather than symbolic-ref

Using name-rev to find the current git branch means that git-p4
does not correctly get the current branch name if there are
multiple branches pointing at HEAD, or a tag.

This change adds a test case which demonstrates the problem.
Configuring which branches are allowed to be submitted from goes
wrong, as git-p4 gets confused about which branch is in use.

This appears to be the only place that git-p4 actually cares
about the current branch.

Signed-off-by: Luke Diamand <luke@diamand.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agosubmodule: prevent backslash expantion in submodule names
Brandon Williams [Fri, 7 Apr 2017 17:23:06 +0000 (10:23 -0700)] 
submodule: prevent backslash expantion in submodule names

When attempting to add a submodule with backslashes in its name 'git
submodule' fails in a funny way.  We can see that some of the
backslashes are expanded resulting in a bogus path:

git -C main submodule add ../sub\\with\\backslash
fatal: repository '/tmp/test/sub\witackslash' does not exist
fatal: clone of '/tmp/test/sub\witackslash' into submodule path

To solve this, convert calls to 'read' to 'read -r' in git-submodule.sh
in order to prevent backslash expantion in submodule names.

Reported-by: Joachim Durchholz <jo@durchholz.org>
Signed-off-by: Brandon Williams <bmwill@google.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agotest-read-cache: setup git dir
René Scharfe [Thu, 6 Apr 2017 20:41:41 +0000 (22:41 +0200)] 
test-read-cache: setup git dir

b1ef400e (setup_git_env: avoid blind fall-back to ".git") made programs
that tried to access a repository without initializing properly die with
a diagnostic message.  One offender is test-read-cache, which is used in
p0002.  Fix it by calling setup_git_directory() before accessing the
index.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agorefs: reject ref updates while GIT_QUARANTINE_PATH is set
Jeff King [Mon, 10 Apr 2017 22:14:12 +0000 (18:14 -0400)] 
refs: reject ref updates while GIT_QUARANTINE_PATH is set

As documented in git-receive-pack(1), updating a ref from
within the pre-receive hook is dangerous and can corrupt
your repo. This patch forbids ref updates entirely during
the hook to make it harder for adventurous hook writers to
shoot themselves in the foot.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoreceive-pack: document user-visible quarantine effects
Jeff King [Mon, 10 Apr 2017 22:13:39 +0000 (18:13 -0400)] 
receive-pack: document user-visible quarantine effects

Commit 722ff7f87 (receive-pack: quarantine objects until
pre-receive accepts, 2016-10-03) changed the underlying
details of how we take in objects. This is mostly
transparent to the user, but there are a few things they
might notice. Let's document them.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoreceive-pack: drop tmp_objdir_env from run_update_hook
Jeff King [Mon, 10 Apr 2017 22:13:22 +0000 (18:13 -0400)] 
receive-pack: drop tmp_objdir_env from run_update_hook

Since 722ff7f87 (receive-pack: quarantine objects until
pre-receive accepts, 2016-10-03), we have to feed the
pre-receive hook the tmp_objdir environment, so that git
programs run from the hook know where to find the objects.

That commit modified run_update_hook() to do the same, but
there it is a noop. By the time we get to the update hooks,
we have already migrated the objects from quarantine, and so
tmp_objdir_env() will always return NULL. We can drop this
useless call.

Note that the ordering here and the lack of support for the
update hook is intentional. The update hook calls are
interspersed with actual ref updates, and we must migrate
the objects before any refs are updated (since otherwise
those refs would appear broken to outside processes). So the
only other options are:

  - remain in quarantine for the _first_ ref, but not the
    others. This is sufficiently confusing that it can be
    rejected outright.

  - run all the individual update hooks first, then migrate,
    then update all the refs. But this changes the repository
    state that the update hooks see (i.e., whether or not
    refs from the same push are updated yet or not).

So the functionality is fine and remains unchanged with this
patch; we're just cleaning up a useless and confusing line
of code.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agot6500: wait for detached auto gc at the end of the test script
SZEDER Gábor [Thu, 13 Apr 2017 10:31:38 +0000 (12:31 +0200)] 
t6500: wait for detached auto gc at the end of the test script

The last test in 't6500-gc', 'background auto gc does not run if
gc.log is present and recent but does if it is old', added in
a831c06a2 (gc: ignore old gc.log files, 2017-02-10), may sporadically
trigger an error message from the test harness:

  rm: cannot remove 'trash directory.t6500-gc/.git/objects': Directory not empty

The test in question ends with executing an auto gc in the backround,
which occasionally takes so long that it's still running when
'test_done' is about to remove the trash directory.  This 'rm -rf
$trash' in the foreground might race with the detached auto gc to
create and delete files and directories, and gc might (re-)create a
path that 'rm' already visited and removed, triggering the above error
message when 'rm' attempts to remove its parent directory.

Commit bb05510e5 (t5510: run auto-gc in the foreground, 2016-05-01)
fixed the same problem in a different test script by simply
disallowing background gc.  Unfortunately, what worked there is not
applicable here, because the purpose of this test is to check the
behavior of a detached auto gc.

Make sure that the test doesn't continue before the gc is finished in
the background with a clever bit of shell trickery:

  - Open fd 9 in the shell, to be inherited by the background gc
    process, because our daemonize() only closes the standard fds 0,
    1 and 2.
  - Duplicate this fd 9 to stdout.
  - Read 'git gc's stdout, and thus fd 9, through a command
    substitution.  We don't actually care about gc's output, but this
    construct has two useful properties:
  - This read blocks until stdout or fd 9 are open.  While stdout is
    closed after the main gc process creates the background process
    and exits, fd 9 remains open until the backround process exits.
  - The variable assignment from the command substitution gets its
    exit status from the command executed within the command
    substitution, i.e. a failing main gc process will cause the test
    to fail.

Note, that this fd trickery doesn't work on Windows, because due to
MSYS limitations the git process only inherits the standard fds 0, 1
and 2 from the shell.  Luckily, it doesn't matter in this case,
because on Windows daemonize() is basically a noop, thus 'git gc
--auto' always runs in the foreground.

And since we can now continue the test reliably after the detached gc
finished, check that there is only a single packfile left at the end,
i.e. that the detached gc actually did what it was supposed to do.
Also add a comment at the end of the test script to warn developers of
future tests about this issue of long running detached gc processes.

Helped-by: Jeff King <peff@peff.net>
Helped-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agopathspec: fix segfault in clear_pathspec
Brandon Williams [Fri, 7 Apr 2017 19:29:19 +0000 (12:29 -0700)] 
pathspec: fix segfault in clear_pathspec

In 'clear_pathspec()' the incorrect index parameter is used to bound an
inner-loop which is used to free a 'struct attr_match' value field.
Using the incorrect index parameter (in addition to being incorrect)
occasionally causes segmentation faults when attempting to free an
invalid pointer.  Fix this by using the correct index parameter 'i'.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agogrep: plug a trivial memory leak
Ævar Arnfjörð Bjarmason [Sun, 9 Apr 2017 19:59:00 +0000 (19:59 +0000)] 
grep: plug a trivial memory leak

Change the cleanup phase for the grep command to free the pathspec
struct that's allocated earlier in the same block, and used just a few
lines earlier.

With "grep hi README.md" valgrind reports a loss of 239 bytes now,
down from 351.

The relevant --num-callers=40 --leak-check=full --show-leak-kinds=all
backtrace is:

    [...] 187 (112 direct, 75 indirect) bytes in 1 blocks are definitely lost in loss record 70 of 110
    [...]    at 0x4C2BBAF: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
    [...]    by 0x60B339: do_xmalloc (wrapper.c:59)
    [...]    by 0x60B2F6: xmalloc (wrapper.c:86)
    [...]    by 0x576B37: parse_pathspec (pathspec.c:652)
    [...]    by 0x4519F0: cmd_grep (grep.c:1215)
    [...]    by 0x4062EF: run_builtin (git.c:371)
    [...]    by 0x40544D: handle_builtin (git.c:572)
    [...]    by 0x4060A2: run_argv (git.c:624)
    [...]    by 0x4051C6: cmd_main (git.c:701)
    [...]    by 0x4C5901: main (common-main.c:43)

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Acked-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoconnect.c: handle errors from split_cmdline
Jeff King [Tue, 11 Apr 2017 00:30:23 +0000 (20:30 -0400)] 
connect.c: handle errors from split_cmdline

Commit e9d9a8a4d (connect: handle putty/plink also in
GIT_SSH_COMMAND, 2017-01-02) added a call to
split_cmdline(), but checks only for a non-zero return to
see if we got any output. Since the function returns
negative values (and a NULL argv) on error, we end up
dereferencing NULL and segfaulting.

Arguably we could report on the parsing error here, but it's
probably not worth it. This is a best-effort attempt to see
if we are using plink. So we can simply return here with
"no, it wasn't plink" and let the shell actually complain
about the bogus quoting.

Reported-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agotravis-ci: unset compiler for jobs that do not need one
Lars Schneider [Tue, 11 Apr 2017 08:33:09 +0000 (10:33 +0200)] 
travis-ci: unset compiler for jobs that do not need one

TravisCI does not need to setup any compiler for the documentation
build. Clear the value to fix this.

The Linux32 build job does not define the compiler but it inherits the
value from the base job. Since it does not need the compiler either
because the build runs inside a Docker container we should clear this,
too.

Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agotravis-ci: parallelize documentation build
Lars Schneider [Tue, 11 Apr 2017 08:33:08 +0000 (10:33 +0200)] 
travis-ci: parallelize documentation build

The documentation job without parallelization takes ~10min on TravisCI.
With parallelization ("--jobs=2") it takes ~6min.

Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>