{"thread":{"id":"54717","subject":"[PATCH v4 0/3] refspec: make @ a synonym of HEAD","startedAt":"2020-11-26T00:16:36Z","lastAt":"2020-11-26T00:16:37Z","messageCount":4,"participants":["Felipe Contreras"],"isPatch":true,"patchVersion":4,"patchTotal":3},"messages":[{"id":"410837","messageId":"20201126001616.663910-1-felipe.contreras@gmail.com","threadId":"54717","inReplyTo":null,"subject":"[PATCH v4 0/3] refspec: make @ a synonym of HEAD","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2020-11-26T00:16:13Z","receivedAt":"2020-11-26T00:16:36Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Basically $subject.\n\nSince v3 the body of the tests was changed to single quotes, as Junio suggested.\n\n\nFelipe Contreras (3):\n  tests: push: improve cleanup of HEAD tests\n  tests: push: trivial cleanup\n  refspec: make @ a synonym of HEAD\n\n refspec.c             |   5 +-\n t/t5511-refspec.sh    |   2 +\n t/t5516-fetch-push.sh | 106 ++++++++++++++++++++++--------------------\n 3 files changed, 62 insertions(+), 51 deletions(-)\n\n-- \n2.29.2\n\n"},{"id":"410838","messageId":"20201126001616.663910-3-felipe.contreras@gmail.com","threadId":"54717","inReplyTo":"20201126001616.663910-1-felipe.contreras@gmail.com","subject":"[PATCH v4 2/3] tests: push: trivial cleanup","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2020-11-26T00:16:15Z","receivedAt":"2020-11-26T00:16:36Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"No need to do two checkouts.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n t/t5516-fetch-push.sh | 3 +--\n 1 file changed, 1 insertion(+), 2 deletions(-)\n\ndiff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh\nindex 4077471937..245eafb170 100755\n--- a/t/t5516-fetch-push.sh\n+++ b/t/t5516-fetch-push.sh\n@@ -457,8 +457,7 @@ test_expect_success 'push with HEAD nonexisting at remote' '\n test_expect_success 'push with +HEAD' '\n \n \tmk_test testrepo heads/master &&\n-\tgit checkout master &&\n-\tgit checkout -b local &&\n+\tgit checkout -b local master &&\n \ttest_when_finished \"git checkout master; git branch -D local\" &&\n \tgit push testrepo master local &&\n \tcheck_push_result testrepo $the_commit heads/master &&\n-- \n2.29.2\n\n"},{"id":"410839","messageId":"20201126001616.663910-2-felipe.contreras@gmail.com","threadId":"54717","inReplyTo":"20201126001616.663910-1-felipe.contreras@gmail.com","subject":"[PATCH v4 1/3] tests: push: improve cleanup of HEAD tests","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2020-11-26T00:16:14Z","receivedAt":"2020-11-26T00:16:36Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"So that we are not left in an inconsistent state between them.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n t/t5516-fetch-push.sh | 4 +++-\n 1 file changed, 3 insertions(+), 1 deletion(-)\n\ndiff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh\nindex d11382f769..4077471937 100755\n--- a/t/t5516-fetch-push.sh\n+++ b/t/t5516-fetch-push.sh\n@@ -449,6 +449,7 @@ test_expect_success 'push with HEAD nonexisting at remote' '\n \n \tmk_test testrepo heads/master &&\n \tgit checkout -b local master &&\n+\ttest_when_finished \"git checkout master; git branch -D local\" &&\n \tgit push testrepo HEAD &&\n \tcheck_push_result testrepo $the_commit heads/local\n '\n@@ -457,8 +458,8 @@ test_expect_success 'push with +HEAD' '\n \n \tmk_test testrepo heads/master &&\n \tgit checkout master &&\n-\tgit branch -D local &&\n \tgit checkout -b local &&\n+\ttest_when_finished \"git checkout master; git branch -D local\" &&\n \tgit push testrepo master local &&\n \tcheck_push_result testrepo $the_commit heads/master &&\n \tcheck_push_result testrepo $the_commit heads/local &&\n@@ -488,6 +489,7 @@ test_expect_success 'push with config remote.*.push = HEAD' '\n \tmk_test testrepo heads/local &&\n \tgit checkout master &&\n \tgit branch -f local $the_commit &&\n+\ttest_when_finished \"git branch -D local\" &&\n \t(\n \t\tcd testrepo &&\n \t\tgit checkout local &&\n-- \n2.29.2\n\n"},{"id":"410840","messageId":"20201126001616.663910-4-felipe.contreras@gmail.com","threadId":"54717","inReplyTo":"20201126001616.663910-1-felipe.contreras@gmail.com","subject":"[PATCH v4 3/3] refspec: make @ a synonym of HEAD","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2020-11-26T00:16:16Z","receivedAt":"2020-11-26T00:16:37Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Since commit 9ba89f484e git learned how to push to a remote branch using\nthe source @, for example:\n\n  git push origin @:master\n\nHowever, if the right-hand side is missing, the push fails:\n\n  git push origin @\n\nIt is obvious what is the desired behavior, and allowing the push makes\nthings more consistent.\n\nAdditionally, @:master now has the same semantics as HEAD:master.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n refspec.c             |   5 +-\n t/t5511-refspec.sh    |   2 +\n t/t5516-fetch-push.sh | 107 ++++++++++++++++++++++--------------------\n 3 files changed, 62 insertions(+), 52 deletions(-)\n\ndiff --git a/refspec.c b/refspec.c\nindex c49347c2d7..adbfb3283a 100644\n--- a/refspec.c\n+++ b/refspec.c\n@@ -71,7 +71,10 @@ static int parse_refspec(struct refspec_item *item, const char *refspec, int fet\n \t}\n \n \titem->pattern = is_glob;\n-\titem->src = xstrndup(lhs, llen);\n+\tif (llen == 1 && *lhs == '@')\n+\t\titem->src = xstrdup(\"HEAD\");\n+\telse\n+\t\titem->src = xstrndup(lhs, llen);\n \tflags = REFNAME_ALLOW_ONELEVEL | (is_glob ? REFNAME_REFSPEC_PATTERN : 0);\n \n \tif (item->negative) {\ndiff --git a/t/t5511-refspec.sh b/t/t5511-refspec.sh\nindex f541f30bc2..f808649de4 100755\n--- a/t/t5511-refspec.sh\n+++ b/t/t5511-refspec.sh\n@@ -58,6 +58,8 @@ test_refspec fetch 'HEAD~4:refs/remotes/frotz/new'\t\tinvalid\n \n test_refspec push 'HEAD'\n test_refspec fetch 'HEAD'\n+test_refspec push '@'\n+test_refspec fetch '@'\n test_refspec push 'refs/heads/ nitfol'\t\t\t\tinvalid\n test_refspec fetch 'refs/heads/ nitfol'\t\t\t\tinvalid\n \ndiff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh\nindex 245eafb170..01004ff680 100755\n--- a/t/t5516-fetch-push.sh\n+++ b/t/t5516-fetch-push.sh\n@@ -436,71 +436,76 @@ test_expect_success 'push ref expression with non-existent, incomplete dest' '\n \n '\n \n-test_expect_success 'push with HEAD' '\n+for head in HEAD @\n+do\n \n-\tmk_test testrepo heads/master &&\n-\tgit checkout master &&\n-\tgit push testrepo HEAD &&\n-\tcheck_push_result testrepo $the_commit heads/master\n+\ttest_expect_success \"push with $head\" '\n \n-'\n+\t\tmk_test testrepo heads/master &&\n+\t\tgit checkout master &&\n+\t\tgit push testrepo $head &&\n+\t\tcheck_push_result testrepo $the_commit heads/master\n \n-test_expect_success 'push with HEAD nonexisting at remote' '\n+\t'\n \n-\tmk_test testrepo heads/master &&\n-\tgit checkout -b local master &&\n-\ttest_when_finished \"git checkout master; git branch -D local\" &&\n-\tgit push testrepo HEAD &&\n-\tcheck_push_result testrepo $the_commit heads/local\n-'\n+\ttest_expect_success \"push with $head nonexisting at remote\" '\n \n-test_expect_success 'push with +HEAD' '\n+\t\tmk_test testrepo heads/master &&\n+\t\tgit checkout -b local master &&\n+\t\ttest_when_finished \"git checkout master; git branch -D local\" &&\n+\t\tgit push testrepo $head &&\n+\t\tcheck_push_result testrepo $the_commit heads/local\n+\t'\n \n-\tmk_test testrepo heads/master &&\n-\tgit checkout -b local master &&\n-\ttest_when_finished \"git checkout master; git branch -D local\" &&\n-\tgit push testrepo master local &&\n-\tcheck_push_result testrepo $the_commit heads/master &&\n-\tcheck_push_result testrepo $the_commit heads/local &&\n+\ttest_expect_success \"push with +$head\" '\n \n-\t# Without force rewinding should fail\n-\tgit reset --hard HEAD^ &&\n-\ttest_must_fail git push testrepo HEAD &&\n-\tcheck_push_result testrepo $the_commit heads/local &&\n+\t\tmk_test testrepo heads/master &&\n+\t\tgit checkout -b local master &&\n+\t\ttest_when_finished \"git checkout master; git branch -D local\" &&\n+\t\tgit push testrepo master local &&\n+\t\tcheck_push_result testrepo $the_commit heads/master &&\n+\t\tcheck_push_result testrepo $the_commit heads/local &&\n \n-\t# With force rewinding should succeed\n-\tgit push testrepo +HEAD &&\n-\tcheck_push_result testrepo $the_first_commit heads/local\n+\t\t# Without force rewinding should fail\n+\t\tgit reset --hard $head^ &&\n+\t\ttest_must_fail git push testrepo $head &&\n+\t\tcheck_push_result testrepo $the_commit heads/local &&\n \n-'\n+\t\t# With force rewinding should succeed\n+\t\tgit push testrepo +$head &&\n+\t\tcheck_push_result testrepo $the_first_commit heads/local\n \n-test_expect_success 'push HEAD with non-existent, incomplete dest' '\n+\t'\n \n-\tmk_test testrepo &&\n-\tgit checkout master &&\n-\tgit push testrepo HEAD:branch &&\n-\tcheck_push_result testrepo $the_commit heads/branch\n+\ttest_expect_success \"push $head with non-existent, incomplete dest\" '\n \n-'\n+\t\tmk_test testrepo &&\n+\t\tgit checkout master &&\n+\t\tgit push testrepo $head:branch &&\n+\t\tcheck_push_result testrepo $the_commit heads/branch\n \n-test_expect_success 'push with config remote.*.push = HEAD' '\n+\t'\n \n-\tmk_test testrepo heads/local &&\n-\tgit checkout master &&\n-\tgit branch -f local $the_commit &&\n-\ttest_when_finished \"git branch -D local\" &&\n-\t(\n-\t\tcd testrepo &&\n-\t\tgit checkout local &&\n-\t\tgit reset --hard $the_first_commit\n-\t) &&\n-\ttest_config remote.there.url testrepo &&\n-\ttest_config remote.there.push HEAD &&\n-\ttest_config branch.master.remote there &&\n-\tgit push &&\n-\tcheck_push_result testrepo $the_commit heads/master &&\n-\tcheck_push_result testrepo $the_first_commit heads/local\n-'\n+\ttest_expect_success \"push with config remote.*.push = $head\" '\n+\n+\t\tmk_test testrepo heads/local &&\n+\t\tgit checkout master &&\n+\t\tgit branch -f local $the_commit &&\n+\t\ttest_when_finished \"git branch -D local\" &&\n+\t\t(\n+\t\t\tcd testrepo &&\n+\t\t\tgit checkout local &&\n+\t\t\tgit reset --hard $the_first_commit\n+\t\t) &&\n+\t\ttest_config remote.there.url testrepo &&\n+\t\ttest_config remote.there.push $head &&\n+\t\ttest_config branch.master.remote there &&\n+\t\tgit push &&\n+\t\tcheck_push_result testrepo $the_commit heads/master &&\n+\t\tcheck_push_result testrepo $the_first_commit heads/local\n+\t'\n+\n+done\n \n test_expect_success 'push with remote.pushdefault' '\n \tmk_test up_repo heads/master &&\n-- \n2.29.2\n\n"}]}