MCPcopy Create free account
hub / github.com/git/git / diff_tree_local

Function diff_tree_local

notes-merge.c:194–274  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

192}
193
194static void diff_tree_local(struct notes_merge_options *o,
195 struct notes_merge_pair *changes, int len,
196 const struct object_id *base,
197 const struct object_id *local)
198{
199 struct diff_options opt;
200 int i;
201
202 trace_printf("\tdiff_tree_local(len = %i, base = %.7s, local = %.7s)\n",
203 len, oid_to_hex(base), oid_to_hex(local));
204
205 repo_diff_setup(o->repo, &opt);
206 opt.flags.recursive = 1;
207 opt.output_format = DIFF_FORMAT_NO_OUTPUT;
208 diff_setup_done(&opt);
209 diff_tree_oid(base, local, "", &opt);
210 diffcore_std(&opt);
211
212 for (i = 0; i < diff_queued_diff.nr; i++) {
213 struct diff_filepair *p = diff_queued_diff.queue[i];
214 struct notes_merge_pair *mp;
215 int match;
216 struct object_id obj;
217
218 if (verify_notes_filepair(p, &obj)) {
219 trace_printf("\t\tCannot merge entry '%s' (%c): "
220 "%.7s -> %.7s. Skipping!\n", p->one->path,
221 p->status, oid_to_hex(&p->one->oid),
222 oid_to_hex(&p->two->oid));
223 continue;
224 }
225 mp = find_notes_merge_pair_pos(changes, len, &obj, 0, &match);
226 if (!match) {
227 trace_printf("\t\tIgnoring local-only change for %s: "
228 "%.7s -> %.7s\n", oid_to_hex(&obj),
229 oid_to_hex(&p->one->oid),
230 oid_to_hex(&p->two->oid));
231 continue;
232 }
233
234 assert(oideq(&mp->obj, &obj));
235 if (is_null_oid(&p->two->oid)) { /* deletion */
236 /*
237 * Either this is a true deletion (1), or it is part
238 * of an A/D pair (2), or D/A pair (3):
239 *
240 * (1) mp->local is uninitialized; set it to null_sha1
241 * (2) mp->local is not uninitialized; don't touch it
242 * (3) mp->local is uninitialized; set it to null_sha1
243 * (will be overwritten by following addition)
244 */
245 if (oideq(&mp->local, &uninitialized))
246 oidclr(&mp->local, the_repository->hash_algo);
247 } else if (is_null_oid(&p->one->oid)) { /* addition */
248 /*
249 * Either this is a true addition (1), or it is part
250 * of an A/D pair (2), or D/A pair (3):
251 *

Callers 1

merge_from_diffsFunction · 0.85

Calls 12

oid_to_hexFunction · 0.85
repo_diff_setupFunction · 0.85
diff_setup_doneFunction · 0.85
diff_tree_oidFunction · 0.85
diffcore_stdFunction · 0.85
verify_notes_filepairFunction · 0.85
oideqFunction · 0.85
is_null_oidFunction · 0.85
oidclrFunction · 0.85
oidcpyFunction · 0.85
diff_flushFunction · 0.85

Tested by

no test coverage detected