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

Re: [PATCH 2/2] Let deny.currentBranch=updateInstead ignore submodules

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 14, 2014, 07:49 UTC
Message-ID
<xmqq1tp643yb.fsf@gitster.dls.corp.google.com>
In-Reply-To
<xmqqzjbuzu6t.fsf@gitster.dls.corp.google.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 10 quoted lines
>> I agree that a new value "mergeInstead" or something should be
>> invented when/if different workflows want a looser semantics.
>> People would rely not only on "being able to push when clean" but
>> also on "being safely prevented from pushing when not" (and that is
>> where my earlier comment to test both sides comes from).  Loosening
>> the check to an existing "updateInstead" would break users who have
>> been using updateInstead.
>
> And thinking about the names again, I have a feeling that
> updateInstead and mergeInstead are both probably misnomer.

Let me take this part back. After all, I do not think I would design the mechanism to implement an alternative logic that decides when it is safe to allow the update of the ref and to reflect the changes to the working tree, and that actually does the checkout to the working tree by using a new value like mergeInstead. So we would only need a single name, and updateInstead is not too bad.

The word "update" is so heavily loaded in the context of accepting a push (i.e. it is unclear what update we are talking about---updating the ref that we normally refuse to update? updating the index? updating the working tree? Some combination of them?), so as a single word, "checkoutInstead" may probably be a better one, though. Upon hearing "checkout", by definition anybody would know that we are involving the working tree.

The mechanism I would employ when doing an alternative logic, possibly looser one but does not necessarily so, would be to have a hook script "push-to-checkout". When denyCurrentBranch is set to updateInstead, if there is no such hook, the "working tree has to be absolutely clean and we would do a 'read-tree -m -u $old $new' (which is the same as 'reset --hard $new' under the precondition)" you implemented will be used as the "logic that decides when it is safe, and that does the checkout to the working tree". When the "push-to-checkout" hook exists, however, we just invoke that hook with $new as argument, and it can decide when it is safe in whatever way it chooses to, and it can checkout the $new to the working tree in whatever way it wants. The users of "mergeInstead" (now a dead and unnecessary name) mode would just have a single-liner

	#!/bin/sh
	git reset --keep "$1" --

in there, as this single command would both decide when it is safe and does the safe (according to its own definition) updating of the working tree.

In your other example (not the "deploy to live website" one) of unidirectional SSH connection, you would be able to connect from machine A to machine B but not the other way, so while sitting on machine A you would typically have one SSH session to have an interactive shell session running on machine B. You may have local modification on machine B but your changes to history on machine A cannot be pulled, so you would emulate it by pushing from A into B. In such a case, unlike the "live website" example, it would be useful to loosen the condition even more than "reset --keep" (which is an equivalent of "checkout -B $current_branch $new_commit").

In such a case, what you want to do is to simulate "git pull" that could conflict and give you a chance to resolve with a push in the reverse direction. You want to run an equivalent of the same "checkout -B" command but with the "-m" option when accepting such a push.

There are other definitions of what is safe and how update should happen depending on the user, and such a logic can be placed in the push-to-checkout hook without harming other users.

Previous: Junio C HamanoNext: Junio C Hamano
Message 27 of 71 in “Support updating working trees when pushing into non-bare repos”
  1. 0/2 Support updating working trees when pushing into non-bare reposJohannes Schindelin, Nov 7, 2014
  2. 1/2 Add a few more values for receive.denyCurrentBranchJohannes Schindelin, Nov 7, 2014
  3. Junio C HamanoNov 7, 2014
  4. Johannes SchindelinNov 7, 2014
  5. Johannes SchindelinNov 10, 2014
  6. Junio C HamanoNov 10, 2014
  7. Johannes SchindelinNov 12, 2014
  8. Junio C HamanoNov 12, 2014
  9. Jeff KingNov 8, 2014
  10. brian m. carlsonNov 8, 2014
  11. Johannes SchindelinNov 10, 2014
  12. 2/2 Let deny.currentBranch=updateInstead ignore submodulesJohannes Schindelin, Nov 7, 2014
  13. Junio C HamanoNov 7, 2014
  14. Jens LehmannNov 9, 2014
  15. Johannes SchindelinNov 10, 2014
  16. Johannes SchindelinNov 10, 2014
  17. Junio C HamanoNov 10, 2014
  18. Junio C HamanoNov 10, 2014
  19. Johannes SchindelinNov 12, 2014
  20. Junio C HamanoNov 12, 2014
  21. Johannes SchindelinNov 13, 2014
  22. Johannes SchindelinNov 13, 2014
  23. Junio C HamanoNov 13, 2014
  24. Johannes SchindelinNov 13, 2014
  25. Junio C HamanoNov 13, 2014
  26. Junio C HamanoNov 13, 2014
  27. Junio C HamanoNov 14, 2014
  28. Junio C HamanoDec 2, 2014
  29. 2/2 receive-pack: support push-to-checkout hookJunio C Hamano, Dec 2, 2014
  30. Johannes SchindelinDec 2, 2014
  31. Michael J GruberDec 2, 2014
  32. Johannes SchindelinDec 2, 2014
  33. Junio C HamanoDec 2, 2014
  34. Johannes SchindelinDec 2, 2014
  35. Junio C HamanoDec 2, 2014
  36. Johannes SchindelinDec 2, 2014
  37. Junio C HamanoDec 2, 2014
  38. Junio C HamanoNov 13, 2014
  39. Johannes SchindelinNov 12, 2014
  40. 0/2 Support updating working trees when pushing into non-bare reposJohannes Schindelin, Nov 10, 2014
  41. 0/1 Support updating working trees when pushing into non-bare reposJohannes Schindelin, Nov 13, 2014
  42. 1/1 Add another option for receive.denyCurrentBranchJohannes Schindelin, Nov 13, 2014
  43. Junio C HamanoNov 13, 2014
  44. Johannes SchindelinNov 13, 2014
  45. Junio C HamanoNov 13, 2014
  46. Junio C HamanoNov 13, 2014
  47. Johannes SchindelinNov 13, 2014
  48. Support updating working trees when pushing into non-bare reposJohannes Schindelin, Nov 26, 2014
  49. Add another option for receive.denyCurrentBranchJohannes Schindelin, Nov 26, 2014
  50. Junio C HamanoNov 26, 2014
  51. Support updating working trees when pushing into non-bare reposJohannes Schindelin, Nov 26, 2014
  52. Add another option for receive.denyCurrentBranchJohannes Schindelin, Nov 26, 2014
  53. Junio C HamanoDec 1, 2014
  54. Johannes SchindelinDec 1, 2014
  55. Junio C HamanoDec 1, 2014
  56. Junio C HamanoDec 2, 2014
  57. Johannes SchindelinDec 2, 2014
  58. Junio C HamanoDec 2, 2014
  59. Johannes SchindelinDec 2, 2014
  60. Junio C HamanoDec 2, 2014
  61. 1/2 Clean stale environment pointer in finish_command()Johannes Schindelin, Nov 10, 2014
  62. Johannes SchindelinNov 10, 2014
  63. Jeff KingNov 11, 2014
  64. Junio C HamanoNov 11, 2014
  65. Johannes SchindelinNov 12, 2014
  66. Jeff KingNov 12, 2014
  67. Jeff KingNov 12, 2014
  68. Junio C HamanoNov 12, 2014
  69. Junio C HamanoNov 10, 2014
  70. Jeff KingNov 11, 2014
  71. 2/2 Add a few more options for receive.denyCurrentBranchJohannes Schindelin, Nov 10, 2014

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.