Commit graph

46119 commits

Author SHA1 Message Date
Jeff King 51054177b3 index-pack: detect local corruption in collision check
When we notice that we have a local copy of an incoming
object, we compare the two objects to make sure we haven't
found a collision. Before we get to the actual object
bytes, though, we compare the type and size from
sha1_object_info().

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

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

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

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-04-01 10:48:11 -07:00
Jeff King 93cff9a978 sha1_loose_object_info: return error for corrupted objects
When sha1_loose_object_info() finds that a loose object file
cannot be stat(2)ed or mmap(2)ed, it returns -1 to signal an
error to the caller.  However, if it found that the loose
object file is corrupt and the object data cannot be used
from it, it stuffs OBJ_BAD into "type" field of the
object_info, but returns zero (i.e., success), which can
confuse callers.

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

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

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

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-04-01 10:45:16 -07:00
Junio C Hamano 49800c9407 Prepare for 2.12.3 2017-03-28 13:54:14 -07:00
Junio C Hamano 67476f59bc Merge branch 'km/config-grammofix' into maint
Doc update.

* km/config-grammofix:
  doc/config: grammar fixes for core.{editor,commentChar}
2017-03-28 13:52:29 -07:00
Junio C Hamano 88fb4aa23a Merge branch 'sb/t3600-rephrase' into maint
A test retitling.

* sb/t3600-rephrase:
  t3600: rename test to describe its functionality
2017-03-28 13:52:29 -07:00
Junio C Hamano 04b4f7d579 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
2017-03-28 13:52:29 -07:00
Junio C Hamano 27ee56f9db 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
2017-03-28 13:52:28 -07:00
Junio C Hamano fd7c41ec97 Merge branch 'rs/update-hook-optim' into maint
Code clean-up.

* rs/update-hook-optim:
  receive-pack: simplify run_update_post_hook()
2017-03-28 13:52:28 -07:00
Junio C Hamano fb0ab976c6 Merge branch 'rs/shortlog-cleanup' into maint
Code clean-up.

* rs/shortlog-cleanup:
  shortlog: don't set after_subject to an empty string
2017-03-28 13:52:28 -07:00
Junio C Hamano 1c91ec0b8e Merge branch 'rs/path-name-safety-cleanup' into maint
Code clean-up.

* rs/path-name-safety-cleanup:
  revision: remove declaration of path_name()
2017-03-28 13:52:27 -07:00
Junio C Hamano 310b94528c 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()
2017-03-28 13:52:26 -07:00
Junio C Hamano e3c551dd7b 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
2017-03-28 13:52:26 -07:00
Junio C Hamano ba5e05ffef 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
2017-03-28 13:52:25 -07:00
Junio C Hamano 8f71209d1e 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
2017-03-28 13:52:25 -07:00
Junio C Hamano a9508a1345 Merge branch 'rs/blame-code-cleanup' into maint
Code clean-up.

* rs/blame-code-cleanup:
  blame: move blame_entry duplication to add_blame_entry()
2017-03-28 13:52:25 -07:00
Junio C Hamano 110bdbddc8 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
2017-03-28 13:52:24 -07:00
Junio C Hamano 57009b1dd9 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'
2017-03-28 13:52:24 -07:00
Junio C Hamano fd3ab91ce6 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
2017-03-28 13:52:23 -07:00
Junio C Hamano c953cf95a5 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
2017-03-28 13:52:23 -07:00
Junio C Hamano bfee58c0a5 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
2017-03-28 13:52:22 -07:00
Junio C Hamano 2b69d3116f 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
2017-03-28 13:52:22 -07:00
Junio C Hamano 41534b626e 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}
2017-03-28 13:52:22 -07:00
Junio C Hamano e25c1229b2 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
2017-03-28 13:52:21 -07:00
Junio C Hamano bb622de88d 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
2017-03-28 13:52:21 -07:00
Junio C Hamano 252ef8fe9e 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
2017-03-28 13:52:21 -07:00
Junio C Hamano 930405224f 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
2017-03-28 13:52:20 -07:00
Junio C Hamano c34aa34299 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
2017-03-28 13:52:20 -07:00
Junio C Hamano e0c74e6f38 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
2017-03-28 13:52:19 -07:00
Junio C Hamano cd27bc7a0b 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
2017-03-28 13:52:19 -07:00
Junio C Hamano c772d1bcdc 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
2017-03-28 13:52:19 -07:00
Junio C Hamano 8f9aeb0d36 Git 2.12.2
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-03-24 12:59:15 -07:00
Junio C Hamano 75d4476f52 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
2017-03-24 12:57:55 -07:00
Junio C Hamano ce9e6178d3 Merge branch 'ab/push-default-doc-fix' into maint
Doc fix.

* ab/push-default-doc-fix:
  push: mention "push.default=tracking" in the documentation
2017-03-24 12:57:54 -07:00
Junio C Hamano 7bd881f7ca 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
2017-03-24 12:57:54 -07:00
Junio C Hamano eb4e87cef9 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
2017-03-24 12:57:54 -07:00
Junio C Hamano ea7aa5a464 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
2017-03-24 12:57:53 -07:00
Junio C Hamano 411a179412 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
2017-03-24 12:57:53 -07:00
Junio C Hamano f3d5bbb283 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
2017-03-24 12:57:52 -07:00
Junio C Hamano f4d3af1859 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
2017-03-24 12:57:52 -07:00
Michael J Gruber 296ab786ee 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>
2017-03-24 12:30:27 -07:00
Santiago Torres b42ca35e5c 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>
2017-03-24 10:19:18 -07:00
Kyle Meyer e7e183d6ee 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>
2017-03-23 12:04:08 -07:00
Junio C Hamano a4dded0189 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>
2017-03-22 15:39:51 -07:00
Junio C Hamano 37e61153e2 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>
2017-03-22 13:31:52 -07:00
Stefan Beller 70471ed9bb 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>
2017-03-22 10:13:17 -07:00
Junio C Hamano 8624735d9a Prepare for 2.12.2
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-03-21 15:04:12 -07:00
Junio C Hamano 71da2fb077 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
2017-03-21 15:03:30 -07:00
Junio C Hamano 7e02ec2c5d 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
2017-03-21 15:03:30 -07:00
Junio C Hamano d6bc22e64b 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
2017-03-21 15:03:29 -07:00
Junio C Hamano 93abd17871 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
2017-03-21 15:03:29 -07:00