git
7 years agogitmodules: clarify what history depth a shallow clone has
Sebastian Schuberth [Wed, 19 Apr 2017 07:56:33 +0000 (07:56 +0000)] 
gitmodules: clarify what history depth a shallow clone has

Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoPrepare for 2.12.3
Junio C Hamano [Tue, 28 Mar 2017 20:54:14 +0000 (13:54 -0700)] 
Prepare for 2.12.3

7 years agoMerge branch 'km/config-grammofix' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:29 +0000 (13:52 -0700)] 
Merge branch 'km/config-grammofix' into maint

Doc update.

* km/config-grammofix:
  doc/config: grammar fixes for core.{editor,commentChar}

7 years agoMerge branch 'sb/t3600-rephrase' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:29 +0000 (13:52 -0700)] 
Merge branch 'sb/t3600-rephrase' into maint

A test retitling.

* sb/t3600-rephrase:
  t3600: rename test to describe its functionality

7 years agoMerge branch 'sb/submodule-update-initial-runs-custom-script' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:29 +0000 (13:52 -0700)] 
Merge branch 'sb/submodule-update-initial-runs-custom-script' into maint

A test fix.

* sb/submodule-update-initial-runs-custom-script:
  t7406: correct test case for submodule-update initial population

7 years agoMerge branch 'jk/quote-env-path-list-component' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:28 +0000 (13:52 -0700)] 
Merge branch 'jk/quote-env-path-list-component' into maint

A test fix.

* jk/quote-env-path-list-component:
  t5615: fix a here-doc syntax error

7 years agoMerge branch 'rs/update-hook-optim' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:28 +0000 (13:52 -0700)] 
Merge branch 'rs/update-hook-optim' into maint

Code clean-up.

* rs/update-hook-optim:
  receive-pack: simplify run_update_post_hook()

7 years agoMerge branch 'rs/shortlog-cleanup' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:27 +0000 (13:52 -0700)] 
Merge branch 'rs/shortlog-cleanup' into maint

Code clean-up.

* rs/shortlog-cleanup:
  shortlog: don't set after_subject to an empty string

7 years agoMerge branch 'rs/path-name-safety-cleanup' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:27 +0000 (13:52 -0700)] 
Merge branch 'rs/path-name-safety-cleanup' into maint

Code clean-up.

* rs/path-name-safety-cleanup:
  revision: remove declaration of path_name()

7 years agoMerge branch 'rs/http-push-cleanup' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:26 +0000 (13:52 -0700)] 
Merge branch 'rs/http-push-cleanup' into maint

Code clean-up.

* rs/http-push-cleanup:
  http-push: don't check return value of lookup_unknown_object()

7 years agoMerge branch 'sb/wt-status-cleanup' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:26 +0000 (13:52 -0700)] 
Merge branch 'sb/wt-status-cleanup' into maint

Code clean-up.

* sb/wt-status-cleanup:
  wt-status: simplify by using for_each_string_list_item

7 years agoMerge branch 'jk/pack-name-cleanups' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:25 +0000 (13:52 -0700)] 
Merge branch 'jk/pack-name-cleanups' into maint

Code clean-up.

* jk/pack-name-cleanups:
  index-pack: make pointer-alias fallbacks safer
  replace snprintf with odb_pack_name()
  odb_pack_keep(): stop generating keepfile name
  sha1_file.c: make pack-name helper globally accessible
  move odb_* declarations out of git-compat-util.h

7 years agoMerge branch 'jk/rev-parse-cleanup' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:25 +0000 (13:52 -0700)] 
Merge branch 'jk/rev-parse-cleanup' into maint

Code clean-up.

* jk/rev-parse-cleanup:
  rev-parse: simplify parsing of ref options
  rev-parse: add helper for parsing "--foo/--foo="
  rev-parse: use skip_prefix when parsing options

7 years agoMerge branch 'rs/blame-code-cleanup' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:25 +0000 (13:52 -0700)] 
Merge branch 'rs/blame-code-cleanup' into maint

Code clean-up.

* rs/blame-code-cleanup:
  blame: move blame_entry duplication to add_blame_entry()

7 years agoMerge branch 'st/verify-tag' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:24 +0000 (13:52 -0700)] 
Merge branch 'st/verify-tag' into maint

A few unterminated here documents in tests were fixed, which in
turn revealed incorrect expectations the tests make. These tests
have been updated.

* st/verify-tag:
  t7004, t7030: fix here-doc syntax errors

7 years agoMerge branch 'js/regexec-buf' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:24 +0000 (13:52 -0700)] 
Merge branch 'js/regexec-buf' into maint

Fix for potential segv introduced in v2.11.0 and later (also
v2.10.2).

* js/regexec-buf:
  pickaxe: fix segfault with '-S<...> --pickaxe-regex'

7 years agoMerge branch 'jk/execv-dashed-external' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:23 +0000 (13:52 -0700)] 
Merge branch 'jk/execv-dashed-external' into maint

Fix for NO_PTHREADS build.

* jk/execv-dashed-external:
  run-command: fix segfault when cleaning forked async process

7 years agoMerge branch 'ew/http-alternates-as-redirects-warning' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:23 +0000 (13:52 -0700)] 
Merge branch 'ew/http-alternates-as-redirects-warning' into maint

Recent versions of Git treats http alternates (used in dumb http
transport) just like HTTP redirects and requires the client to
enable following it, due to security concerns.  But we forgot to
give a warning when we decide not to honor the alternates.

* ew/http-alternates-as-redirects-warning:
  http: release strbuf on disabled alternates
  http: inform about alternates-as-redirects behavior

7 years agoMerge branch 'dp/filter-branch-prune-empty' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:22 +0000 (13:52 -0700)] 
Merge branch 'dp/filter-branch-prune-empty' into maint

"git filter-branch --prune-empty" drops a single-parent commit that
becomes a no-op, but did not drop a root commit whose tree is empty.

* dp/filter-branch-prune-empty:
  p7000: add test for filter-branch with --prune-empty
  filter-branch: fix --prune-empty on parentless commits
  t7003: ensure --prune-empty removes entire branch when applicable
  t7003: ensure --prune-empty can prune root commit

7 years agoMerge branch 'mm/fetch-show-error-message-on-unadvertised-object' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:22 +0000 (13:52 -0700)] 
Merge branch 'mm/fetch-show-error-message-on-unadvertised-object' into maint

"git fetch" that requests a commit by object name, when the other
side does not allow such an request, failed without much
explanation.

* mm/fetch-show-error-message-on-unadvertised-object:
  fetch-pack: add specific error for fetching an unadvertised object
  fetch_refs_via_pack: call report_unmatched_refs
  fetch-pack: move code to report unmatched refs to a function

7 years agoMerge branch 'jk/interpret-branch-name' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:22 +0000 (13:52 -0700)] 
Merge branch 'jk/interpret-branch-name' into maint

"git branch @" created refs/heads/@ as a branch, and in general the
code that handled @{-1} and @{upstream} was a bit too loose in
disambiguating.

* jk/interpret-branch-name:
  checkout: restrict @-expansions when finding branch
  strbuf_check_ref_format(): expand only local branches
  branch: restrict @-expansions when deleting
  t3204: test git-branch @-expansion corner cases
  interpret_branch_name: allow callers to restrict expansions
  strbuf_branchname: add docstring
  strbuf_branchname: drop return value
  interpret_branch_name: move docstring to header file
  interpret_branch_name(): handle auto-namelen for @{-1}

7 years agoMerge branch 'ab/cond-skip-tests' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:21 +0000 (13:52 -0700)] 
Merge branch 'ab/cond-skip-tests' into maint

A few tests were run conditionally under (rare) conditions where
they cannot be run (like running cvs tests under 'root' account).

* ab/cond-skip-tests:
  gitweb tests: skip tests when we don't have Time::HiRes
  gitweb tests: change confusing "skip_all" phrasing
  cvs tests: skip tests that call "cvs commit" when running as root

7 years agoMerge branch 'jk/ident-empty' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:21 +0000 (13:52 -0700)] 
Merge branch 'jk/ident-empty' into maint

user.email that consists of only cruft chars should consistently
error out, but didn't.

* jk/ident-empty:
  ident: do not ignore empty config name/email
  ident: reject all-crud ident name
  ident: handle NULL email when complaining of empty name
  ident: mark error messages for translation

7 years agoMerge branch 'jk/delta-chain-limit' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:20 +0000 (13:52 -0700)] 
Merge branch 'jk/delta-chain-limit' into maint

"git repack --depth=<n>" for a long time busted the specified depth
when reusing delta from existing packs.  This has been corrected.

* jk/delta-chain-limit:
  pack-objects: convert recursion to iteration in break_delta_chain()
  pack-objects: enforce --depth limit in reused deltas

7 years agoMerge branch 'sg/test-with-stdin' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:20 +0000 (13:52 -0700)] 
Merge branch 'sg/test-with-stdin' into maint

Teach the "debug" helper used in the test framework that allows a
command to run under "gdb" to make the session interactive.

* sg/test-with-stdin:
  tests: make the 'test_pause' helper work in non-verbose mode
  tests: create an interactive gdb session with the 'debug' helper

7 years agoMerge branch 'jk/interop-test' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:20 +0000 (13:52 -0700)] 
Merge branch 'jk/interop-test' into maint

Picking two versions of Git and running tests to make sure the
older one and the newer one interoperate happily has now become
possible.

* jk/interop-test:
  t/interop: add test of old clients against modern git-daemon
  t: add an interoperability test harness

7 years agoMerge branch 'jt/perf-updates' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:19 +0000 (13:52 -0700)] 
Merge branch 'jt/perf-updates' into maint

The t/perf performance test suite was not prepared to test not so
old versions of Git, but now it covers versions of Git that are not
so ancient.

* jt/perf-updates:
  t/perf: add fallback for pre-bin-wrappers versions of git
  t/perf: use $MODERN_GIT for all repo-copying steps
  t/perf: export variable used in other blocks

7 years agoMerge branch 'rs/strbuf-add-real-path' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:19 +0000 (13:52 -0700)] 
Merge branch 'rs/strbuf-add-real-path' into maint

An helper function to make it easier to append the result from
real_path() to a strbuf has been added.

* rs/strbuf-add-real-path:
  strbuf: add strbuf_add_real_path()
  cocci: use ALLOC_ARRAY

7 years agoMerge branch 'jk/parse-config-key-cleanup' into maint
Junio C Hamano [Tue, 28 Mar 2017 20:52:18 +0000 (13:52 -0700)] 
Merge branch 'jk/parse-config-key-cleanup' into maint

The "parse_config_key()" API function has been cleaned up.

* jk/parse-config-key-cleanup:
  parse_hide_refs_config: tell parse_config_key we don't want a subsection
  parse_config_key: allow matching single-level config
  parse_config_key: use skip_prefix instead of starts_with
  refs: parse_hide_refs_config to use parse_config_key

7 years agoGit 2.12.2 v2.12.2
Junio C Hamano [Fri, 24 Mar 2017 19:59:15 +0000 (12:59 -0700)] 
Git 2.12.2

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMerge branch 'ab/doc-no-option-notation-fix' into maint
Junio C Hamano [Fri, 24 Mar 2017 19:57:55 +0000 (12:57 -0700)] 
Merge branch 'ab/doc-no-option-notation-fix' into maint

Doc fix.

* ab/doc-no-option-notation-fix:
  doc: change erroneous --[no]-whatever into --[no-]whatever

7 years agoMerge branch 'ab/push-default-doc-fix' into maint
Junio C Hamano [Fri, 24 Mar 2017 19:57:54 +0000 (12:57 -0700)] 
Merge branch 'ab/push-default-doc-fix' into maint

Doc fix.

* ab/push-default-doc-fix:
  push: mention "push.default=tracking" in the documentation

7 years agoMerge branch 'nd/commit-hook-doc-fix' into maint
Junio C Hamano [Fri, 24 Mar 2017 19:57:54 +0000 (12:57 -0700)] 
Merge branch 'nd/commit-hook-doc-fix' into maint

Doc fix.

* nd/commit-hook-doc-fix:
  git-commit.txt: list post-rewrite in HOOKS section

7 years agoMerge branch 'jc/config-case-cmdline-take-2' into maint
Junio C Hamano [Fri, 24 Mar 2017 19:57:54 +0000 (12:57 -0700)] 
Merge branch 'jc/config-case-cmdline-take-2' into maint

The code to parse "git -c VAR=VAL cmd" and set configuration
variable for the duration of cmd had two small bugs, which have
been fixed.
This supersedes jc/config-case-cmdline topic that has been discarded.

* jc/config-case-cmdline-take-2:
  config: use git_config_parse_key() in git_config_parse_parameter()
  config: move a few helper functions up

7 years agoMerge branch 'jk/grep-no-index-fix' into maint
Junio C Hamano [Fri, 24 Mar 2017 19:57:53 +0000 (12:57 -0700)] 
Merge branch 'jk/grep-no-index-fix' into maint

The code to parse the command line "git grep <patterns>... <rev>
[[--] <pathspec>...]" has been cleaned up, and a handful of bugs
have been fixed (e.g. we used to check "--" if it is a rev).

* jk/grep-no-index-fix:
  grep: treat revs the same for --untracked as for --no-index
  grep: do not diagnose misspelt revs with --no-index
  grep: avoid resolving revision names in --no-index case
  grep: fix "--" rev/pathspec disambiguation
  grep: re-order rev-parsing loop
  grep: do not unnecessarily query repo for "--"
  grep: move thread initialization a little lower

7 years agoMerge branch 'jn/remote-helpers-with-git-dir' into maint
Junio C Hamano [Fri, 24 Mar 2017 19:57:53 +0000 (12:57 -0700)] 
Merge branch 'jn/remote-helpers-with-git-dir' into maint

"git ls-remote" and "git archive --remote" are designed to work
without being in a directory under Git's control.  However, recent
updates revealed that we randomly look into a directory called
.git/ without actually doing necessary set-up when working in a
repository.  Stop doing so.

* jn/remote-helpers-with-git-dir:
  remote helpers: avoid blind fall-back to ".git" when setting GIT_DIR
  remote: avoid reading $GIT_DIR config in non-repo

7 years agoMerge branch 'sb/submodule-config-parse-ignore-fix' into maint
Junio C Hamano [Fri, 24 Mar 2017 19:57:52 +0000 (12:57 -0700)] 
Merge branch 'sb/submodule-config-parse-ignore-fix' into maint

Code to read submodule.<name>.ignore config did not state the
variable name correctly when giving an error message diagnosing
misconfiguration.

* sb/submodule-config-parse-ignore-fix:
  submodule-config: correct error reporting for invalid ignore value

7 years agoMerge branch 'jk/push-deadlock-regression-fix' into maint
Junio C Hamano [Fri, 24 Mar 2017 19:57:52 +0000 (12:57 -0700)] 
Merge branch 'jk/push-deadlock-regression-fix' into maint

"git push" had a handful of codepaths that could lead to a deadlock
when unexpected error happened, which has been fixed.

* jk/push-deadlock-regression-fix:
  send-pack: report signal death of pack-objects
  send-pack: read "unpack" status even on pack-objects failure
  send-pack: improve unpack-status error messages
  send-pack: use skip_prefix for parsing unpack status
  send-pack: extract parsing of "unpack" response
  receive-pack: fix deadlock when we cannot create tmpdir

7 years agomailmap: use Michael J Gruber's new address
Michael J Gruber [Fri, 24 Mar 2017 14:01:36 +0000 (15:01 +0100)] 
mailmap: use Michael J Gruber's new address

Map both old addresses to the new, hopefully more permanent one.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Michael J Gruber <git@grubix.eu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agot7004, t7030: fix here-doc syntax errors
Santiago Torres [Thu, 23 Mar 2017 22:28:47 +0000 (18:28 -0400)] 
t7004, t7030: fix here-doc syntax errors

Jan Palus noticed that some here-doc are spelled incorrectly,
resulting the entire remainder of the test snippet being slurped
into the "expect" file as if it were data, e.g. in this sequence

cat >expect <<EOF &&
... expectation ...
EOF
git $cmd_being_tested >actual &&
test_cmp expect actual

the last command of the test is "cat" that sends everything to
'expect' and succeeds.

Fixing these issues in t7004 and t7030 reveals that "git tag -v"
and "git verify-tag" with their --format option do not work as the
test was expecting originally.  Instead of showing both valid tags
and tags with incorrect signatures on their output, tags that do not
pass verification are omitted from the output.  Another breakage that
is uncovered is that these tests must be restricted to environment
where gpg is available.

Arguably, that is a safer behaviour, and because the format
specifiers like %(tag) do not have a way to show if the signature
verifies correctly, the command with the --format option cannot be
used to get a list of tags annotated with their signature validity
anyway.

For now, let's fix the here-doc syntax, update the expectation to
match the reality, and update the test prerequisite.

Maybe later when we extend the --format language available to "git
tag -v" and "git verify-tag" to include things like "%(gpg:status)",
we may want to change the behaviour so that piping a list of tag
names into

    xargs git verify-tag --format='%(gpg:status) %(tag)'

becomes a good way to produce such a list, but that is a separate
topic.

Noticed-by: Jan Palus <jan.palus@gmail.com>
Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Santiago Torres <santiago@nyu.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agodoc/config: grammar fixes for core.{editor,commentChar}
Kyle Meyer [Thu, 23 Mar 2017 17:32:16 +0000 (13:32 -0400)] 
doc/config: grammar fixes for core.{editor,commentChar}

Signed-off-by: Kyle Meyer <kyle@kyleam.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agot7406: correct test case for submodule-update initial population
Junio C Hamano [Wed, 22 Mar 2017 22:12:07 +0000 (15:12 -0700)] 
t7406: correct test case for submodule-update initial population

There are three issues with the test:

* The syntax of the here-doc was wrong, such that the entire test was
  sucked into the here-doc, which is why the test succeeded.

* The variable $submodulesha1 was not expanded as it was inside a quoted
  here text.  We do not want to quote EOF marker for this.

* The redirection from the git command to the output file for comparison
  was wrong as the -C operator from git doesn't apply to the redirect path.
  Also we're interested in stderr of that command.

Noticed-by: Jan Palus <jan.palus@gmail.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agot5615: fix a here-doc syntax error
Junio C Hamano [Wed, 22 Mar 2017 19:56:43 +0000 (12:56 -0700)] 
t5615: fix a here-doc syntax error

This came as part of jk/quote-env-path-list-component and was merged
to 2.11.1 and later.

Noticed-by: Jan Palus <jan.palus@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agot3600: rename test to describe its functionality
Stefan Beller [Tue, 21 Mar 2017 21:08:02 +0000 (14:08 -0700)] 
t3600: rename test to describe its functionality

This was an oversight in 55856a35b2 (rm: absorb a submodules git dir
before deletion, 2016-12-27), as the body of the test changed without
adapting the test subject.

Signed-off-by: Stefan Beller <sbeller@google.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoPrepare for 2.12.2
Junio C Hamano [Tue, 21 Mar 2017 22:04:12 +0000 (15:04 -0700)] 
Prepare for 2.12.2

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMerge branch 'jh/send-email-one-cc' into maint
Junio C Hamano [Tue, 21 Mar 2017 22:03:30 +0000 (15:03 -0700)] 
Merge branch 'jh/send-email-one-cc' into maint

"Cc:" on the trailer part does not have to conform to RFC strictly,
unlike in the e-mail header.  "git send-email" has been updated to
ignore anything after '>' when picking addresses, to allow non-address
cruft like " # stable 4.4" after the address.

* jh/send-email-one-cc:
  send-email: only allow one address per body tag

7 years agoMerge branch 'jk/t6300-cleanup' into maint
Junio C Hamano [Tue, 21 Mar 2017 22:03:30 +0000 (15:03 -0700)] 
Merge branch 'jk/t6300-cleanup' into maint

A test that creates a confusing branch whose name is HEAD has been
corrected not to do so.

* jk/t6300-cleanup:
  t6300: avoid creating refs/heads/HEAD

7 years agoMerge branch 'rs/commit-parsing-optim' into maint
Junio C Hamano [Tue, 21 Mar 2017 22:03:29 +0000 (15:03 -0700)] 
Merge branch 'rs/commit-parsing-optim' into maint

The code that parses header fields in the commit object has been
updated for (micro)performance and code hygiene.

* rs/commit-parsing-optim:
  commit: don't check for space twice when looking for header
  commit: be more precise when searching for headers

7 years agoMerge branch 'jk/show-branch-lift-name-len-limit' into maint
Junio C Hamano [Tue, 21 Mar 2017 22:03:29 +0000 (15:03 -0700)] 
Merge branch 'jk/show-branch-lift-name-len-limit' into maint

"git show-branch" expected there were only very short branch names
in the repository and used a fixed-length buffer to hold them
without checking for overflow.

* jk/show-branch-lift-name-len-limit:
  show-branch: use skip_prefix to drop magic numbers
  show-branch: store resolved head in heap buffer
  show-branch: drop head_len variable

7 years agoMerge branch 'jk/tempfile-ferror-fclose-confusion' into maint
Junio C Hamano [Tue, 21 Mar 2017 22:03:28 +0000 (15:03 -0700)] 
Merge branch 'jk/tempfile-ferror-fclose-confusion' into maint

A caller of tempfile API that uses stdio interface to write to
files may ignore errors while writing, which is detected when
tempfile is closed (with a call to ferror()).  By that time, the
original errno that may have told us what went wrong is likely to
be long gone and was overwritten by an irrelevant value.
close_tempfile() now resets errno to EIO to make errno at least
predictable.

* jk/tempfile-ferror-fclose-confusion:
  tempfile: set errno to a known value before calling ferror()

7 years agoMerge branch 'rl/remote-allow-missing-branch-name-merge' into maint
Junio C Hamano [Tue, 21 Mar 2017 22:03:28 +0000 (15:03 -0700)] 
Merge branch 'rl/remote-allow-missing-branch-name-merge' into maint

"git remote rm X", when a branch has remote X configured as the
value of its branch.*.remote, tried to remove branch.*.remote and
branch.*.merge and failed if either is unset.

* rl/remote-allow-missing-branch-name-merge:
  remote: ignore failure to remove missing branch.<name>.merge

7 years agoMerge branch 'dt/gc-ignore-old-gc-logs' into maint
Junio C Hamano [Tue, 21 Mar 2017 22:03:28 +0000 (15:03 -0700)] 
Merge branch 'dt/gc-ignore-old-gc-logs' into maint

A "gc.log" file left by a backgrounded "gc --auto" disables further
automatic gc; it has been taught to run at least once a day (by
default) by ignoring a stale "gc.log" file that is too old.

* dt/gc-ignore-old-gc-logs:
  gc: ignore old gc.log files

7 years agoMerge branch 'jt/upload-pack-error-report' into maint
Junio C Hamano [Tue, 21 Mar 2017 22:03:27 +0000 (15:03 -0700)] 
Merge branch 'jt/upload-pack-error-report' into maint

"git upload-pack", which is a counter-part of "git fetch", did not
report a request for a ref that was not advertised as invalid.
This is generally not a problem (because "git fetch" will stop
before making such a request), but is the right thing to do.

* jt/upload-pack-error-report:
  upload-pack: report "not our ref" to client

7 years agoMerge branch 'rs/sha1-file-plug-fallback-base-leak' into maint
Junio C Hamano [Tue, 21 Mar 2017 22:03:27 +0000 (15:03 -0700)] 
Merge branch 'rs/sha1-file-plug-fallback-base-leak' into maint

A leak in a codepath to read from a packed object in (rare) cases
has been plugged.

* rs/sha1-file-plug-fallback-base-leak:
  sha1_file: release fallback base's memory in unpack_entry()

7 years agoMerge branch 'ss/remote-bzr-hg-placeholder-wo-python' into maint
Junio C Hamano [Tue, 21 Mar 2017 22:03:26 +0000 (15:03 -0700)] 
Merge branch 'ss/remote-bzr-hg-placeholder-wo-python' into maint

There is no need for Python only to give a few messages to the
standard error stream, but we somehow did.

* ss/remote-bzr-hg-placeholder-wo-python:
  contrib: git-remote-{bzr,hg} placeholders don't need Python

7 years agoMerge branch 'jc/diff-populate-filespec-size-only-fix' into maint
Junio C Hamano [Tue, 21 Mar 2017 22:03:26 +0000 (15:03 -0700)] 
Merge branch 'jc/diff-populate-filespec-size-only-fix' into maint

"git diff --quiet" relies on the size field in diff_filespec to be
correctly populated, but diff_populate_filespec() helper function
made an incorrect short-cut when asked only to populate the size
field for paths that need to go through convert_to_git() (e.g. CRLF
conversion).

* jc/diff-populate-filespec-size-only-fix:
  diff: do not short-cut CHECK_SIZE_ONLY check in diff_populate_filespec()

7 years agoMerge branch 'jk/http-walker-buffer-underflow-fix' into maint
Junio C Hamano [Tue, 21 Mar 2017 22:03:25 +0000 (15:03 -0700)] 
Merge branch 'jk/http-walker-buffer-underflow-fix' into maint

"Dumb http" transport used to misparse a nonsense http-alternates
response, which has been fixed.

* jk/http-walker-buffer-underflow-fix:
  http-walker: fix buffer underflow processing remote alternates

7 years agoMerge branch 'mg/status-porcelain-no-i18n' into maint
Junio C Hamano [Tue, 21 Mar 2017 22:03:25 +0000 (15:03 -0700)] 
Merge branch 'mg/status-porcelain-no-i18n' into maint

"git status --porcelain" is supposed to give a stable output, but a
few strings were left as translatable by mistake.

* mg/status-porcelain-no-i18n:
  git-status: make porcelain more robust

7 years agoMerge branch 'ps/docs-diffcore' into maint
Junio C Hamano [Tue, 21 Mar 2017 22:03:25 +0000 (15:03 -0700)] 
Merge branch 'ps/docs-diffcore' into maint

Doc update.

* ps/docs-diffcore:
  docs/diffcore: unquote "Complete Rewrites" in headers
  docs/diffcore: fix grammar in diffcore-rename header

7 years agoMerge branch 'ew/markdown-url-in-readme' into maint
Junio C Hamano [Tue, 21 Mar 2017 22:03:24 +0000 (15:03 -0700)] 
Merge branch 'ew/markdown-url-in-readme' into maint

Doc update.

* ew/markdown-url-in-readme:
  README: create HTTP/HTTPS links from URLs in Markdown

7 years agoMerge branch 'rj/remove-unused-mktemp' into maint
Junio C Hamano [Tue, 21 Mar 2017 22:03:24 +0000 (15:03 -0700)] 
Merge branch 'rj/remove-unused-mktemp' into maint

Code cleanup.

* rj/remove-unused-mktemp:
  wrapper.c: remove unused gitmkstemps() function
  wrapper.c: remove unused git_mkstemp() function

7 years agoMerge branch 'jk/ewah-use-right-type-in-sizeof' into maint
Junio C Hamano [Tue, 21 Mar 2017 22:03:23 +0000 (15:03 -0700)] 
Merge branch 'jk/ewah-use-right-type-in-sizeof' into maint

Code clean-up.

* jk/ewah-use-right-type-in-sizeof:
  ewah: fix eword_t/uint64_t confusion

7 years agoGit 2.12.1 v2.12.1
Junio C Hamano [Mon, 20 Mar 2017 20:17:08 +0000 (13:17 -0700)] 
Git 2.12.1

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agopush: mention "push.default=tracking" in the documentation
Ævar Arnfjörð Bjarmason [Sun, 19 Mar 2017 14:36:36 +0000 (14:36 +0000)] 
push: mention "push.default=tracking" in the documentation

Change the documentation for push.tracking=* to re-include a mention
of what "tracking" does.

The "tracking" option was renamed to "upstream" back in
53c4031 ("push.default: Rename 'tracking' to 'upstream'", 2011-02-16),
this section was then subsequently rewritten in 87a70e4 ("config doc:
rewrite push.default section", 2013-06-19) to remove any mention of
"tracking".

Maybe we should just warn or die nowadays if this option is in the
config, but I had some old config of mine use this option, I'd
forgotten that it was a synonym, and nothing in git's documentation
mentioned that.

That's bad, either we shouldn't support it at all, or we should
document what it does. This patch does the latter.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agogit-commit.txt: list post-rewrite in HOOKS section
Nguyễn Thái Ngọc Duy [Sun, 19 Mar 2017 09:01:02 +0000 (16:01 +0700)] 
git-commit.txt: list post-rewrite in HOOKS section

The hook was added in a86ed83cce (Merge branch 'tr/notes-display' -
2010-03-24), which updated githooks.txt but not git-commit.txt.

git-commit.txt was later updated in e858af6d50 (commit: document a
couple of options - 2012-06-08). Since this commit focused on command
line options, this section was probably forgotten.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agodoc: change erroneous --[no]-whatever into --[no-]whatever
Ævar Arnfjörð Bjarmason [Mon, 20 Mar 2017 13:20:29 +0000 (13:20 +0000)] 
doc: change erroneous --[no]-whatever into --[no-]whatever

Change these two obvious typos to be in line with the rest of the
documentation, which uses the correct --[no-]whatever form.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agopickaxe: fix segfault with '-S<...> --pickaxe-regex'
SZEDER Gábor [Sat, 18 Mar 2017 18:24:08 +0000 (19:24 +0100)] 
pickaxe: fix segfault with '-S<...> --pickaxe-regex'

'git {log,diff,...} -S<...> --pickaxe-regex' can segfault as a result
of out-of-bounds memory reads.

diffcore-pickaxe.c:contains() looks for all matches of the given regex
in a buffer in a loop, advancing the buffer pointer to the end of the
last match in each iteration.  When we switched to REG_STARTEND in
b7d36ffca (regex: use regexec_buf(), 2016-09-21), we started passing
the size of that buffer to the regexp engine, too.  Unfortunately,
this buffer size is never updated on subsequent iterations, and as the
buffer pointer advances on each iteration, this "bufptr+bufsize"
points past the end of the buffer.  This results in segmentation
fault, if that memory can't be accessed.  In case of 'git log' it can
also result in erroneously listed commits, if the memory past the end
of buffer is accessible and happens to contain data matching the
regex.

Reduce the buffer size on each iteration as the buffer pointer is
advanced, thus maintaining the correct end of buffer location.
Furthermore, make sure that the buffer pointer is not dereferenced in
the control flow statements when we already reached the end of the
buffer.

The new test is flaky, I've never seen it fail on my Linux box even
without the fix, but this is expected according to db5dfa3 (regex:
-G<pattern> feeds a non NUL-terminated string to regexec() and fails,
2016-09-21).  However, it did fail on Travis CI with the first (and
incomplete) version of the fix, and based on that commit message I
would expect the new test without the fix to fail most of the time on
Windows.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agorun-command: fix segfault when cleaning forked async process
Jeff King [Fri, 17 Mar 2017 23:20:04 +0000 (19:20 -0400)] 
run-command: fix segfault when cleaning forked async process

Callers of the run-command API may mark a child as
"clean_on_exit"; it gets added to a list and killed when the
main process dies.  Since commit 46df6906f
(execv_dashed_external: wait for child on signal death,
2017-01-06), we respect an extra "wait_after_clean" flag,
which we expect to find in the child_process struct.

When Git is built with NO_PTHREADS, we start "struct
async" processes by forking rather than spawning a thread.
The resulting processes get added to the cleanup list but
they don't have a child_process struct, and the cleanup
function ends up dereferencing NULL.

We should notice this case and assume that the processes do
not need to be waited for (i.e., the same behavior they had
before 46df6906f).

Reported-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Jeff King <peff@peff.net>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoshortlog: don't set after_subject to an empty string
René Scharfe [Fri, 17 Mar 2017 23:52:28 +0000 (00:52 +0100)] 
shortlog: don't set after_subject to an empty string

The string after_subject is added to a strbuf by pp_title_line() if
it's not NULL.  Adding an empty string has the same effect as not
adding anything, but the latter is easier, so don't bother changing
the context member from NULL to "".

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agotests: make the 'test_pause' helper work in non-verbose mode
SZEDER Gábor [Sat, 18 Mar 2017 16:14:00 +0000 (17:14 +0100)] 
tests: make the 'test_pause' helper work in non-verbose mode

When the 'test_pause' helper function invokes the shell mid-test, it
explicitly redirects the shell's stdout and stderr to file descriptors
3 and 4, which are the stdout and stderr of the tests (i.e. where they
would be connected anyway without those redirections).  These file
descriptors are only attached to the terminal in verbose mode, hence
the restriction of 'test_pause' to work only with '-v'.

Redirect the shell's stdout and stderr to the test environment's
original stdout and stderr, allowing it to work properly even in
non-verbose mode, and the restriction can be lifted.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agotests: create an interactive gdb session with the 'debug' helper
SZEDER Gábor [Sat, 18 Mar 2017 16:13:59 +0000 (17:13 +0100)] 
tests: create an interactive gdb session with the 'debug' helper

The 'debug' test helper is supposed to facilitate debugging by running
a command of the test suite under gdb.  Unfortunately, its usefulness
is severely limited, because that gdb session is not interactive,
since the test's, and thus gdb's standard input is redirected from
/dev/null (for a good reason, see 781f76b15 (test-lib: redirect stdin
of tests, 2011-12-15)).

Redirect gdb's standard file descriptors from/to the test
environment's stdin, stdout and stderr in the 'debug' helper, thus
creating an interactive gdb session (even in non-verbose mode), which
is much, much more useful.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agorevision: remove declaration of path_name()
René Scharfe [Fri, 17 Mar 2017 22:15:03 +0000 (23:15 +0100)] 
revision: remove declaration of path_name()

The definition of path_name() was removed by 2824e1841 (list-objects:
pass full pathname to callbacks); remove its declaration as well.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agohttp-push: don't check return value of lookup_unknown_object()
René Scharfe [Fri, 17 Mar 2017 22:12:31 +0000 (23:12 +0100)] 
http-push: don't check return value of lookup_unknown_object()

This function always returns a reference to an object, creating one if
needed, so remove the unnecessary NULL check.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoreceive-pack: simplify run_update_post_hook()
René Scharfe [Fri, 17 Mar 2017 22:02:13 +0000 (23:02 +0100)] 
receive-pack: simplify run_update_post_hook()

Instead of counting the arguments to see if there are any and then
building the full command use a single loop and add the hook command
just before the first argument.  This reduces duplication and overall
code size.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agowt-status: simplify by using for_each_string_list_item
Stefan Beller [Thu, 16 Mar 2017 21:36:19 +0000 (14:36 -0700)] 
wt-status: simplify by using for_each_string_list_item

Improve readability by using the for_each_string_list_item helper
instead of manually iterating with an integer counter.

Signed-off-by: Stefan Beller <sbeller@google.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoPreparing for 2.12.1
Junio C Hamano [Thu, 16 Mar 2017 21:01:00 +0000 (14:01 -0700)] 
Preparing for 2.12.1

Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoMerge branch 'js/realpath-pathdup-fix' into maint
Junio C Hamano [Thu, 16 Mar 2017 20:56:43 +0000 (13:56 -0700)] 
Merge branch 'js/realpath-pathdup-fix' into maint

Git v2.12 was shipped with an embarrassing breakage where various
operations that verify paths given from the user stopped dying when
seeing an issue, and instead later triggering segfault.
... and then to down to 'maint'.

* js/realpath-pathdup-fix:
  real_pathdup(): fix callsites that wanted it to die on error
  t1501: demonstrate NULL pointer access with invalid GIT_WORK_TREE

7 years agoMerge branch 'mm/two-more-xstrfmt' into maint
Junio C Hamano [Thu, 16 Mar 2017 20:56:43 +0000 (13:56 -0700)] 
Merge branch 'mm/two-more-xstrfmt' into maint

Code clean-up and a string truncation fix.

* mm/two-more-xstrfmt:
  bisect_next_all: convert xsnprintf to xstrfmt
  stop_progress_msg: convert xsnprintf to xstrfmt

7 years agoMerge branch 'vn/line-log-memcpy-size-fix' into maint
Junio C Hamano [Thu, 16 Mar 2017 20:56:42 +0000 (13:56 -0700)] 
Merge branch 'vn/line-log-memcpy-size-fix' into maint

The command-line parsing of "git log -L" copied internal data
structures using incorrect size on ILP32 systems.

* vn/line-log-memcpy-size-fix:
  line-log: use COPY_ARRAY to fix mis-sized memcpy

7 years agoMerge branch 'ax/line-log-range-merge-fix' into maint
Junio C Hamano [Thu, 16 Mar 2017 20:56:42 +0000 (13:56 -0700)] 
Merge branch 'ax/line-log-range-merge-fix' into maint

The code to parse "git log -L..." command line was buggy when there
are many ranges specified with -L; overrun of the allocated buffer
has been fixed.

* ax/line-log-range-merge-fix:
  line-log.c: prevent crash during union of too many ranges

7 years agoMerge branch 'jk/add-i-patch-do-prompt' into maint
Junio C Hamano [Thu, 16 Mar 2017 20:56:42 +0000 (13:56 -0700)] 
Merge branch 'jk/add-i-patch-do-prompt' into maint

The patch subcommand of "git add -i" was meant to have paths
selection prompt just like other subcommand, unlike "git add -p"
directly jumps to hunk selection.  Recently, this was broken and
"add -i" lost the paths selection dialog, but it now has been
fixed.

* jk/add-i-patch-do-prompt:
  add--interactive: fix missing file prompt for patch mode with "-i"

7 years agoMerge branch 'jt/http-base-url-update-upon-redirect' into maint
Junio C Hamano [Thu, 16 Mar 2017 20:56:42 +0000 (13:56 -0700)] 
Merge branch 'jt/http-base-url-update-upon-redirect' into maint

When a redirected http transport gets an error during the
redirected request, we ignored the error we got from the server,
and ended up giving a not-so-useful error message.

* jt/http-base-url-update-upon-redirect:
  http: attempt updating base URL only if no error

7 years agoMerge branch 'js/travis-32bit-linux' into maint
Junio C Hamano [Thu, 16 Mar 2017 20:56:41 +0000 (13:56 -0700)] 
Merge branch 'js/travis-32bit-linux' into maint

Add 32-bit Linux variant to the set of platforms to be tested with
Travis CI.

* js/travis-32bit-linux:
  Travis: also test on 32-bit Linux

7 years agoMerge branch 'jh/mingw-openssl-sha1' into maint
Junio C Hamano [Thu, 16 Mar 2017 20:56:41 +0000 (13:56 -0700)] 
Merge branch 'jh/mingw-openssl-sha1' into maint

Windows port wants to use OpenSSL's implementation of SHA-1
routines, so let them.

* jh/mingw-openssl-sha1:
  mingw: use OpenSSL's SHA-1 routines

7 years agoMerge branch 'jk/http-auth' into maint
Junio C Hamano [Thu, 16 Mar 2017 20:56:41 +0000 (13:56 -0700)] 
Merge branch 'jk/http-auth' into maint

Reduce authentication round-trip over HTTP when the server supports
just a single authentication method.

* jk/http-auth:
  http: add an "auto" mode for http.emptyauth
  http: restrict auth methods to what the server advertises

7 years agoindex-pack: make pointer-alias fallbacks safer
Jeff King [Thu, 16 Mar 2017 14:27:20 +0000 (10:27 -0400)] 
index-pack: make pointer-alias fallbacks safer

The final() function accepts a NULL value for certain
parameters, and falls back to writing into a reusable "name"
buffer, and then either:

  1. For "keep_name", requiring all uses to do "keep_name ?
     keep_name : name.buf". This is awkward, and it's easy
     to accidentally look at the maybe-NULL keep_name.

  2. For "final_index_name" and "final_pack_name", aliasing
     those pointers to the "name" buffer. This is easier to
     use, but the aliased pointers become invalid after the
     buffer is reused (this isn't a bug now, but it's a
     potential pitfall).

One way to make this safer would be to introduce an extra
pointer to do the aliasing, and have its lifetime match the
validity of the "name" buffer. But it's still easy to
accidentally use the wrong name (i.e., to use
"final_pack_name" instead of the aliased pointer).

Instead, let's use three separate buffers that will remain
valid through the function. That makes it safe to alias the
pointers and use them consistently. The extra allocations
shouldn't matter, as this function is not performance
sensitive.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoreplace snprintf with odb_pack_name()
Jeff King [Thu, 16 Mar 2017 14:27:15 +0000 (10:27 -0400)] 
replace snprintf with odb_pack_name()

In several places we write the name of the pack filename
into a fixed-size buffer using snprintf(), but do not check
the return value.  As a result, a very long object directory
could cause us to quietly truncate the pack filename
(potentially leading to a corrupted repository, as a newly
written packfile could be missing its .pack extension).

We can use odb_pack_name() to do this with a strbuf (and
shorten the code, as well).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoodb_pack_keep(): stop generating keepfile name
Jeff King [Thu, 16 Mar 2017 14:27:12 +0000 (10:27 -0400)] 
odb_pack_keep(): stop generating keepfile name

The odb_pack_keep() function generates the name of a .keep
file and opens it. This has two problems:

  1. It requires a fixed-size buffer to create the filename
     and doesn't notice when the result is truncated.

  2. Of the two callers, one sometimes wants to open a
     filename it already has, which makes things awkward (it
     has to do so manually, and skips the leading-directory
     creation).

Instead, let's have odb_pack_keep() just open the file.
Generating the name isn't hard, and a future patch will
switch callers over to odb_pack_name() anyway.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agosha1_file.c: make pack-name helper globally accessible
Jeff King [Thu, 16 Mar 2017 14:27:06 +0000 (10:27 -0400)] 
sha1_file.c: make pack-name helper globally accessible

We provide sha1_pack_name() and sha1_pack_index_name(), but
the more generic form (which takes its own strbuf and an
arbitrary extension) is only used to implement the other
two.  Let's make it available, but clean up a few things:

  1. Name it odb_pack_name(), as the original
     sha1_get_pack_name() is long but not all that
     descriptive.

  2. Switch the strbuf argument to the beginning, so that it
     matches similar path-building functions like
     git_path_buf().

  3. Clean up the out-dated docstring and move it to the
     public declaration.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agomove odb_* declarations out of git-compat-util.h
Jeff King [Thu, 16 Mar 2017 14:27:00 +0000 (10:27 -0400)] 
move odb_* declarations out of git-compat-util.h

These functions were originally conceived as wrapper
functions similar to xmkstemp(). They were later moved by
463db9b10 (wrapper: move odb_* to environment.c,
2010-11-06). The more appropriate place for a declaration is
in cache.h.

While we're at it, let's add some basic docstrings.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agorev-parse: simplify parsing of ref options
Jeff King [Wed, 15 Mar 2017 20:08:02 +0000 (16:08 -0400)] 
rev-parse: simplify parsing of ref options

All of these options do the same thing "--foo" iterates over
the "foo" refs, and "--foo=<glob>" does the same with a
glob. We can factor this into its own function to avoid
repeating ourselves.

There are two subtleties to note:

  - the original called for_each_branch_ref(), etc, in the
    non-glob case. Now we will call for_each_ref_in("refs/heads/")
    which is exactly what for_each_branch_ref() did under
    the hood.

  - for --glob, we'll call for_each_glob_ref_in() with a
    NULL "prefix" argument. Which is exactly what
    for_each_glob_ref() was doing already.

So both cases should behave identically, and it seems
reasonable to assume that this will remain the same. The
functions we are calling now are the more-generic ones, and
the ones we are dropping are just convenience wrappers.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agorev-parse: add helper for parsing "--foo/--foo="
Jeff King [Wed, 15 Mar 2017 20:06:53 +0000 (16:06 -0400)] 
rev-parse: add helper for parsing "--foo/--foo="

We can't just use a bare skip_prefix() for these cases,
because we need to match both the "--foo" form and the
"--foo=<value>" form (and tell the difference between the
two in the caller).

We can wrap this in a simple helper which has two obvious
callsites, and will gain some more in the next patch.

Note that the error output for abbrev-ref changes slightly,
as we don't keep our original "arg" pointer. However, the
new output should hopefully be more clear:

  [before]
  fatal: unknown mode for --abbrev-ref=foo

  [after]
  fatal: unknown mode for --abbrev-ref: foo

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agorev-parse: use skip_prefix when parsing options
Jeff King [Wed, 15 Mar 2017 20:05:36 +0000 (16:05 -0400)] 
rev-parse: use skip_prefix when parsing options

Using skip_prefix lets us avoid manually-counted offsets
into the argument string. This patch converts the simple and
obvious cases.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agosubmodule-config: correct error reporting for invalid ignore value
Stefan Beller [Tue, 14 Mar 2017 22:14:40 +0000 (15:14 -0700)] 
submodule-config: correct error reporting for invalid ignore value

As 'var' contains the whole value we get error messages that repeat
the section and key currently:

warning: Invalid parameter 'true' for config option 'submodule.submodule.plugins/hooks.ignore.ignore'

Fix this by only giving the section name in the warning.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agogit-status: make porcelain more robust
Michael J Gruber [Tue, 14 Mar 2017 16:02:02 +0000 (17:02 +0100)] 
git-status: make porcelain more robust

git status provides a porcelain mode for porcelain writers with a
supposedly stable (plumbing) interface.
7a76c28ff2 ("status: disable translation when --porcelain is used", 2014-03-20)
made sure that ahead/behind info is not translated (i.e. is stable).

Make sure that the remaining two strings (initial commit, detached head)
are stable, too.

These changes are for the v1 porcelain interface. While we do have a perfectly
stable v2 porcelain interface now, some tools (such as
powerline-gitstatus) are written against v1 and profit from fixing v1
without any changes on their side.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agohttp-walker: fix buffer underflow processing remote alternates
Jeff King [Mon, 13 Mar 2017 14:04:45 +0000 (10:04 -0400)] 
http-walker: fix buffer underflow processing remote alternates

If we parse a remote alternates (or http-alternates), we
expect relative lines like:

  ../../foo.git/objects

which we convert into "$URL/../foo.git/" (and then use that
as a base for fetching more objects).

But if the remote feeds us nonsense like just:

  ../

we will try to blindly strip the last 7 characters, assuming
they contain the string "objects". Since we don't _have_ 7
characters at all, this results in feeding a small negative
value to strbuf_add(), which converts it to a size_t,
resulting in a big positive value. This should consistently
fail (since we can't generall allocate the max size_t minus
7 bytes), so there shouldn't be any security implications.

Let's fix this by using strbuf_strip_suffix() to drop the
characters we want. If they're not present, we'll ignore the
alternate (in theory we could use it as-is, but the rest of
the http-walker code unconditionally tacks "objects/" back
on, so it is it not prepared to handle such a case).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoblame: move blame_entry duplication to add_blame_entry()
René Scharfe [Fri, 10 Mar 2017 00:12:59 +0000 (01:12 +0100)] 
blame: move blame_entry duplication to add_blame_entry()

All callers of add_blame_entry() allocate and copy the second argument.
Let the function do it for them, reducing code duplication.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agot/interop: add test of old clients against modern git-daemon
Jeff King [Sat, 25 Feb 2017 09:37:30 +0000 (04:37 -0500)] 
t/interop: add test of old clients against modern git-daemon

This test just checks that old clients can clone and fetch
from a newer git-daemon. The opposite should also be true,
but it's hard to test ancient versions of git-daemon because
they lack basic options like "--listen".

Note that we have to make a slight tweak to the
lib-git-daemon helper from the regular tests, so that it
starts the daemon with our correct git.a version.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agot: add an interoperability test harness
Jeff King [Sat, 25 Feb 2017 09:37:07 +0000 (04:37 -0500)] 
t: add an interoperability test harness

The current test suite is good at letting you test a
particular version of Git. But it's not very good at letting
you test _two_ versions and seeing how they interact (e.g.,
one cloning from the other).

This commit adds a test harness that will build two
arbitrary versions of git and make it easy to call them from
inside your tests. See the README and the example script for
details.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
7 years agoreal_pathdup(): fix callsites that wanted it to die on error
Johannes Schindelin [Wed, 8 Mar 2017 15:43:40 +0000 (16:43 +0100)] 
real_pathdup(): fix callsites that wanted it to die on error

In 4ac9006f832 (real_path: have callers use real_pathdup and
strbuf_realpath, 2016-12-12), we changed the xstrdup(real_path())
pattern to use real_pathdup() directly.

The problem with this change is that real_path() calls
strbuf_realpath() with die_on_error = 1 while real_pathdup() calls
it with die_on_error = 0. Meaning that in cases where real_path()
causes Git to die() with an error message, real_pathdup() is silent
and returns NULL instead.

The callers, however, are ill-prepared for that change, as they expect
the return value to be non-NULL (and otherwise the function died
with an appropriate error message).

Fix this by extending real_pathdup()'s signature to accept the
die_on_error flag and simply pass it through to strbuf_realpath(),
and then adjust all callers after a careful audit whether they would
handle NULLs well.

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