Skip to content

Commit 6b9315d

Browse files
Clemens Buchachergitster
authored andcommitted
unpack-trees: handle failure in verify_absent
Commit 203a2fe (Allow callers of unpack_trees() to handle failure) changed the "die on error" behavior to "return failure code". verify_absent did not handle errors returned by verify_clean_subdirectory, however. Signed-off-by: Junio C Hamano <[email protected]>
1 parent ea02eef commit 6b9315d

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

t/t1001-read-tree-m-2way.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,4 +341,28 @@ test_expect_success \
341341
check_cache_at DF/DF dirty &&
342342
:'
343343

344+
test_expect_success \
345+
'a/b (untracked) vs a case setup.' \
346+
'rm -f .git/index &&
347+
: >a &&
348+
git update-index --add a &&
349+
treeM=`git write-tree` &&
350+
echo treeM $treeM &&
351+
git ls-tree $treeM &&
352+
git ls-files --stage >treeM.out &&
353+
354+
rm -f a &&
355+
git update-index --remove a &&
356+
mkdir a &&
357+
: >a/b &&
358+
treeH=`git write-tree` &&
359+
echo treeH $treeH &&
360+
git ls-tree $treeH'
361+
362+
test_expect_success \
363+
'a/b (untracked) vs a, plus c/d case test.' \
364+
'! git read-tree -u -m "$treeH" "$treeM" &&
365+
git ls-files --stage &&
366+
test -f a/b'
367+
344368
test_done

unpack-trees.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ static int verify_absent(struct cache_entry *ce, const char *action,
587587
return 0;
588588

589589
if (!lstat(ce->name, &st)) {
590-
int cnt;
590+
int ret;
591591
int dtype = ce_to_dtype(ce);
592592
struct cache_entry *result;
593593

@@ -615,7 +615,9 @@ static int verify_absent(struct cache_entry *ce, const char *action,
615615
* files that are in "foo/" we would lose
616616
* it.
617617
*/
618-
cnt = verify_clean_subdirectory(ce, action, o);
618+
ret = verify_clean_subdirectory(ce, action, o);
619+
if (ret < 0)
620+
return ret;
619621

620622
/*
621623
* If this removed entries from the index,
@@ -634,7 +636,7 @@ static int verify_absent(struct cache_entry *ce, const char *action,
634636
* We need to increment it by the number of
635637
* deleted entries here.
636638
*/
637-
o->pos += cnt;
639+
o->pos += ret;
638640
return 0;
639641
}
640642

0 commit comments

Comments
 (0)