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

Re: possible bug in git apply?

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 6, 2007, 08:29 UTC
Message-ID
<7vabt5dq11.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<alpine.LFD.0.999.0708050949220.5037@woody.linux-foundation.org>
Linus Torvalds <torvalds@linux-foundation.org> writes:
Show 6 quoted lines
> That said, if we really wanted to get it right, we should do this as a 
> three-phase thing: (1) remove old files (2) create new files (3) for all 
> removals and renames, try to remove source directories that might have 
> become empty.
>
> That would fix it properly and for all cases.

Actually that will break the case of removing foo/bar, which is the only file in directory foo, and creating a new file foo. So if we really want to do all the corner cases, we would need to do something like:

 * scan the list of files that will remain (i.e., renamed-to,
   modifed-in-place and created-anew) to note which directories
   should remain in the result;
 * remove old files, and remove its empty parent directories
   that are not in the above list;
 * create new files.

But in the meantime for 1.5.3, I think your patch is better than what we currently have.

Previous: David KastrupNext: Junio C Hamano
Message 14 of 15 in “possible bug in git apply?”
  1. david@lang.hmAug 4, 2007
  2. Junio C HamanoAug 4, 2007
  3. David KastrupAug 4, 2007
  4. Linus TorvaldsAug 5, 2007
  5. Linus TorvaldsAug 5, 2007
  6. Junio C HamanoAug 5, 2007
  7. David KastrupAug 5, 2007
  8. Linus TorvaldsAug 5, 2007
  9. David KastrupAug 5, 2007
  10. Linus TorvaldsAug 5, 2007
  11. David KastrupAug 5, 2007
  12. Linus TorvaldsAug 5, 2007
  13. David KastrupAug 5, 2007
  14. Junio C HamanoAug 6, 2007
  15. Junio C HamanoAug 6, 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.