git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* feature request - add --only-author option to git push
@ 2020-08-27  7:47 Toni Brkic
  2020-08-27 10:19 ` Pratyush Yadav
  0 siblings, 1 reply; 6+ messages in thread
From: Toni Brkic @ 2020-08-27  7:47 UTC (permalink / raw)
  To: git

Sorry if this mail list is not used for feature requests/discussions.
This was the best list I found.
Let me know if should post it somewhere else.

I would like to be able to configure git so that when doing git push
git checks that I am author of
all patches that are being pushed. If I am not authour it should not do push.

The reason for this is that a common mistake that happens when working
with gerrit (at least for me)

Person A has uploaded patch1
I need patch1 to continue development and cherry pick it to my repo.
Person A uploads new version of patch1
I have finished my patch and push to gerrit. What then happens is that
I have an older version of patch1 and thus overwrite the new version
by Person A

Maybe there is some way already to do this, but I could not find
anything when searching.

BR,

Toni

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: feature request - add --only-author option to git push
  2020-08-27  7:47 feature request - add --only-author option to git push Toni Brkic
@ 2020-08-27 10:19 ` Pratyush Yadav
  2020-08-27 11:39   ` Toni Brkic
  0 siblings, 1 reply; 6+ messages in thread
From: Pratyush Yadav @ 2020-08-27 10:19 UTC (permalink / raw)
  To: Toni Brkic; +Cc: git

Hi Toni,

On 27/08/20 09:47AM, Toni Brkic wrote:
> Sorry if this mail list is not used for feature requests/discussions.
> This was the best list I found.
> Let me know if should post it somewhere else.
> 
> I would like to be able to configure git so that when doing git push
> git checks that I am author of
> all patches that are being pushed. If I am not authour it should not do push.
> 
> The reason for this is that a common mistake that happens when working
> with gerrit (at least for me)
> 
> Person A has uploaded patch1
> I need patch1 to continue development and cherry pick it to my repo.
> Person A uploads new version of patch1
> I have finished my patch and push to gerrit. What then happens is that
> I have an older version of patch1 and thus overwrite the new version
> by Person A
> 
> Maybe there is some way already to do this, but I could not find
> anything when searching.

Have you tried using a pre-push hook? It looks like it is exactly what 
you need:

   pre-push
     This hook is called by git-push(1) and can be used to prevent a 
     push from taking place. The hook is called with two parameters 
     which provide the name and location of the destination remote, if a 
     named remote is not being used both values will be the same.

     Information about what is to be pushed is provided on the hook’s 
     standard input with lines of the form:

         <local ref> SP <local sha1> SP <remote ref> SP <remote sha1> LF

     For instance, if the command git push origin master:foreign were 
     run the hook would receive a line like the following:

         refs/heads/master 67890 refs/heads/foreign 12345

     although the full, 40-character SHA-1s would be supplied. If the 
     foreign ref does not yet exist the <remote SHA-1> will be 40 0. If 
     a ref is to be deleted, the <local ref> will be supplied as
     (delete) and the <local SHA-1> will be 40 0. If the local commit 
     was specified by something other than a name which could be 
     expanded (such as HEAD~, or a SHA-1) it will be supplied as it was 
     originally given.

     If this hook exits with a non-zero status, git push will abort 
     without pushing anything. Information about why the push is 
     rejected may be sent to the user by writing to standard error.

-- 
Regards,
Pratyush Yadav

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: feature request - add --only-author option to git push
  2020-08-27 10:19 ` Pratyush Yadav
@ 2020-08-27 11:39   ` Toni Brkic
  2020-08-27 11:53     ` Pratyush Yadav
  0 siblings, 1 reply; 6+ messages in thread
From: Toni Brkic @ 2020-08-27 11:39 UTC (permalink / raw)
  To: Pratyush Yadav; +Cc: git

>
> Hi Toni,
>
> On 27/08/20 09:47AM, Toni Brkic wrote:
> > Sorry if this mail list is not used for feature requests/discussions.
> > This was the best list I found.
> > Let me know if should post it somewhere else.
> >
> > I would like to be able to configure git so that when doing git push
> > git checks that I am author of
> > all patches that are being pushed. If I am not authour it should not do push.
> >
> > The reason for this is that a common mistake that happens when working
> > with gerrit (at least for me)
> >
> > Person A has uploaded patch1
> > I need patch1 to continue development and cherry pick it to my repo.
> > Person A uploads new version of patch1
> > I have finished my patch and push to gerrit. What then happens is that
> > I have an older version of patch1 and thus overwrite the new version
> > by Person A
> >
> > Maybe there is some way already to do this, but I could not find
> > anything when searching.
>
> Have you tried using a pre-push hook? It looks like it is exactly what
> you need:
>
>    pre-push
>      This hook is called by git-push(1) and can be used to prevent a
>      push from taking place. The hook is called with two parameters
>      which provide the name and location of the destination remote, if a
>      named remote is not being used both values will be the same.
>
>      Information about what is to be pushed is provided on the hook’s
>      standard input with lines of the form:
>
>          <local ref> SP <local sha1> SP <remote ref> SP <remote sha1> LF
>
>      For instance, if the command git push origin master:foreign were
>      run the hook would receive a line like the following:
>
>          refs/heads/master 67890 refs/heads/foreign 12345
>
>      although the full, 40-character SHA-1s would be supplied. If the
>      foreign ref does not yet exist the <remote SHA-1> will be 40 0. If
>      a ref is to be deleted, the <local ref> will be supplied as
>      (delete) and the <local SHA-1> will be 40 0. If the local commit
>      was specified by something other than a name which could be
>      expanded (such as HEAD~, or a SHA-1) it will be supplied as it was
>      originally given.
>
>      If this hook exits with a non-zero status, git push will abort
>      without pushing anything. Information about why the push is
>      rejected may be sent to the user by writing to standard error.
>
> --
> Regards,
> Pratyush Yadav

The pre-push hook I do not believe could be used to solve it. Due to
that it seems that you cannot have options to
pre-hooks. I only want the pre-hook to run when having the
--only-authors option. Or some other way to not run the hook.

Since there might be situation where I want to change somebody elses patch.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: feature request - add --only-author option to git push
  2020-08-27 11:39   ` Toni Brkic
@ 2020-08-27 11:53     ` Pratyush Yadav
  2020-08-27 13:32       ` Toni Brkic
  0 siblings, 1 reply; 6+ messages in thread
From: Pratyush Yadav @ 2020-08-27 11:53 UTC (permalink / raw)
  To: Toni Brkic; +Cc: git

On 27/08/20 01:39PM, Toni Brkic wrote:
> >
> > Hi Toni,
> >
> > On 27/08/20 09:47AM, Toni Brkic wrote:
> > > Sorry if this mail list is not used for feature requests/discussions.
> > > This was the best list I found.
> > > Let me know if should post it somewhere else.
> > >
> > > I would like to be able to configure git so that when doing git push
> > > git checks that I am author of
> > > all patches that are being pushed. If I am not authour it should not do push.
> > >
> > > The reason for this is that a common mistake that happens when working
> > > with gerrit (at least for me)
> > >
> > > Person A has uploaded patch1
> > > I need patch1 to continue development and cherry pick it to my repo.
> > > Person A uploads new version of patch1
> > > I have finished my patch and push to gerrit. What then happens is that
> > > I have an older version of patch1 and thus overwrite the new version
> > > by Person A
> > >
> > > Maybe there is some way already to do this, but I could not find
> > > anything when searching.
> >
> > Have you tried using a pre-push hook? It looks like it is exactly what
> > you need:
> >
> >    pre-push
> >      This hook is called by git-push(1) and can be used to prevent a
> >      push from taking place. The hook is called with two parameters
> >      which provide the name and location of the destination remote, if a
> >      named remote is not being used both values will be the same.
> >
> >      Information about what is to be pushed is provided on the hook’s
> >      standard input with lines of the form:
> >
> >          <local ref> SP <local sha1> SP <remote ref> SP <remote sha1> LF
> >
> >      For instance, if the command git push origin master:foreign were
> >      run the hook would receive a line like the following:
> >
> >          refs/heads/master 67890 refs/heads/foreign 12345
> >
> >      although the full, 40-character SHA-1s would be supplied. If the
> >      foreign ref does not yet exist the <remote SHA-1> will be 40 0. If
> >      a ref is to be deleted, the <local ref> will be supplied as
> >      (delete) and the <local SHA-1> will be 40 0. If the local commit
> >      was specified by something other than a name which could be
> >      expanded (such as HEAD~, or a SHA-1) it will be supplied as it was
> >      originally given.
> >
> >      If this hook exits with a non-zero status, git push will abort
> >      without pushing anything. Information about why the push is
> >      rejected may be sent to the user by writing to standard error.
> >
> > --
> > Regards,
> > Pratyush Yadav
> 
> The pre-push hook I do not believe could be used to solve it. Due to
> that it seems that you cannot have options to
> pre-hooks. I only want the pre-hook to run when having the
> --only-authors option. Or some other way to not run the hook.
> 
> Since there might be situation where I want to change somebody elses patch.

You can pass `--no-verify` to `git push` to skip the pre-push hook:

  --[no-]verify
     Toggle the pre-push hook (see githooks(5)). The default is 
     --verify, giving the hook a chance to prevent the push. With 
     --no-verify, the hook is bypassed completely.

-- 
Regards,
Pratyush Yadav

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: feature request - add --only-author option to git push
  2020-08-27 11:53     ` Pratyush Yadav
@ 2020-08-27 13:32       ` Toni Brkic
  2020-08-27 15:58         ` Junio C Hamano
  0 siblings, 1 reply; 6+ messages in thread
From: Toni Brkic @ 2020-08-27 13:32 UTC (permalink / raw)
  To: Pratyush Yadav; +Cc: git

> >
> > The pre-push hook I do not believe could be used to solve it. Due to
> > that it seems that you cannot have options to
> > pre-hooks. I only want the pre-hook to run when having the
> > --only-authors option. Or some other way to not run the hook.
> >
> > Since there might be situation where I want to change somebody elses patch.
>
> You can pass `--no-verify` to `git push` to skip the pre-push hook:
>
>   --[no-]verify
>      Toggle the pre-push hook (see githooks(5)). The default is
>      --verify, giving the hook a chance to prevent the push. With
>      --no-verify, the hook is bypassed completely.
>
> --
> Regards,
> Pratyush Yadav

Thanks. I could do that for myself. Would not be ideal, but it would
work as work around for me.
I still think this would be a good feature to add to git.
Not sure how the flow for requesting new features. If this would be
something that would be of interest to be added I could take a look
myself and try
to write a patch.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: feature request - add --only-author option to git push
  2020-08-27 13:32       ` Toni Brkic
@ 2020-08-27 15:58         ` Junio C Hamano
  0 siblings, 0 replies; 6+ messages in thread
From: Junio C Hamano @ 2020-08-27 15:58 UTC (permalink / raw)
  To: Toni Brkic; +Cc: Pratyush Yadav, git

Toni Brkic <brkict@gmail.com> writes:

> ... If this would be
> something that would be of interest to be added I could take a look
> myself and try
> to write a patch.

I am personally not interested with "all my commits must be from me
and nobody else", but it might be a useful thing to have if we can
come up with an easy way to give a "git shortlog [-s]" (and other
"history summary" command the user can ask with configuration
variables and such) over the range of commits that will be pushed
(which theoretically cannot be known before "git push" starts
running) before the actual push happens.

Thanks.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-08-27 15:58 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-27  7:47 feature request - add --only-author option to git push Toni Brkic
2020-08-27 10:19 ` Pratyush Yadav
2020-08-27 11:39   ` Toni Brkic
2020-08-27 11:53     ` Pratyush Yadav
2020-08-27 13:32       ` Toni Brkic
2020-08-27 15:58         ` Junio C Hamano

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).