| 814 | } |
| 815 | |
| 816 | static 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 | |
| 847 | static const char conflicting_remote_refs_advice[] = N_( |
| 848 | "The remote you are trying to rename has conflicting references in the\n" |
no test coverage detected