Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit 55cfde2

Browse files
artagnongitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fe3c195 commit 55cfde2

File tree

1 file changed

+4
-19
lines changed

1 file changed

+4
-19
lines changed

remote.c

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -276,10 +276,9 @@ static void read_remotes_file(struct remote *remote)
276276

277277
static void read_branches_file(struct remote *remote)
278278
{
279-
const char *slash = strchr(remote->name, '/');
280279
char *frag;
281280
struct strbuf branch = STRBUF_INIT;
282-
int n = slash ? slash - remote->name : 1000;
281+
int n = 1000;
283282
FILE *f = fopen(git_path("branches/%.*s", n, remote->name), "r");
284283
char *s, *p;
285284
int len;
@@ -299,21 +298,11 @@ static void read_branches_file(struct remote *remote)
299298
while (isspace(p[-1]))
300299
*--p = 0;
301300
len = p - s;
302-
if (slash)
303-
len += strlen(slash);
304301
p = xmalloc(len + 1);
305302
strcpy(p, s);
306-
if (slash)
307-
strcat(p, slash);
308303

309304
/*
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
317306
* #branch specified. The "master" (or specified) branch is
318307
* fetched and stored in the local branch of the same name.
319308
*/
@@ -323,12 +312,8 @@ static void read_branches_file(struct remote *remote)
323312
strbuf_addf(&branch, "refs/heads/%s", frag);
324313
} else
325314
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);
332317
add_url_alias(remote, p);
333318
add_fetch_refspec(remote, strbuf_detach(&branch, NULL));
334319
/*

0 commit comments

Comments
 (0)