summaryrefslogtreecommitdiff
path: root/builtin/remote.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2020-11-09 22:06:26 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-11-09 22:06:26 (GMT)
commitecf95d938b390e1ee7c1df78b9ebe3a59ffd44c9 (patch)
tree521b6d2bc5ef5d51482e4313b9579ab80568b8ad /builtin/remote.c
parent4c7eb63d2d4ad6d88a336357baaa6a934b604eda (diff)
parent9144ba4cf52bb0e891d7c10a331fc32c1d3e8f64 (diff)
downloadgit-ecf95d938b390e1ee7c1df78b9ebe3a59ffd44c9.zip
git-ecf95d938b390e1ee7c1df78b9ebe3a59ffd44c9.tar.gz
git-ecf95d938b390e1ee7c1df78b9ebe3a59ffd44c9.tar.bz2
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.c42
1 files changed, 28 insertions, 14 deletions
diff --git a/builtin/remote.c b/builtin/remote.c
index 63f2b46..c1b211b 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);