git-commit-vandalism/builtin
Jeff King 77583e7739 index-pack: distinguish missing objects from type errors
When we fetch a pack that does not contain an object we
expected to receive, we get an error like:

  $ git init --bare tmp.git && cd tmp.git
  $ git fetch ../parent.git
  [...]
  error: Could not read 964953ec7bcc0245cb1d0db4095455edd21a2f2e
  fatal: Failed to traverse parents of commit b8247b40caf6704fe52736cdece6d6aae87471aa
  error: ../parent.git did not send all necessary objects

This comes from the check_everything_connected rev-list. If
we try cloning the same repo (rather than a fetch), we end
up using index-pack's --check-self-contained-and-connected
option instead, which produces output like:

  $ git clone --no-local --bare parent.git tmp.git
  [...]
  fatal: object of unexpected type
  fatal: index-pack failed

Not only is the sha1 missing, but it's a misleading message.
There's no type problem, but rather a missing object
problem; we don't notice the difference because we simply
compare OBJ_BAD != OBJ_BLOB.  Let's provide a different
message for this case:

  $ git clone --no-local --bare parent.git tmp.git
  fatal: did not receive expected object 6b00a8c61ed379d5f925a72c1987c9c52129d364
  fatal: index-pack failed

While we're at it, let's also improve a true type mismatch
error to look like

  fatal: object 6b00a8c61ed379d5f925a72c1987c9c52129d364: expected type blob, got tree

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-05-12 11:27:50 -07:00
..
add.c pathspec: convert some match_pathspec_depth() to dir_path_match() 2014-02-24 14:37:09 -08:00
annotate.c
apply.c comments: fix misuses of "nor" 2014-03-31 15:29:27 -07:00
archive.c replace {pre,suf}fixcmp() with {starts,ends}_with() 2013-12-05 14:13:21 -08:00
bisect--helper.c Replace deprecated OPT_BOOLEAN by OPT_BOOL 2013-08-05 11:32:19 -07:00
blame.c Merge branch 'js/lift-parent-count-limit' 2014-01-10 10:33:36 -08:00
branch.c Merge branch 'cc/starts-n-ends-with' 2013-12-17 12:02:44 -08:00
bundle.c
cat-file.c Merge branch 'jk/oi-delta-base' 2014-01-10 10:33:11 -08:00
check-attr.c Merge branch 'jc/check-attr-honor-working-tree' into maint 2014-03-18 14:03:03 -07:00
check-ignore.c Merge branch 'dw/check-ignore-sans-index' 2013-09-20 12:37:32 -07:00
check-mailmap.c builtin: add git-check-mailmap command 2013-07-13 10:19:37 -07:00
check-ref-format.c
checkout-index.c Merge branch 'nd/lift-path-max' 2013-10-30 12:10:56 -07:00
checkout.c Merge branch 'jl/nor-or-nand-and' into maint 2014-04-09 12:03:26 -07:00
clean.c code and test: fix misuses of "nor" 2014-03-31 15:29:33 -07:00
clone.c commit: fix patch hunk editing with "commit -p -m" 2014-03-18 11:25:12 -07:00
column.c replace {pre,suf}fixcmp() with {starts,ends}_with() 2013-12-05 14:13:21 -08:00
commit-tree.c commit-tree: document -S option consistently 2013-03-25 15:01:22 -07:00
commit.c Merge branch 'jl/nor-or-nand-and' into maint 2014-04-09 12:03:26 -07:00
config.c repo-config: remove deprecated alias for "git config" 2013-11-12 14:10:17 -08:00
count-objects.c count-objects: add -H option to humanize sizes 2013-04-10 13:27:26 -07:00
credential.c git credential fill: output the whole 'struct credential' 2012-06-25 11:56:24 -07:00
describe.c replace {pre,suf}fixcmp() with {starts,ends}_with() 2013-12-05 14:13:21 -08:00
diff-files.c convert read_cache_preload() to take struct pathspec 2013-07-15 10:56:08 -07:00
diff-index.c convert read_cache_preload() to take struct pathspec 2013-07-15 10:56:08 -07:00
diff-tree.c
diff.c Merge branch 'tg/diff-no-index-refactor' 2013-12-27 14:58:17 -08:00
fast-export.c Merge branch 'cc/starts-n-ends-with' 2013-12-17 12:02:44 -08:00
fetch-pack.c Merge branch 'nd/shallow-clone' 2014-01-17 12:21:20 -08:00
fetch.c Merge branch 'nd/transport-positive-depth-only' into maint 2014-02-05 13:58:52 -08:00
fmt-merge-msg.c replace {pre,suf}fixcmp() with {starts,ends}_with() 2013-12-05 14:13:21 -08:00
for-each-ref.c Merge branch 'maint' 2013-12-30 12:27:01 -08:00
fsck.c replace {pre,suf}fixcmp() with {starts,ends}_with() 2013-12-05 14:13:21 -08:00
gc.c commit: fix patch hunk editing with "commit -p -m" 2014-03-18 11:25:12 -07:00
get-tar-commit-id.c stop installing git-tar-tree link 2013-12-03 12:35:22 -08:00
grep.c pathspec: convert some match_pathspec_depth() to dir_path_match() 2014-02-24 14:37:09 -08:00
hash-object.c hash-object: replace stdin parsing OPT_BOOLEAN by OPT_COUNTUP 2013-08-07 08:30:55 -07:00
help.c builtin/help.c: speed up is_git_command() by checking for builtin commands first 2014-01-06 11:26:31 -08:00
index-pack.c index-pack: distinguish missing objects from type errors 2014-05-12 11:27:50 -07:00
init-db.c Merge branch 'mh/safe-create-leading-directories' 2014-01-27 10:45:33 -08:00
log.c comments: fix misuses of "nor" 2014-03-31 15:29:27 -07:00
ls-files.c pathspec: pass directory indicator to match_pathspec_item() 2014-02-24 14:37:19 -08:00
ls-remote.c replace {pre,suf}fixcmp() with {starts,ends}_with() 2013-12-05 14:13:21 -08:00
ls-tree.c pathspec: rename match_pathspec_depth() to match_pathspec() 2014-02-24 14:37:14 -08:00
mailinfo.c replace {pre,suf}fixcmp() with {starts,ends}_with() 2013-12-05 14:13:21 -08:00
mailsplit.c mailsplit: sort maildir filenames more cleverly 2013-03-02 22:52:44 -08:00
merge-base.c Merge branch 'bm/merge-base-octopus-dedup' into maint 2014-02-13 13:38:59 -08:00
merge-file.c Replace deprecated OPT_BOOLEAN by OPT_BOOL 2013-08-05 11:32:19 -07:00
merge-index.c Convert "struct cache_entry *" to "const ..." wherever possible 2013-07-09 09:12:48 -07:00
merge-ours.c
merge-recursive.c replace {pre,suf}fixcmp() with {starts,ends}_with() 2013-12-05 14:13:21 -08:00
merge-tree.c merge-tree: handle directory/empty conflict correctly 2013-05-06 22:17:00 -07:00
merge.c merge: fix GIT_EDITOR override for commit hook 2014-03-18 11:25:38 -07:00
mktag.c
mktree.c i18n: mktree: mark parseopt strings for translation 2012-08-20 12:23:18 -07:00
mv.c mv: prevent mismatched data when ignoring errors. 2014-03-17 11:38:41 -07:00
name-rev.c Merge branch 'cc/starts-n-ends-with' 2013-12-17 12:02:44 -08:00
notes.c replace {pre,suf}fixcmp() with {starts,ends}_with() 2013-12-05 14:13:21 -08:00
pack-objects.c comments: fix misuses of "nor" 2014-03-31 15:29:27 -07:00
pack-redundant.c Fix sizeof usage in get_permutations 2012-12-13 11:13:44 -08:00
pack-refs.c pack-refs: merge code from pack-refs.{c,h} into refs.{c,h} 2013-05-01 15:33:11 -07:00
patch-id.c
prune-packed.c prune-packed: use strbuf to avoid having to worry about PATH_MAX 2013-12-17 10:43:30 -08:00
prune.c Merge branch 'nd/shallow-clone' 2014-01-17 12:21:20 -08:00
push.c Merge branch 'jc/push-refmap' 2013-12-27 14:57:50 -08:00
read-tree.c C: have space around && and || operators 2013-10-16 10:26:39 -07:00
receive-pack.c shallow: automatically clean up shallow tempfiles 2014-02-27 12:07:13 -08:00
reflog.c replace {pre,suf}fixcmp() with {starts,ends}_with() 2013-12-05 14:13:21 -08:00
remote-ext.c
remote-fd.c
remote.c Merge branch 'cc/starts-n-ends-with' 2013-12-17 12:02:44 -08:00
repack.c Merge branch 'sb/repack-in-c' into maint 2014-02-13 13:38:09 -08:00
replace.c replace info: rename 'full' to 'long' and clarify in-code symbols 2013-12-30 12:33:11 -08:00
rerere.c rerere: convert to use parse_pathspec 2013-07-15 10:56:07 -07:00
reset.c reset: optionally setup worktree and refresh index on --mixed 2014-02-18 14:40:23 -08:00
rev-list.c C: have space around && and || operators 2013-10-16 10:26:39 -07:00
rev-parse.c Merge branch 'ds/rev-parse-required-args' into maint 2014-03-18 14:01:05 -07:00
revert.c Merge branch 'hu/cherry-pick-previous-branch' 2013-10-23 13:21:35 -07:00
rm.c pathspec: convert some match_pathspec_depth() to ce_path_match() 2014-02-24 14:36:52 -08:00
send-pack.c Merge branch 'nd/shallow-clone' 2014-01-17 12:21:20 -08:00
shortlog.c replace {pre,suf}fixcmp() with {starts,ends}_with() 2013-12-05 14:13:21 -08:00
show-branch.c Merge branch 'cc/starts-n-ends-with' 2013-12-17 12:02:44 -08:00
show-ref.c replace {pre,suf}fixcmp() with {starts,ends}_with() 2013-12-05 14:13:21 -08:00
stripspace.c builtin/stripspace.c: fix broken indentation 2013-09-06 13:33:17 -07:00
symbolic-ref.c replace {pre,suf}fixcmp() with {starts,ends}_with() 2013-12-05 14:13:21 -08:00
tag.c replace {pre,suf}fixcmp() with {starts,ends}_with() 2013-12-05 14:13:21 -08:00
unpack-file.c
unpack-objects.c replace {pre,suf}fixcmp() with {starts,ends}_with() 2013-12-05 14:13:21 -08:00
update-index.c pathspec: convert some match_pathspec_depth() to ce_path_match() 2014-02-24 14:36:52 -08:00
update-ref.c update-ref: fail create operation over stdin if ref already exists 2014-04-02 10:40:43 -07:00
update-server-info.c i18n: update-server-info: mark parseopt strings for translation 2012-08-22 10:58:29 -07:00
upload-archive.c replace {pre,suf}fixcmp() with {starts,ends}_with() 2013-12-05 14:13:21 -08:00
var.c ident: rename IDENT_ERROR_ON_NO_NAME to IDENT_STRICT 2012-05-24 17:16:41 -07:00
verify-pack.c i18n: verify-pack: mark parseopt strings for translation 2012-08-22 10:58:29 -07:00
verify-tag.c gpg_interface: allow to request status return 2013-02-14 09:30:04 -08:00
write-tree.c i18n: write-tree: mark parseopt strings for translation 2012-08-22 10:58:29 -07:00