summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 211c896)
raw | patch | inline | side by side (parent: 211c896)
author | Johannes Schindelin <Johannes.Schindelin@gmx.de> | |
Fri, 29 Feb 2008 01:46:07 +0000 (01:46 +0000) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sat, 1 Mar 2008 09:51:44 +0000 (01:51 -0800) |
This adds special handling for mirror remotes.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
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 25b02275dae539d58f89e51cfaacd363662e4368..d0c07c7a0b7e31aeb61b4c8d94b1dac3c381598b 100644 (file)
--- a/builtin-remote.c
+++ b/builtin-remote.c
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_reset(&buf);
- strbuf_addf(&buf, "refs/remotes/%s/%s", *argv,
- states.stale.items[i].path);
+ strbuf_setlen(&buf, prefix_len);
+ strbuf_addstr(&buf, states.stale.items[i].path);
result |= delete_ref(buf.buf, NULL);
}
diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh
index 5986982adfb9bd089a1803366e27e0a4be0ee2c5..0a25c8b71c63802602abab689a0bcbb6ff9c0f05 100755 (executable)
--- a/t/t5505-remote.sh
+++ b/t/t5505-remote.sh
! git rev-parse refs/remotes/origin/side)
'
+test_expect_success 'add --mirror && prune' '
+ (mkdir mirror &&
+ cd mirror &&
+ git init &&
+ git remote add --mirror -f origin ../one) &&
+ (cd one &&
+ git branch -m side2 side) &&
+ (cd mirror &&
+ git rev-parse --verify refs/heads/side2 &&
+ ! git rev-parse --verify refs/heads/side &&
+ git fetch origin &&
+ git remote prune origin &&
+ ! git rev-parse --verify refs/heads/side2 &&
+ git rev-parse --verify refs/heads/side)
+'
+
test_done