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>

Jeff King committed Aug 10, 2015 at 05:35 UTC b21a5d66055e0a446e61a12d540406f2757f6263
1 file changed +2 -5
builtin/remote.c
+2 -5
@@ -581,7 +581,6 @@ static int migrate_file(struct remote *remote)
581 {
582 struct strbuf buf = STRBUF_INIT;
583 int i;
584 - const char *path = NULL;
584
585 strbuf_addf(&buf, "remote.%s.url", remote->name);
586 for (i = 0; i < remote->url_nr; i++)
@@ -601,11 +600,9 @@ static int migrate_file(struct remote *remote)
600 return error(_("Could not append '%s' to '%s'"),
601 remote->fetch_refspec[i], buf.buf);
602 if (remote->origin == REMOTE_REMOTES)
604 - path = git_path("remotes/%s", remote->name);
603 + unlink_or_warn(git_path("remotes/%s", remote->name));
604 else if (remote->origin == REMOTE_BRANCHES)
606 - path = git_path("branches/%s", remote->name);
607 - if (path)
608 - unlink_or_warn(path);
605 + unlink_or_warn(git_path("branches/%s", remote->name));
606 return 0;
607 }
608