Browse Source

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>
maint
Nguyễn Thái Ngọc Duy 11 years ago committed by Junio C Hamano
parent
commit
8e5dd3d654
  1. 13
      diff.c
  2. 6
      diffcore-rename.c
  3. 3
      diffcore.h

13
diff.c

@ -376,7 +376,7 @@ static unsigned long diff_filespec_size(struct diff_filespec *one)
{ {
if (!DIFF_FILE_VALID(one)) if (!DIFF_FILE_VALID(one))
return 0; return 0;
diff_populate_filespec(one, 1); diff_populate_filespec(one, CHECK_SIZE_ONLY);
return one->size; return one->size;
} }


@ -1910,11 +1910,11 @@ static void show_dirstat(struct diff_options *options)
diff_free_filespec_data(p->one); diff_free_filespec_data(p->one);
diff_free_filespec_data(p->two); diff_free_filespec_data(p->two);
} else if (DIFF_FILE_VALID(p->one)) { } else if (DIFF_FILE_VALID(p->one)) {
diff_populate_filespec(p->one, 1); diff_populate_filespec(p->one, CHECK_SIZE_ONLY);
copied = added = 0; copied = added = 0;
diff_free_filespec_data(p->one); diff_free_filespec_data(p->one);
} else if (DIFF_FILE_VALID(p->two)) { } else if (DIFF_FILE_VALID(p->two)) {
diff_populate_filespec(p->two, 1); diff_populate_filespec(p->two, CHECK_SIZE_ONLY);
copied = 0; copied = 0;
added = p->two->size; added = p->two->size;
diff_free_filespec_data(p->two); diff_free_filespec_data(p->two);
@ -2668,8 +2668,9 @@ static int diff_populate_gitlink(struct diff_filespec *s, int size_only)
* grab the data for the blob (or file) for our own in-core comparison. * grab the data for the blob (or file) for our own in-core comparison.
* diff_filespec has data and size fields for this purpose. * diff_filespec has data and size fields for this purpose.
*/ */
int diff_populate_filespec(struct diff_filespec *s, int size_only) int diff_populate_filespec(struct diff_filespec *s, unsigned int flags)
{ {
int size_only = flags & CHECK_SIZE_ONLY;
int err = 0; int err = 0;
/* /*
* demote FAIL to WARN to allow inspecting the situation * demote FAIL to WARN to allow inspecting the situation
@ -4688,8 +4689,8 @@ static int diff_filespec_check_stat_unmatch(struct diff_filepair *p)
!DIFF_FILE_VALID(p->two) || !DIFF_FILE_VALID(p->two) ||
(p->one->sha1_valid && p->two->sha1_valid) || (p->one->sha1_valid && p->two->sha1_valid) ||
(p->one->mode != p->two->mode) || (p->one->mode != p->two->mode) ||
diff_populate_filespec(p->one, 1) || diff_populate_filespec(p->one, CHECK_SIZE_ONLY) ||
diff_populate_filespec(p->two, 1) || diff_populate_filespec(p->two, CHECK_SIZE_ONLY) ||
(p->one->size != p->two->size) || (p->one->size != p->two->size) ||
!diff_filespec_is_identical(p->one, p->two)) /* (2) */ !diff_filespec_is_identical(p->one, p->two)) /* (2) */
p->skip_stat_unmatch_result = 1; p->skip_stat_unmatch_result = 1;

6
diffcore-rename.c

@ -147,9 +147,11 @@ static int estimate_similarity(struct diff_filespec *src,
* is a possible size - we really should have a flag to * is a possible size - we really should have a flag to
* say whether the size is valid or not!) * say whether the size is valid or not!)
*/ */
if (!src->cnt_data && diff_populate_filespec(src, 1)) if (!src->cnt_data &&
diff_populate_filespec(src, CHECK_SIZE_ONLY))
return 0; return 0;
if (!dst->cnt_data && diff_populate_filespec(dst, 1)) if (!dst->cnt_data &&
diff_populate_filespec(dst, CHECK_SIZE_ONLY))
return 0; return 0;


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

3
diffcore.h

@ -55,7 +55,8 @@ extern void free_filespec(struct diff_filespec *);
extern void fill_filespec(struct diff_filespec *, const unsigned char *, extern void fill_filespec(struct diff_filespec *, const unsigned char *,
int, unsigned short); int, unsigned short);


extern int diff_populate_filespec(struct diff_filespec *, int); #define CHECK_SIZE_ONLY 1
extern int diff_populate_filespec(struct diff_filespec *, unsigned int);
extern void diff_free_filespec_data(struct diff_filespec *); extern void diff_free_filespec_data(struct diff_filespec *);
extern void diff_free_filespec_blob(struct diff_filespec *); extern void diff_free_filespec_blob(struct diff_filespec *);
extern int diff_filespec_is_binary(struct diff_filespec *); extern int diff_filespec_is_binary(struct diff_filespec *);

Loading…
Cancel
Save