summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--builtin/checkout-index.c8
-rwxr-xr-xt/t2004-checkout-cache-temp.sh10
2 files changed, 17 insertions, 1 deletions
diff --git a/builtin/checkout-index.c b/builtin/checkout-index.c
index a854fd1..195165d 100644
--- a/builtin/checkout-index.c
+++ b/builtin/checkout-index.c
@@ -79,6 +79,14 @@ static int checkout_file(const char *name, const char *prefix)
return errs > 0 ? -1 : 0;
}
+ /*
+ * At this point we know we didn't try to check anything out. If it was
+ * because we did find an entry but it was stage 0, that's not an
+ * error.
+ */
+ if (has_same_name && checkout_stage == CHECKOUT_ALL)
+ return 0;
+
if (!state.quiet) {
fprintf(stderr, "git checkout-index: %s ", name);
if (!has_same_name)
diff --git a/t/t2004-checkout-cache-temp.sh b/t/t2004-checkout-cache-temp.sh
index a12afe9..4308d69 100755
--- a/t/t2004-checkout-cache-temp.sh
+++ b/t/t2004-checkout-cache-temp.sh
@@ -88,9 +88,17 @@ test_expect_success 'checkout all stage 2 to temporary files' '
done
'
+test_expect_failure 'checkout all stages of unknown path' '
+ rm -f path* .merge_* actual &&
+ test_must_fail git checkout-index --stage=all --temp \
+ -- does-not-exist 2>stderr &&
+ test_i18ngrep not.in.the.cache stderr
+'
+
test_expect_success 'checkout all stages/one file to nothing' '
rm -f path* .merge_* actual &&
- git checkout-index --stage=all --temp -- path0 >actual &&
+ git checkout-index --stage=all --temp -- path0 >actual 2>stderr &&
+ test_must_be_empty stderr &&
test_line_count = 0 actual
'