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

Function prune_shallow

shallow.c:485–515  ·  view source on GitHub ↗

* mark_reachable_objects() should have been run prior to this and all * reachable commits marked as "SEEN", except when quick_prune is non-zero, * in which case lines are excised from the shallow file if they refer to * commits that do not exist (any longer). */

Source from the content-addressed store, hash-verified

483 * commits that do not exist (any longer).
484 */
485void prune_shallow(unsigned options)
486{
487 struct shallow_lock shallow_lock = SHALLOW_LOCK_INIT;
488 struct strbuf sb = STRBUF_INIT;
489 unsigned flags = SEEN_ONLY;
490 int fd;
491
492 if (options & PRUNE_QUICK)
493 flags |= QUICK;
494
495 if (options & PRUNE_SHOW_ONLY) {
496 flags |= VERBOSE;
497 write_shallow_commits_1(&sb, 0, NULL, flags);
498 strbuf_release(&sb);
499 return;
500 }
501 fd = hold_lock_file_for_update(&shallow_lock.lock,
502 git_path_shallow(the_repository),
503 LOCK_DIE_ON_ERROR);
504 check_shallow_file_for_update(the_repository);
505 if (write_shallow_commits_1(&sb, 0, NULL, flags)) {
506 if (write_in_full(fd, sb.buf, sb.len) < 0)
507 die_errno("failed to write to %s",
508 get_lock_file_path(&shallow_lock.lock));
509 commit_shallow_file(the_repository, &shallow_lock);
510 } else {
511 unlink(git_path_shallow(the_repository));
512 rollback_shallow_file(the_repository, &shallow_lock);
513 }
514 strbuf_release(&sb);
515}
516
517struct trace_key trace_shallow = TRACE_KEY_INIT(SHALLOW);
518

Callers 2

cmd_pruneFunction · 0.85
cmd_repackFunction · 0.85

Calls 9

write_shallow_commits_1Function · 0.85
strbuf_releaseFunction · 0.85
write_in_fullFunction · 0.85
die_errnoFunction · 0.85
get_lock_file_pathFunction · 0.85
commit_shallow_fileFunction · 0.85
rollback_shallow_fileFunction · 0.85

Tested by

no test coverage detected