git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/2] git-init: set receive.guardCurrentBranch = true for non-bare repositories

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Mar 24, 2008, 17:10 UTC
Message-ID
<alpine.LSU.1.00.0803241807210.4353@racer.site>
In-Reply-To
<7v4pawvzgg.fsf@gitster.siamese.dyndns.org>
Hi,
On Mon, 24 Mar 2008, Junio C Hamano wrote:
Show 23 quoted lines
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> 
> > On Sun, 23 Mar 2008, Junio C Hamano wrote:
> > ...
> >> As I described in my other message, I suspect that treating the 
> >> current branch specially like this is a wrong approach.  The 
> >> configuration might be a good idea, but shouldn't it prevent any 
> >> local branch from getting updated?  Push into non-bare repository is 
> >> simply a fetch run in reverse direction.
> >
> > That would break this work flow:
> >
> > 	# machine A
> > 	$ git push B master:refs/heads/tmp
> >
> > 	# machine B
> > 	$ git merge tmp
> > 	$ git branch -d tmp
> 
> I am afraid that the above is irrelevant.
> 
> (1) You can push the temporary into anywhere outside refs/heads/ if that
>     becomes the problem;
Okay, didn't think about that one.
Show 11 quoted lines
> (2) Your change to forbid current branch already "breaks" another workflow
>     (which I happen to use everyday) anyway:
> 
> 	# machine A (primary development repository)
>         $ git push k.org ;# master->master, next->next, ...
> 
>         # machine B (build test repository)
>         $ git reset --hard
>         $ for b in master maint next pu
>           do git checkout $b && make clean test || break
> 	  done

It would not, because it is not activated by default. Only newly initialised repositories will have that config variable set.

Show 12 quoted lines
> > Besides, there is a _vital_ difference between the current branch,...
> 
> [...]
>
> Now think.  What if one of these operations you do in the repository to 
> advance the tip was to merge from one of _your_ local branches?  Yes, 
> you end up merging something you did not expect to merge if you allowed 
> a push from sideways to affect that local branch, only because the 
> branch happened to be un-checked-out and you implemented this protection 
> to forbid only to current branch.  Allowing a push from sideways to any 
> local branch destabilizes your work environment, not just the current 
> one.
Okay, I am starting to see the light.
How about
	receive.localBranches = (refuse | allow)

with a default "allow"? Then we could add more rope later with the "update" option, which would run "git read-tree -u -m HEAD" if the current branch is updated, and simply allow all other branches being updated.

Hmm?

Ciao, Dscho

Previous: Junio C HamanoNext: Daniel Barkalow
Message 6 of 11 in “Introduce receive.guardCurrentBranch”
  1. 1/2 Introduce receive.guardCurrentBranchJohannes Schindelin, Mar 23, 2008
  2. 2/2 git-init: set receive.guardCurrentBranch = true for non-bare repositoriesJohannes Schindelin, Mar 23, 2008
  3. Junio C HamanoMar 24, 2008
  4. Johannes SchindelinMar 24, 2008
  5. Junio C HamanoMar 24, 2008
  6. Johannes SchindelinMar 24, 2008
  7. Daniel BarkalowMar 24, 2008
  8. Johannes SchindelinMar 24, 2008
  9. Miklos VajnaMar 24, 2008
  10. Johannes SchindelinMar 24, 2008
  11. Miklos VajnaMar 24, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.