Skip to content

Commit 1626a18

Browse files
committed
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]>
1 parent f3f9031 commit 1626a18

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

add-interactive.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,7 @@ static int run_patch(struct add_i_state *s, const struct pathspec *ps,
913913

914914
opts->prompt = N_("Patch update");
915915
count = list_and_choose(s, files, opts);
916-
if (count >= 0) {
916+
if (count > 0) {
917917
struct argv_array args = ARGV_ARRAY_INIT;
918918
struct pathspec ps_selected = { 0 };
919919

@@ -954,7 +954,7 @@ static int run_diff(struct add_i_state *s, const struct pathspec *ps,
954954
opts->flags = IMMEDIATE;
955955
count = list_and_choose(s, files, opts);
956956
opts->flags = 0;
957-
if (count >= 0) {
957+
if (count > 0) {
958958
struct argv_array args = ARGV_ARRAY_INIT;
959959

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

0 commit comments

Comments
 (0)