summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 40cf043)
raw | patch | inline | side by side (parent: 40cf043)
author | Johannes Sixt <johannes.sixt@telecom.at> | |
Mon, 13 Nov 2006 13:50:00 +0000 (13:50 +0000) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Mon, 13 Nov 2006 22:26:51 +0000 (14:26 -0800) |
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>
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>
cache-tree.c | patch | blob | history | |
t/t0000-basic.sh | patch | blob | history |
diff --git a/cache-tree.c b/cache-tree.c
index a80326289dbea2c08acce577cf8eef26a0cfba68..9b73c8669a0946c3bcbf1de777e9acd4cd34bcae 100644 (file)
--- a/cache-tree.c
+++ b/cache-tree.c
baselen + sublen + 1,
missing_ok,
dryrun);
+ if (subcnt < 0)
+ return subcnt;
i += subcnt - 1;
sub->used = 1;
}
diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh
index 2c9bbb59b03d97ea668ab3010eaca95eb36f64e8..6aff0b808cbf6ccf973070898976854b1f874b5b 100755 (executable)
--- a/t/t0000-basic.sh
+++ b/t/t0000-basic.sh
'validate object ID for a known tree.' \
'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
test_expect_success \