aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2015-08-10 05:35:49 -0400
committerJunio C Hamano <gitster@pobox.com>2015-08-10 15:37:12 -0700
commitb21a5d66055e0a446e61a12d540406f2757f6263 (patch)
treefcabbff3d8c936d0ac082cfc9667c805ef2a553a
parente3cf230324f740653d4fb4a3087c2daf9da62029 (diff)
downloadgit-b21a5d66055e0a446e61a12d540406f2757f6263.tar.gz
git-b21a5d66055e0a446e61a12d540406f2757f6263.tar.xz
remote.c: drop extraneous local variable from migrate_file
It's an anti-pattern to assign the result of git_path to a variable, since other calls may reuse our buffer. In this case, we feed the result to unlink_or_warn immediately afterwards, so it's OK. However, it's nice to avoid assignment entirely, which makes it more obvious that there's no bug. We can just pass the result directly to unlink_or_warn, which is a known-simple function. As a bonus, the code flow is a little more obvious, as we eliminate an extra conditional (a reader does not have to wonder any more "under which circumstances is 'path' set?"). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--builtin/remote.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/builtin/remote.c b/builtin/remote.c
index cc3c7410f..181668ded 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -581,7 +581,6 @@ static int migrate_file(struct remote *remote)
{
struct strbuf buf = STRBUF_INIT;
int i;
- const char *path = NULL;
strbuf_addf(&buf, "remote.%s.url", remote->name);
for (i = 0; i < remote->url_nr; i++)
@@ -601,11 +600,9 @@ static int migrate_file(struct remote *remote)
return error(_("Could not append '%s' to '%s'"),
remote->fetch_refspec[i], buf.buf);
if (remote->origin == REMOTE_REMOTES)
- path = git_path("remotes/%s", remote->name);
+ unlink_or_warn(git_path("remotes/%s", remote->name));
else if (remote->origin == REMOTE_BRANCHES)
- path = git_path("branches/%s", remote->name);
- if (path)
- unlink_or_warn(path);
+ unlink_or_warn(git_path("branches/%s", remote->name));
return 0;
}