summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorThomas Gummerer <t.gummerer@gmail.com>2016-02-16 09:47:51 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-02-16 21:33:12 (GMT)
commitcc8e538d45e4260b27196c3238e6f15d64236523 (patch)
tree2e0bafd5cb169ddadc64c72c25152c6e6118f970 /builtin
parent674468b3642abfff7c61d5ff95fffc43b87f70b7 (diff)
downloadgit-cc8e538d45e4260b27196c3238e6f15d64236523.zip
git-cc8e538d45e4260b27196c3238e6f15d64236523.tar.gz
git-cc8e538d45e4260b27196c3238e6f15d64236523.tar.bz2
remote: actually check if remote exits
When converting the git remote command to a builtin in 211c89 ("Make git-remote a builtin"), a few calls to check if a remote exists were converted from: if (!exists $remote->{$name}) { [...] to: remote = remote_get(argv[1]); if (!remote) [...] The new check is not quite correct, because remote_get() never returns NULL if a name is given. This leaves us with the somewhat cryptic error message "error: Could not remove config section 'remote.test'", if we are trying to remove a remote that does not exist, or a similar error if we try to rename a remote. Use the remote_is_configured() function to check whether the remote actually exists, and die with a more sensible error message ("No such remote: $remotename") instead if it doesn't. Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com> Reviewed-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/remote.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/builtin/remote.c b/builtin/remote.c
index d966262..981c487 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -634,7 +634,7 @@ static int mv(int argc, const char **argv)
rename.remote_branches = &remote_branches;
oldremote = remote_get(rename.old);
- if (!oldremote)
+ if (!remote_is_configured(oldremote))
die(_("No such remote: %s"), rename.old);
if (!strcmp(rename.old, rename.new) && oldremote->origin != REMOTE_CONFIG)
@@ -773,7 +773,7 @@ static int rm(int argc, const char **argv)
usage_with_options(builtin_remote_rm_usage, options);
remote = remote_get(argv[1]);
- if (!remote)
+ if (!remote_is_configured(remote))
die(_("No such remote: %s"), argv[1]);
known_remotes.to_delete = remote;