summaryrefslogtreecommitdiff
path: root/add-interactive.c
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2020-01-16 08:33:06 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-01-16 22:10:21 (GMT)
commitd660a30ceb9d8bd9940be82d240901c87999186b (patch)
tree1dd87ac8eb5f06dbc95bb00be5478131e0dc7bfe /add-interactive.c
parent2e697ced9d647d6998d70f010d582ba8019fe3af (diff)
downloadgit-d660a30ceb9d8bd9940be82d240901c87999186b.zip
git-d660a30ceb9d8bd9940be82d240901c87999186b.tar.gz
git-d660a30ceb9d8bd9940be82d240901c87999186b.tar.bz2
built-in add -i: do not try to `patch`/`diff` an empty list of files
When the user does not select any files to `patch` or `diff`, there is no need to call `run_add_p()` on them. Even worse: we _have_ to avoid calling `parse_pathspec()` with an empty list because that would trigger this error: BUG: pathspec.c:557: PATHSPEC_PREFER_CWD requires arguments So let's avoid doing any work on a list of files that is empty anyway. This fixes https://github.com/git-for-windows/git/issues/2466. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'add-interactive.c')
-rw-r--r--add-interactive.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/add-interactive.c b/add-interactive.c
index f395d54..14d4688 100644
--- a/add-interactive.c
+++ b/add-interactive.c
@@ -915,7 +915,7 @@ static int run_patch(struct add_i_state *s, const struct pathspec *ps,
opts->prompt = N_("Patch update");
count = list_and_choose(s, files, opts);
- if (count >= 0) {
+ if (count > 0) {
struct argv_array args = ARGV_ARRAY_INIT;
argv_array_pushl(&args, "git", "add--interactive", "--patch",
@@ -953,7 +953,7 @@ static int run_diff(struct add_i_state *s, const struct pathspec *ps,
opts->flags = IMMEDIATE;
count = list_and_choose(s, files, opts);
opts->flags = 0;
- if (count >= 0) {
+ if (count > 0) {
struct argv_array args = ARGV_ARRAY_INIT;
argv_array_pushl(&args, "git", "diff", "-p", "--cached",