<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/apply.c, branch v2.34.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.34.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.34.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2021-09-15T20:15:26Z</updated>
<entry>
<title>Merge branch 'jc/trivial-threeway-binary-merge'</title>
<updated>2021-09-15T20:15:26Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2021-09-15T20:15:26Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=c76fcf3e46a86d389739b7ee94b3d4faa351af84'/>
<id>urn:sha1:c76fcf3e46a86d389739b7ee94b3d4faa351af84</id>
<content type='text'>
The "git apply -3" code path learned not to bother the lower level
merge machinery when the three-way merge can be trivially resolved
without the content level merge.

* jc/trivial-threeway-binary-merge:
  apply: resolve trivial merge without hitting ll-merge with "--3way"
</content>
</entry>
<entry>
<title>apply: resolve trivial merge without hitting ll-merge with "--3way"</title>
<updated>2021-09-05T22:39:02Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2021-09-05T19:06:57Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=57f183b698ca4f967266577687f09b09a79f0b8c'/>
<id>urn:sha1:57f183b698ca4f967266577687f09b09a79f0b8c</id>
<content type='text'>
The ll_binary_merge() function assumes that the ancestor blob is
different from either side of the new versions, and always fails
the merge in conflict, unless -Xours or -Xtheirs is in effect.

The normal "merge" machineries all resolve the trivial cases
(e.g. if our side changed while their side did not, the result
is ours) without triggering the file-level merge drivers, so the
assumption is warranted.

The code path in "git apply --3way", however, does not check for
the trivial three-way merge situation and always calls the
file-level merge drivers.  This used to be perfectly OK back
when we always first attempted a straight patch application and
used the three-way code path only as a fallback.  Any binary
patch that can be applied as a trivial three-way merge (e.g. the
patch is based exactly on the version we happen to have) would
always cleanly apply, so the ll_binary_merge() that is not
prepared to see the trivial case would not have to handle such a
case.

This no longer is true after we made "--3way" to mean "first try
three-way and then fall back to straight application", and made
"git apply -3" on a binary patch that is based on the current
version no longer apply.

Teach "git apply -3" to first check for the trivial merge cases
and resolve them without hitting the file-level merge drivers.

Signed-off-by: Jerry Zhang &lt;jerry@skydio.com&gt;
[jc: stolen tests from Jerry's patch]
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'jk/apply-binary-hunk-parsing-fix'</title>
<updated>2021-08-30T23:06:04Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2021-08-30T23:06:04Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=7e3b9d15344fa5a09fe5c70270c9f2c2f75d0f90'/>
<id>urn:sha1:7e3b9d15344fa5a09fe5c70270c9f2c2f75d0f90</id>
<content type='text'>
"git apply" miscounted the bytes and failed to read to the end of
binary hunks.

* jk/apply-binary-hunk-parsing-fix:
  apply: keep buffer/size pair in sync when parsing binary hunks
</content>
</entry>
<entry>
<title>apply: keep buffer/size pair in sync when parsing binary hunks</title>
<updated>2021-08-10T18:38:13Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2021-08-10T01:01:52Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=46d723ce57f2dd3c50504dc6f4ca73b4c392fa6f'/>
<id>urn:sha1:46d723ce57f2dd3c50504dc6f4ca73b4c392fa6f</id>
<content type='text'>
We parse through binary hunks by looping through the buffer with code
like:

    llen = linelen(buffer, size);

    ...do something with the line...

    buffer += llen;
    size -= llen;

However, before we enter the loop, there is one call that increments
"buffer" but forgets to decrement "size". As a result, our "size" is off
by the length of that line, and subsequent calls to linelen() may look
past the end of the buffer for a newline.

The fix is easy: we just need to decrement size as we do elsewhere.

This bug goes all the way back to 0660626caf (binary diff: further
updates., 2006-05-05). Presumably nobody noticed because it only
triggers if the patch is corrupted, and even then we are often "saved"
by luck. We use a strbuf to store the incoming patch, so we overallocate
there, plus we add a 16-byte run of NULs as slop for memory comparisons.
So if this happened accidentally, the common case is that we'd just read
a few uninitialized bytes from the end of the strbuf before producing
the expected "this patch is corrupted" error complaint.

However, it is possible to carefully construct a case which reads off
the end of the buffer. The included test does so. It will pass both
before and after this patch when run normally, but using a tool like
ASan shows that we get an out-of-bounds read before this patch, but not
after.

Reported-by: Xingman Chen &lt;xichixingman@gmail.com&gt;
Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>string-list.h users: change to use *_{nodup,dup}()</title>
<updated>2021-07-01T19:32:22Z</updated>
<author>
<name>Ævar Arnfjörð Bjarmason</name>
<email>avarab@gmail.com</email>
</author>
<published>2021-07-01T10:51:29Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=bc40dfb10a06612813a3f9b733d65af0732208b2'/>
<id>urn:sha1:bc40dfb10a06612813a3f9b733d65af0732208b2</id>
<content type='text'>
Change all in-tree users of the string_list_init(LIST, BOOL) API to
use string_list_init_{nodup,dup}(LIST) instead.

As noted in the preceding commit let's leave the now-unused
string_list_init() wrapper in-place for any in-flight users, it can be
removed at some later date.

Signed-off-by: Ævar Arnfjörð Bjarmason &lt;avarab@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'jz/apply-3way-first-message-fix'</title>
<updated>2021-05-07T03:47:38Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2021-05-07T03:47:38Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=6d99f31ddafb064795d1d8f9b9bd930296f7069e'/>
<id>urn:sha1:6d99f31ddafb064795d1d8f9b9bd930296f7069e</id>
<content type='text'>
When we swapped the order of --3way fallback, we forgot to adjust
the message we give when the first method fails and the second
method is attempted (which used to be "direct application failed
hence we try 3way", now it is the other way around).

* jz/apply-3way-first-message-fix:
  apply: adjust messages to account for --3way changes
</content>
</entry>
<entry>
<title>apply: adjust messages to account for --3way changes</title>
<updated>2021-04-29T03:27:45Z</updated>
<author>
<name>Jerry Zhang</name>
<email>jerry@skydio.com</email>
</author>
<published>2021-04-29T02:35:03Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=526705fd3d14a38646a12235ee385dcc0ffc7321'/>
<id>urn:sha1:526705fd3d14a38646a12235ee385dcc0ffc7321</id>
<content type='text'>
"git apply" specifically calls out when it is falling back to 3way
merge application.  Since the order changed to preferring 3way and
falling back to direct application, continue that behavior by
printing whenever 3way fails and git has to fall back.

Signed-off-by: Jerry Zhang &lt;jerry@skydio.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>git-apply: allow simultaneous --cached and --3way options</title>
<updated>2021-04-08T05:20:33Z</updated>
<author>
<name>Jerry Zhang</name>
<email>jerry@skydio.com</email>
</author>
<published>2021-04-08T02:13:44Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=c0c2a37ac2b9338c3a93340cbcbab69690da4df0'/>
<id>urn:sha1:c0c2a37ac2b9338c3a93340cbcbab69690da4df0</id>
<content type='text'>
"git apply" does not allow "--cached" and "--3way" to be used
together, since "--3way" writes conflict markers into the working
tree.

Allow "git apply" to accept "--cached" and "--3way" at the same
time.  When a single file auto-resolves cleanly, the result is
placed in the index at stage #0 and the command exits with 0 status.

For a file that has a conflict which cannot be cleanly
auto-resolved, the original contents from common ancestor (stage
conflict at the content level, and the command exists with non-zero
status, because there is no place (like the working tree) to leave a
half-resolved merge for the user to resolve.

The user can use `git diff` to view the contents of the conflict, or
`git checkout -m -- .` to regenerate the conflict markers in the
working directory.

Don't attempt rerere in this case since it depends on conflict
markers written to file for its database storage and lookup. There
would be two main changes required to get rerere working:

1. Allow the rerere api to accept in memory object rather than
   files, which would allow us to pass in the conflict markers
   contained in the result from ll_merge().

2. Rerere can't write to the working directory, so it would have to
   apply the result to cache stage #0 directly. A flag would be
   needed to control this.

Signed-off-by: Jerry Zhang &lt;jerry@skydio.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>git-apply: try threeway first when "--3way" is used</title>
<updated>2021-04-07T00:11:41Z</updated>
<author>
<name>Jerry Zhang</name>
<email>jerry@skydio.com</email>
</author>
<published>2021-04-06T23:25:32Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=923cd87ac8550a8e277bfeb19198a11b6a8ed854'/>
<id>urn:sha1:923cd87ac8550a8e277bfeb19198a11b6a8ed854</id>
<content type='text'>
The apply_fragments() method of "git apply"
can silently apply patches incorrectly if
a file has repeating contents. In these
cases a three-way merge is capable of applying
it correctly in more situations, and will
show a conflict rather than applying it
incorrectly. However, because the patches
apply "successfully" using apply_fragments(),
git will never fall back to the merge, even
if the "--3way" flag is used, and the user has
no way to ensure correctness by forcing the
three-way merge method.

Change the behavior so that when "--3way" is used,
git will always try the three-way merge first and
will only fall back to apply_fragments() in cases
where blobs are not available or some other error
(but not in the case of a merge conflict).

Since user-facing results will be different,
this has backwards compatibility implications
for users depending on the old behavior. In
addition, the three-way merge will be slower
than direct patch application.

Signed-off-by: Jerry Zhang &lt;jerry@skydio.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'mt/parallel-checkout-part-1'</title>
<updated>2021-04-02T21:43:14Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2021-04-02T21:43:14Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=c47679d0405f134703fcae0f8f0b7ef82ecf96d5'/>
<id>urn:sha1:c47679d0405f134703fcae0f8f0b7ef82ecf96d5</id>
<content type='text'>
Preparatory API changes for parallel checkout.

* mt/parallel-checkout-part-1:
  entry: add checkout_entry_ca() taking preloaded conv_attrs
  entry: move conv_attrs lookup up to checkout_entry()
  entry: extract update_ce_after_write() from write_entry()
  entry: make fstat_output() and read_blob_entry() public
  entry: extract a header file for entry.c functions
  convert: add classification for conv_attrs struct
  convert: add get_stream_filter_ca() variant
  convert: add [async_]convert_to_working_tree_ca() variants
  convert: make convert_attrs() and convert structs public
</content>
</entry>
</feed>
