Catch errors when writing an index that contains invalid objects.
If git-write-index is called without --missing-ok, it reports invalid objects that it finds in the index. But without this patch it dies right away or may run into an infinite loop. Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at> Signed-off-by: Junio C Hamano <junkio@cox.net>maint
parent
40cf043389
commit
3d12d0cfbb
|
@ -282,6 +282,8 @@ static int update_one(struct cache_tree *it,
|
||||||
baselen + sublen + 1,
|
baselen + sublen + 1,
|
||||||
missing_ok,
|
missing_ok,
|
||||||
dryrun);
|
dryrun);
|
||||||
|
if (subcnt < 0)
|
||||||
|
return subcnt;
|
||||||
i += subcnt - 1;
|
i += subcnt - 1;
|
||||||
sub->used = 1;
|
sub->used = 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -209,6 +209,28 @@ test_expect_success \
|
||||||
'validate object ID for a known tree.' \
|
'validate object ID for a known tree.' \
|
||||||
'test "$ptree" = 3c5e5399f3a333eddecce7a9b9465b63f65f51e2'
|
'test "$ptree" = 3c5e5399f3a333eddecce7a9b9465b63f65f51e2'
|
||||||
|
|
||||||
|
cat >badobjects <<EOF
|
||||||
|
100644 blob 1000000000000000000000000000000000000000 dir/file1
|
||||||
|
100644 blob 2000000000000000000000000000000000000000 dir/file2
|
||||||
|
100644 blob 3000000000000000000000000000000000000000 dir/file3
|
||||||
|
100644 blob 4000000000000000000000000000000000000000 dir/file4
|
||||||
|
100644 blob 5000000000000000000000000000000000000000 dir/file5
|
||||||
|
EOF
|
||||||
|
|
||||||
|
rm .git/index
|
||||||
|
test_expect_success \
|
||||||
|
'put invalid objects into the index.' \
|
||||||
|
'git-update-index --index-info < badobjects'
|
||||||
|
|
||||||
|
test_expect_failure \
|
||||||
|
'writing this tree without --missing-ok.' \
|
||||||
|
'git-write-tree'
|
||||||
|
|
||||||
|
test_expect_success \
|
||||||
|
'writing this tree with --missing-ok.' \
|
||||||
|
'git-write-tree --missing-ok'
|
||||||
|
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
rm .git/index
|
rm .git/index
|
||||||
test_expect_success \
|
test_expect_success \
|
||||||
|
|
Loading…
Reference in New Issue