summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6a15bc0)
raw | patch | inline | side by side (parent: 6a15bc0)
author | Shawn O. Pearce <spearce@spearce.org> | |
Sun, 1 Jun 2008 03:58:05 +0000 (23:58 -0400) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sun, 1 Jun 2008 06:55:15 +0000 (23:55 -0700) |
A remote may be configured to fetch into tracking branches that
do not match the remote name. For example a user may have created
extra remotes that will fetch to the same tracking branch namespace,
but from different URLs:
[remote "origin"]
url = git://git.kernel.org/pub/scm/git/git.git
fetch = refs/heads/*:refs/remotes/origin/*
[remote "alt"]
url = git://repo.or.cz/alt-git.git
fetch = refs/heads/*:refs/remotes/origin/*
When running `git remote prune alt` we expect stale branches to
be removed from "refs/remotes/origin/*" and not from the unused
namespace of "refs/remotes/alt/*".
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
do not match the remote name. For example a user may have created
extra remotes that will fetch to the same tracking branch namespace,
but from different URLs:
[remote "origin"]
url = git://git.kernel.org/pub/scm/git/git.git
fetch = refs/heads/*:refs/remotes/origin/*
[remote "alt"]
url = git://repo.or.cz/alt-git.git
fetch = refs/heads/*:refs/remotes/origin/*
When running `git remote prune alt` we expect stale branches to
be removed from "refs/remotes/origin/*" and not from the unused
namespace of "refs/remotes/alt/*".
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-remote.c | patch | blob | history | |
t/t5505-remote.sh | patch | blob | history |
diff --git a/builtin-remote.c b/builtin-remote.c
index c76fe2e0ede09a8b548742b06a8ffd47f9d76db0..e5cfc882b5a2411038cd13a1926762933cfafed5 100644 (file)
--- a/builtin-remote.c
+++ b/builtin-remote.c
states.remote->name);
if (prune) {
- struct strbuf buf;
- int prefix_len;
-
- strbuf_init(&buf, 0);
- if (states.remote->fetch_refspec_nr == 1 &&
- states.remote->fetch->pattern &&
- !strcmp(states.remote->fetch->src,
- states.remote->fetch->dst))
- /* handle --mirror remote */
- strbuf_addstr(&buf, "refs/heads/");
- else
- strbuf_addf(&buf, "refs/remotes/%s/", *argv);
- prefix_len = buf.len;
-
for (i = 0; i < states.stale.nr; i++) {
- strbuf_setlen(&buf, prefix_len);
- strbuf_addstr(&buf, states.stale.items[i].path);
- result |= delete_ref(buf.buf, NULL);
+ const char *refname = states.stale.items[i].util;
+ result |= delete_ref(refname, NULL);
}
-
- strbuf_release(&buf);
goto cleanup_states;
}
diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh
index a37b6f52135fcd8f02cc7290568756b9067c5ec7..0d7ed1f99b327c3130c43519c3a8a8fd4ee37892 100755 (executable)
--- a/t/t5505-remote.sh
+++ b/t/t5505-remote.sh
git rev-parse --verify refs/heads/side)
'
+test_expect_success 'add alt && prune' '
+ (mkdir alttst &&
+ cd alttst &&
+ git init &&
+ git remote add -f origin ../one &&
+ git config remote.alt.url ../one &&
+ git config remote.alt.fetch "+refs/heads/*:refs/remotes/origin/*") &&
+ (cd one &&
+ git branch -m side side2) &&
+ (cd alttst &&
+ git rev-parse --verify refs/remotes/origin/side &&
+ ! git rev-parse --verify refs/remotes/origin/side2 &&
+ git fetch alt &&
+ git remote prune alt &&
+ ! git rev-parse --verify refs/remotes/origin/side &&
+ git rev-parse --verify refs/remotes/origin/side2)
+'
+
cat > one/expect << EOF
apis/master
apis/side