{"thread":{"id":"58893","subject":"[RFC PATCH 0/1] push: introduce '--heads' option","startedAt":"2022-12-05T13:35:39Z","lastAt":"2023-05-07T06:44:06Z","messageCount":18,"participants":["Teng Long","ZheNing Hu","Junio C Hamano","Felipe Contreras"],"isPatch":true,"patchVersion":1,"patchTotal":1},"messages":[{"id":"468515","messageId":"20221205133525.60464-1-tenglong.tl@alibaba-inc.com","threadId":"58893","inReplyTo":null,"subject":"[RFC PATCH 0/1] push: introduce '--heads' option","fromName":"Teng Long","fromEmail":"dyroneteng@gmail.com","sentAt":"2022-12-05T13:35:24Z","receivedAt":"2022-12-05T13:35:39Z","isPatch":true,"sender":{"key":"dyroneteng@gmail.com","avatar":"https://avatars.githubusercontent.com/u/7803958?v=4"},"body":"From: Teng Long <dyroneteng@gmail.com>\n\nThis RFC patch try to introduce a new option '--heads' in 'git-push' subcmd. The\nvalue of this patch may come from my personal point of view, and the patch might\nnot have enough tests so far. It's pleasure to hear any suggestion, test\nscenario which need to be covered or any test method which need to be noticed if\nit's worthy.\n\nThanks.\n\nTeng Long (1):\n  push: introduce '--heads' option\n\n Documentation/git-push.txt |  1 +\n builtin/push.c             | 13 +++++++------\n t/t5523-push-upstream.sh   | 19 ++++++++++++-------\n 3 files changed, 20 insertions(+), 13 deletions(-)\n\n-- \n2.39.0.rc1.5.ge01d593fc21.dirty\n\n"},{"id":"468516","messageId":"20221205133525.60464-2-tenglong.tl@alibaba-inc.com","threadId":"58893","inReplyTo":"20221205133525.60464-1-tenglong.tl@alibaba-inc.com","subject":"[RFC PATCH 1/1] push: introduce '--heads' option","fromName":"Teng Long","fromEmail":"dyroneteng@gmail.com","sentAt":"2022-12-05T13:35:25Z","receivedAt":"2022-12-05T13:35:43Z","isPatch":true,"sender":{"key":"dyroneteng@gmail.com","avatar":"https://avatars.githubusercontent.com/u/7803958?v=4"},"body":"From: Teng Long <dyroneteng@gmail.com>\n\nThe '--all' option of git-push built-in cmd support to push all branches\n(refs under refs/heads) to remote. Under the usage, a user can easlily\nwork in some scenarios, for example, branches synchronization and batch\nupload.\n\n'--all' was introduced for a long time, meanwhile, git supports to\ncustomize the storage location under \"refs/\". when a new git user see\nthe usage like, 'git push origin --all', we might feel like we're\npushing _all_ the refs instead of just branches without looking at the\ndocuments until we found the related description of it or '--mirror'.\n\nTo ensure compatibility, we cannot rename '--all' to another name\ndirectly, one way is, we can try to add a new option '--heads' which be\nidentical with the functionality of '--all' to let the user understand\nthe meaning of representation more clearly. Actually, We've more or less\nnamed options this way already, for example, in 'git-show-ref' and 'git\nls-remote'.\n\nAt the same time, we fix a related issue about the wrong help\ninformation of '--all' option in code.\n\nSigned-off-by: Teng Long <dyroneteng@gmail.com>\n---\n Documentation/git-push.txt |  1 +\n builtin/push.c             | 13 +++++++------\n t/t5523-push-upstream.sh   | 19 ++++++++++++-------\n 3 files changed, 20 insertions(+), 13 deletions(-)\n\ndiff --git a/Documentation/git-push.txt b/Documentation/git-push.txt\nindex 5bb1d5aae25..a5d18fb90b6 100644\n--- a/Documentation/git-push.txt\n+++ b/Documentation/git-push.txt\n@@ -147,6 +147,7 @@ already exists on the remote side.\n `tag <tag>` means the same as `refs/tags/<tag>:refs/tags/<tag>`.\n \n --all::\n+--heads::\n \tPush all branches (i.e. refs under `refs/heads/`); cannot be\n \tused with other <refspec>.\n \ndiff --git a/builtin/push.c b/builtin/push.c\nindex 60ac8017e52..970cabaa78b 100644\n--- a/builtin/push.c\n+++ b/builtin/push.c\n@@ -588,11 +588,12 @@ int cmd_push(int argc, const char **argv, const char *prefix)\n \tstruct option options[] = {\n \t\tOPT__VERBOSITY(&verbosity),\n \t\tOPT_STRING( 0 , \"repo\", &repo, N_(\"repository\"), N_(\"repository\")),\n-\t\tOPT_BIT( 0 , \"all\", &flags, N_(\"push all refs\"), TRANSPORT_PUSH_ALL),\n+\t\tOPT_BIT( 0 , \"all\", &flags, N_(\"push all branches\"), TRANSPORT_PUSH_ALL),\n+\t\tOPT_BIT( 0 , \"heads\", &flags, N_(\"push all branches\"), TRANSPORT_PUSH_ALL),\n \t\tOPT_BIT( 0 , \"mirror\", &flags, N_(\"mirror all refs\"),\n \t\t\t    (TRANSPORT_PUSH_MIRROR|TRANSPORT_PUSH_FORCE)),\n \t\tOPT_BOOL('d', \"delete\", &deleterefs, N_(\"delete refs\")),\n-\t\tOPT_BOOL( 0 , \"tags\", &tags, N_(\"push tags (can't be used with --all or --mirror)\")),\n+\t\tOPT_BOOL( 0 , \"tags\", &tags, N_(\"push tags (can't be used with --all or --heads or --mirror)\")),\n \t\tOPT_BIT('n' , \"dry-run\", &flags, N_(\"dry run\"), TRANSPORT_PUSH_DRY_RUN),\n \t\tOPT_BIT( 0,  \"porcelain\", &flags, N_(\"machine-readable output\"), TRANSPORT_PUSH_PORCELAIN),\n \t\tOPT_BIT('f', \"force\", &flags, N_(\"force updates\"), TRANSPORT_PUSH_FORCE),\n@@ -635,7 +636,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)\n \tset_push_cert_flags(&flags, push_cert);\n \n \tif (deleterefs && (tags || (flags & (TRANSPORT_PUSH_ALL | TRANSPORT_PUSH_MIRROR))))\n-\t\tdie(_(\"options '%s' and '%s' cannot be used together\"), \"--delete\", \"--all/--mirror/--tags\");\n+\t\tdie(_(\"options '%s' and '%s' cannot be used together\"), \"--delete\", \"--all/--heads/--mirror/--tags\");\n \tif (deleterefs && argc < 2)\n \t\tdie(_(\"--delete doesn't make sense without any refs\"));\n \n@@ -673,9 +674,9 @@ int cmd_push(int argc, const char **argv, const char *prefix)\n \n \tif (flags & TRANSPORT_PUSH_ALL) {\n \t\tif (tags)\n-\t\t\tdie(_(\"options '%s' and '%s' cannot be used together\"), \"--all\", \"--tags\");\n+\t\t\tdie(_(\"options '%s' and '%s' cannot be used together\"), \"--all/--heads\", \"--tags\");\n \t\tif (argc >= 2)\n-\t\t\tdie(_(\"--all can't be combined with refspecs\"));\n+\t\t\tdie(_(\"--all/--heads can't be combined with refspecs\"));\n \t}\n \tif (flags & TRANSPORT_PUSH_MIRROR) {\n \t\tif (tags)\n@@ -684,7 +685,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)\n \t\t\tdie(_(\"--mirror can't be combined with refspecs\"));\n \t}\n \tif ((flags & TRANSPORT_PUSH_ALL) && (flags & TRANSPORT_PUSH_MIRROR))\n-\t\tdie(_(\"options '%s' and '%s' cannot be used together\"), \"--all\", \"--mirror\");\n+\t\tdie(_(\"options '%s' and '%s' cannot be used together\"), \"--all/--heads\", \"--mirror\");\n \n \tif (!is_empty_cas(&cas) && (flags & TRANSPORT_PUSH_FORCE_IF_INCLUDES))\n \t\tcas.use_force_if_includes = 1;\ndiff --git a/t/t5523-push-upstream.sh b/t/t5523-push-upstream.sh\nindex fdb42920564..29d03b2f58b 100755\n--- a/t/t5523-push-upstream.sh\n+++ b/t/t5523-push-upstream.sh\n@@ -60,13 +60,18 @@ test_expect_success 'push -u :topic_2' '\n \tcheck_config topic_2 upstream refs/heads/other2\n '\n \n-test_expect_success 'push -u --all' '\n-\tgit branch all1 &&\n-\tgit branch all2 &&\n-\tgit push -u --all &&\n-\tcheck_config all1 upstream refs/heads/all1 &&\n-\tcheck_config all2 upstream refs/heads/all2\n-'\n+\n+for option in 'all' 'heads'\n+do\n+\n+\ttest_expect_success \"push -u --$option\" '\n+\t\tgit branch \"$option\"1 &&\n+\t\tgit branch \"$option\"2 &&\n+\t\tgit push -u --\"$option\" &&\n+\t\tcheck_config \"$option\"1 upstream refs/heads/\"$option\"1 &&\n+\t\tcheck_config \"$option\"2 upstream refs/heads/\"$option\"2\n+\t'\n+done\n \n test_expect_success 'push -u HEAD' '\n \tgit checkout -b headbranch &&\n-- \n2.39.0.rc1.5.ge01d593fc21.dirty\n\n"},{"id":"468517","messageId":"CAOLTT8QcvPfXKap2aa6iyi0jq-cySL=XjDP2G2wG8m57=u0aGw@mail.gmail.com","threadId":"58893","inReplyTo":"20221205133525.60464-2-tenglong.tl@alibaba-inc.com","subject":"Re: [RFC PATCH 1/1] push: introduce '--heads' option","fromName":"ZheNing Hu","fromEmail":"adlternative@gmail.com","sentAt":"2022-12-05T14:23:38Z","receivedAt":"2022-12-05T14:24:12Z","isPatch":true,"sender":{"key":"adlternative@gmail.com","avatar":"https://avatars.githubusercontent.com/u/58138461?v=4"},"body":"Hi,\n\nTeng Long <dyroneteng@gmail.com> 于2022年12月5日周一 21:44写道：\n>\n> From: Teng Long <dyroneteng@gmail.com>\n>\n> The '--all' option of git-push built-in cmd support to push all branches\n> (refs under refs/heads) to remote. Under the usage, a user can easlily\n> work in some scenarios, for example, branches synchronization and batch\n> upload.\n>\n> '--all' was introduced for a long time, meanwhile, git supports to\n> customize the storage location under \"refs/\". when a new git user see\n> the usage like, 'git push origin --all', we might feel like we're\n> pushing _all_ the refs instead of just branches without looking at the\n> documents until we found the related description of it or '--mirror'.\n>\n\n\"--all\" sounds like it will include all things: branches, tags, but it only\nincludes branches under ref/heads/, which does cause a little confusion\nfor users.\n\n> To ensure compatibility, we cannot rename '--all' to another name\n> directly, one way is, we can try to add a new option '--heads' which be\n> identical with the functionality of '--all' to let the user understand\n> the meaning of representation more clearly. Actually, We've more or less\n> named options this way already, for example, in 'git-show-ref' and 'git\n> ls-remote'.\n>\n> At the same time, we fix a related issue about the wrong help\n> information of '--all' option in code.\n>\n> Signed-off-by: Teng Long <dyroneteng@gmail.com>\n> ---\n>  Documentation/git-push.txt |  1 +\n>  builtin/push.c             | 13 +++++++------\n>  t/t5523-push-upstream.sh   | 19 ++++++++++++-------\n>  3 files changed, 20 insertions(+), 13 deletions(-)\n>\n> diff --git a/Documentation/git-push.txt b/Documentation/git-push.txt\n> index 5bb1d5aae25..a5d18fb90b6 100644\n> --- a/Documentation/git-push.txt\n> +++ b/Documentation/git-push.txt\n> @@ -147,6 +147,7 @@ already exists on the remote side.\n>  `tag <tag>` means the same as `refs/tags/<tag>:refs/tags/<tag>`.\n>\n>  --all::\n> +--heads::\n>         Push all branches (i.e. refs under `refs/heads/`); cannot be\n>         used with other <refspec>.\n>\n> diff --git a/builtin/push.c b/builtin/push.c\n> index 60ac8017e52..970cabaa78b 100644\n> --- a/builtin/push.c\n> +++ b/builtin/push.c\n> @@ -588,11 +588,12 @@ int cmd_push(int argc, const char **argv, const char *prefix)\n>         struct option options[] = {\n>                 OPT__VERBOSITY(&verbosity),\n>                 OPT_STRING( 0 , \"repo\", &repo, N_(\"repository\"), N_(\"repository\")),\n> -               OPT_BIT( 0 , \"all\", &flags, N_(\"push all refs\"), TRANSPORT_PUSH_ALL),\n> +               OPT_BIT( 0 , \"all\", &flags, N_(\"push all branches\"), TRANSPORT_PUSH_ALL),\n> +               OPT_BIT( 0 , \"heads\", &flags, N_(\"push all branches\"), TRANSPORT_PUSH_ALL),\n\nMaybe OPT_ALIAS() will be better?\n"},{"id":"468559","messageId":"xmqqilippgp2.fsf@gitster.g","threadId":"58893","inReplyTo":"20221205133525.60464-1-tenglong.tl@alibaba-inc.com","subject":"Re: [RFC PATCH 0/1] push: introduce '--heads' option","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-12-05T23:35:21Z","receivedAt":"2022-12-05T23:37:17Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Teng Long <dyroneteng@gmail.com> writes:\n\n> From: Teng Long <dyroneteng@gmail.com>\n>\n> This RFC patch try to introduce a new option '--heads' in 'git-push' subcmd. The\n> value of this patch may come from my personal point of view, and the patch might\n> not have enough tests so far. It's pleasure to hear any suggestion, test\n> scenario which need to be covered or any test method which need to be noticed if\n> it's worthy.\n\nMy knee-jerk reaction is to avoid \"--heads\" and instead use\n\"--branches\", if this is about pushing all local branches.  The\noption \"--heads\" may still remain in some commands added to the\nsystem in the earliest part of our history, but soon we started\nto use \"branch\" over \"head\", as it is a more commonly used word.\n\nHow should it interact with --follow-tags?  Just as if you listed\nall local branch names on the command line?  I.e. is\n\n    git push $URL --heads\n\nequivalent to the long-hand\n\n    git push $URL $(git for-each-ref --format='%(refname)' refs/heads/\\*)\n\nand because of that, does\n\n    git push $URL --any --other --option --heads\n\nbehave identically to the long-hand with these other options added?\n"},{"id":"468621","messageId":"20221206121853.69819-1-tenglong.tl@alibaba-inc.com","threadId":"58893","inReplyTo":"CAOLTT8QcvPfXKap2aa6iyi0jq-cySL=XjDP2G2wG8m57=u0aGw@mail.gmail.com","subject":"Re: [RFC PATCH 1/1] push: introduce '--heads' option","fromName":"Teng Long","fromEmail":"dyroneteng@gmail.com","sentAt":"2022-12-06T12:18:53Z","receivedAt":"2022-12-06T12:19:05Z","isPatch":true,"sender":{"key":"dyroneteng@gmail.com","avatar":"https://avatars.githubusercontent.com/u/7803958?v=4"},"body":"> > '--all' was introduced for a long time, meanwhile, git supports to\n> > customize the storage location under \"refs/\". when a new git user see\n> > the usage like, 'git push origin --all', we might feel like we're\n> > pushing _all_ the refs instead of just branches without looking at the\n> > documents until we found the related description of it or '--mirror'.\n> >\n>\n> \"--all\" sounds like it will include all things: branches, tags, but it only\n> includes branches under ref/heads/, which does cause a little confusion\n> for users.\n\n\"under refs/heads\", right （^ヮ^）? But The overall is nice to\nme, I'm sure I will use some to revise.\n\n> Maybe OPT_ALIAS() will be better?\n\nI think it's suitable for this if there is no misunderstanding for\n'OPT_ALIAS()'.\n\nThanks.\n"},{"id":"469120","messageId":"20221215122719.11996-1-tenglong.tl@alibaba-inc.com","threadId":"58893","inReplyTo":"xmqqilippgp2.fsf@gitster.g","subject":"Re: [RFC PATCH 0/1] push: introduce '--heads' option","fromName":"Teng Long","fromEmail":"dyroneteng@gmail.com","sentAt":"2022-12-15T12:27:19Z","receivedAt":"2022-12-15T12:27:29Z","isPatch":true,"sender":{"key":"dyroneteng@gmail.com","avatar":"https://avatars.githubusercontent.com/u/7803958?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> My knee-jerk reaction is to avoid \"--heads\" and instead use\n> \"--branches\", if this is about pushing all local branches.  The\n> option \"--heads\" may still remain in some commands added to the\n> system in the earliest part of our history, but soon we started\n> to use \"branch\" over \"head\", as it is a more commonly used word.\n\nOK, that's true, I just misled by some existing '--heads' in other\ncommands.\n\n> How should it interact with --follow-tags?  Just as if you listed\n> all local branch names on the command line?  I.e. is\n\nActually I didn't try '--follow-tags' before, but the documentation\nabout it is a  ittle hard to understand for me on first reading. Then,\nI think it supports to use as negative '--[no-]follow-tags' but not\nmarked in the git-push.txt documentation.\n\n>     git push $URL --heads\n>\n> equivalent to the long-hand\n>\n>     git push $URL $(git for-each-ref --format='%(refname)' refs/heads/\\*)\n\ngit push $URL $(git for-each-ref --format='%(refname)' refs/heads/\\*\\*) maybe\nto recursivly subdirectories matching?\n\nActually I didn't get why you represent this, maybe try to let's us know there\nis another way we could make it as the same result?\n\n> and because of that, does\n>\n>     git push $URL --any --other --option --heads\n>\n> behave identically to the long-hand with these other options added?\n\nI think you concerned about the compatibility with the interaction of\nthe options, if so, I think a direct way is to keep --all and --heads\nboth have the some behavior when interact with other options, a little\nconfused why we have to use the long-hand to do that.\n\nBy the way, it seems like there are no specify tests for '--all', maybe\nwe can add some tests about '--all' first if this RFC patch is worthy to\ncontinue.\n\nThanks.\n"},{"id":"476265","messageId":"20230428095955.66292-1-tenglong.tl@alibaba-inc.com","threadId":"58893","inReplyTo":"xmqqilippgp2.fsf@gitster.g","subject":"Re: [RFC PATCH 0/1] push: introduce '--heads' option","fromName":"Teng Long","fromEmail":"dyroneteng@gmail.com","sentAt":"2023-04-28T09:59:55Z","receivedAt":"2023-04-28T10:01:16Z","isPatch":true,"sender":{"key":"dyroneteng@gmail.com","avatar":"https://avatars.githubusercontent.com/u/7803958?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n>My knee-jerk reaction is to avoid \"--heads\" and instead use\n>\"--branches\", if this is about pushing all local branches.  The\n>option \"--heads\" may still remain in some commands added to the\n>system in the earliest part of our history, but soon we started\n>to use \"branch\" over \"head\", as it is a more commonly used word.\n>\n>How should it interact with --follow-tags?  Just as if you listed\n>all local branch names on the command line?  I.e. is\n>\n>    git push $URL --heads\n>\n>equivalent to the long-hand\n>\n>    git push $URL $(git for-each-ref --format='%(refname)' refs/heads/\\*)\n>\n>and because of that, does\n>\n>    git push $URL --any --other --option --heads\n>\n>behave identically to the long-hand with these other options added?\n\nZheNing Hu mentioned me that could use \"OPT_ALIAS\" instead, it seems\nlike could be better than OPT_BIT in this scenario. If so, are problems\nthat may arise from interactions shielded? If not, I'm willing to add\nextra test about it (some relevant advice if possible).\n\nThanks.\n"},{"id":"476267","messageId":"644bba3f96e3b_1c66e29436@chronos.notmuch","threadId":"58893","inReplyTo":"20221205133525.60464-2-tenglong.tl@alibaba-inc.com","subject":"Re: [RFC PATCH 1/1] push: introduce '--heads' option","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2023-04-28T12:21:19Z","receivedAt":"2023-04-28T12:21:38Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Teng Long wrote:\n> From: Teng Long <dyroneteng@gmail.com>\n> \n> The '--all' option of git-push built-in cmd support to push all branches\n> (refs under refs/heads) to remote. Under the usage, a user can easlily\n> work in some scenarios, for example, branches synchronization and batch\n> upload.\n> \n> '--all' was introduced for a long time, meanwhile, git supports to\n> customize the storage location under \"refs/\". when a new git user see\n> the usage like, 'git push origin --all', we might feel like we're\n> pushing _all_ the refs instead of just branches without looking at the\n> documents until we found the related description of it or '--mirror'.\n\nCompletely agree.\n\nThis is something I spotted a long time ago. Although I would prefer\n`--branches` over `--heads`.\n\n-- \nFelipe Contreras\n"},{"id":"476284","messageId":"xmqq7ctvetbo.fsf@gitster.g","threadId":"58893","inReplyTo":"20230428095955.66292-1-tenglong.tl@alibaba-inc.com","subject":"Re: [RFC PATCH 0/1] push: introduce '--heads' option","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2023-04-28T18:48:43Z","receivedAt":"2023-04-28T18:48:50Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Teng Long <dyroneteng@gmail.com> writes:\n\n> ZheNing Hu mentioned me that could use \"OPT_ALIAS\" instead, it seems\n> like could be better than OPT_BIT in this scenario. If so, are problems\n> that may arise from interactions shielded? If not, I'm willing to add\n> extra test about it (some relevant advice if possible).\n\nThe intent of ALIAS is to just add an extra option visible at the UI\nlevel that behaves exactly the same as the other one at the code\nlevel, so the codepath that is prepared to deal with one can handle\nthe other one without any extra effort.  In fact, after the option\nparsing is finished, the rest of the code should not even be able to\ntell which one, the original or the alias, was used on the command\nline.\n\nAnd in this case, you'd want a new \"push all branches\" option that\nbehaves exactly like existing \"--all\", and possibly you may over\ntime want to deprecate the latter.  All the code to ensure how\n\"--all\" should interact with other options should be working fine\n(or if there is a bug, that needs to be corrected whether we would\nadd this alias or not).\n\nSounds like a very good plan to me.\n\nThanks.\n\n"},{"id":"476308","messageId":"20230430010948.4396-1-tenglong.tl@alibaba-inc.com","threadId":"58893","inReplyTo":"xmqq7ctvetbo.fsf@gitster.g","subject":"Re: [RFC PATCH 0/1] push: introduce '--heads' option","fromName":"Teng Long","fromEmail":"dyroneteng@gmail.com","sentAt":"2023-04-30T01:09:48Z","receivedAt":"2023-04-30T01:15:07Z","isPatch":true,"sender":{"key":"dyroneteng@gmail.com","avatar":"https://avatars.githubusercontent.com/u/7803958?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n>Teng Long <dyroneteng@gmail.com> writes:\n>\n>> ZheNing Hu mentioned me that could use \"OPT_ALIAS\" instead, it seems\n>> like could be better than OPT_BIT in this scenario. If so, are problems\n>> that may arise from interactions shielded? If not, I'm willing to add\n>> extra test about it (some relevant advice if possible).\n>\n>The intent of ALIAS is to just add an extra option visible at the UI\n>level that behaves exactly the same as the other one at the code\n>level, so the codepath that is prepared to deal with one can handle\n>the other one without any extra effort.  In fact, after the option\n>parsing is finished, the rest of the code should not even be able to\n>tell which one, the original or the alias, was used on the command\n>line.\n>\n>And in this case, you'd want a new \"push all branches\" option that\n>behaves exactly like existing \"--all\", and possibly you may over\n>time want to deprecate the latter.  All the code to ensure how\n>\"--all\" should interact with other options should be working fine\n>(or if there is a bug, that needs to be corrected whether we would\n>add this alias or not).\n\nMake sense.\n\nThanks.\n"},{"id":"476309","messageId":"20230430010553.4253-1-tenglong.tl@alibaba-inc.com","threadId":"58893","inReplyTo":"644bba3f96e3b_1c66e29436@chronos.notmuch","subject":"Re: [RFC PATCH 1/1] push: introduce '--heads' option","fromName":"Teng Long","fromEmail":"dyroneteng@gmail.com","sentAt":"2023-04-30T01:05:53Z","receivedAt":"2023-04-30T01:15:07Z","isPatch":true,"sender":{"key":"dyroneteng@gmail.com","avatar":"https://avatars.githubusercontent.com/u/7803958?v=4"},"body":"Felipe Contreras <felipe.contreras@gmail.com> writes:\n\n> Teng Long wrote:\n>> From: Teng Long <dyroneteng@gmail.com>\n>> \n>> The '--all' option of git-push built-in cmd support to push all branches\n>> (refs under refs/heads) to remote. Under the usage, a user can easlily\n>> work in some scenarios, for example, branches synchronization and batch\n>> upload.\n>> \n>> '--all' was introduced for a long time, meanwhile, git supports to\n>> customize the storage location under \"refs/\". when a new git user see\n>> the usage like, 'git push origin --all', we might feel like we're\n>> pushing _all_ the refs instead of just branches without looking at the\n>> documents until we found the related description of it or '--mirror'.\n>\n>Completely agree.\n>\n>This is something I spotted a long time ago. Although I would prefer\n>`--branches` over `--heads`.\n\nI will cook this recently, maybe we need some well prepared test cases\nat first.\n\nThanks.\n"},{"id":"476672","messageId":"20230506112740.61454-1-tenglong.tl@alibaba-inc.com","threadId":"58893","inReplyTo":"20221205133525.60464-2-tenglong.tl@alibaba-inc.com","subject":"[PATCH 0/1] push: introduce '--branches' option","fromName":"Teng Long","fromEmail":"dyroneteng@gmail.com","sentAt":"2023-05-06T11:27:39Z","receivedAt":"2023-05-06T11:27:54Z","isPatch":true,"sender":{"key":"dyroneteng@gmail.com","avatar":"https://avatars.githubusercontent.com/u/7803958?v=4"},"body":"From: Teng Long <dyroneteng@gmail.com>\n\nBased on the feedback I got from the previous RFC\npatch, I made a formal patch with some additional\ntest cases, but I don't know if the scenarios covered by\nthe test cases are sufficient, if not, the cases will be\nimproved in a subsequent patch.\n\nThanks.\n\nTeng Long (1):\n  push: introduce '--branches' option\n\n Documentation/git-push.txt |   3 +-\n builtin/push.c             |   7 ++-\n t/t5523-push-upstream.sh   |  12 +++-\n t/t5543-atomic-push.sh     |   5 +-\n t/t5583-push-branches.sh   | 115 +++++++++++++++++++++++++++++++++++++\n 5 files changed, 135 insertions(+), 7 deletions(-)\n create mode 100755 t/t5583-push-branches.sh\n\nRange-diff:\n1:  9c9438c3 < -:  -------- push: introduce '--heads' option\n-:  -------- > 1:  b16bdfe6 push: introduce '--branches' option\n-- \n2.40.1.446.gf331623a.dirty\n\n"},{"id":"476673","messageId":"20230506112740.61454-2-tenglong.tl@alibaba-inc.com","threadId":"58893","inReplyTo":"20230506112740.61454-1-tenglong.tl@alibaba-inc.com","subject":"[PATCH 1/1] push: introduce '--branches' option","fromName":"Teng Long","fromEmail":"dyroneteng@gmail.com","sentAt":"2023-05-06T11:27:40Z","receivedAt":"2023-05-06T11:28:01Z","isPatch":true,"sender":{"key":"dyroneteng@gmail.com","avatar":"https://avatars.githubusercontent.com/u/7803958?v=4"},"body":"From: Teng Long <dyroneteng@gmail.com>\n\nThe '--all' option of git-push built-in cmd support to push all branches\n(refs under refs/heads) to remote. Under the usage, a user can easlily\nwork in some scenarios, for example, branches synchronization and batch\nupload.\n\nThe '--all' was introduced for a long time, meanwhile, git supports to\ncustomize the storage location under \"refs/\". when a new git user see\nthe usage like, 'git push origin --all', we might feel like we're\npushing _all_ the refs instead of just branches without looking at the\ndocuments until we found the related description of it or '--mirror'.\n\nTo ensure compatibility, we cannot rename '--all' to another name\ndirectly, one way is, we can try to add a new option '--heads' which be\nidentical with the functionality of '--all' to let the user understand\nthe meaning of representation more clearly. Actually, We've more or less\nnamed options this way already, for example, in 'git-show-ref' and 'git\nls-remote'.\n\nAt the same time, we fix a related issue about the wrong help\ninformation of '--all' option in code and add some test cases in\nt5523, t5543 and t5583.\n\nSigned-off-by: Teng Long <dyroneteng@gmail.com>\n---\n Documentation/git-push.txt |   3 +-\n builtin/push.c             |   7 ++-\n t/t5523-push-upstream.sh   |  12 +++-\n t/t5543-atomic-push.sh     |   5 +-\n t/t5583-push-branches.sh   | 115 +++++++++++++++++++++++++++++++++++++\n 5 files changed, 135 insertions(+), 7 deletions(-)\n create mode 100755 t/t5583-push-branches.sh\n\ndiff --git a/Documentation/git-push.txt b/Documentation/git-push.txt\nindex 5bb1d5aa..297927d8 100644\n--- a/Documentation/git-push.txt\n+++ b/Documentation/git-push.txt\n@@ -9,7 +9,7 @@ git-push - Update remote refs along with associated objects\n SYNOPSIS\n --------\n [verse]\n-'git push' [--all | --mirror | --tags] [--follow-tags] [--atomic] [-n | --dry-run] [--receive-pack=<git-receive-pack>]\n+'git push' [--all | --branches | --mirror | --tags] [--follow-tags] [--atomic] [-n | --dry-run] [--receive-pack=<git-receive-pack>]\n \t   [--repo=<repository>] [-f | --force] [-d | --delete] [--prune] [-v | --verbose]\n \t   [-u | --set-upstream] [-o <string> | --push-option=<string>]\n \t   [--[no-]signed|--signed=(true|false|if-asked)]\n@@ -147,6 +147,7 @@ already exists on the remote side.\n `tag <tag>` means the same as `refs/tags/<tag>:refs/tags/<tag>`.\n \n --all::\n+--branches::\n \tPush all branches (i.e. refs under `refs/heads/`); cannot be\n \tused with other <refspec>.\n \ndiff --git a/builtin/push.c b/builtin/push.c\nindex 6001e4ae..d616fa83 100644\n--- a/builtin/push.c\n+++ b/builtin/push.c\n@@ -593,11 +593,12 @@ int cmd_push(int argc, const char **argv, const char *prefix)\n \tstruct option options[] = {\n \t\tOPT__VERBOSITY(&verbosity),\n \t\tOPT_STRING( 0 , \"repo\", &repo, N_(\"repository\"), N_(\"repository\")),\n-\t\tOPT_BIT( 0 , \"all\", &flags, N_(\"push all refs\"), TRANSPORT_PUSH_ALL),\n+\t\tOPT_BIT( 0 , \"all\", &flags, N_(\"push all branches\"), TRANSPORT_PUSH_ALL),\n+\t\tOPT_ALIAS( 0 , \"branches\", \"all\"),\n \t\tOPT_BIT( 0 , \"mirror\", &flags, N_(\"mirror all refs\"),\n \t\t\t    (TRANSPORT_PUSH_MIRROR|TRANSPORT_PUSH_FORCE)),\n \t\tOPT_BOOL('d', \"delete\", &deleterefs, N_(\"delete refs\")),\n-\t\tOPT_BOOL( 0 , \"tags\", &tags, N_(\"push tags (can't be used with --all or --mirror)\")),\n+\t\tOPT_BOOL( 0 , \"tags\", &tags, N_(\"push tags (can't be used with --all or --branches or --mirror)\")),\n \t\tOPT_BIT('n' , \"dry-run\", &flags, N_(\"dry run\"), TRANSPORT_PUSH_DRY_RUN),\n \t\tOPT_BIT( 0,  \"porcelain\", &flags, N_(\"machine-readable output\"), TRANSPORT_PUSH_PORCELAIN),\n \t\tOPT_BIT('f', \"force\", &flags, N_(\"force updates\"), TRANSPORT_PUSH_FORCE),\n@@ -640,7 +641,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)\n \tset_push_cert_flags(&flags, push_cert);\n \n \tif (deleterefs && (tags || (flags & (TRANSPORT_PUSH_ALL | TRANSPORT_PUSH_MIRROR))))\n-\t\tdie(_(\"options '%s' and '%s' cannot be used together\"), \"--delete\", \"--all/--mirror/--tags\");\n+\t\tdie(_(\"options '%s' and '%s' cannot be used together\"), \"--delete\", \"--all/--branches/--mirror/--tags\");\n \tif (deleterefs && argc < 2)\n \t\tdie(_(\"--delete doesn't make sense without any refs\"));\n \ndiff --git a/t/t5523-push-upstream.sh b/t/t5523-push-upstream.sh\nindex c9acc076..1b8d6098 100755\n--- a/t/t5523-push-upstream.sh\n+++ b/t/t5523-push-upstream.sh\n@@ -61,12 +61,20 @@ test_expect_success 'push -u :topic_2' '\n \tcheck_config topic_2 upstream refs/heads/other2\n '\n \n-test_expect_success 'push -u --all' '\n+test_expect_success 'push -u --all(the same behavior with--branches)' '\n \tgit branch all1 &&\n \tgit branch all2 &&\n \tgit push -u --all &&\n \tcheck_config all1 upstream refs/heads/all1 &&\n-\tcheck_config all2 upstream refs/heads/all2\n+\tcheck_config all2 upstream refs/heads/all2 &&\n+\tgit config --get-regexp branch.all* > expect &&\n+\tgit config --remove-section branch.all1 &&\n+\tgit config --remove-section branch.all2 &&\n+\tgit push -u --branches &&\n+\tcheck_config all1 upstream refs/heads/all1 &&\n+\tcheck_config all2 upstream refs/heads/all2 &&\n+\tgit config --get-regexp branch.all* > actual &&\n+\ttest_cmp expect actual\n '\n \n test_expect_success 'push -u HEAD' '\ndiff --git a/t/t5543-atomic-push.sh b/t/t5543-atomic-push.sh\nindex 70431122..04b47ad8 100755\n--- a/t/t5543-atomic-push.sh\n+++ b/t/t5543-atomic-push.sh\n@@ -117,7 +117,10 @@ test_expect_success 'atomic push fails if one branch fails' '\n \t\ttest_commit five &&\n \t\tgit checkout main &&\n \t\ttest_commit six &&\n-\t\ttest_must_fail git push --atomic --all up\n+\t\ttest_must_fail git push --atomic --all up >output-all 2>&1 &&\n+\t\t# --all and --branches have the same behavior when be combined with --atomic\n+\t\ttest_must_fail git push --atomic --branches up >output-branches 2>&1 &&\n+\t\ttest_cmp output-all output-branches\n \t) &&\n \ttest_refs main HEAD@{7} &&\n \ttest_refs second HEAD@{4}\ndiff --git a/t/t5583-push-branches.sh b/t/t5583-push-branches.sh\nnew file mode 100755\nindex 00000000..29a5c560\n--- /dev/null\n+++ b/t/t5583-push-branches.sh\n@@ -0,0 +1,115 @@\n+#!bin/sh\n+\n+test_description='check the consisitency of behavior of --all and --branches'\n+\n+GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main\n+export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\n+\n+. ./test-lib.sh\n+\n+delete_refs() {\n+\tdir=$1\n+\tshift\n+\trm -rf deletes\n+\tfor arg in $*\n+\tdo\n+\t\techo \"delete ${arg}\" >>deletes\n+\tdone\n+\tgit -C $dir update-ref --stdin < deletes\n+}\n+\n+test_expect_success 'setup bare remote' '\n+\tgit init --bare remote-1 &&\n+\tgit -C remote-1 config gc.auto 0 &&\n+\ttest_commit one &&\n+\tgit push remote-1 HEAD\n+'\n+\n+test_expect_success 'setup different types of references' '\n+\tcat >refs <<-EOF &&\n+\tupdate refs/heads/branch-1 HEAD\n+\tupdate refs/heads/branch-2 HEAD\n+\tEOF\n+\n+\tgit tag -a -m \"annotated\" annotated-1 HEAD &&\n+\tgit tag -a -m \"annotated\" annotated-2 HEAD &&\n+\tgit update-ref --stdin < refs\n+'\n+\n+test_expect_success '--all and --branches have the same behavior' '\n+\ttest_when_finished \"delete_refs remote-1 \\\n+\t\t\t   refs/heads/branch-1 \\\n+\t\t\t   refs/heads/branch-2\" &&\n+\tgit push remote-1 --all &&\n+\tcommit=$(git rev-parse HEAD) &&\n+\tcat >expect <<-EOF &&\n+\t$commit refs/heads/branch-1\n+\t$commit refs/heads/branch-2\n+\t$commit refs/heads/main\n+\tEOF\n+\n+\tgit -C remote-1 show-ref --heads >actual.all &&\n+\tdelete_refs remote-1 refs/heads/branch-1 refs/heads/branch-2 &&\n+\tgit push remote-1 --branches &&\n+\tgit -C remote-1 show-ref --heads >actual.branches &&\n+\ttest_cmp actual.all actual.branches &&\n+\ttest_cmp expect actual.all\n+'\n+\n+test_expect_success '--all or --branches can not be combined with refspecs' '\n+\ttest_must_fail git push remote-1 --all main >actual.all 2>&1 &&\n+\ttest_must_fail git push remote-1 --branches main >actual.branches 2>&1 &&\n+\ttest_cmp actual.all actual.branches &&\n+\tgrep \"be combined with refspecs\" actual.all\n+'\n+\n+test_expect_success '--all or --branches can not be combined with --mirror' '\n+\ttest_must_fail git push remote-1 --all --mirror >actual.all 2>&1 &&\n+\ttest_must_fail git push remote-1 --branches --mirror >actual.branches 2>&1 &&\n+\ttest_cmp actual.all actual.branches &&\n+\tgrep \"cannot be used together\" actual.all\n+'\n+\n+test_expect_success '--all or --branches can not be combined with --tags' '\n+\ttest_must_fail git push remote-1 --all --tags >actual.all 2>&1 &&\n+\ttest_must_fail git push remote-1 --branches --tags >actual.branches 2>&1 &&\n+\ttest_cmp actual.all actual.branches &&\n+\tgrep \"cannot be used together\" actual.all\n+'\n+\n+\n+test_expect_success '--all or --branches can not be combined with --delete' '\n+\ttest_must_fail git push remote-1 --all --delete >actual.all 2>&1 &&\n+\ttest_must_fail git push remote-1 --branches --delete >actual.branches 2>&1 &&\n+\ttest_cmp actual.all actual.branches &&\n+\tgrep \"cannot be used together\" actual.all\n+'\n+\n+test_expect_success '--all or --branches combines with --follow-tags have same behavior' '\n+\ttest_when_finished \"delete_refs remote-1 \\\n+\t\t\t   refs/heads/branch-1 \\\n+\t\t\t   refs/heads/branch-2 \\\n+\t\t\t   refs/tags/annotated-1 \\\n+\t\t\t   refs/tags/annotated-2\" &&\n+\tgit push remote-1 --all --follow-tags &&\n+\tgit -C remote-1 show-ref > actual.all &&\n+\tcat >expect <<-EOF &&\n+\t$commit refs/heads/branch-1\n+\t$commit refs/heads/branch-2\n+\t$commit refs/heads/main\n+\t$(git rev-parse annotated-1) refs/tags/annotated-1\n+\t$(git rev-parse annotated-2) refs/tags/annotated-2\n+\tEOF\n+\n+\tdelete_refs remote-1 \\\n+\t\t    refs/heads/branch-1 \\\n+\t\t    refs/heads/branch-2 \\\n+\t\t    refs/tags/annotated-1 \\\n+\t\t    refs/tags/annotated-2 &&\n+\tgit push remote-1 --branches --follow-tags &&\n+\tgit -C remote-1 show-ref >actual.branches &&\n+\ttest_cmp actual.all actual.branches &&\n+\ttest_cmp expect actual.all\n+'\n+\n+test_done\n-- \n2.40.1.446.gf331623a.dirty\n\n"},{"id":"476674","messageId":"20230506113408.61529-1-tenglong.tl@alibaba-inc.com","threadId":"58893","inReplyTo":"20221205133525.60464-1-tenglong.tl@alibaba-inc.com","subject":"[PATCH 0/1] push: introduce '--branches' option","fromName":"Teng Long","fromEmail":"dyroneteng@gmail.com","sentAt":"2023-05-06T11:34:07Z","receivedAt":"2023-05-06T11:34:18Z","isPatch":true,"sender":{"key":"dyroneteng@gmail.com","avatar":"https://avatars.githubusercontent.com/u/7803958?v=4"},"body":"From: Teng Long <dyroneteng@gmail.com>\n\nBased on the feedback I got from the previous RFC\npatch, I made a formal patch with some additional\ntest cases, but I don't know if the scenarios covered by\nthe test cases are sufficient, if not, the cases will be\nimproved in a subsequent patch.\n\nThanks.\n\nTeng Long (1):\n  push: introduce '--branches' option\n\n Documentation/git-push.txt |   3 +-\n builtin/push.c             |   7 ++-\n t/t5523-push-upstream.sh   |  12 +++-\n t/t5543-atomic-push.sh     |   5 +-\n t/t5583-push-branches.sh   | 115 +++++++++++++++++++++++++++++++++++++\n 5 files changed, 135 insertions(+), 7 deletions(-)\n create mode 100755 t/t5583-push-branches.sh\n\nRange-diff:\n1:  9c9438c3 < -:  -------- push: introduce '--heads' option\n-:  -------- > 1:  b16bdfe6 push: introduce '--branches' option\n-- \n2.40.1.446.gf331623a.dirty\n\n"},{"id":"476675","messageId":"20230506113408.61529-2-tenglong.tl@alibaba-inc.com","threadId":"58893","inReplyTo":"20230506113408.61529-1-tenglong.tl@alibaba-inc.com","subject":"[PATCH 1/1] push: introduce '--branches' option","fromName":"Teng Long","fromEmail":"dyroneteng@gmail.com","sentAt":"2023-05-06T11:34:08Z","receivedAt":"2023-05-06T11:34:26Z","isPatch":true,"sender":{"key":"dyroneteng@gmail.com","avatar":"https://avatars.githubusercontent.com/u/7803958?v=4"},"body":"From: Teng Long <dyroneteng@gmail.com>\n\nThe '--all' option of git-push built-in cmd support to push all branches\n(refs under refs/heads) to remote. Under the usage, a user can easlily\nwork in some scenarios, for example, branches synchronization and batch\nupload.\n\nThe '--all' was introduced for a long time, meanwhile, git supports to\ncustomize the storage location under \"refs/\". when a new git user see\nthe usage like, 'git push origin --all', we might feel like we're\npushing _all_ the refs instead of just branches without looking at the\ndocuments until we found the related description of it or '--mirror'.\n\nTo ensure compatibility, we cannot rename '--all' to another name\ndirectly, one way is, we can try to add a new option '--heads' which be\nidentical with the functionality of '--all' to let the user understand\nthe meaning of representation more clearly. Actually, We've more or less\nnamed options this way already, for example, in 'git-show-ref' and 'git\nls-remote'.\n\nAt the same time, we fix a related issue about the wrong help\ninformation of '--all' option in code and add some test cases in\nt5523, t5543 and t5583.\n\nSigned-off-by: Teng Long <dyroneteng@gmail.com>\n---\n Documentation/git-push.txt |   3 +-\n builtin/push.c             |   7 ++-\n t/t5523-push-upstream.sh   |  12 +++-\n t/t5543-atomic-push.sh     |   5 +-\n t/t5583-push-branches.sh   | 115 +++++++++++++++++++++++++++++++++++++\n 5 files changed, 135 insertions(+), 7 deletions(-)\n create mode 100755 t/t5583-push-branches.sh\n\ndiff --git a/Documentation/git-push.txt b/Documentation/git-push.txt\nindex 5bb1d5aa..297927d8 100644\n--- a/Documentation/git-push.txt\n+++ b/Documentation/git-push.txt\n@@ -9,7 +9,7 @@ git-push - Update remote refs along with associated objects\n SYNOPSIS\n --------\n [verse]\n-'git push' [--all | --mirror | --tags] [--follow-tags] [--atomic] [-n | --dry-run] [--receive-pack=<git-receive-pack>]\n+'git push' [--all | --branches | --mirror | --tags] [--follow-tags] [--atomic] [-n | --dry-run] [--receive-pack=<git-receive-pack>]\n \t   [--repo=<repository>] [-f | --force] [-d | --delete] [--prune] [-v | --verbose]\n \t   [-u | --set-upstream] [-o <string> | --push-option=<string>]\n \t   [--[no-]signed|--signed=(true|false|if-asked)]\n@@ -147,6 +147,7 @@ already exists on the remote side.\n `tag <tag>` means the same as `refs/tags/<tag>:refs/tags/<tag>`.\n \n --all::\n+--branches::\n \tPush all branches (i.e. refs under `refs/heads/`); cannot be\n \tused with other <refspec>.\n \ndiff --git a/builtin/push.c b/builtin/push.c\nindex 6001e4ae..d616fa83 100644\n--- a/builtin/push.c\n+++ b/builtin/push.c\n@@ -593,11 +593,12 @@ int cmd_push(int argc, const char **argv, const char *prefix)\n \tstruct option options[] = {\n \t\tOPT__VERBOSITY(&verbosity),\n \t\tOPT_STRING( 0 , \"repo\", &repo, N_(\"repository\"), N_(\"repository\")),\n-\t\tOPT_BIT( 0 , \"all\", &flags, N_(\"push all refs\"), TRANSPORT_PUSH_ALL),\n+\t\tOPT_BIT( 0 , \"all\", &flags, N_(\"push all branches\"), TRANSPORT_PUSH_ALL),\n+\t\tOPT_ALIAS( 0 , \"branches\", \"all\"),\n \t\tOPT_BIT( 0 , \"mirror\", &flags, N_(\"mirror all refs\"),\n \t\t\t    (TRANSPORT_PUSH_MIRROR|TRANSPORT_PUSH_FORCE)),\n \t\tOPT_BOOL('d', \"delete\", &deleterefs, N_(\"delete refs\")),\n-\t\tOPT_BOOL( 0 , \"tags\", &tags, N_(\"push tags (can't be used with --all or --mirror)\")),\n+\t\tOPT_BOOL( 0 , \"tags\", &tags, N_(\"push tags (can't be used with --all or --branches or --mirror)\")),\n \t\tOPT_BIT('n' , \"dry-run\", &flags, N_(\"dry run\"), TRANSPORT_PUSH_DRY_RUN),\n \t\tOPT_BIT( 0,  \"porcelain\", &flags, N_(\"machine-readable output\"), TRANSPORT_PUSH_PORCELAIN),\n \t\tOPT_BIT('f', \"force\", &flags, N_(\"force updates\"), TRANSPORT_PUSH_FORCE),\n@@ -640,7 +641,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)\n \tset_push_cert_flags(&flags, push_cert);\n \n \tif (deleterefs && (tags || (flags & (TRANSPORT_PUSH_ALL | TRANSPORT_PUSH_MIRROR))))\n-\t\tdie(_(\"options '%s' and '%s' cannot be used together\"), \"--delete\", \"--all/--mirror/--tags\");\n+\t\tdie(_(\"options '%s' and '%s' cannot be used together\"), \"--delete\", \"--all/--branches/--mirror/--tags\");\n \tif (deleterefs && argc < 2)\n \t\tdie(_(\"--delete doesn't make sense without any refs\"));\n \ndiff --git a/t/t5523-push-upstream.sh b/t/t5523-push-upstream.sh\nindex c9acc076..1b8d6098 100755\n--- a/t/t5523-push-upstream.sh\n+++ b/t/t5523-push-upstream.sh\n@@ -61,12 +61,20 @@ test_expect_success 'push -u :topic_2' '\n \tcheck_config topic_2 upstream refs/heads/other2\n '\n \n-test_expect_success 'push -u --all' '\n+test_expect_success 'push -u --all(the same behavior with--branches)' '\n \tgit branch all1 &&\n \tgit branch all2 &&\n \tgit push -u --all &&\n \tcheck_config all1 upstream refs/heads/all1 &&\n-\tcheck_config all2 upstream refs/heads/all2\n+\tcheck_config all2 upstream refs/heads/all2 &&\n+\tgit config --get-regexp branch.all* > expect &&\n+\tgit config --remove-section branch.all1 &&\n+\tgit config --remove-section branch.all2 &&\n+\tgit push -u --branches &&\n+\tcheck_config all1 upstream refs/heads/all1 &&\n+\tcheck_config all2 upstream refs/heads/all2 &&\n+\tgit config --get-regexp branch.all* > actual &&\n+\ttest_cmp expect actual\n '\n \n test_expect_success 'push -u HEAD' '\ndiff --git a/t/t5543-atomic-push.sh b/t/t5543-atomic-push.sh\nindex 70431122..04b47ad8 100755\n--- a/t/t5543-atomic-push.sh\n+++ b/t/t5543-atomic-push.sh\n@@ -117,7 +117,10 @@ test_expect_success 'atomic push fails if one branch fails' '\n \t\ttest_commit five &&\n \t\tgit checkout main &&\n \t\ttest_commit six &&\n-\t\ttest_must_fail git push --atomic --all up\n+\t\ttest_must_fail git push --atomic --all up >output-all 2>&1 &&\n+\t\t# --all and --branches have the same behavior when be combined with --atomic\n+\t\ttest_must_fail git push --atomic --branches up >output-branches 2>&1 &&\n+\t\ttest_cmp output-all output-branches\n \t) &&\n \ttest_refs main HEAD@{7} &&\n \ttest_refs second HEAD@{4}\ndiff --git a/t/t5583-push-branches.sh b/t/t5583-push-branches.sh\nnew file mode 100755\nindex 00000000..29a5c560\n--- /dev/null\n+++ b/t/t5583-push-branches.sh\n@@ -0,0 +1,115 @@\n+#!bin/sh\n+\n+test_description='check the consisitency of behavior of --all and --branches'\n+\n+GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main\n+export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\n+\n+. ./test-lib.sh\n+\n+delete_refs() {\n+\tdir=$1\n+\tshift\n+\trm -rf deletes\n+\tfor arg in $*\n+\tdo\n+\t\techo \"delete ${arg}\" >>deletes\n+\tdone\n+\tgit -C $dir update-ref --stdin < deletes\n+}\n+\n+test_expect_success 'setup bare remote' '\n+\tgit init --bare remote-1 &&\n+\tgit -C remote-1 config gc.auto 0 &&\n+\ttest_commit one &&\n+\tgit push remote-1 HEAD\n+'\n+\n+test_expect_success 'setup different types of references' '\n+\tcat >refs <<-EOF &&\n+\tupdate refs/heads/branch-1 HEAD\n+\tupdate refs/heads/branch-2 HEAD\n+\tEOF\n+\n+\tgit tag -a -m \"annotated\" annotated-1 HEAD &&\n+\tgit tag -a -m \"annotated\" annotated-2 HEAD &&\n+\tgit update-ref --stdin < refs\n+'\n+\n+test_expect_success '--all and --branches have the same behavior' '\n+\ttest_when_finished \"delete_refs remote-1 \\\n+\t\t\t   refs/heads/branch-1 \\\n+\t\t\t   refs/heads/branch-2\" &&\n+\tgit push remote-1 --all &&\n+\tcommit=$(git rev-parse HEAD) &&\n+\tcat >expect <<-EOF &&\n+\t$commit refs/heads/branch-1\n+\t$commit refs/heads/branch-2\n+\t$commit refs/heads/main\n+\tEOF\n+\n+\tgit -C remote-1 show-ref --heads >actual.all &&\n+\tdelete_refs remote-1 refs/heads/branch-1 refs/heads/branch-2 &&\n+\tgit push remote-1 --branches &&\n+\tgit -C remote-1 show-ref --heads >actual.branches &&\n+\ttest_cmp actual.all actual.branches &&\n+\ttest_cmp expect actual.all\n+'\n+\n+test_expect_success '--all or --branches can not be combined with refspecs' '\n+\ttest_must_fail git push remote-1 --all main >actual.all 2>&1 &&\n+\ttest_must_fail git push remote-1 --branches main >actual.branches 2>&1 &&\n+\ttest_cmp actual.all actual.branches &&\n+\tgrep \"be combined with refspecs\" actual.all\n+'\n+\n+test_expect_success '--all or --branches can not be combined with --mirror' '\n+\ttest_must_fail git push remote-1 --all --mirror >actual.all 2>&1 &&\n+\ttest_must_fail git push remote-1 --branches --mirror >actual.branches 2>&1 &&\n+\ttest_cmp actual.all actual.branches &&\n+\tgrep \"cannot be used together\" actual.all\n+'\n+\n+test_expect_success '--all or --branches can not be combined with --tags' '\n+\ttest_must_fail git push remote-1 --all --tags >actual.all 2>&1 &&\n+\ttest_must_fail git push remote-1 --branches --tags >actual.branches 2>&1 &&\n+\ttest_cmp actual.all actual.branches &&\n+\tgrep \"cannot be used together\" actual.all\n+'\n+\n+\n+test_expect_success '--all or --branches can not be combined with --delete' '\n+\ttest_must_fail git push remote-1 --all --delete >actual.all 2>&1 &&\n+\ttest_must_fail git push remote-1 --branches --delete >actual.branches 2>&1 &&\n+\ttest_cmp actual.all actual.branches &&\n+\tgrep \"cannot be used together\" actual.all\n+'\n+\n+test_expect_success '--all or --branches combines with --follow-tags have same behavior' '\n+\ttest_when_finished \"delete_refs remote-1 \\\n+\t\t\t   refs/heads/branch-1 \\\n+\t\t\t   refs/heads/branch-2 \\\n+\t\t\t   refs/tags/annotated-1 \\\n+\t\t\t   refs/tags/annotated-2\" &&\n+\tgit push remote-1 --all --follow-tags &&\n+\tgit -C remote-1 show-ref > actual.all &&\n+\tcat >expect <<-EOF &&\n+\t$commit refs/heads/branch-1\n+\t$commit refs/heads/branch-2\n+\t$commit refs/heads/main\n+\t$(git rev-parse annotated-1) refs/tags/annotated-1\n+\t$(git rev-parse annotated-2) refs/tags/annotated-2\n+\tEOF\n+\n+\tdelete_refs remote-1 \\\n+\t\t    refs/heads/branch-1 \\\n+\t\t    refs/heads/branch-2 \\\n+\t\t    refs/tags/annotated-1 \\\n+\t\t    refs/tags/annotated-2 &&\n+\tgit push remote-1 --branches --follow-tags &&\n+\tgit -C remote-1 show-ref >actual.branches &&\n+\ttest_cmp actual.all actual.branches &&\n+\ttest_cmp expect actual.all\n+'\n+\n+test_done\n-- \n2.40.1.446.gf331623a.dirty\n\n"},{"id":"476676","messageId":"20230506113626.61560-1-tenglong.tl@alibaba-inc.com","threadId":"58893","inReplyTo":"20230506112740.61454-1-tenglong.tl@alibaba-inc.com","subject":"[PATCH 0/1] push: introduce '--branches' option","fromName":"Teng Long","fromEmail":"dyroneteng@gmail.com","sentAt":"2023-05-06T11:36:26Z","receivedAt":"2023-05-06T11:36:36Z","isPatch":true,"sender":{"key":"dyroneteng@gmail.com","avatar":"https://avatars.githubusercontent.com/u/7803958?v=4"},"body":"wrong context, please ignore it, refer to\n\n  https://public-inbox.org/git/20230506113408.61529-1-tenglong.tl@alibaba-inc.com/\n\nThanks.\n"},{"id":"476683","messageId":"xmqqedntrvg5.fsf@gitster.g","threadId":"58893","inReplyTo":"20230506113408.61529-2-tenglong.tl@alibaba-inc.com","subject":"Re: [PATCH 1/1] push: introduce '--branches' option","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2023-05-06T21:39:22Z","receivedAt":"2023-05-06T21:41:46Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Teng Long <dyroneteng@gmail.com> writes:\n\n> -'git push' [--all | --mirror | --tags] [--follow-tags] [--atomic] [-n | --dry-run] [--receive-pack=<git-receive-pack>]\n> +'git push' [--all | --branches | --mirror | --tags] [--follow-tags] ...\n\nWill queue.\n\nBy the way, you may want to check and correct your patch sending\nprocedure.  Somebody in your toolchain is adding \"--cc=\" to the\nfirst recipient address or something silly like that.\n\n> Cc: --cc=avarab@gmail.com,  git@vger.kernel.org,  me@ttaylorr.com,  tenglong.tl@alibaba-inc.com,  adlternative@gmail.com\n"},{"id":"476716","messageId":"20230507064329.2158-1-tenglong.tl@alibaba-inc.com","threadId":"58893","inReplyTo":"xmqqedntrvg5.fsf@gitster.g","subject":"Re: [PATCH 1/1] push: introduce '--branches' option","fromName":"Teng Long","fromEmail":"dyroneteng@gmail.com","sentAt":"2023-05-07T06:43:29Z","receivedAt":"2023-05-07T06:44:06Z","isPatch":true,"sender":{"key":"dyroneteng@gmail.com","avatar":"https://avatars.githubusercontent.com/u/7803958?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n>By the way, you may want to check and correct your patch sending\n>procedure.  Somebody in your toolchain is adding \"--cc=\" to the\n>first recipient address or something silly like that.\n\nMy fault, thank you for mentioning that.\n\nThanks.\n"}]}