summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--builtin-remote.c21
-rwxr-xr-xt/t5505-remote.sh18
2 files changed, 20 insertions, 19 deletions
diff --git a/builtin-remote.c b/builtin-remote.c
index c76fe2e0ed..e5cfc882b5 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;
}
diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh
index a37b6f5213..0d7ed1f99b 100755
--- a/t/t5505-remote.sh
+++ b/t/t5505-remote.sh
@@ -164,6 +164,24 @@ test_expect_success 'add --mirror && prune' '
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