summaryrefslogtreecommitdiff
path: root/remote.c
diff options
context:
space:
mode:
authorRamkumar Ramachandra <artagnon@gmail.com>2013-06-22 07:58:12 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-06-23 07:33:57 (GMT)
commit55cfde251b4bee36f64f2067cccc4ba346aaf1b0 (patch)
tree76d11db51d104818c557f7ba054a7eeaef42476b /remote.c
parentfe3c1956e2289f083cf6777b3ff22fe628c92951 (diff)
downloadgit-55cfde251b4bee36f64f2067cccc4ba346aaf1b0.zip
git-55cfde251b4bee36f64f2067cccc4ba346aaf1b0.tar.gz
git-55cfde251b4bee36f64f2067cccc4ba346aaf1b0.tar.bz2
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>
Diffstat (limited to 'remote.c')
-rw-r--r--remote.c23
1 files changed, 4 insertions, 19 deletions
diff --git a/remote.c b/remote.c
index e71f66d..6f57830 100644
--- a/remote.c
+++ b/remote.c
@@ -276,10 +276,9 @@ static void read_remotes_file(struct remote *remote)
static void read_branches_file(struct remote *remote)
{
- const char *slash = strchr(remote->name, '/');
char *frag;
struct strbuf branch = STRBUF_INIT;
- int n = slash ? slash - remote->name : 1000;
+ int n = 1000;
FILE *f = fopen(git_path("branches/%.*s", n, remote->name), "r");
char *s, *p;
int len;
@@ -299,21 +298,11 @@ static void read_branches_file(struct remote *remote)
while (isspace(p[-1]))
*--p = 0;
len = p - s;
- if (slash)
- len += strlen(slash);
p = xmalloc(len + 1);
strcpy(p, s);
- if (slash)
- strcat(p, slash);
/*
- * With "slash", e.g. "git fetch jgarzik/netdev-2.6" when
- * reading from $GIT_DIR/branches/jgarzik fetches "HEAD" from
- * the partial URL obtained from the branches file plus
- * "/netdev-2.6" and does not store it in any tracking ref.
- * #branch specifier in the file is ignored.
- *
- * Otherwise, the branches file would have URL and optionally
+ * The branches file would have URL and optionally
* #branch specified. The "master" (or specified) branch is
* fetched and stored in the local branch of the same name.
*/
@@ -323,12 +312,8 @@ static void read_branches_file(struct remote *remote)
strbuf_addf(&branch, "refs/heads/%s", frag);
} else
strbuf_addstr(&branch, "refs/heads/master");
- if (!slash) {
- strbuf_addf(&branch, ":refs/heads/%s", remote->name);
- } else {
- strbuf_reset(&branch);
- strbuf_addstr(&branch, "HEAD:");
- }
+
+ strbuf_addf(&branch, ":refs/heads/%s", remote->name);
add_url_alias(remote, p);
add_fetch_refspec(remote, strbuf_detach(&branch, NULL));
/*