Return error when not checking out an entry due to dirtiness.
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>
Junio C Hamano committed
Oct 3, 2005 at 12:44 UTC
4b12dae69a41471e7c8139de26c1135f7ecccbd8
2 files changed
+8
-3
checkout-index.c
+7
-2
@@ -63,15 +63,20 @@ static int checkout_file(const char *name)
63
64
static int checkout_all(void)
65
{
66
- int i;
66
+ int i, errs = 0;
67
68
for (i = 0; i < active_nr ; i++) {
69
struct cache_entry *ce = active_cache[i];
70
if (ce_stage(ce))
71
continue;
72
if (checkout_entry(ce, &state) < 0)
73
- return -1;
73
+ errs++;
74
}
75
+ if (errs)
76
+ /* we have already done our error reporting.
77
+ * exit with the same code as die().
78
+ */
79
+ exit(128);
80
return 0;
81
}
82
entry.c
+1
-1
@@ -132,7 +132,7 @@ int checkout_entry(struct cache_entry *ce, struct checkout *state)
132
if (!state->force) {
133
if (!state->quiet)
134
fprintf(stderr, "git-checkout-index: %s already exists\n", path);
135
- return 0;
135
+ return -1;
136
}
137
138
/*