Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit 0aac7bb

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0e15ad9 commit 0aac7bb

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

builtin/clone.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,8 @@ static int checkout(void)
579579
tree = parse_tree_indirect(sha1);
580580
parse_tree(tree);
581581
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"));
583584

584585
if (write_cache(fd, active_cache, active_nr) ||
585586
commit_locked_index(lock_file))

t/t1060-object-corruption.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ test_expect_success 'clone --local detects corruption' '
8989
test_must_fail git clone --local bit-error corrupt-checkout
9090
'
9191

92-
test_expect_failure 'clone --local detects missing objects' '
92+
test_expect_success 'clone --local detects missing objects' '
9393
test_must_fail git clone --local missing missing-checkout
9494
'
9595

t/t5710-info-alternate.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ test_expect_success 'creating too deep nesting' \
5858
git clone -l -s D E &&
5959
git clone -l -s E F &&
6060
git clone -l -s F G &&
61-
git clone -l -s G H'
61+
git clone --bare -l -s G H'
6262

6363
test_expect_success 'invalidity of deepest repository' \
6464
'cd H && {

0 commit comments

Comments
 (0)