Skip to content

Commit

Permalink
combine-diff: calculate mode_differs earlier
Browse files Browse the repository at this point in the history
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 <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Jeff King authored and Junio C Hamano committed May 23, 2011
1 parent 7c978a0 commit c95b99b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions combine-diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,13 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
close(fd);
}

for (i = 0; i < num_parent; i++) {
if (elem->parent[i].mode != elem->mode) {
mode_differs = 1;
break;
}
}

for (cnt = 0, cp = result; cp < result + result_size; cp++) {
if (*cp == '\n')
cnt++;
Expand Down Expand Up @@ -893,8 +900,6 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
elem->parent[i].mode,
&result_file, sline,
cnt, i, num_parent, result_deleted);
if (elem->parent[i].mode != elem->mode)
mode_differs = 1;
}

show_hunks = make_hunks(sline, cnt, num_parent, dense);
Expand Down

0 comments on commit c95b99b

Please sign in to comment.