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

Re: [PATCH] Switch receive.denyCurrentBranch to "refuse"

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 13, 2010, 17:57 UTC
Message-ID
<7vtyrfutep.fsf@alter.siamese.dyndns.org>
In-Reply-To
<alpine.DEB.2.00.0901291729540.22558@vellum.laroia.net>
Asheesh Laroia <asheesh@asheesh.org> writes:
Show 12 quoted lines
> On Fri, 30 Jan 2009, Johannes Schindelin wrote:
>
>> 	case DENY_REFUSE:
>> +		if (is_bare_repository() || !is_ref_checked_out(name))
>> 			break;
>> +		error("refusing to update checked out branch: %s\n"
>> +			"if you know what you are doing, you can allow it by "
>> +			"setting\n\n"
>> +			"\tgit config receive.denyCurrentBranch true\n", name);
>
> Being told how to do it right is even better than being told that
> you're doing it wrong. (-:

Of course you are correct, but there are two _right ways_ that are completely different, depending on how the repository you are pushing into is meant to be used:

 - If you are using it as a shared central repository, a distribution
   point, or a back-up location, you don't need a working tree, and
   as you say, the "checked out branch" condition will not trigger, if
   you made it a bare one.
 - People do wish a way to keep a repository with a checkout, and that is
   often the reason why this codepath is triggered.  They want a checkout
   in the repository (perhaps they are serving the files in them from a
   webserver).  For them, "pushing into it" is not the ultimate goal, but
   "having its working tree and keeping it up-to-date" is.  For that,
   pushing into a "reception branch" and merging that to the checkout from
   the post-update hook is probably the right way (Cf. [*1*] especially is
   "See also ...").

Also I do not think it would help users to suggest "bare repository" even for the first class of users.

 - If the user knows what a "bare" repository is, the user would realize
   "Hmm, I am not allowed to push to the checked out branch?  Wait, this
   repository does not even need a working tree, so if I make it a bare
   one, I wouldn't have any checked out branch by definition and I
   wouldn't have this issue" without being told.
 - If the user does not know what a "bare" repository is, the user may not
   even realize that the target repository does not have to have a working
   tree.  In such a case, there won't be a mental "click" between "checked
   out" and "bare" anyway.  The added message to suggest "bare" will be
   another line of unintelligible gitspeak in the message to them.
[Reference]
*1* https://git.wiki.kernel.org/index.php/GitFaq#Why_won.27t_I_see_changes_in_the_remote_repo_after_.22git_push.22.3F
Previous: Dave AbrahamsNext: Miklos Vajna
Message 5 of 43 in “Switch receive.denyCurrentBranch to "refuse"”
  1. Switch receive.denyCurrentBranch to "refuse"Johannes Schindelin, Jan 30, 2009
  2. Jay SoffianJan 30, 2009
  3. Asheesh LaroiaJan 30, 2009
  4. Dave AbrahamsApr 13, 2010
  5. Junio C HamanoApr 13, 2010
  6. Miklos VajnaJan 30, 2009
  7. Johannes SchindelinJan 30, 2009
  8. Miklos VajnaFeb 11, 2009
  9. Junio C HamanoFeb 11, 2009
  10. Jeff KingJan 30, 2009
  11. Johannes SchindelinJan 30, 2009
  12. Johannes SixtJan 30, 2009
  13. Jeff KingJan 30, 2009
  14. Johannes SchindelinJan 30, 2009
  15. Jeff KingJan 30, 2009
  16. Jay SoffianJan 30, 2009
  17. Jeff KingJan 30, 2009
  18. Johannes SchindelinJan 30, 2009
  19. Jay SoffianJan 30, 2009
  20. Johannes SchindelinJan 30, 2009
  21. Nanako ShiraishiJan 31, 2009
  22. Junio C HamanoFeb 1, 2009
  23. Junio C HamanoFeb 1, 2009
  24. Jeff KingFeb 2, 2009
  25. Junio C HamanoFeb 3, 2009
  26. Junio C HamanoFeb 3, 2009
  27. Jeff KingFeb 6, 2009
  28. Junio C HamanoFeb 7, 2009
  29. Junio C HamanoFeb 3, 2009
  30. Jeff KingFeb 3, 2009
  31. Junio C HamanoFeb 3, 2009
  32. Junio C HamanoFeb 1, 2009
  33. Sam VilainFeb 1, 2009
  34. Junio C HamanoFeb 1, 2009
  35. Sam VilainFeb 2, 2009
  36. Junio C HamanoFeb 2, 2009
  37. Sam VilainFeb 2, 2009
  38. Johannes SchindelinFeb 1, 2009
  39. Junio C HamanoFeb 1, 2009
  40. Junio C HamanoJan 30, 2009
  41. Johannes SchindelinJan 30, 2009
  42. Jeff KingJan 30, 2009
  43. Johannes SchindelinJan 30, 2009

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.