Re: [BUG] git-am silently applying patches incorrectly
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 5, 2011, 00:05 UTC
- Message-ID
- <7vd3m65t4g.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <4D717116.3050305@miseler.de>
Alexander Miseler <alexander@miseler.de> writes:
> .... On a side note: if this problem is tackled it might be > sensible to add a heuristic to git format-patch that increases the > context size for hunks that are likely to be ambiguous.
In general that approach would not help. Imagine a case where the problematic patch from David Henningsson were only about moving the calling site of check_required() within the element_probe() function. IOW, imagine that the hunk starting at line 1018 to modify check_required() itself weren't involved in his change.
Before or after such a change, there would be only one location that closes two blocks followed by a blank line and return 0 at the end of the function, which is the necessary context of the "moved after" hunk of the patch, so when producing the patch, there is no way for format-patch to notice that it is likely to become ambiguous.
But if the change to check_required() were applied as a separate patch before the change to move the call site was applied, at the application time, the patch becomes ambiguous.