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
This commit is contained in:
Junio C Hamano 2013-07-01 12:41:58 -07:00
commit 7e5ad06f68
3 changed files with 485 additions and 407 deletions

View File

@ -48,9 +48,9 @@ OPTIONS
exit without talking to the remote. exit without talking to the remote.
<repository>:: <repository>::
Location of the repository. The shorthand defined in The "remote" repository to query. This parameter can be
$GIT_DIR/branches/ can be used. Use "." (dot) to list references in either a URL or the name of a remote (see the GIT URLS and
the local repository. REMOTES sections of linkgit:git-fetch[1]).
<refs>...:: <refs>...::
When unspecified, all references, after filtering done When unspecified, all references, after filtering done
@ -70,9 +70,8 @@ EXAMPLES
$ git ls-remote http://www.kernel.org/pub/scm/git/git.git master pu rc $ git ls-remote http://www.kernel.org/pub/scm/git/git.git master pu rc
5fe978a5381f1fbad26a80e682ddd2a401966740 refs/heads/master 5fe978a5381f1fbad26a80e682ddd2a401966740 refs/heads/master
c781a84b5204fb294c9ccc79f8b3baceeb32c061 refs/heads/pu c781a84b5204fb294c9ccc79f8b3baceeb32c061 refs/heads/pu
b1d096f2926c4e37c9c0b6a7bf2119bedaa277cb refs/heads/rc $ git remote add korg http://www.kernel.org/pub/scm/git/git.git
$ echo http://www.kernel.org/pub/scm/git/git.git >.git/branches/public $ git ls-remote --tags korg v\*
$ git ls-remote --tags public v\*
d6602ec5194c87b0fc87103ca4d67251c76f233a refs/tags/v0.99 d6602ec5194c87b0fc87103ca4d67251c76f233a refs/tags/v0.99
f25a265a342aed6041ab0cc484224d9ca54b6f41 refs/tags/v0.99.1 f25a265a342aed6041ab0cc484224d9ca54b6f41 refs/tags/v0.99.1
c5db5456ae3b0873fc659c19fafdde22313cc441 refs/tags/v0.99.2 c5db5456ae3b0873fc659c19fafdde22313cc441 refs/tags/v0.99.2

View File

@ -276,10 +276,9 @@ static void read_remotes_file(struct remote *remote)
static void read_branches_file(struct remote *remote) static void read_branches_file(struct remote *remote)
{ {
const char *slash = strchr(remote->name, '/');
char *frag; char *frag;
struct strbuf branch = STRBUF_INIT; 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"); FILE *f = fopen(git_path("branches/%.*s", n, remote->name), "r");
char *s, *p; char *s, *p;
int len; int len;
@ -299,21 +298,11 @@ static void read_branches_file(struct remote *remote)
while (isspace(p[-1])) while (isspace(p[-1]))
*--p = 0; *--p = 0;
len = p - s; len = p - s;
if (slash)
len += strlen(slash);
p = xmalloc(len + 1); p = xmalloc(len + 1);
strcpy(p, s); strcpy(p, s);
if (slash)
strcat(p, slash);
/* /*
* With "slash", e.g. "git fetch jgarzik/netdev-2.6" when * The branches file would have URL and optionally
* 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
* #branch specified. The "master" (or specified) branch is * #branch specified. The "master" (or specified) branch is
* fetched and stored in the local branch of the same name. * 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); strbuf_addf(&branch, "refs/heads/%s", frag);
} else } else
strbuf_addstr(&branch, "refs/heads/master"); strbuf_addstr(&branch, "refs/heads/master");
if (!slash) {
strbuf_addf(&branch, ":refs/heads/%s", remote->name); strbuf_addf(&branch, ":refs/heads/%s", remote->name);
} else {
strbuf_reset(&branch);
strbuf_addstr(&branch, "HEAD:");
}
add_url_alias(remote, p); add_url_alias(remote, p);
add_fetch_refspec(remote, strbuf_detach(&branch, NULL)); add_fetch_refspec(remote, strbuf_detach(&branch, NULL));
/* /*

File diff suppressed because it is too large Load Diff