request-pull: resurrect "pretty refname" feature
authorJunio C Hamano <gitster@pobox.com>
Tue, 25 Feb 2014 21:44:46 +0000 (13:44 -0800)
committerJunio C Hamano <gitster@pobox.com>
Tue, 25 Feb 2014 21:45:38 +0000 (13:45 -0800)
When asking to fetch/pull a branch whose name is B or a tag whose
name is T, we used to show the command to run as:

git pull $URL B
git pull $URL tags/T

even when B and T were spelled in a more qualified way in order to
disambiguate, e.g. heads/B or refs/tags/T, but the recent update
lost this feature. Resurrect it.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-request-pull.sh
t/t5150-request-pull.sh
index 93b41357abd0ad0f02e3746778f35018a3dc1754..b67513a2e76e6136ee2dd028b9cd17ea070542ac 100755 (executable)
@@ -53,6 +53,8 @@ fi
 local=${3%:*}
 local=${local:-HEAD}
 remote=${3#*:}
+pretty_remote=${remote#refs/}
+pretty_remote=${pretty_remote#heads/}
 head=$(git symbolic-ref -q "$local")
 head=${head:-$(git show-ref --heads --tags "$local" | cut -d' ' -f2)}
 head=${head:-$(git rev-parse --quiet --verify "$local")}
@@ -124,7 +126,7 @@ git show -s --format='The following changes since commit %H:
 
 are available in the git repository at:
 ' $merge_base &&
-echo "  $url $remote" &&
+echo "  $url $pretty_remote" &&
 git show -s --format='
 for you to fetch changes up to %H:
 
index 262205729d19af5e571b44e26859c7961def356b..75d6b3843ad4070f225e82aec160eca494ab6238 100755 (executable)
@@ -216,8 +216,14 @@ test_expect_success 'pull request format' '
                git request-pull initial "$downstream_url" tags/full >../request
        ) &&
        <request sed -nf fuzz.sed >request.fuzzy &&
-       test_i18ncmp expect request.fuzzy
+       test_i18ncmp expect request.fuzzy &&
 
+       (
+               cd local &&
+               git request-pull initial "$downstream_url" tags/full:refs/tags/full
+       ) >request &&
+       sed -nf fuzz.sed <request >request.fuzzy &&
+       test_i18ncmp expect request.fuzzy
 '
 
 test_expect_success 'request-pull ignores OPTIONS_KEEPDASHDASH poison' '