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

Re: [RFC PATCH 0/4] deny push to current branch of non-bare repo

From
Jeff King <peff@peff.net>
Date
Nov 14, 2008, 06:37 UTC
Message-ID
<20081114063740.GA12001@coredump.intra.peff.net>
In-Reply-To
<f73f7ab80811130558h34cb1220q76ef5536e853151c@mail.gmail.com>
On Thu, Nov 13, 2008 at 08:58:50AM -0500, Kyle Moffett wrote:
> I guess the issue comes down to a UI complication.  It would very easy
> for me to tell somebody how to check out and test their branch in my
> testbed if I'm not around, except for that little bit of arcane
> syntax.  Moreover, the consequences if they forget are really

If the problem is merely the syntax, then perhaps that argues for "git checkout -d" to force detaching.

> frustrating and hard to figure out.  It's also very easy with a GUI to
> do the simple *rightclick branch, click "Checkout"*, but would be much
> harder to do the detached HEAD checkout correctly.
And again, perhaps this argues for a "Detach" option in the GUI.

But I have to admit, this is a pretty infrequently-used use-case. I detach all the time when looking at non-branches, but I can't think of the last time I used "ref^0" to detach intentionally.

Show 6 quoted lines
> If it didn't involve reconfiguring a lot of other people's
> repositories, I might consider having them push to "refs/remotes/*".
> In theory that's actually much closer to what I'm doing anyways.  That
> would force any checkouts to be bare, but it would require lots of
> git-foo on the pushing side.  Perhaps some way to "git push" which
> asks the remote repository where it wants the stuff?

Or git-receive could even just silently munge the incoming refs when writing them out (i.e., it exposes "refs/test/*" as "refs/heads/*", and when you ask to write "refs/heads/foo" it writes "refs/test/foo" instead).

Though that sort of lying feels a little wrong to me, since the pushing side will incorrectly update its tracking branches. It wouldn't so bad if the "fetch" side respected the munging, too.

But again, this seems uncommon enough that it is not worth trying to implement something too clever.

> Alternatively, it might be possible to add ref attributes or a config
> option to force detached HEAD checkouts.

I think that is a more sensible solution. Your workflow is not about "sometimes I want to detach the HEAD" but rather "in this particular repo, we should _always_ detach the HEAD." Which a config option represents very nicely.

-Peff
Previous: Kyle MoffettNext: Leo Razoumov
Message 20 of 25 in “deny push to current branch of non-bare repo”
  1. 0/4 deny push to current branch of non-bare repoJeff King, Nov 7, 2008
  2. 1/4 t5400: expect success for denying deletionJeff King, Nov 7, 2008
  3. Jan KrügerNov 9, 2008
  4. 2/4 t5516: refactor oddball testsJeff King, Nov 7, 2008
  5. 3/4 tests: avoid pushing to current branch of non-bare repoJeff King, Nov 7, 2008
  6. 4/4 receive-pack: deny push to current branch of non-bare repoJeff King, Nov 7, 2008
  7. Mark BurtonNov 7, 2008
  8. Junio C HamanoNov 7, 2008
  9. Jeff KingNov 8, 2008
  10. Johannes SchindelinNov 8, 2008
  11. Junio C HamanoNov 8, 2008
  12. Jeff KingNov 9, 2008
  13. Junio C HamanoNov 9, 2008
  14. Kyle MoffettNov 12, 2008
  15. Jeff KingNov 12, 2008
  16. Kyle MoffettNov 13, 2008
  17. Jeff KingNov 13, 2008
  18. Junio C HamanoNov 13, 2008
  19. Kyle MoffettNov 13, 2008
  20. Jeff KingNov 14, 2008
  21. Leo RazoumovDec 2, 2008
  22. Junio C HamanoDec 2, 2008
  23. Leo RazoumovDec 2, 2008
  24. Jeff KingDec 2, 2008
  25. Leo RazoumovDec 2, 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.