path: root/builtin/checkout-index.c
diff options
authorJeff King <>2020-10-27 07:36:02 (GMT)
committerJunio C Hamano <>2020-10-27 19:41:54 (GMT)
commit0b809c82480a870f4a46fa66f0eddc1c1b04cf6b (patch)
treeac766b1f5e226b95d804eb911a3b7533e35d4ce4 /builtin/checkout-index.c
parentb927c80531cca9b9107754186532e8cb00884008 (diff)
checkout-index: drop error message from empty --stage=all
If checkout-index is given --stage=all for a specific path, it will try to write stages 1-3 (if present) for that path to temporary files. However, if the file is present only at stage 0, it writes nothing but gives a confusing message: $ git checkout-index --stage=all -- Makefile git checkout-index: Makefile does not exist at stage 4 This is nonsense. There is no stage 4 (it's just an internal enum value we use for "all"), and the documentation clearly states: Paths which only have a stage 0 entry will always be omitted from the output. Here it's talking about the list of tempfiles written to stdout, but it seems clear that this case was not meant to be an error. We even have a test which covers it, but it only checks that the command reports an exit code of 0, not its stderr. And it reports 0 only because of another bug which fails to propagate errors (which will be fixed in a subsequent patch). So let's make the test more thorough. We'll also cover the case that we found _no_ entry, not even a stage zero, which should still be an error. However, because of the other bug, we'll have to mark this as expecting failure for the moment. Signed-off-by: Jeff King <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'builtin/checkout-index.c')
1 files changed, 8 insertions, 0 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)