Skip to content

Commit 0d4217d

Browse files
peffgitster
authored andcommitted
run_external_diff: hoist common bits out of conditional
Whether we have diff_filespecs to give to the diff command or not, we always are going to run the program and pass it the pathname. Let's pull that duplicated part out of the conditional to make it more obvious. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 5b88caa commit 0d4217d

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

diff.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2911,13 +2911,14 @@ static void run_external_diff(const char *pgm,
29112911
struct argv_array env = ARGV_ARRAY_INIT;
29122912
struct diff_queue_struct *q = &diff_queued_diff;
29132913

2914+
argv_array_push(&argv, pgm);
2915+
argv_array_push(&argv, name);
2916+
29142917
if (one && two) {
29152918
struct diff_tempfile *temp_one, *temp_two;
29162919
const char *othername = (other ? other : name);
29172920
temp_one = prepare_temp_file(name, one);
29182921
temp_two = prepare_temp_file(othername, two);
2919-
argv_array_push(&argv, pgm);
2920-
argv_array_push(&argv, name);
29212922
argv_array_push(&argv, temp_one->name);
29222923
argv_array_push(&argv, temp_one->hex);
29232924
argv_array_push(&argv, temp_one->mode);
@@ -2928,9 +2929,6 @@ static void run_external_diff(const char *pgm,
29282929
argv_array_push(&argv, other);
29292930
argv_array_push(&argv, xfrm_msg);
29302931
}
2931-
} else {
2932-
argv_array_push(&argv, pgm);
2933-
argv_array_push(&argv, name);
29342932
}
29352933

29362934
argv_array_pushf(&env, "GIT_DIFF_PATH_COUNTER=%d", ++o->diff_path_counter);

0 commit comments

Comments
 (0)