@matheusbsbs / matheus-bagliano / commits / 6b9315d5a1
Fork 0

unpack-trees: handle failure in verify_absent

Commit 203a2fe1 (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 <gitster@pobox.com>

Clemens Buchacher committed Jan 1, 2009 at 21:54 UTC 6b9315d5a14b4d1389cff347fcfcb86624bbf645
2 files changed +29 -3
t/t1001-read-tree-m-2way.sh
+24
@@ -341,4 +341,28 @@ test_expect_success \
341 check_cache_at DF/DF dirty &&
342 :'
343
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 +
368 test_done
unpack-trees.c
+5 -3
@@ -587,7 +587,7 @@ static int verify_absent(struct cache_entry *ce, const char *action,
587 return 0;
588
589 if (!lstat(ce->name, &st)) {
590 - int cnt;
590 + int ret;
591 int dtype = ce_to_dtype(ce);
592 struct cache_entry *result;
593
@@ -615,7 +615,9 @@ static int verify_absent(struct cache_entry *ce, const char *action,
615 * files that are in "foo/" we would lose
616 * it.
617 */
618 - cnt = verify_clean_subdirectory(ce, action, o);
618 + ret = verify_clean_subdirectory(ce, action, o);
619 + if (ret < 0)
620 + return ret;
621
622 /*
623 * If this removed entries from the index,
@@ -634,7 +636,7 @@ static int verify_absent(struct cache_entry *ce, const char *action,
636 * We need to increment it by the number of
637 * deleted entries here.
638 */
637 - o->pos += cnt;
639 + o->pos += ret;
640 return 0;
641 }
642