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

Re: git push to a non-bare repository

From
Shawn O. Pearce <spearce@spearce.org>
Date
Mar 19, 2007, 03:47 UTC
Message-ID
<20070319034755.GH20658@spearce.org>
In-Reply-To
<20070319033340.GG11371@thunk.org>
Theodore Tso <tytso@mit.edu> wrote:
Show 5 quoted lines
> Ah, so that's controlled by receive.denyNonFastForwards, right?  Cool,
> I missed that.  Thanks!!
> 
> Documentation/config.txt doesn't say it defaults to true, but from
> your comments that is the default?
Ah, my bad, it defaults to false:
  static int deny_non_fast_forwards = 0;
I should have known better, as I run a 1.5.x (aka 'next') server
for a workgroup and I never have that set, but use instead a complex
update hook that decides if a fast-forward is required or not.
 
Show 12 quoted lines
> > > 	* Only accept the push if there are no locally modified files
> > > 		that would be affected when the working directory is
> > > 		updated to reflect the new HEAD
> > 
> > If git-runstatus exits to indicate the tree is clean (nothing to
> > commit) then a simple `read-tree -m -u HEAD $new` should update
> > the working directory and index, right?
> 
> What git-runstatus will allow me to do is to abort if there are any
> local modifications, regardless of whether or not they would conflict
> with the working tree update.  The key phrase in my criteria was no
> locally modified files "THAT WOULD BE AFFECTED".
  git-diff $old $new | git-apply --index ?

If the patch does not apply, nothing gets updated. If it does apply, the index is also updated and stat data updated.

OK, it doesn't quite handle every case, as sometimes a patch will reject but the internal 3-way merge from xdiff that is called by merge-recursive will succeed, but this does protect your working tree and doesn't require making a temporary copy.

Of course another possible approach is to stuff the entire working directory into a temporary tree, and then merge. If the merge doesn't work, you can reset to the temporary tree. Unfortunately the working directory is "in flux" during that process... its not atomic.

-- 
Shawn.
Previous: Theodore TsoNext: Junio C Hamano
Message 22 of 27 in “git push to a non-bare repository”
  1. Matthieu MoyMar 18, 2007
  2. Junio C HamanoMar 18, 2007
  3. Sam VilainMar 18, 2007
  4. Jakub NarebskiMar 18, 2007
  5. Junio C HamanoMar 18, 2007
  6. Theodore TsoMar 19, 2007
  7. Junio C HamanoMar 19, 2007
  8. Shawn O. PearceMar 19, 2007
  9. Theodore TsoMar 19, 2007
  10. Shawn O. PearceMar 19, 2007
  11. Theodore TsoMar 19, 2007
  12. Shawn O. PearceMar 19, 2007
  13. Nicolas PitreMar 19, 2007
  14. Theodore TsoMar 19, 2007
  15. Junio C HamanoMar 19, 2007
  16. Nicolas PitreMar 19, 2007
  17. Nicolas PitreMar 19, 2007
  18. Sam VilainMar 19, 2007
  19. Junio C HamanoMar 20, 2007
  20. Junio C HamanoMar 20, 2007
  21. Theodore TsoMar 19, 2007
  22. Shawn O. PearceMar 19, 2007
  23. Junio C HamanoMar 19, 2007
  24. Matthieu MoyMar 19, 2007
  25. Jakub NarebskiMar 19, 2007
  26. Neil SchemenauerMar 21, 2007
  27. Sergio CallegariMar 19, 2007

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.