Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit f377e7a

Browse files
carlosmngitster
authored andcommitted
fetch: add a failing test for prunning with overlapping refspecs
When a remote has multiple fetch refspecs and these overlap in the target namespace, fetch may prune a remote-tracking branch which still exists in the remote. The test uses a popular form of this, by putting pull requests as stored in a popular hosting platform alongside "real" remote-tracking branches. The fetch command makes a decision of whether to prune based on the first matching refspec, which in this case is insufficient, as it covers the pull request names. This pair of refspecs does work as expected if the more "specific" refspec is the first in the list. Signed-off-by: Carlos Martín Nieto <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7bbc4e8 commit f377e7a

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

t/t5510-fetch.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,26 @@ test_expect_success 'fetch --prune with a namespace keeps other namespaces' '
113113
git rev-parse origin/master
114114
'
115115

116+
test_expect_failure 'fetch --prune handles overlapping refspecs' '
117+
cd "$D" &&
118+
git update-ref refs/pull/42/head master &&
119+
git clone . prune-overlapping &&
120+
cd prune-overlapping &&
121+
git config --add remote.origin.fetch refs/pull/*/head:refs/remotes/origin/pr/* &&
122+
123+
git fetch --prune origin &&
124+
git rev-parse origin/master &&
125+
git rev-parse origin/pr/42 &&
126+
127+
git config --unset-all remote.origin.fetch
128+
git config remote.origin.fetch refs/pull/*/head:refs/remotes/origin/pr/* &&
129+
git config --add remote.origin.fetch refs/heads/*:refs/remotes/origin/* &&
130+
131+
git fetch --prune origin &&
132+
git rev-parse origin/master &&
133+
git rev-parse origin/pr/42
134+
'
135+
116136
test_expect_success 'fetch --prune --tags does not delete the remote-tracking branches' '
117137
cd "$D" &&
118138
git clone . prune-tags &&

0 commit comments

Comments
 (0)