From: Jeff King Date: Mon, 15 Feb 2016 18:23:24 GMT Subject: Re: [PATCH 3/4] remote: actually check if remote exits Message-ID: <20160215182324.GG26443@sigill.intra.peff.net> In-Reply-To: <1455558150-30267-4-git-send-email-t.gummerer@gmail.com> On Mon, Feb 15, 2016 at 06:42:29PM +0100, Thomas Gummerer wrote: > 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 > --- > builtin/remote.c | 4 ++-- > t/t5505-remote.sh | 18 ++++++++++++++++++ > 2 files changed, 20 insertions(+), 2 deletions(-) Nice. Very cleanly explained and implemented. -Peff