Skip to content

Commit d660a30

Browse files
dschogitster
authored andcommitted
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 git-for-windows#2466. Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2e697ce commit d660a30

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

add-interactive.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -915,7 +915,7 @@ static int run_patch(struct add_i_state *s, const struct pathspec *ps,
915915

916916
opts->prompt = N_("Patch update");
917917
count = list_and_choose(s, files, opts);
918-
if (count >= 0) {
918+
if (count > 0) {
919919
struct argv_array args = ARGV_ARRAY_INIT;
920920

921921
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,
953953
opts->flags = IMMEDIATE;
954954
count = list_and_choose(s, files, opts);
955955
opts->flags = 0;
956-
if (count >= 0) {
956+
if (count > 0) {
957957
struct argv_array args = ARGV_ARRAY_INIT;
958958

959959
argv_array_pushl(&args, "git", "diff", "-p", "--cached",

0 commit comments

Comments
 (0)