forked from gitster/git
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiffcore.h
More file actions
Latest commit
132 lines (112 loc) · 4.37 KB
/
Copy pathdiffcore.h
File metadata and controls
132 lines (112 loc) · 4.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/*
* Copyright (C) 2005 Junio C Hamano
*/
#ifndefDIFFCORE_H
#defineDIFFCORE_H
/* This header file is internal between diff.c and its diff transformers
* (e.g. diffcore-rename, diffcore-pickaxe). Never include this header
* in anything else.
*/
/* We internally use unsigned short as the score value,
* and rely on an int capable to hold 32-bits. -B can take
* -Bmerge_score/break_score format and the two scores are
* passed around in one int (high 16-bit for merge and low 16-bit
* for break).
*/
#defineMAX_SCORE 60000.0
#defineDEFAULT_RENAME_SCORE 30000 /* rename/copy similarity minimum (50%) */
#defineDEFAULT_BREAK_SCORE 30000 /* minimum for break to happen (50%) */
#defineDEFAULT_MERGE_SCORE 36000 /* maximum for break-merge to happen (60%) */
#defineMINIMUM_BREAK_SIZE 400 /* do not break a file smaller than this */
structuserdiff_driver;
structdiff_filespec {
unsigned charsha1[20];
char*path;
void*data;
void*cnt_data;
constchar*funcname_pattern_ident;
unsigned longsize;
intcount; /* Reference count */
intxfrm_flags; /* for use by the xfrm */
intrename_used; /* Count of rename users */
unsigned shortmode; /* file mode */
unsignedsha1_valid : 1; /* if true, use sha1 and trust mode;
* if false, use the name and read from
* the filesystem.
*/
#defineDIFF_FILE_VALID(spec) (((spec)->mode) != 0)
unsignedshould_free : 1; /* data should be free()'ed */
unsignedshould_munmap : 1; /* data should be munmap()'ed */
unsigneddirty_submodule : 2; /* For submodules: its work tree is dirty */
#defineDIRTY_SUBMODULE_UNTRACKED 1
#defineDIRTY_SUBMODULE_MODIFIED 2
unsignedhas_more_entries : 1; /* only appear in combined diff */
structuserdiff_driver*driver;
/* data should be considered "binary"; -1 means "don't know yet" */
intis_binary;
};
externstructdiff_filespec*alloc_filespec(constchar*);
externvoidfree_filespec(structdiff_filespec*);
externvoidfill_filespec(structdiff_filespec*, constunsigned char*,
unsigned short);
externintdiff_populate_filespec(structdiff_filespec*, int);
externvoiddiff_free_filespec_data(structdiff_filespec*);
externvoiddiff_free_filespec_blob(structdiff_filespec*);
externintdiff_filespec_is_binary(structdiff_filespec*);
structdiff_filepair {
structdiff_filespec*one;
structdiff_filespec*two;
unsigned short intscore;
charstatus; /* M C R A D U etc. (see Documentation/diff-format.txt or DIFF_STATUS_* in diff.h) */
unsignedbroken_pair : 1;
unsignedrenamed_pair : 1;
unsignedis_unmerged : 1;
};
#defineDIFF_PAIR_UNMERGED(p) ((p)->is_unmerged)
#defineDIFF_PAIR_RENAME(p) ((p)->renamed_pair)
#defineDIFF_PAIR_BROKEN(p) \
( (!DIFF_FILE_VALID((p)->one) != !DIFF_FILE_VALID((p)->two)) && \
((p)->broken_pair != 0) )
#defineDIFF_PAIR_TYPE_CHANGED(p) \
((S_IFMT & (p)->one->mode) != (S_IFMT & (p)->two->mode))
#defineDIFF_PAIR_MODE_CHANGED(p) ((p)->one->mode != (p)->two->mode)
externvoiddiff_free_filepair(structdiff_filepair*);
externintdiff_unmodified_pair(structdiff_filepair*);
structdiff_queue_struct {
structdiff_filepair**queue;
intalloc;
intnr;
};
#defineDIFF_QUEUE_CLEAR(q) \
do { \
(q)->queue = NULL; \
(q)->nr = (q)->alloc = 0; \
} while (0)
externstructdiff_queue_structdiff_queued_diff;
externstructdiff_filepair*diff_queue(structdiff_queue_struct*,
structdiff_filespec*,
structdiff_filespec*);
externvoiddiff_q(structdiff_queue_struct*, structdiff_filepair*);
externvoiddiffcore_break(int);
externvoiddiffcore_rename(structdiff_options*);
externvoiddiffcore_merge_broken(void);
externvoiddiffcore_pickaxe(structdiff_options*);
externvoiddiffcore_order(constchar*orderfile);
#defineDIFF_DEBUG 0
#ifDIFF_DEBUG
voiddiff_debug_filespec(structdiff_filespec*, int, constchar*);
voiddiff_debug_filepair(conststructdiff_filepair*, int);
voiddiff_debug_queue(constchar*, structdiff_queue_struct*);
#else
#definediff_debug_filespec(a,b,c) do { /* nothing */ } while (0)
#definediff_debug_filepair(a,b) do { /* nothing */ } while (0)
#definediff_debug_queue(a,b) do { /* nothing */ } while (0)
#endif
externintdiffcore_count_changes(structdiff_filespec*src,
structdiff_filespec*dst,
void**src_count_p,
void**dst_count_p,
unsigned longdelta_limit,
unsigned long*src_copied,
unsigned long*literal_added);
#endif