From: Johannes Sixt Date: Mon, 13 Nov 2006 13:50:00 GMT Subject: [PATCH] Catch errors when writing an index that contains invalid objects. Message-ID: <11634257782215-git-send-email-j.sixt@eudaptics.com> In-Reply-To: <11634257784001-git-send-email-j.sixt@eudaptics.com> From: Johannes Sixt 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 --- cache-tree.c | 2 ++ t/t0000-basic.sh | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 0 deletions(-) diff --git a/cache-tree.c b/cache-tree.c index a803262..9b73c86 100644 --- a/cache-tree.c +++ b/cache-tree.c @@ -282,6 +282,8 @@ static int update_one(struct cache_tree 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 2c9bbb5..6aff0b8 100755 --- a/t/t0000-basic.sh +++ b/t/t0000-basic.sh @@ -209,6 +209,28 @@ test_expect_success \ 'validate object ID for a known tree.' \ 'test "$ptree" = 3c5e5399f3a333eddecce7a9b9465b63f65f51e2' +cat >badobjects <