From f377e7a37c1b28359a228cf5bb43161a8a22b385 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Thu, 27 Feb 2014 10:00:09 +0100 Subject: fetch: add a failing test for prunning with overlapping refspecs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Junio C Hamano --- t/t5510-fetch.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 't/t5510-fetch.sh') diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh index 07986d94b..473e855c9 100755 --- a/t/t5510-fetch.sh +++ b/t/t5510-fetch.sh @@ -113,6 +113,26 @@ test_expect_success 'fetch --prune with a namespace keeps other namespaces' ' git rev-parse origin/master ' +test_expect_failure 'fetch --prune handles overlapping refspecs' ' + cd "$D" && + git update-ref refs/pull/42/head master && + git clone . prune-overlapping && + cd prune-overlapping && + git config --add remote.origin.fetch refs/pull/*/head:refs/remotes/origin/pr/* && + + git fetch --prune origin && + git rev-parse origin/master && + git rev-parse origin/pr/42 && + + git config --unset-all remote.origin.fetch + git config remote.origin.fetch refs/pull/*/head:refs/remotes/origin/pr/* && + git config --add remote.origin.fetch refs/heads/*:refs/remotes/origin/* && + + git fetch --prune origin && + git rev-parse origin/master && + git rev-parse origin/pr/42 +' + test_expect_success 'fetch --prune --tags does not delete the remote-tracking branches' ' cd "$D" && git clone . prune-tags && -- cgit v1.2.1 From e6f637122ecd60c59df27b8188b6ddac39ac0063 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Thu, 27 Feb 2014 10:00:10 +0100 Subject: fetch: handle overlaping refspecs on --prune MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We need to consider that a remote-tracking branch may match more than one rhs of a fetch refspec. In such a case, it is not enough to stop at the first match but look at all of the matches in order to determine whether a head is stale. To this goal, introduce a variant of query_refspecs which returns all of the matching refspecs and loop over those answers to check for staleness. Signed-off-by: Carlos Martín Nieto Signed-off-by: Junio C Hamano --- t/t5510-fetch.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/t5510-fetch.sh') diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh index 473e855c9..06161280b 100755 --- a/t/t5510-fetch.sh +++ b/t/t5510-fetch.sh @@ -113,7 +113,7 @@ test_expect_success 'fetch --prune with a namespace keeps other namespaces' ' git rev-parse origin/master ' -test_expect_failure 'fetch --prune handles overlapping refspecs' ' +test_expect_success 'fetch --prune handles overlapping refspecs' ' cd "$D" && git update-ref refs/pull/42/head master && git clone . prune-overlapping && -- cgit v1.2.1