Skip to content

Commit 8e5dd3d

Browse files
pcloudsgitster
authored andcommitted
diff.c: allow to pass more flags to diff_populate_filespec
Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 735efde commit 8e5dd3d

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

diff.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ static unsigned long diff_filespec_size(struct diff_filespec *one)
376376
{
377377
if (!DIFF_FILE_VALID(one))
378378
return 0;
379-
diff_populate_filespec(one, 1);
379+
diff_populate_filespec(one, CHECK_SIZE_ONLY);
380380
return one->size;
381381
}
382382

@@ -1910,11 +1910,11 @@ static void show_dirstat(struct diff_options *options)
19101910
diff_free_filespec_data(p->one);
19111911
diff_free_filespec_data(p->two);
19121912
} else if (DIFF_FILE_VALID(p->one)) {
1913-
diff_populate_filespec(p->one, 1);
1913+
diff_populate_filespec(p->one, CHECK_SIZE_ONLY);
19141914
copied = added = 0;
19151915
diff_free_filespec_data(p->one);
19161916
} else if (DIFF_FILE_VALID(p->two)) {
1917-
diff_populate_filespec(p->two, 1);
1917+
diff_populate_filespec(p->two, CHECK_SIZE_ONLY);
19181918
copied = 0;
19191919
added = p->two->size;
19201920
diff_free_filespec_data(p->two);
@@ -2668,8 +2668,9 @@ static int diff_populate_gitlink(struct diff_filespec *s, int size_only)
26682668
* grab the data for the blob (or file) for our own in-core comparison.
26692669
* diff_filespec has data and size fields for this purpose.
26702670
*/
2671-
int diff_populate_filespec(struct diff_filespec *s, int size_only)
2671+
int diff_populate_filespec(struct diff_filespec *s, unsigned int flags)
26722672
{
2673+
int size_only = flags & CHECK_SIZE_ONLY;
26732674
int err = 0;
26742675
/*
26752676
* demote FAIL to WARN to allow inspecting the situation
@@ -4688,8 +4689,8 @@ static int diff_filespec_check_stat_unmatch(struct diff_filepair *p)
46884689
!DIFF_FILE_VALID(p->two) ||
46894690
(p->one->sha1_valid && p->two->sha1_valid) ||
46904691
(p->one->mode != p->two->mode) ||
4691-
diff_populate_filespec(p->one, 1) ||
4692-
diff_populate_filespec(p->two, 1) ||
4692+
diff_populate_filespec(p->one, CHECK_SIZE_ONLY) ||
4693+
diff_populate_filespec(p->two, CHECK_SIZE_ONLY) ||
46934694
(p->one->size != p->two->size) ||
46944695
!diff_filespec_is_identical(p->one, p->two)) /* (2) */
46954696
p->skip_stat_unmatch_result = 1;

diffcore-rename.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,11 @@ static int estimate_similarity(struct diff_filespec *src,
147147
* is a possible size - we really should have a flag to
148148
* say whether the size is valid or not!)
149149
*/
150-
if (!src->cnt_data && diff_populate_filespec(src, 1))
150+
if (!src->cnt_data &&
151+
diff_populate_filespec(src, CHECK_SIZE_ONLY))
151152
return 0;
152-
if (!dst->cnt_data && diff_populate_filespec(dst, 1))
153+
if (!dst->cnt_data &&
154+
diff_populate_filespec(dst, CHECK_SIZE_ONLY))
153155
return 0;
154156

155157
max_size = ((src->size > dst->size) ? src->size : dst->size);

diffcore.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ extern void free_filespec(struct diff_filespec *);
5555
extern void fill_filespec(struct diff_filespec *, const unsigned char *,
5656
int, unsigned short);
5757

58-
extern int diff_populate_filespec(struct diff_filespec *, int);
58+
#define CHECK_SIZE_ONLY 1
59+
extern int diff_populate_filespec(struct diff_filespec *, unsigned int);
5960
extern void diff_free_filespec_data(struct diff_filespec *);
6061
extern void diff_free_filespec_blob(struct diff_filespec *);
6162
extern int diff_filespec_is_binary(struct diff_filespec *);

0 commit comments

Comments
 (0)