Skip to content

Commit c95b99b

Browse files
peffgitster
authored andcommitted
combine-diff: calculate mode_differs earlier
One loop combined both the patch generation and checking whether there was any mode change to report. Let's factor that into two separate loops, as we may care about the mode change even if we are not generating patches (e.g., because we are showing a binary diff, which will come in a future patch). Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7c978a0 commit c95b99b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

combine-diff.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,13 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
845845
close(fd);
846846
}
847847

848+
for (i = 0; i < num_parent; i++) {
849+
if (elem->parent[i].mode != elem->mode) {
850+
mode_differs = 1;
851+
break;
852+
}
853+
}
854+
848855
for (cnt = 0, cp = result; cp < result + result_size; cp++) {
849856
if (*cp == '\n')
850857
cnt++;
@@ -893,8 +900,6 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
893900
elem->parent[i].mode,
894901
&result_file, sline,
895902
cnt, i, num_parent, result_deleted);
896-
if (elem->parent[i].mode != elem->mode)
897-
mode_differs = 1;
898903
}
899904

900905
show_hunks = make_hunks(sline, cnt, num_parent, dense);

0 commit comments

Comments
 (0)