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

Re: [PATCH] Teach 'git apply' to look at $GIT_DIR/config

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Feb 19, 2007, 22:57 UTC
Message-ID
<Pine.LNX.4.64.0702191450580.20368@woody.linux-foundation.org>
In-Reply-To
<20070217233203.GA6014@coredump.intra.peff.net>
On Sat, 17 Feb 2007, Jeff King wrote:
Show 8 quoted lines
>
> On Sat, Feb 17, 2007 at 03:31:18PM -0800, Junio C Hamano wrote:
> 
> > I thought about that, but decided against it.  If you are truly
> > operating outside a git managed repository, it does not feel
> > right to apply configuration user has for git.
> 
> Then why are they using git-apply, and not patch?

I don't know about others, but I use "git apply" even outside git (*) simply because the defaults for it are a lot better than "patch".

I've always hated how patch has some _really_ unsafe default behaviour:
 - it will guess at filenames. As in *totally* guess. If you have a patch 
   that touches a Makefile in a subdirectory, but that subdirectory had 
   been renamed or removed, it's entirely possible that "patch" will 
   actually find *another* file called "Makefile" (most likely your 
   top-most one) and apply the patch to that.
   And yes, this has actually happened to me.
 - it defaults to various unsafe options, like allowing a big fuzz factor 
   (I think it defaults to --fuzz=2), which means that if you've already 
   applied the patch, but there was _another_ place that looks a bit like 
   the original place, "patch" will happily apply it *again* because the 
   default fuzz-factor is so permissive.

git-apply has much saner defaults (it defaults to something pretty safe, and you can then make it less safe if the patch doesn't apply).

It also knows about renames. I hope that some day people will start sending rename-patches around, just because they are *so* much more readable than delete/create patches.

		Linus

(*) Although I have also noticed that even more often than using "git apply" outside a git thing, I just import everything into git these days. So I may not have actually used git-apply outside of a git project in a long time any more. But I did, a few times.

Previous: Jeff KingNext: Shawn O. Pearce
Message 6 of 49 in “Teach core.autocrlf to 'git apply'”
  1. Teach core.autocrlf to 'git apply'Junio C Hamano, Feb 17, 2007
  2. Teach 'git apply' to look at $GIT_DIR/configJunio C Hamano, Feb 17, 2007
  3. Jeff KingFeb 17, 2007
  4. Junio C HamanoFeb 17, 2007
  5. Jeff KingFeb 17, 2007
  6. Linus TorvaldsFeb 19, 2007
  7. Shawn O. PearceFeb 19, 2007
  8. Junio C HamanoFeb 19, 2007
  9. Linus TorvaldsFeb 19, 2007
  10. Junio C HamanoFeb 19, 2007
  11. Linus TorvaldsFeb 20, 2007
  12. Junio C HamanoFeb 20, 2007
  13. Johannes SchindelinFeb 20, 2007
  14. Junio C HamanoFeb 20, 2007
  15. Johannes SchindelinFeb 20, 2007
  16. git-apply: require -p<n> when working in a subdirectory.Junio C Hamano, Feb 20, 2007
  17. apply: fix memory leak in prefix_one()Johannes Schindelin, Feb 20, 2007
  18. Junio C HamanoFeb 20, 2007
  19. Johannes SchindelinFeb 20, 2007
  20. git-apply: do not lose cwd when run from a subdirectory.Junio C Hamano, Feb 20, 2007
  21. Junio C HamanoFeb 20, 2007
  22. Linus TorvaldsFeb 20, 2007
  23. Daniel BarkalowFeb 21, 2007
  24. Junio C HamanoFeb 21, 2007
  25. Daniel BarkalowFeb 21, 2007
  26. Linus TorvaldsFeb 21, 2007
  27. Junio C HamanoFeb 21, 2007
  28. git-apply: notice "diff --git" patch againJunio C Hamano, Feb 21, 2007
  29. git-apply: guess correct -p<n> value for non-git patches.Junio C Hamano, Feb 22, 2007
  30. Johannes SchindelinFeb 20, 2007
  31. Simon 'corecode' SchubertFeb 20, 2007
  32. Johannes SchindelinFeb 18, 2007
  33. Junio C HamanoFeb 18, 2007
  34. Johannes SchindelinFeb 18, 2007
  35. Junio C HamanoFeb 18, 2007
  36. Johannes SchindelinFeb 18, 2007
  37. Junio C HamanoFeb 18, 2007
  38. Johannes SchindelinFeb 18, 2007
  39. Junio C HamanoFeb 18, 2007
  40. Johannes SchindelinFeb 18, 2007
  41. Jakub NarebskiFeb 18, 2007
  42. Johannes SchindelinFeb 18, 2007
  43. Junio C HamanoFeb 18, 2007
  44. Johannes SchindelinFeb 18, 2007
  45. Junio C HamanoFeb 18, 2007
  46. Johannes SchindelinFeb 18, 2007
  47. Junio C HamanoFeb 18, 2007
  48. Johannes SchindelinFeb 18, 2007
  49. Junio C HamanoFeb 18, 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.