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

Function handle_push_default

builtin/remote.c:816–845  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

814}
815
816static void handle_push_default(const char* old_name, const char* new_name)
817{
818 struct push_default_info push_default = {
819 .old_name = old_name,
820 .scope = CONFIG_SCOPE_UNKNOWN,
821 .origin = STRBUF_INIT,
822 .linenr = -1,
823 };
824 repo_config(the_repository, config_read_push_default, &push_default);
825 if (push_default.scope >= CONFIG_SCOPE_COMMAND)
826 ; /* pass */
827 else if (push_default.scope >= CONFIG_SCOPE_LOCAL) {
828 int result = repo_config_set_gently(the_repository, "remote.pushDefault",
829 new_name);
830 if (new_name && result && result != CONFIG_NOTHING_SET)
831 die(_("could not set '%s'"), "remote.pushDefault");
832 else if (!new_name && result && result != CONFIG_NOTHING_SET)
833 die(_("could not unset '%s'"), "remote.pushDefault");
834 } else if (push_default.scope >= CONFIG_SCOPE_SYSTEM) {
835 /* warn */
836 warning(_("The %s configuration remote.pushDefault in:\n"
837 "\t%s:%d\n"
838 "now names the non-existent remote '%s'"),
839 config_scope_name(push_default.scope),
840 push_default.origin.buf, push_default.linenr,
841 old_name);
842 }
843
844 strbuf_release(&push_default.origin);
845}
846
847static const char conflicting_remote_refs_advice[] = N_(
848 "The remote you are trying to rename has conflicting references in the\n"

Callers 2

mvFunction · 0.85
rmFunction · 0.85

Calls 6

repo_config_set_gentlyFunction · 0.85
warningFunction · 0.85
config_scope_nameFunction · 0.85
strbuf_releaseFunction · 0.85
repo_configFunction · 0.50
dieFunction · 0.50

Tested by

no test coverage detected