Skip to content

Commit dcc883d

Browse files
committed
Merge branch 'jc/diff-files-ita'
Code cleanup. * jc/diff-files-ita: run_diff_files(): clarify computation of sha1 validity
2 parents 070f6fe + 0b86fe8 commit dcc883d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

diff-lib.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
101101
struct cache_entry *ce = active_cache[i];
102102
int changed;
103103
unsigned dirty_submodule = 0;
104+
const unsigned char *old_sha1, *new_sha1;
104105

105106
if (diff_can_quit_early(&revs->diffopt))
106107
break;
@@ -224,9 +225,12 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
224225
continue;
225226
}
226227
oldmode = ce->ce_mode;
228+
old_sha1 = ce->sha1;
229+
new_sha1 = changed ? null_sha1 : ce->sha1;
227230
diff_change(&revs->diffopt, oldmode, newmode,
228-
ce->sha1, (changed ? null_sha1 : ce->sha1),
229-
!is_null_sha1(ce->sha1), (changed ? 0 : !is_null_sha1(ce->sha1)),
231+
old_sha1, new_sha1,
232+
!is_null_sha1(old_sha1),
233+
!is_null_sha1(new_sha1),
230234
ce->name, 0, dirty_submodule);
231235

232236
}

0 commit comments

Comments
 (0)