Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit fceb907

Browse files
pcloudsgitster
authored andcommitted
diff.c: move diffcore_skip_stat_unmatch core logic out for reuse later
Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2f93541 commit fceb907

File tree

1 file changed

+28
-21
lines changed

1 file changed

+28
-21
lines changed

diff.c

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4592,6 +4592,33 @@ static int diff_filespec_is_identical(struct diff_filespec *one,
45924592
return !memcmp(one->data, two->data, one->size);
45934593
}
45944594

4595+
static int diff_filespec_check_stat_unmatch(struct diff_filepair *p)
4596+
{
4597+
/*
4598+
* 1. Entries that come from stat info dirtiness
4599+
* always have both sides (iow, not create/delete),
4600+
* one side of the object name is unknown, with
4601+
* the same mode and size. Keep the ones that
4602+
* do not match these criteria. They have real
4603+
* differences.
4604+
*
4605+
* 2. At this point, the file is known to be modified,
4606+
* with the same mode and size, and the object
4607+
* name of one side is unknown. Need to inspect
4608+
* the identical contents.
4609+
*/
4610+
if (!DIFF_FILE_VALID(p->one) || /* (1) */
4611+
!DIFF_FILE_VALID(p->two) ||
4612+
(p->one->sha1_valid && p->two->sha1_valid) ||
4613+
(p->one->mode != p->two->mode) ||
4614+
diff_populate_filespec(p->one, 1) ||
4615+
diff_populate_filespec(p->two, 1) ||
4616+
(p->one->size != p->two->size) ||
4617+
!diff_filespec_is_identical(p->one, p->two)) /* (2) */
4618+
return 1;
4619+
return 0;
4620+
}
4621+
45954622
static void diffcore_skip_stat_unmatch(struct diff_options *diffopt)
45964623
{
45974624
int i;
@@ -4602,27 +4629,7 @@ static void diffcore_skip_stat_unmatch(struct diff_options *diffopt)
46024629
for (i = 0; i < q->nr; i++) {
46034630
struct diff_filepair *p = q->queue[i];
46044631

4605-
/*
4606-
* 1. Entries that come from stat info dirtiness
4607-
* always have both sides (iow, not create/delete),
4608-
* one side of the object name is unknown, with
4609-
* the same mode and size. Keep the ones that
4610-
* do not match these criteria. They have real
4611-
* differences.
4612-
*
4613-
* 2. At this point, the file is known to be modified,
4614-
* with the same mode and size, and the object
4615-
* name of one side is unknown. Need to inspect
4616-
* the identical contents.
4617-
*/
4618-
if (!DIFF_FILE_VALID(p->one) || /* (1) */
4619-
!DIFF_FILE_VALID(p->two) ||
4620-
(p->one->sha1_valid && p->two->sha1_valid) ||
4621-
(p->one->mode != p->two->mode) ||
4622-
diff_populate_filespec(p->one, 1) ||
4623-
diff_populate_filespec(p->two, 1) ||
4624-
(p->one->size != p->two->size) ||
4625-
!diff_filespec_is_identical(p->one, p->two)) /* (2) */
4632+
if (diff_filespec_check_stat_unmatch(p))
46264633
diff_q(&outq, p);
46274634
else {
46284635
/*

0 commit comments

Comments
 (0)