Skip to content

Commit

Permalink
Return error when not checking out an entry due to dirtiness.
Browse files Browse the repository at this point in the history
Without -f flag, 'git-checkout-index foo.c' issued an error message
when foo.c already existed in the working tree and did not match index.
However it did not return an error from the underlying checkout_entry()
function and resulted in a successful exit(0).

Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Junio C Hamano committed Oct 5, 2005
1 parent 64a2228 commit 4b12dae
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions checkout-index.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,20 @@ static int checkout_file(const char *name)

static int checkout_all(void)
{
int i;
int i, errs = 0;

for (i = 0; i < active_nr ; i++) {
struct cache_entry *ce = active_cache[i];
if (ce_stage(ce))
continue;
if (checkout_entry(ce, &state) < 0)
return -1;
errs++;
}
if (errs)
/* we have already done our error reporting.
* exit with the same code as die().
*/
exit(128);
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion entry.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ int checkout_entry(struct cache_entry *ce, struct checkout *state)
if (!state->force) {
if (!state->quiet)
fprintf(stderr, "git-checkout-index: %s already exists\n", path);
return 0;
return -1;
}

/*
Expand Down

0 comments on commit 4b12dae

Please sign in to comment.