diff options
author | Junio C Hamano <gitster@pobox.com> | 2020-11-09 14:06:26 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-11-09 14:06:26 -0800 |
commit | 92d6bd2e9064200b14f3730b674eb8eb7b7cd50e (patch) | |
tree | 893ad27fed4f7f9abcb6fc394a69f526ca283327 /builtin | |
parent | Merge branch 'jk/perl-warning' (diff) | |
parent | checkout-index: propagate errors to exit code (diff) | |
download | tgif-92d6bd2e9064200b14f3730b674eb8eb7b7cd50e.tar.xz |
Merge branch 'jk/checkout-index-errors'
"git checkout-index" did not consistently signal an error with its
exit status.
* jk/checkout-index-errors:
checkout-index: propagate errors to exit code
checkout-index: drop error message from empty --stage=all
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/checkout-index.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/builtin/checkout-index.c b/builtin/checkout-index.c index a854fd16e7..4bbfc92dce 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) @@ -159,6 +167,7 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix) int prefix_length; int force = 0, quiet = 0, not_new = 0; int index_opt = 0; + int err = 0; struct option builtin_checkout_index_options[] = { OPT_BOOL('a', "all", &all, N_("check out all files in the index")), @@ -223,7 +232,7 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix) if (read_from_stdin) die("git checkout-index: don't mix '--stdin' and explicit filenames"); p = prefix_path(prefix, prefix_length, arg); - checkout_file(p, prefix); + err |= checkout_file(p, prefix); free(p); } @@ -245,13 +254,16 @@ int cmd_checkout_index(int argc, const char **argv, const char *prefix) strbuf_swap(&buf, &unquoted); } p = prefix_path(prefix, prefix_length, buf.buf); - checkout_file(p, prefix); + err |= checkout_file(p, prefix); free(p); } strbuf_release(&unquoted); strbuf_release(&buf); } + if (err) + return 1; + if (all) checkout_all(prefix, prefix_length); |