summaryrefslogtreecommitdiff
path: root/builtin-remote.c
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2008-06-01 03:58:05 (GMT)
committerJunio C Hamano <gitster@pobox.com>2008-06-01 06:55:15 (GMT)
commitc175a7ad32ee978baaa6524304e9406684bd1286 (patch)
treef4dfac9616a1d0118864aff474b56713eeadfdf3 /builtin-remote.c
parent6a15bc0d220cf3b139d80326afa0d70411916aed (diff)
downloadgit-c175a7ad32ee978baaa6524304e9406684bd1286.zip
git-c175a7ad32ee978baaa6524304e9406684bd1286.tar.gz
git-c175a7ad32ee978baaa6524304e9406684bd1286.tar.bz2
Make "git-remote prune" delete refs according to fetch specs
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>
Diffstat (limited to 'builtin-remote.c')
-rw-r--r--builtin-remote.c21
1 files changed, 2 insertions, 19 deletions
diff --git a/builtin-remote.c b/builtin-remote.c
index c76fe2e..e5cfc88 100644
--- a/builtin-remote.c
+++ b/builtin-remote.c
@@ -419,27 +419,10 @@ static int show_or_prune(int argc, const char **argv, int prune)
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;
}