{"thread":{"id":"54716","subject":"[PATCH v3 0/3] refspec: make @ a synonym of HEAD","startedAt":"2020-11-25T23:35:03Z","lastAt":"2020-11-27T11:07:21Z","messageCount":7,"participants":["Felipe Contreras","Junio C Hamano","Johannes Schindelin"],"isPatch":true,"patchVersion":3,"patchTotal":3},"messages":[{"id":"410829","messageId":"20201125233443.63130-1-felipe.contreras@gmail.com","threadId":"54716","inReplyTo":null,"subject":"[PATCH v3 0/3] refspec: make @ a synonym of HEAD","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2020-11-25T23:34:40Z","receivedAt":"2020-11-25T23:35:03Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Basically $subject.\n\nSince v2 the tests have been revamped at the behest of Junio.\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 | 105 ++++++++++++++++++++++--------------------\n 3 files changed, 61 insertions(+), 51 deletions(-)\n\n-- \n2.29.2\n\n"},{"id":"410830","messageId":"20201125233443.63130-2-felipe.contreras@gmail.com","threadId":"54716","inReplyTo":"20201125233443.63130-1-felipe.contreras@gmail.com","subject":"[PATCH v3 1/3] tests: push: improve cleanup of HEAD tests","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2020-11-25T23:34:41Z","receivedAt":"2020-11-25T23:35:03Z","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":"410831","messageId":"20201125233443.63130-3-felipe.contreras@gmail.com","threadId":"54716","inReplyTo":"20201125233443.63130-1-felipe.contreras@gmail.com","subject":"[PATCH v3 2/3] tests: push: trivial cleanup","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2020-11-25T23:34:42Z","receivedAt":"2020-11-25T23:35:03Z","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":"410832","messageId":"20201125233443.63130-4-felipe.contreras@gmail.com","threadId":"54716","inReplyTo":"20201125233443.63130-1-felipe.contreras@gmail.com","subject":"[PATCH v3 3/3] refspec: make @ a synonym of HEAD","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2020-11-25T23:34:43Z","receivedAt":"2020-11-25T23:35:03Z","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 | 106 ++++++++++++++++++++++--------------------\n 3 files changed, 61 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..0cc5688135 100755\n--- a/t/t5516-fetch-push.sh\n+++ b/t/t5516-fetch-push.sh\n@@ -436,71 +436,75 @@ 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 @; 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"},{"id":"410833","messageId":"xmqqtutdatqn.fsf@gitster.c.googlers.com","threadId":"54716","inReplyTo":"20201125233443.63130-1-felipe.contreras@gmail.com","subject":"Re: [PATCH v3 0/3] refspec: make @ a synonym of HEAD","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-11-25T23:42:40Z","receivedAt":"2020-11-25T23:43:01Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Felipe Contreras <felipe.contreras@gmail.com> writes:\n\n> Basically $subject.\n\nWill replace what was on 'seen'.\n\nDscho, heads-up as this series will add more references of 'master'\nin the test suite.\n\nThanks.\n"},{"id":"410835","messageId":"xmqqpn41at89.fsf@gitster.c.googlers.com","threadId":"54716","inReplyTo":"20201125233443.63130-4-felipe.contreras@gmail.com","subject":"Re: [PATCH v3 3/3] refspec: make @ a synonym of HEAD","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-11-25T23:53:42Z","receivedAt":"2020-11-25T23:53:47Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Felipe Contreras <felipe.contreras@gmail.com> writes:\n\n> Since commit 9ba89f484e git learned how to push to a remote branch using\n> the source @, for example:\n>\n>   git push origin @:master\n>\n> However, if the right-hand side is missing, the push fails:\n>\n>   git push origin @\n>\n> It is obvious what is the desired behavior, and allowing the push makes\n> things more consistent.\n>\n> Additionally, @:master now has the same semantics as HEAD:master.\n>\n> Signed-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 | 106 ++++++++++++++++++++++--------------------\n>  3 files changed, 61 insertions(+), 52 deletions(-)\n\nSorry, but I cannot queue this version in today's pushout due to\ntime constraints.\n\n> -test_expect_success 'push with HEAD' '\n> +for head in HEAD @; do\n\nStyle: replace \"; \" with a LF.\n\n> +\ttest_expect_success \"push with $head\" \"\n\nDon't open the test body with double-quote; keep using the original\nsingle-quote and the reference to $head is resolved while running\nthe test, not when the test body is formulated before eval'ed.\n\nTwo benefits are\n\n - (obvious) you do not need extra quoting, e.g. \\$the_commit etc.\n\n - in this case it does not matter, but it works intuitively when\n   the variable has $IFS whitespace in it.  If you write in the test\n   body that is enclosed in a single-quote pair,\n\n\t\tgit push testrepo \"$head\"\n\n   would correctly give the contents of variable head as a single\n   element in argv[] of \"git push\".\n\nFor the latter reason, it is encouraged to make it a habit to do so.\n\nThanks.\n"},{"id":"410929","messageId":"nycvar.QRO.7.76.6.2011271205360.54@tvgsbejvaqbjf.bet","threadId":"54716","inReplyTo":"xmqqtutdatqn.fsf@gitster.c.googlers.com","subject":"Re: [PATCH v3 0/3] refspec: make @ a synonym of HEAD","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2020-11-27T11:07:04Z","receivedAt":"2020-11-27T11:07:21Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Junio,\n\nOn Wed, 25 Nov 2020, Junio C Hamano wrote:\n\n> Dscho, heads-up as this series will add more references of 'master' in\n> the test suite.\n\nThanks for the heads-up,\nDscho\n"}]}