remote: remove dead code in read_branches_file()

The first line of the function checks that the remote-name contains a slash ('/'), and sets the "slash" variable accordingly. The only caller of read_branches_file() is remote_get_1(); the calling codepath is guarded by valid_remote_nick(), which checks that the remote does not contain a slash. Therefore, the "slash" variable can never be set: remove the dead code that assumes otherwise. Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ramkumar Ramachandra committed Jun 22, 2013 at 13:28 UTC 55cfde251b4bee36f64f2067cccc4ba346aaf1b0
1 file changed +4 -19
remote.c
+4 -19
@@ -276,10 +276,9 @@ static void read_remotes_file(struct remote *remote)
276
277 static void read_branches_file(struct remote *remote)
278 {
279 - const char *slash = strchr(remote->name, '/');
279 char *frag;
280 struct strbuf branch = STRBUF_INIT;
282 - int n = slash ? slash - remote->name : 1000;
281 + int n = 1000;
282 FILE *f = fopen(git_path("branches/%.*s", n, remote->name), "r");
283 char *s, *p;
284 int len;
@@ -299,21 +298,11 @@ static void read_branches_file(struct remote *remote)
298 while (isspace(p[-1]))
299 *--p = 0;
300 len = p - s;
302 - if (slash)
303 - len += strlen(slash);
301 p = xmalloc(len + 1);
302 strcpy(p, s);
306 - if (slash)
307 - strcat(p, slash);
303
304 /*
310 - * With "slash", e.g. "git fetch jgarzik/netdev-2.6" when
311 - * reading from $GIT_DIR/branches/jgarzik fetches "HEAD" from
312 - * the partial URL obtained from the branches file plus
313 - * "/netdev-2.6" and does not store it in any tracking ref.
314 - * #branch specifier in the file is ignored.
315 - *
316 - * Otherwise, the branches file would have URL and optionally
305 + * The branches file would have URL and optionally
306 * #branch specified. The "master" (or specified) branch is
307 * fetched and stored in the local branch of the same name.
308 */
@@ -323,12 +312,8 @@ static void read_branches_file(struct remote *remote)
312 strbuf_addf(&branch, "refs/heads/%s", frag);
313 } else
314 strbuf_addstr(&branch, "refs/heads/master");
326 - if (!slash) {
327 - strbuf_addf(&branch, ":refs/heads/%s", remote->name);
328 - } else {
329 - strbuf_reset(&branch);
330 - strbuf_addstr(&branch, "HEAD:");
331 - }
315 +
316 + strbuf_addf(&branch, ":refs/heads/%s", remote->name);
317 add_url_alias(remote, p);
318 add_fetch_refspec(remote, strbuf_detach(&branch, NULL));
319 /*