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

Function find_origin

blame.c:1325–1416  ·  view source on GitHub ↗

* We have an origin -- check if the same path exists in the * parent and return an origin structure to represent it. */

Source from the content-addressed store, hash-verified

1323 * parent and return an origin structure to represent it.
1324 */
1325static struct blame_origin *find_origin(struct repository *r,
1326 struct commit *parent,
1327 struct blame_origin *origin,
1328 struct blame_bloom_data *bd)
1329{
1330 struct blame_origin *porigin;
1331 struct diff_options diff_opts;
1332 const char *paths[2];
1333
1334 /* First check any existing origins */
1335 for (porigin = get_blame_suspects(parent); porigin; porigin = porigin->next)
1336 if (!strcmp(porigin->path, origin->path)) {
1337 /*
1338 * The same path between origin and its parent
1339 * without renaming -- the most common case.
1340 */
1341 return blame_origin_incref (porigin);
1342 }
1343
1344 /* See if the origin->path is different between parent
1345 * and origin first. Most of the time they are the
1346 * same and diff-tree is fairly efficient about this.
1347 */
1348 repo_diff_setup(r, &diff_opts);
1349 diff_opts.flags.recursive = 1;
1350 diff_opts.detect_rename = 0;
1351 diff_opts.output_format = DIFF_FORMAT_NO_OUTPUT;
1352 paths[0] = origin->path;
1353 paths[1] = NULL;
1354
1355 parse_pathspec(&diff_opts.pathspec,
1356 PATHSPEC_ALL_MAGIC & ~PATHSPEC_LITERAL,
1357 PATHSPEC_LITERAL_PATH, "", paths);
1358 diff_setup_done(&diff_opts);
1359
1360 if (is_null_oid(&origin->commit->object.oid))
1361 do_diff_cache(get_commit_tree_oid(parent), &diff_opts);
1362 else {
1363 int compute_diff = 1;
1364 if (origin->commit->parents &&
1365 oideq(&parent->object.oid,
1366 &origin->commit->parents->item->object.oid))
1367 compute_diff = maybe_changed_path(r, origin, bd);
1368
1369 if (compute_diff)
1370 diff_tree_oid(get_commit_tree_oid(parent),
1371 get_commit_tree_oid(origin->commit),
1372 "", &diff_opts);
1373 }
1374 diffcore_std(&diff_opts);
1375
1376 if (!diff_queued_diff.nr) {
1377 /* The path is the same as parent */
1378 porigin = get_origin(parent, origin->path);
1379 oidcpy(&porigin->blob_oid, &origin->blob_oid);
1380 porigin->mode = origin->mode;
1381 } else {
1382 /*

Callers

nothing calls this directly

Calls 15

get_blame_suspectsFunction · 0.85
blame_origin_increfFunction · 0.85
repo_diff_setupFunction · 0.85
parse_pathspecFunction · 0.85
diff_setup_doneFunction · 0.85
is_null_oidFunction · 0.85
do_diff_cacheFunction · 0.85
get_commit_tree_oidFunction · 0.85
oideqFunction · 0.85
diff_tree_oidFunction · 0.85
diffcore_stdFunction · 0.85
get_originFunction · 0.85

Tested by

no test coverage detected