Skip to content

Commit db19535

Browse files
dschoGit for Windows Build Agent
authored and
Git for Windows Build Agent
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 #2466. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent f5afcb8 commit db19535

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
@@ -931,7 +931,7 @@ static int run_patch(struct add_i_state *s, const struct pathspec *ps,
931931

932932
opts->prompt = N_("Patch update");
933933
count = list_and_choose(s, files, opts);
934-
if (count >= 0) {
934+
if (count > 0) {
935935
struct argv_array args = ARGV_ARRAY_INIT;
936936
struct pathspec ps_selected = { 0 };
937937

@@ -972,7 +972,7 @@ static int run_diff(struct add_i_state *s, const struct pathspec *ps,
972972
opts->flags = IMMEDIATE;
973973
count = list_and_choose(s, files, opts);
974974
opts->flags = 0;
975-
if (count >= 0) {
975+
if (count > 0) {
976976
struct argv_array args = ARGV_ARRAY_INIT;
977977

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

0 commit comments

Comments
 (0)