Skip to content

Commit 706098a

Browse files
committed
diffcore_filespec: add is_binary
diffcore-break and diffcore-rename would want to behave slightly differently depending on the binary-ness of the data, so add one bit to the filespec, as the structure is now passed down to diffcore_count_changes() function. Signed-off-by: Junio C Hamano <[email protected]>
1 parent d8c3d03 commit 706098a

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

diff.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3005,6 +3005,22 @@ void diffcore_std(struct diff_options *options)
30053005
{
30063006
if (options->quiet)
30073007
return;
3008+
3009+
/*
3010+
* break/rename count similarity differently depending on
3011+
* the binary-ness.
3012+
*/
3013+
if ((options->break_opt != -1) || (options->detect_rename)) {
3014+
struct diff_queue_struct *q = &diff_queued_diff;
3015+
int i;
3016+
3017+
for (i = 0; i < q->nr; i++) {
3018+
struct diff_filepair *p = q->queue[i];
3019+
p->one->is_binary = file_is_binary(p->one);
3020+
p->two->is_binary = file_is_binary(p->two);
3021+
}
3022+
}
3023+
30083024
if (options->break_opt != -1)
30093025
diffcore_break(options->break_opt);
30103026
if (options->detect_rename)

diffcore.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ struct diff_filespec {
3737
#define DIFF_FILE_VALID(spec) (((spec)->mode) != 0)
3838
unsigned should_free : 1; /* data should be free()'ed */
3939
unsigned should_munmap : 1; /* data should be munmap()'ed */
40+
unsigned is_binary : 1; /* data should be considered "binary" */
4041
};
4142

4243
extern struct diff_filespec *alloc_filespec(const char *);

0 commit comments

Comments
 (0)