diff options
author | Junio C Hamano <gitster@pobox.com> | 2020-11-09 14:06:26 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-11-09 14:06:26 -0800 |
commit | ecf95d938b390e1ee7c1df78b9ebe3a59ffd44c9 (patch) | |
tree | 521b6d2bc5ef5d51482e4313b9579ab80568b8ad /builtin/remote.c | |
parent | Merge branch 'pb/ref-filter-with-crlf' (diff) | |
parent | remote: add meaningful exit code on missing/existing (diff) | |
download | tgif-ecf95d938b390e1ee7c1df78b9ebe3a59ffd44c9.tar.xz |
Merge branch 'ab/git-remote-exit-code'
Exit codes from "git remote add" etc. were not usable by scripted
callers.
* ab/git-remote-exit-code:
remote: add meaningful exit code on missing/existing
Diffstat (limited to 'builtin/remote.c')
-rw-r--r-- | builtin/remote.c | 42 |
1 files changed, 28 insertions, 14 deletions
diff --git a/builtin/remote.c b/builtin/remote.c index 63f2b46c3d..c1b211b272 100644 --- a/builtin/remote.c +++ b/builtin/remote.c @@ -191,8 +191,10 @@ static int add(int argc, const char **argv) url = argv[1]; remote = remote_get(name); - if (remote_is_configured(remote, 1)) - die(_("remote %s already exists."), name); + if (remote_is_configured(remote, 1)) { + error(_("remote %s already exists."), name); + exit(3); + } if (!valid_remote_name(name)) die(_("'%s' is not a valid remote name"), name); @@ -685,15 +687,19 @@ static int mv(int argc, const char **argv) rename.remote_branches = &remote_branches; oldremote = remote_get(rename.old_name); - if (!remote_is_configured(oldremote, 1)) - die(_("No such remote: '%s'"), rename.old_name); + if (!remote_is_configured(oldremote, 1)) { + error(_("No such remote: '%s'"), rename.old_name); + exit(2); + } if (!strcmp(rename.old_name, rename.new_name) && oldremote->origin != REMOTE_CONFIG) return migrate_file(oldremote); newremote = remote_get(rename.new_name); - if (remote_is_configured(newremote, 1)) - die(_("remote %s already exists."), rename.new_name); + if (remote_is_configured(newremote, 1)) { + error(_("remote %s already exists."), rename.new_name); + exit(3); + } if (!valid_remote_name(rename.new_name)) die(_("'%s' is not a valid remote name"), rename.new_name); @@ -826,8 +832,10 @@ static int rm(int argc, const char **argv) usage_with_options(builtin_remote_rm_usage, options); remote = remote_get(argv[1]); - if (!remote_is_configured(remote, 1)) - die(_("No such remote: '%s'"), argv[1]); + if (!remote_is_configured(remote, 1)) { + error(_("No such remote: '%s'"), argv[1]); + exit(2); + } known_remotes.to_delete = remote; for_each_remote(add_known_remote, &known_remotes); @@ -1508,8 +1516,10 @@ static int set_remote_branches(const char *remotename, const char **branches, strbuf_addf(&key, "remote.%s.fetch", remotename); remote = remote_get(remotename); - if (!remote_is_configured(remote, 1)) - die(_("No such remote '%s'"), remotename); + if (!remote_is_configured(remote, 1)) { + error(_("No such remote '%s'"), remotename); + exit(2); + } if (!add_mode && remove_all_fetch_refspecs(key.buf)) { strbuf_release(&key); @@ -1562,8 +1572,10 @@ static int get_url(int argc, const char **argv) remotename = argv[0]; remote = remote_get(remotename); - if (!remote_is_configured(remote, 1)) - die(_("No such remote '%s'"), remotename); + if (!remote_is_configured(remote, 1)) { + error(_("No such remote '%s'"), remotename); + exit(2); + } url_nr = 0; if (push_mode) { @@ -1630,8 +1642,10 @@ static int set_url(int argc, const char **argv) oldurl = newurl; remote = remote_get(remotename); - if (!remote_is_configured(remote, 1)) - die(_("No such remote '%s'"), remotename); + if (!remote_is_configured(remote, 1)) { + error(_("No such remote '%s'"), remotename); + exit(2); + } if (push_mode) { strbuf_addf(&name_buf, "remote.%s.pushurl", remotename); |