MCPcopy Index your code
hub / github.com/git/git / run_diff_files

Function run_diff_files

diff-lib.c:109–297  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

107}
108
109void run_diff_files(struct rev_info *revs, unsigned int option)
110{
111 int entries, i;
112 int diff_unmerged_stage = revs->max_count;
113 unsigned ce_option = ((option & DIFF_RACY_IS_MODIFIED)
114 ? CE_MATCH_RACY_IS_DIRTY : 0);
115 uint64_t start = getnanotime();
116 struct index_state *istate = revs->diffopt.repo->index;
117
118 if (revs->diffopt.max_depth_valid)
119 die(_("max-depth is not supported for worktree diffs"));
120
121 diff_set_mnemonic_prefix(&revs->diffopt, "i/", "w/");
122
123 refresh_fsmonitor(istate);
124
125 if (diff_unmerged_stage < 0)
126 diff_unmerged_stage = 2;
127 entries = istate->cache_nr;
128 for (i = 0; i < entries; i++) {
129 unsigned int oldmode, newmode;
130 struct cache_entry *ce = istate->cache[i];
131 int changed;
132 unsigned dirty_submodule = 0;
133 const struct object_id *old_oid, *new_oid;
134
135 if (diff_can_quit_early(&revs->diffopt))
136 break;
137
138 /*
139 * NEEDSWORK:
140 * Here we filter with pathspec but the result is further
141 * filtered out when --relative is in effect. To end-users,
142 * a pathspec element that matched only to paths outside the
143 * current directory is like not matching anything at all;
144 * the handling of ps_matched[] here may become problematic
145 * if/when we add the "--error-unmatch" option to "git diff".
146 */
147 if (!ce_path_match(istate, ce, &revs->prune_data, revs->ps_matched))
148 continue;
149
150 if (revs->diffopt.prefix &&
151 strncmp(ce->name, revs->diffopt.prefix, revs->diffopt.prefix_length))
152 continue;
153
154 if (ce_stage(ce)) {
155 struct combine_diff_path *dpath;
156 struct diff_filepair *pair;
157 unsigned int wt_mode = 0;
158 int num_compare_stages = 0;
159 struct stat st;
160
161 changed = check_removed(ce, &st);
162 if (!changed)
163 wt_mode = ce_mode_from_stat(ce, st.st_mode);
164 else {
165 if (changed < 0) {
166 perror(ce->name);

Callers 12

has_unstaged_changesFunction · 0.85
get_modified_filesFunction · 0.85
add_files_to_cacheFunction · 0.85
cmd_diff_filesFunction · 0.85
evaluate_resultFunction · 0.85
edit_patchFunction · 0.85
status_submoduleFunction · 0.85
builtin_diff_filesFunction · 0.85

Calls 15

getnanotimeFunction · 0.85
diff_set_mnemonic_prefixFunction · 0.85
refresh_fsmonitorFunction · 0.85
diff_can_quit_earlyFunction · 0.85
ce_path_matchFunction · 0.85
check_removedFunction · 0.85
ce_mode_from_statFunction · 0.85
combine_diff_path_newFunction · 0.85
null_oidFunction · 0.85
oidcpyFunction · 0.85
show_combined_diffFunction · 0.85
diff_unmergeFunction · 0.85

Tested by

no test coverage detected