diff.c: allow to pass more flags to diff_populate_filespec
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy committed
Aug 16, 2014 at 10:08 UTC
8e5dd3d654ebb9e86e06b9ef5ca86bd6ebf44de1
3 files changed
+13
-9
diff.c
+7
-6
@@ -376,7 +376,7 @@ static unsigned long diff_filespec_size(struct diff_filespec *one)
376
{
377
if (!DIFF_FILE_VALID(one))
378
return 0;
379
- diff_populate_filespec(one, 1);
379
+ diff_populate_filespec(one, CHECK_SIZE_ONLY);
380
return one->size;
381
}
382
@@ -1910,11 +1910,11 @@ static void show_dirstat(struct diff_options *options)
1910
diff_free_filespec_data(p->one);
1911
diff_free_filespec_data(p->two);
1912
} else if (DIFF_FILE_VALID(p->one)) {
1913
- diff_populate_filespec(p->one, 1);
1913
+ diff_populate_filespec(p->one, CHECK_SIZE_ONLY);
1914
copied = added = 0;
1915
diff_free_filespec_data(p->one);
1916
} else if (DIFF_FILE_VALID(p->two)) {
1917
- diff_populate_filespec(p->two, 1);
1917
+ diff_populate_filespec(p->two, CHECK_SIZE_ONLY);
1918
copied = 0;
1919
added = p->two->size;
1920
diff_free_filespec_data(p->two);
@@ -2668,8 +2668,9 @@ static int diff_populate_gitlink(struct diff_filespec *s, int size_only)
2668
* grab the data for the blob (or file) for our own in-core comparison.
2669
* diff_filespec has data and size fields for this purpose.
2670
*/
2671
-int diff_populate_filespec(struct diff_filespec *s, int size_only)
2671
+int diff_populate_filespec(struct diff_filespec *s, unsigned int flags)
2672
{
2673
+ int size_only = flags & CHECK_SIZE_ONLY;
2674
int err = 0;
2675
/*
2676
* demote FAIL to WARN to allow inspecting the situation
@@ -4688,8 +4689,8 @@ static int diff_filespec_check_stat_unmatch(struct diff_filepair *p)
4689
!DIFF_FILE_VALID(p->two) ||
4690
(p->one->sha1_valid && p->two->sha1_valid) ||
4691
(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) ||
4694
(p->one->size != p->two->size) ||
4695
!diff_filespec_is_identical(p->one, p->two)) /* (2) */
4696
p->skip_stat_unmatch_result = 1;
diffcore-rename.c
+4
-2
@@ -147,9 +147,11 @@ static int estimate_similarity(struct diff_filespec *src,
147
* is a possible size - we really should have a flag to
148
* say whether the size is valid or not!)
149
*/
150
- if (!src->cnt_data && diff_populate_filespec(src, 1))
150
+ if (!src->cnt_data &&
151
+ diff_populate_filespec(src, CHECK_SIZE_ONLY))
152
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))
155
return 0;
156
157
max_size = ((src->size > dst->size) ? src->size : dst->size);
diffcore.h
+2
-1
@@ -55,7 +55,8 @@ extern void free_filespec(struct diff_filespec *);
55
extern void fill_filespec(struct diff_filespec *, const unsigned char *,
56
int, unsigned short);
57
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);
60
extern void diff_free_filespec_data(struct diff_filespec *);
61
extern void diff_free_filespec_blob(struct diff_filespec *);
62
extern int diff_filespec_is_binary(struct diff_filespec *);