Skip to content

Commit

Permalink
clone: die on errors from unpack_trees
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jeff King authored and Junio C Hamano committed Mar 27, 2013
1 parent 0e15ad9 commit 0aac7bb
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion builtin/clone.c
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,8 @@ static int checkout(void)
tree = parse_tree_indirect(sha1);
parse_tree(tree);
init_tree_desc(&t, tree->buffer, tree->size);
unpack_trees(1, &t, &opts);
if (unpack_trees(1, &t, &opts) < 0)
die(_("unable to checkout working tree"));

if (write_cache(fd, active_cache, active_nr) ||
commit_locked_index(lock_file))
Expand Down
2 changes: 1 addition & 1 deletion t/t1060-object-corruption.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ test_expect_success 'clone --local detects corruption' '
test_must_fail git clone --local bit-error corrupt-checkout
'

test_expect_failure 'clone --local detects missing objects' '
test_expect_success 'clone --local detects missing objects' '
test_must_fail git clone --local missing missing-checkout
'

Expand Down
2 changes: 1 addition & 1 deletion t/t5710-info-alternate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ test_expect_success 'creating too deep nesting' \
git clone -l -s D E &&
git clone -l -s E F &&
git clone -l -s F G &&
git clone -l -s G H'
git clone --bare -l -s G H'

test_expect_success 'invalidity of deepest repository' \
'cd H && {
Expand Down

0 comments on commit 0aac7bb

Please sign in to comment.