<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/apply.c, branch v2.16.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.16.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.16.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2017-11-27T02:06:36Z</updated>
<entry>
<title>Merge branch 'rs/apply-inaccurate-eof-with-incomplete-line'</title>
<updated>2017-11-27T02:06:36Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2017-11-27T02:06:36Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=d78a122e9cb33df8e625fcf15cb075cc6d61b984'/>
<id>urn:sha1:d78a122e9cb33df8e625fcf15cb075cc6d61b984</id>
<content type='text'>
"git apply --inaccurate-eof" when used with "--ignore-space-change"
triggered an internal sanity check, which has been fixed.

* rs/apply-inaccurate-eof-with-incomplete-line:
  apply: update line lengths for --inaccurate-eof
</content>
</entry>
<entry>
<title>Merge branch 'rs/apply-fuzzy-match-fix'</title>
<updated>2017-11-21T05:07:52Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2017-11-21T05:07:52Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=5ed69ca6dbcef6122d90b9b8fb9a1b1f65208a6d'/>
<id>urn:sha1:5ed69ca6dbcef6122d90b9b8fb9a1b1f65208a6d</id>
<content type='text'>
A fix for an ancient bug in "git apply --ignore-space-change" codepath.

* rs/apply-fuzzy-match-fix:
  apply: avoid out-of-bounds access in fuzzy_matchlines()
</content>
</entry>
<entry>
<title>apply: update line lengths for --inaccurate-eof</title>
<updated>2017-11-17T01:42:08Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2017-11-16T18:50:31Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=4855de123391daab82407b44de03ba5647e97694'/>
<id>urn:sha1:4855de123391daab82407b44de03ba5647e97694</id>
<content type='text'>
Some diff implementations don't report missing newlines at the end of
files.  Applying such a patch can cause a newline character to be
added inadvertently.  The option --inaccurate-eof of git apply can be
used to remove trailing newlines if needed.

apply_one_fragment() cuts it off from the buffers for preimage and
postimage.  Before it does, it builds an array with the lengths of each
line for both.  Make sure to update the length of the last line in
these line info structures as well to keep them consistent with their
respective buffer.

Without this fix the added test fails; git apply dies and reports:

   fatal: BUG: caller miscounted postlen: asked 1, orig = 1, used = 2

That sanity check is only called if whitespace changes are ignored.

Reported-by: Mahmoud Al-Qudsi &lt;mqudsi@neosmart.net&gt;
Signed-off-by: Rene Scharfe &lt;l.s.r@web.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>apply: avoid out-of-bounds access in fuzzy_matchlines()</title>
<updated>2017-11-12T05:41:40Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2017-11-11T14:10:19Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=6ce15ce576afb0510e9d6189ff3780369fdc5b2b'/>
<id>urn:sha1:6ce15ce576afb0510e9d6189ff3780369fdc5b2b</id>
<content type='text'>
fuzzy_matchlines() uses a pointers to the first and last characters of
two lines to keep track while matching them.  This makes it impossible
to deal with empty strings.  It accesses characters before the start of
empty lines.  It can also access characters after the end when checking
for trailing whitespace in the main loop.

Avoid that by using pointers to the first character and the one *after*
the last one.  This is well-defined as long as the latter is not
dereferenced.  Basically rewrite the function based on that premise; it
becomes much simpler as a result.  There is no need to check for
leading whitespace outside of the main loop anymore.

Reported-by: Mahmoud Al-Qudsi &lt;mqudsi@neosmart.net&gt;
Signed-off-by: Rene Scharfe &lt;l.s.r@web.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>apply: remove `newfd` from `struct apply_state`</title>
<updated>2017-10-06T01:07:18Z</updated>
<author>
<name>Martin Ågren</name>
<email>martin.agren@gmail.com</email>
</author>
<published>2017-10-05T20:32:10Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=d13cd4c92760d8fe01fb51fbab556a4d1f3713b4'/>
<id>urn:sha1:d13cd4c92760d8fe01fb51fbab556a4d1f3713b4</id>
<content type='text'>
Similar to a previous patch, we do not need to use `newfd` to signal
that we have a lockfile to clean up. We can just unconditionally call
`rollback_lock_file`. If we do not hold the lock, it will be a no-op.

Where we check `newfd` to decide whether we need to take the lock, we
can instead use `is_lock_file_locked()`.

Signed-off-by: Martin Ågren &lt;martin.agren@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>apply: move lockfile into `apply_state`</title>
<updated>2017-10-06T01:07:18Z</updated>
<author>
<name>Martin Ågren</name>
<email>martin.agren@gmail.com</email>
</author>
<published>2017-10-05T20:32:09Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=6d058c882643dc45c8d708be98e86c38f25511a9'/>
<id>urn:sha1:6d058c882643dc45c8d708be98e86c38f25511a9</id>
<content type='text'>
We have two users of `struct apply_state` and the related functionality
in apply.c. Each user sets up its `apply_state` by handing over a
pointer to its static `lock_file`. (Before 076aa2cbd (tempfile:
auto-allocate tempfiles on heap, 2017-09-05), we could never free
lockfiles, so making them static was a reasonable approach.)

Other than that, they never directly access their `lock_file`s, which
are instead handled by the functionality in apply.c.

To make life easier for the caller and to make it less tempting for a
future caller to mess with the lock, make apply.c fully responsible for
setting up the `lock_file`. As mentioned above, it is now safe to free a
`lock_file`, so we can make the `struct apply_state` contain an actual
`struct lock_file` instead of a pointer to one.

The user in builtin/apply.c is rather simple. For builtin/am.c, we might
worry that the lock state is actually meant to be inherited across
calls. But the lock is only taken as `apply_all_patches()` executes, and
code inspection shows that it will always be released.

Alternatively, we can observe that the lock itself is never queried
directly. When we decide whether we should lock, we check a related
variable `newfd`. That variable is not inherited, so from the point of
view of apply.c, the state machine really is reset with each call to
`init_apply_state()`. (It would be a bug if `newfd` and the lock status
were not in sync. The duplication of information in `newfd` and the lock
will be addressed in the next patch.)

Signed-off-by: Martin Ågren &lt;martin.agren@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>consistently use "fallthrough" comments in switches</title>
<updated>2017-09-22T03:49:57Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2017-09-21T06:25:41Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=1cf01a34eaccd6da613dba82291666db237916ab'/>
<id>urn:sha1:1cf01a34eaccd6da613dba82291666db237916ab</id>
<content type='text'>
Gcc 7 adds -Wimplicit-fallthrough, which can warn when a
switch case falls through to the next case. The general idea
is that the compiler can't tell if this was intentional or
not, so you should annotate any intentional fall-throughs as
such, leaving it to complain about any unannotated ones.

There's a GNU __attribute__ which can be used for
annotation, but of course we'd have to #ifdef it away on
non-gcc compilers. Gcc will also recognize
specially-formatted comments, which matches our current
practice. Let's extend that practice to all of the
unannotated sites (which I did look over and verify that
they were behaving as intended).

Ideally in each case we'd actually give some reasons in the
comment about why we're falling through, or what we're
falling through to. And gcc does support that with
-Wimplicit-fallthrough=2, which relaxes the comment pattern
matching to anything that contains "fallthrough" (or a
variety of spelling variants). However, this isn't the
default for -Wimplicit-fallthrough, nor for -Wextra. In the
name of simplicity, it's probably better for us to support
the default level, which requires "fallthrough" to be the
only thing in the comment (modulo some window dressing like
"else" and some punctuation; see the gcc manual for the
complete set of patterns).

This patch suppresses all warnings due to
-Wimplicit-fallthrough. We might eventually want to add that
to the DEVELOPER Makefile knob, but we should probably wait
until gcc 7 is more widely adopted (since earlier versions
will complain about the unknown warning type).

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>Merge branch 'rs/apply-epoch'</title>
<updated>2017-09-10T08:08:25Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2017-09-10T08:08:25Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=ef1d87c64b4f9a41fa03b039761f599750227d5a'/>
<id>urn:sha1:ef1d87c64b4f9a41fa03b039761f599750227d5a</id>
<content type='text'>
Code simplification.

* rs/apply-epoch:
  apply: remove epoch date from regex
  apply: check date of potential epoch timestamps first
</content>
</entry>
<entry>
<title>Merge branch 'tb/apply-with-crlf'</title>
<updated>2017-08-27T05:55:05Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2017-08-27T05:55:05Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=a17483fcfe313e9ff5b9b0eb8245605fe7f66ea7'/>
<id>urn:sha1:a17483fcfe313e9ff5b9b0eb8245605fe7f66ea7</id>
<content type='text'>
"git apply" that is used as a better "patch -p1" failed to apply a
taken from a file with CRLF line endings to a file with CRLF line
endings.  The root cause was because it misused convert_to_git()
that tried to do "safe-crlf" processing by looking at the index
entry at the same path, which is a nonsense---in that mode, "apply"
is not working on the data in (or derived from) the index at all.
This has been fixed.

* tb/apply-with-crlf:
  apply: file commited with CRLF should roundtrip diff and apply
  convert: add SAFE_CRLF_KEEP_CRLF
</content>
</entry>
<entry>
<title>apply: remove epoch date from regex</title>
<updated>2017-08-25T21:06:09Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2017-08-25T19:06:28Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=0db3dc75f30239aa3b36071c7b9ff21c16ba449a'/>
<id>urn:sha1:0db3dc75f30239aa3b36071c7b9ff21c16ba449a</id>
<content type='text'>
We check the date of epoch timestamp candidates already with
starts_with().  Move beyond that part using skip_prefix() instead of
checking it again using a regular expression.  Also group the minutes
part, so that we can access them using a substring match instead of
using a magic number.

Signed-off-by: Rene Scharfe &lt;l.s.r@web.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
