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

Function cmd_unregister

scalar.c:873–917  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

871}
872
873static int cmd_unregister(int argc, const char **argv)
874{
875 struct option options[] = {
876 OPT_END(),
877 };
878 const char * const usage[] = {
879 N_("scalar unregister [<enlistment>]"),
880 NULL
881 };
882
883 argc = parse_options(argc, argv, NULL, options,
884 usage, 0);
885
886 /*
887 * Be forgiving when the enlistment or worktree does not even exist any
888 * longer; This can be the case if a user deleted the worktree by
889 * mistake and _still_ wants to unregister the thing.
890 */
891 if (argc == 1) {
892 struct strbuf src_path = STRBUF_INIT, workdir_path = STRBUF_INIT;
893
894 strbuf_addf(&src_path, "%s/src/.git", argv[0]);
895 strbuf_addf(&workdir_path, "%s/.git", argv[0]);
896 if (!is_directory(src_path.buf) && !is_directory(workdir_path.buf)) {
897 /* remove possible matching registrations */
898 int res = -1;
899
900 strbuf_strip_suffix(&src_path, "/.git");
901 res = remove_deleted_enlistment(&src_path) && res;
902
903 strbuf_strip_suffix(&workdir_path, "/.git");
904 res = remove_deleted_enlistment(&workdir_path) && res;
905
906 strbuf_release(&src_path);
907 strbuf_release(&workdir_path);
908 return res;
909 }
910 strbuf_release(&src_path);
911 strbuf_release(&workdir_path);
912 }
913
914 setup_enlistment_directory(argc, argv, usage, options, NULL);
915
916 return unregister_dir();
917}
918
919static int cmd_delete(int argc, const char **argv)
920{

Callers

nothing calls this directly

Calls 8

parse_optionsFunction · 0.85
strbuf_addfFunction · 0.85
is_directoryFunction · 0.85
strbuf_strip_suffixFunction · 0.85
strbuf_releaseFunction · 0.85
unregister_dirFunction · 0.85

Tested by

no test coverage detected