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

Commit 7e5ad06

Browse files
committed
Merge branch 'rr/remote-branch-config-refresh'
The original way to specify remote repository using .git/branches/ used to have a nifty feature. The code to support the feature was still in a function but the caller was changed not to call it 5 years ago, breaking that feature and leaving the supporting code unreachable. * rr/remote-branch-config-refresh: t/t5505-remote: test multiple push/pull in remotes-file ls-remote doc: don't encourage use of branches-file ls-remote doc: rewrite <repository> paragraph ls-remote doc: fix example invocation on git.git t/t5505-remote: test url-with-# in branches-file remote: remove dead code in read_branches_file() t/t5505-remote: use test_path_is_missing t/t5505-remote: test push-refspec in branches-file t/t5505-remote: modernize style
2 parents 46b0459 + f0f249d commit 7e5ad06

File tree

3 files changed

+480
-402
lines changed

3 files changed

+480
-402
lines changed

Documentation/git-ls-remote.txt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ OPTIONS
4848
exit without talking to the remote.
4949

5050
<repository>::
51-
Location of the repository. The shorthand defined in
52-
$GIT_DIR/branches/ can be used. Use "." (dot) to list references in
53-
the local repository.
51+
The "remote" repository to query. This parameter can be
52+
either a URL or the name of a remote (see the GIT URLS and
53+
REMOTES sections of linkgit:git-fetch[1]).
5454

5555
<refs>...::
5656
When unspecified, all references, after filtering done
@@ -70,9 +70,8 @@ EXAMPLES
7070
$ git ls-remote http://www.kernel.org/pub/scm/git/git.git master pu rc
7171
5fe978a5381f1fbad26a80e682ddd2a401966740 refs/heads/master
7272
c781a84b5204fb294c9ccc79f8b3baceeb32c061 refs/heads/pu
73-
b1d096f2926c4e37c9c0b6a7bf2119bedaa277cb refs/heads/rc
74-
$ echo http://www.kernel.org/pub/scm/git/git.git >.git/branches/public
75-
$ git ls-remote --tags public v\*
73+
$ git remote add korg http://www.kernel.org/pub/scm/git/git.git
74+
$ git ls-remote --tags korg v\*
7675
d6602ec5194c87b0fc87103ca4d67251c76f233a refs/tags/v0.99
7776
f25a265a342aed6041ab0cc484224d9ca54b6f41 refs/tags/v0.99.1
7877
c5db5456ae3b0873fc659c19fafdde22313cc441 refs/tags/v0.99.2

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)