{"thread":{"id":"54139","subject":"feature request - add --only-author option to git push","startedAt":"2020-08-27T07:47:37Z","lastAt":"2020-08-27T15:58:27Z","messageCount":6,"participants":["Toni Brkic","Pratyush Yadav","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"404587","messageId":"CAF2SHyBYZ7=vcL4sPdP=T9zRCBrwW_z0-o1v9=gC4=oPqv4oXQ@mail.gmail.com","threadId":"54139","inReplyTo":null,"subject":"feature request - add --only-author option to git push","fromName":"Toni Brkic","fromEmail":"brkict@gmail.com","sentAt":"2020-08-27T07:47:13Z","receivedAt":"2020-08-27T07:47:37Z","isPatch":false,"sender":{"key":"brkict@gmail.com","avatar":null},"body":"Sorry if this mail list is not used for feature requests/discussions.\nThis was the best list I found.\nLet me know if should post it somewhere else.\n\nI would like to be able to configure git so that when doing git push\ngit checks that I am author of\nall patches that are being pushed. If I am not authour it should not do push.\n\nThe reason for this is that a common mistake that happens when working\nwith gerrit (at least for me)\n\nPerson A has uploaded patch1\nI need patch1 to continue development and cherry pick it to my repo.\nPerson A uploads new version of patch1\nI have finished my patch and push to gerrit. What then happens is that\nI have an older version of patch1 and thus overwrite the new version\nby Person A\n\nMaybe there is some way already to do this, but I could not find\nanything when searching.\n\nBR,\n\nToni\n"},{"id":"404598","messageId":"20200827101924.iklvsy6lnscrpojs@yadavpratyush.com","threadId":"54139","inReplyTo":"CAF2SHyBYZ7=vcL4sPdP=T9zRCBrwW_z0-o1v9=gC4=oPqv4oXQ@mail.gmail.com","subject":"Re: feature request - add --only-author option to git push","fromName":"Pratyush Yadav","fromEmail":"me@yadavpratyush.com","sentAt":"2020-08-27T10:19:24Z","receivedAt":"2020-08-27T10:19:36Z","isPatch":false,"sender":{"key":"me@yadavpratyush.com","avatar":"https://avatars.githubusercontent.com/u/8817931?v=4"},"body":"Hi Toni,\n\nOn 27/08/20 09:47AM, Toni Brkic wrote:\n> Sorry if this mail list is not used for feature requests/discussions.\n> This was the best list I found.\n> Let me know if should post it somewhere else.\n> \n> I would like to be able to configure git so that when doing git push\n> git checks that I am author of\n> all patches that are being pushed. If I am not authour it should not do push.\n> \n> The reason for this is that a common mistake that happens when working\n> with gerrit (at least for me)\n> \n> Person A has uploaded patch1\n> I need patch1 to continue development and cherry pick it to my repo.\n> Person A uploads new version of patch1\n> I have finished my patch and push to gerrit. What then happens is that\n> I have an older version of patch1 and thus overwrite the new version\n> by Person A\n> \n> Maybe there is some way already to do this, but I could not find\n> anything when searching.\n\nHave you tried using a pre-push hook? It looks like it is exactly what \nyou need:\n\n   pre-push\n     This hook is called by git-push(1) and can be used to prevent a \n     push from taking place. The hook is called with two parameters \n     which provide the name and location of the destination remote, if a \n     named remote is not being used both values will be the same.\n\n     Information about what is to be pushed is provided on the hook’s \n     standard input with lines of the form:\n\n         <local ref> SP <local sha1> SP <remote ref> SP <remote sha1> LF\n\n     For instance, if the command git push origin master:foreign were \n     run the hook would receive a line like the following:\n\n         refs/heads/master 67890 refs/heads/foreign 12345\n\n     although the full, 40-character SHA-1s would be supplied. If the \n     foreign ref does not yet exist the <remote SHA-1> will be 40 0. If \n     a ref is to be deleted, the <local ref> will be supplied as\n     (delete) and the <local SHA-1> will be 40 0. If the local commit \n     was specified by something other than a name which could be \n     expanded (such as HEAD~, or a SHA-1) it will be supplied as it was \n     originally given.\n\n     If this hook exits with a non-zero status, git push will abort \n     without pushing anything. Information about why the push is \n     rejected may be sent to the user by writing to standard error.\n\n-- \nRegards,\nPratyush Yadav\n"},{"id":"404599","messageId":"CAF2SHyA_bg1wxaDaLN=m2G+0sZB=b30LTnm3rOPVEYgAx9Uazg@mail.gmail.com","threadId":"54139","inReplyTo":"20200827101924.iklvsy6lnscrpojs@yadavpratyush.com","subject":"Re: feature request - add --only-author option to git push","fromName":"Toni Brkic","fromEmail":"brkict@gmail.com","sentAt":"2020-08-27T11:39:54Z","receivedAt":"2020-08-27T11:41:20Z","isPatch":false,"sender":{"key":"brkict@gmail.com","avatar":null},"body":">\n> Hi Toni,\n>\n> On 27/08/20 09:47AM, Toni Brkic wrote:\n> > Sorry if this mail list is not used for feature requests/discussions.\n> > This was the best list I found.\n> > Let me know if should post it somewhere else.\n> >\n> > I would like to be able to configure git so that when doing git push\n> > git checks that I am author of\n> > all patches that are being pushed. If I am not authour it should not do push.\n> >\n> > The reason for this is that a common mistake that happens when working\n> > with gerrit (at least for me)\n> >\n> > Person A has uploaded patch1\n> > I need patch1 to continue development and cherry pick it to my repo.\n> > Person A uploads new version of patch1\n> > I have finished my patch and push to gerrit. What then happens is that\n> > I have an older version of patch1 and thus overwrite the new version\n> > by Person A\n> >\n> > Maybe there is some way already to do this, but I could not find\n> > anything when searching.\n>\n> Have you tried using a pre-push hook? It looks like it is exactly what\n> you need:\n>\n>    pre-push\n>      This hook is called by git-push(1) and can be used to prevent a\n>      push from taking place. The hook is called with two parameters\n>      which provide the name and location of the destination remote, if a\n>      named remote is not being used both values will be the same.\n>\n>      Information about what is to be pushed is provided on the hook’s\n>      standard input with lines of the form:\n>\n>          <local ref> SP <local sha1> SP <remote ref> SP <remote sha1> LF\n>\n>      For instance, if the command git push origin master:foreign were\n>      run the hook would receive a line like the following:\n>\n>          refs/heads/master 67890 refs/heads/foreign 12345\n>\n>      although the full, 40-character SHA-1s would be supplied. If the\n>      foreign ref does not yet exist the <remote SHA-1> will be 40 0. If\n>      a ref is to be deleted, the <local ref> will be supplied as\n>      (delete) and the <local SHA-1> will be 40 0. If the local commit\n>      was specified by something other than a name which could be\n>      expanded (such as HEAD~, or a SHA-1) it will be supplied as it was\n>      originally given.\n>\n>      If this hook exits with a non-zero status, git push will abort\n>      without pushing anything. Information about why the push is\n>      rejected may be sent to the user by writing to standard error.\n>\n> --\n> Regards,\n> Pratyush Yadav\n\nThe pre-push hook I do not believe could be used to solve it. Due to\nthat it seems that you cannot have options to\npre-hooks. I only want the pre-hook to run when having the\n--only-authors option. Or some other way to not run the hook.\n\nSince there might be situation where I want to change somebody elses patch.\n"},{"id":"404600","messageId":"20200827115350.q3xzad3c2v4sgvaf@yadavpratyush.com","threadId":"54139","inReplyTo":"CAF2SHyA_bg1wxaDaLN=m2G+0sZB=b30LTnm3rOPVEYgAx9Uazg@mail.gmail.com","subject":"Re: feature request - add --only-author option to git push","fromName":"Pratyush Yadav","fromEmail":"me@yadavpratyush.com","sentAt":"2020-08-27T11:53:50Z","receivedAt":"2020-08-27T11:54:57Z","isPatch":false,"sender":{"key":"me@yadavpratyush.com","avatar":"https://avatars.githubusercontent.com/u/8817931?v=4"},"body":"On 27/08/20 01:39PM, Toni Brkic wrote:\n> >\n> > Hi Toni,\n> >\n> > On 27/08/20 09:47AM, Toni Brkic wrote:\n> > > Sorry if this mail list is not used for feature requests/discussions.\n> > > This was the best list I found.\n> > > Let me know if should post it somewhere else.\n> > >\n> > > I would like to be able to configure git so that when doing git push\n> > > git checks that I am author of\n> > > all patches that are being pushed. If I am not authour it should not do push.\n> > >\n> > > The reason for this is that a common mistake that happens when working\n> > > with gerrit (at least for me)\n> > >\n> > > Person A has uploaded patch1\n> > > I need patch1 to continue development and cherry pick it to my repo.\n> > > Person A uploads new version of patch1\n> > > I have finished my patch and push to gerrit. What then happens is that\n> > > I have an older version of patch1 and thus overwrite the new version\n> > > by Person A\n> > >\n> > > Maybe there is some way already to do this, but I could not find\n> > > anything when searching.\n> >\n> > Have you tried using a pre-push hook? It looks like it is exactly what\n> > you need:\n> >\n> >    pre-push\n> >      This hook is called by git-push(1) and can be used to prevent a\n> >      push from taking place. The hook is called with two parameters\n> >      which provide the name and location of the destination remote, if a\n> >      named remote is not being used both values will be the same.\n> >\n> >      Information about what is to be pushed is provided on the hook’s\n> >      standard input with lines of the form:\n> >\n> >          <local ref> SP <local sha1> SP <remote ref> SP <remote sha1> LF\n> >\n> >      For instance, if the command git push origin master:foreign were\n> >      run the hook would receive a line like the following:\n> >\n> >          refs/heads/master 67890 refs/heads/foreign 12345\n> >\n> >      although the full, 40-character SHA-1s would be supplied. If the\n> >      foreign ref does not yet exist the <remote SHA-1> will be 40 0. If\n> >      a ref is to be deleted, the <local ref> will be supplied as\n> >      (delete) and the <local SHA-1> will be 40 0. If the local commit\n> >      was specified by something other than a name which could be\n> >      expanded (such as HEAD~, or a SHA-1) it will be supplied as it was\n> >      originally given.\n> >\n> >      If this hook exits with a non-zero status, git push will abort\n> >      without pushing anything. Information about why the push is\n> >      rejected may be sent to the user by writing to standard error.\n> >\n> > --\n> > Regards,\n> > Pratyush Yadav\n> \n> The pre-push hook I do not believe could be used to solve it. Due to\n> that it seems that you cannot have options to\n> pre-hooks. I only want the pre-hook to run when having the\n> --only-authors option. Or some other way to not run the hook.\n> \n> Since there might be situation where I want to change somebody elses patch.\n\nYou can pass `--no-verify` to `git push` to skip the pre-push hook:\n\n  --[no-]verify\n     Toggle the pre-push hook (see githooks(5)). The default is \n     --verify, giving the hook a chance to prevent the push. With \n     --no-verify, the hook is bypassed completely.\n\n-- \nRegards,\nPratyush Yadav\n"},{"id":"404602","messageId":"CAF2SHyD2EO7o7RhKRGmMaffAa2=6z_rkO+CeBPWREObD=4HmuQ@mail.gmail.com","threadId":"54139","inReplyTo":"20200827115350.q3xzad3c2v4sgvaf@yadavpratyush.com","subject":"Re: feature request - add --only-author option to git push","fromName":"Toni Brkic","fromEmail":"brkict@gmail.com","sentAt":"2020-08-27T13:32:12Z","receivedAt":"2020-08-27T13:33:36Z","isPatch":false,"sender":{"key":"brkict@gmail.com","avatar":null},"body":"> >\n> > The pre-push hook I do not believe could be used to solve it. Due to\n> > that it seems that you cannot have options to\n> > pre-hooks. I only want the pre-hook to run when having the\n> > --only-authors option. Or some other way to not run the hook.\n> >\n> > Since there might be situation where I want to change somebody elses patch.\n>\n> You can pass `--no-verify` to `git push` to skip the pre-push hook:\n>\n>   --[no-]verify\n>      Toggle the pre-push hook (see githooks(5)). The default is\n>      --verify, giving the hook a chance to prevent the push. With\n>      --no-verify, the hook is bypassed completely.\n>\n> --\n> Regards,\n> Pratyush Yadav\n\nThanks. I could do that for myself. Would not be ideal, but it would\nwork as work around for me.\nI still think this would be a good feature to add to git.\nNot sure how the flow for requesting new features. If this would be\nsomething that would be of interest to be added I could take a look\nmyself and try\nto write a patch.\n"},{"id":"404623","messageId":"xmqqv9h4qdwh.fsf@gitster.c.googlers.com","threadId":"54139","inReplyTo":"CAF2SHyD2EO7o7RhKRGmMaffAa2=6z_rkO+CeBPWREObD=4HmuQ@mail.gmail.com","subject":"Re: feature request - add --only-author option to git push","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-08-27T15:58:22Z","receivedAt":"2020-08-27T15:58:27Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Toni Brkic <brkict@gmail.com> writes:\n\n> ... If this would be\n> something that would be of interest to be added I could take a look\n> myself and try\n> to write a patch.\n\nI am personally not interested with \"all my commits must be from me\nand nobody else\", but it might be a useful thing to have if we can\ncome up with an easy way to give a \"git shortlog [-s]\" (and other\n\"history summary\" command the user can ask with configuration\nvariables and such) over the range of commits that will be pushed\n(which theoretically cannot be known before \"git push\" starts\nrunning) before the actual push happens.\n\nThanks.\n"}]}