Skip to content

Commit

Permalink
unpack-trees: handle failure in verify_absent
Browse files Browse the repository at this point in the history
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 <gitster@pobox.com>
  • Loading branch information
Clemens Buchacher authored and Junio C Hamano committed Jan 5, 2009
1 parent ea02eef commit 6b9315d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
24 changes: 24 additions & 0 deletions t/t1001-read-tree-m-2way.sh
Original file line number Diff line number Diff line change
Expand Up @@ -341,4 +341,28 @@ test_expect_success \
check_cache_at DF/DF dirty &&
:'

test_expect_success \
'a/b (untracked) vs a case setup.' \
'rm -f .git/index &&
: >a &&
git update-index --add a &&
treeM=`git write-tree` &&
echo treeM $treeM &&
git ls-tree $treeM &&
git ls-files --stage >treeM.out &&
rm -f a &&
git update-index --remove a &&
mkdir a &&
: >a/b &&
treeH=`git write-tree` &&
echo treeH $treeH &&
git ls-tree $treeH'

test_expect_success \
'a/b (untracked) vs a, plus c/d case test.' \
'! git read-tree -u -m "$treeH" "$treeM" &&
git ls-files --stage &&
test -f a/b'

test_done
8 changes: 5 additions & 3 deletions unpack-trees.c
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ static int verify_absent(struct cache_entry *ce, const char *action,
return 0;

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

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

/*
* If this removed entries from the index,
Expand All @@ -634,7 +636,7 @@ static int verify_absent(struct cache_entry *ce, const char *action,
* We need to increment it by the number of
* deleted entries here.
*/
o->pos += cnt;
o->pos += ret;
return 0;
}

Expand Down

0 comments on commit 6b9315d

Please sign in to comment.