提交 7e5ad06f 编写于 作者: J Junio C Hamano

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
......@@ -48,9 +48,9 @@ OPTIONS
exit without talking to the remote.
<repository>::
Location of the repository. The shorthand defined in
$GIT_DIR/branches/ can be used. Use "." (dot) to list references in
the local repository.
The "remote" repository to query. This parameter can be
either a URL or the name of a remote (see the GIT URLS and
REMOTES sections of linkgit:git-fetch[1]).
<refs>...::
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
5fe978a5381f1fbad26a80e682ddd2a401966740 refs/heads/master
c781a84b5204fb294c9ccc79f8b3baceeb32c061 refs/heads/pu
b1d096f2926c4e37c9c0b6a7bf2119bedaa277cb refs/heads/rc
$ echo http://www.kernel.org/pub/scm/git/git.git >.git/branches/public
$ git ls-remote --tags public v\*
$ git remote add korg http://www.kernel.org/pub/scm/git/git.git
$ git ls-remote --tags korg v\*
d6602ec5194c87b0fc87103ca4d67251c76f233a refs/tags/v0.99
f25a265a342aed6041ab0cc484224d9ca54b6f41 refs/tags/v0.99.1
c5db5456ae3b0873fc659c19fafdde22313cc441 refs/tags/v0.99.2
......
......@@ -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));
/*
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册