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

Function rm

builtin/remote.c:1006–1110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1004}
1005
1006static int rm(int argc, const char **argv, const char *prefix,
1007 struct repository *repo UNUSED)
1008{
1009 struct option options[] = {
1010 OPT_END()
1011 };
1012 struct remote *remote;
1013 struct strbuf buf = STRBUF_INIT;
1014 struct known_remotes known_remotes = { NULL, NULL };
1015 struct string_list branches = STRING_LIST_INIT_DUP;
1016 struct string_list skipped = STRING_LIST_INIT_DUP;
1017 struct branches_for_remote cb_data;
1018 int result;
1019
1020 memset(&cb_data, 0, sizeof(cb_data));
1021 cb_data.branches = &branches;
1022 cb_data.skipped = &skipped;
1023 cb_data.keep = &known_remotes;
1024
1025 argc = parse_options(argc, argv, prefix, options,
1026 builtin_remote_rm_usage, 0);
1027 if (argc != 1)
1028 usage_with_options(builtin_remote_rm_usage, options);
1029
1030 remote = remote_get(argv[0]);
1031 if (!remote_is_configured(remote, 1)) {
1032 error(_("No such remote: '%s'"), argv[0]);
1033 exit(2);
1034 }
1035
1036 known_remotes.to_delete = remote;
1037 for_each_remote(add_known_remote, &known_remotes);
1038
1039 read_branches();
1040 for (size_t i = 0; i < branch_list.nr; i++) {
1041 struct string_list_item *item = branch_list.items + i;
1042 struct branch_info *info = item->util;
1043 if (info->remote_name && !strcmp(info->remote_name, remote->name)) {
1044 const char *keys[] = { "remote", "merge", NULL }, **k;
1045 for (k = keys; *k; k++) {
1046 strbuf_reset(&buf);
1047 strbuf_addf(&buf, "branch.%s.%s",
1048 item->string, *k);
1049 result = repo_config_set_gently(the_repository, buf.buf, NULL);
1050 if (result && result != CONFIG_NOTHING_SET)
1051 die(_("could not unset '%s'"), buf.buf);
1052 }
1053 }
1054 if (info->push_remote_name && !strcmp(info->push_remote_name, remote->name)) {
1055 strbuf_reset(&buf);
1056 strbuf_addf(&buf, "branch.%s.pushremote", item->string);
1057 result = repo_config_set_gently(the_repository, buf.buf, NULL);
1058 if (result && result != CONFIG_NOTHING_SET)
1059 die(_("could not unset '%s'"), buf.buf);
1060 }
1061 }
1062
1063 /*

Callers

nothing calls this directly

Calls 15

parse_optionsFunction · 0.85
usage_with_optionsFunction · 0.85
remote_getFunction · 0.85
remote_is_configuredFunction · 0.85
errorFunction · 0.85
for_each_remoteFunction · 0.85
read_branchesFunction · 0.85
strbuf_addfFunction · 0.85
repo_config_set_gentlyFunction · 0.85
refs_for_each_refFunction · 0.85
get_main_ref_storeFunction · 0.85
strbuf_releaseFunction · 0.85

Tested by

no test coverage detected