summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ed43de6)
raw | patch | inline | side by side (parent: ed43de6)
author | Carlos Martín Nieto <cmn@elego.de> | |
Sat, 15 Oct 2011 05:04:26 +0000 (07:04 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sun, 16 Oct 2011 05:00:37 +0000 (22:00 -0700) |
If --tags is specified, add that refspec to the list given to
prune_refs so it knows to treat it as a filter on what refs to
should consider for prunning. This way
git fetch --prune --tags origin
only prunes tags and doesn't delete the branch refs.
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
prune_refs so it knows to treat it as a filter on what refs to
should consider for prunning. This way
git fetch --prune --tags origin
only prunes tags and doesn't delete the branch refs.
Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/fetch.c | patch | blob | history | |
t/t5510-fetch.sh | patch | blob | history |
diff --git a/builtin/fetch.c b/builtin/fetch.c
index e295d97fdb90a1db960c85c38b5e7fc9f5c60560..9d481f8ca9d9470311b356e9bd5356fa362ffd6a 100644 (file)
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
return 1;
}
if (prune) {
- if (ref_count)
+ /* If --tags was specified, pretend the user gave us the canonical tags refspec */
+ if (tags == TAGS_SET) {
+ const char *tags_str = "refs/tags/*:refs/tags/*";
+ struct refspec *tags_refspec, *refspec;
+
+ /* Copy the refspec and add the tags to it */
+ refspec = xcalloc(ref_count + 1, sizeof(struct refspec));
+ tags_refspec = parse_fetch_refspec(1, &tags_str);
+ memcpy(refspec, refs, ref_count * sizeof(struct refspec));
+ memcpy(&refspec[ref_count], tags_refspec, sizeof(struct refspec));
+ ref_count++;
+
+ prune_refs(refspec, ref_count, ref_map);
+
+ ref_count--;
+ /* The rest of the strings belong to fetch_one */
+ free_refspec(1, tags_refspec);
+ free(refspec);
+ } else if (ref_count) {
prune_refs(refs, ref_count, ref_map);
- else
+ } else {
prune_refs(transport->remote->fetch, transport->remote->fetch_refspec_nr, ref_map);
+ }
}
free_refs(ref_map);
diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh
index 581049bf941148ba8779108af630b05e91e2f0bd..e0af4c4e62c40a563f692361944cc58e2c8e38e2 100755 (executable)
--- a/t/t5510-fetch.sh
+++ b/t/t5510-fetch.sh
git rev-parse origin/master
'
-test_expect_failure 'fetch --prune --tags does not delete the remote-tracking branches' '
+test_expect_success 'fetch --prune --tags does not delete the remote-tracking branches' '
cd "$D" &&
git clone . prune-tags &&
cd prune-tags &&
@@ -116,7 +116,7 @@ test_expect_failure 'fetch --prune --tags does not delete the remote-tracking br
test_must_fail git rev-parse somebranch
'
-test_expect_failure 'fetch --prune --tags with branch does not delete other remote-tracking branches' '
+test_expect_success 'fetch --prune --tags with branch does not delete other remote-tracking branches' '
cd "$D" &&
git clone . prune-tags-branch &&
cd prune-tags-branch &&