clone: die on errors from unpack_trees

When clone is populating the working tree, it ignores the return status from unpack_trees; this means we may report a successful clone, even when the checkout fails. When checkout fails, we may want to leave the $GIT_DIR in place, as it might be possible to recover the data through further use of "git checkout" (e.g., if the checkout failed due to a transient error, disk full, etc). However, we already die on a number of other checkout-related errors, so this patch follows that pattern. In addition to marking a now-passing test, we need to adjust t5710, which blindly assumed it could make bogus clones of very deep alternates hierarchies. By using "--bare", we can avoid it actually touching any objects. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Mar 25, 2013 at 16:23 UTC 0aac7bb287645dd72ad8ad6b805128b8ff7f111f
3 files changed +4 -3
builtin/clone.c
+2 -1
@@ -579,7 +579,8 @@ static int checkout(void)
579 tree = parse_tree_indirect(sha1);
580 parse_tree(tree);
581 init_tree_desc(&t, tree->buffer, tree->size);
582 - unpack_trees(1, &t, &opts);
582 + if (unpack_trees(1, &t, &opts) < 0)
583 + die(_("unable to checkout working tree"));
584
585 if (write_cache(fd, active_cache, active_nr) ||
586 commit_locked_index(lock_file))
t/t1060-object-corruption.sh
+1 -1
@@ -89,7 +89,7 @@ test_expect_success 'clone --local detects corruption' '
89 test_must_fail git clone --local bit-error corrupt-checkout
90 '
91
92 -test_expect_failure 'clone --local detects missing objects' '
92 +test_expect_success 'clone --local detects missing objects' '
93 test_must_fail git clone --local missing missing-checkout
94 '
95
t/t5710-info-alternate.sh
+1 -1
@@ -58,7 +58,7 @@ test_expect_success 'creating too deep nesting' \
58 git clone -l -s D E &&
59 git clone -l -s E F &&
60 git clone -l -s F G &&
61 -git clone -l -s G H'
61 +git clone --bare -l -s G H'
62
63 test_expect_success 'invalidity of deepest repository' \
64 'cd H && {