<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/diff.c, branch v2.15.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.15.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.15.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2017-11-15T03:04:59Z</updated>
<entry>
<title>Merge branch 'ao/diff-populate-filespec-lstat-errorpath-fix' into maint</title>
<updated>2017-11-15T03:04:59Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2017-11-15T03:04:59Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=eae59c1b574d2a424abc2447985d10c06f2a840e'/>
<id>urn:sha1:eae59c1b574d2a424abc2447985d10c06f2a840e</id>
<content type='text'>
After an error from lstat(), diff_populate_filespec() function
sometimes still went ahead and used invalid data in struct stat,
which has been fixed.

* ao/diff-populate-filespec-lstat-errorpath-fix:
  diff: fix lstat() error handling in diff_populate_filespec()
</content>
</entry>
<entry>
<title>diff: fix lstat() error handling in diff_populate_filespec()</title>
<updated>2017-10-29T01:16:36Z</updated>
<author>
<name>Andrey Okoshkin</name>
<email>a.okoshkin@samsung.com</email>
</author>
<published>2017-10-27T09:33:25Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=10e0ca843dea3e8135678600f22e0baa1edf6e44'/>
<id>urn:sha1:10e0ca843dea3e8135678600f22e0baa1edf6e44</id>
<content type='text'>
Add lstat() error handling not only for ENOENT case.
Otherwise uninitialised 'struct stat st' variable is used later in case of
lstat() non-ENOENT failure which leads to processing of rubbish values of
file mode ('S_ISLNK(st.st_mode)' check) or size ('xsize_t(st.st_size)').

Signed-off-by: Andrey Okoshkin &lt;a.okoshkin@samsung.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>diff.c: get rid of duplicate implementation</title>
<updated>2017-10-26T02:23:32Z</updated>
<author>
<name>Stefan Beller</name>
<email>sbeller@google.com</email>
</author>
<published>2017-10-25T18:49:12Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=01be97c2b285e8ba377ba58385ef6ad2e7815c93'/>
<id>urn:sha1:01be97c2b285e8ba377ba58385ef6ad2e7815c93</id>
<content type='text'>
The implementations in diff.c to detect moved lines needs to compare
strings and hash strings, which is implemented in that file, as well
as in the xdiff library.

Remove the rather recent implementation in diff.c and rely on the well
exercised code in the xdiff lib.

With this change the hash used for bucketing the strings for the moved
line detection changes from FNV32 (that is provided via the hashmaps
memhash) to DJB2 (which is used internally in xdiff).  Benchmarks found
on the web[1] do not indicate that these hashes are different in
performance for readable strings.

[1] https://softwareengineering.stackexchange.com/questions/49550/which-hashing-algorithm-is-best-for-uniqueness-and-speed

Signed-off-by: Stefan Beller &lt;sbeller@google.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>diff: handle NULs in get_string_hash()</title>
<updated>2017-10-21T12:12:53Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2017-10-19T20:31:20Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=b66b5072921fb706f1e9352f471098c988b0ca39'/>
<id>urn:sha1:b66b5072921fb706f1e9352f471098c988b0ca39</id>
<content type='text'>
For computing moved lines, we feed the characters of each
line into a hash. When we've been asked to ignore
whitespace, then we pick each character using next_byte(),
which returns -1 on end-of-string, which it determines using
the start/end pointers we feed it.

However our check of its return value treats "0" the same as
"-1", meaning we'd quit if the string has an embedded NUL.
This is unlikely to ever come up in practice since our line
boundaries generally come from calling strlen() in the first
place.

But it was a bit surprising to me as a reader of the
next_byte() code. And it's possible that we may one day feed
this function with more exotic input, which otherwise works
with arbitrary ptr/len pairs.

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>diff: fix whitespace-skipping with --color-moved</title>
<updated>2017-10-21T12:12:35Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2017-10-19T20:29:26Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=da58318e76b37c345e4d0da4c42987ad45b4f155'/>
<id>urn:sha1:da58318e76b37c345e4d0da4c42987ad45b4f155</id>
<content type='text'>
The code for handling whitespace with --color-moved
represents partial strings as a pair of pointers. There are
two possible conventions for the end pointer:

  1. It points to the byte right after the end of the
     string.

  2. It points to the final byte of the string.

But we seem to use both conventions in the code:

  a. we assign the initial pointers from the NUL-terminated
     string using (1)

  b. we eat trailing whitespace by checking the second
     pointer for isspace(), which needs (2)

  c. the next_byte() function checks for end-of-string with
     "if (cp &gt; endp)", which is (2)

  d. in next_byte() we skip past internal whitespace with
     "while (cp &lt; end)", which is (1)

This creates fewer bugs than you might think, because there
are some subtle interactions. Because of (a) and (c), we
always return the NUL-terminator from next_byte(). But all
of the callers of next_byte() happen to handle that
gracefully.

Because of the mismatch between (d) and (c), next_byte()
could accidentally return a whitespace character right at
endp. But because of the interaction of (a) and (b), we fail
to actually chomp trailing whitespace, meaning our endp
_always_ points to a NUL, canceling out the problem.

But that does leave (b) as a real bug: when ignoring
whitespace only at the end-of-line, we don't correctly trim
it, and fail to match up lines.

We can fix the whole thing by moving consistently to one
convention. Since convention (1) is idiomatic in our code
base, we'll pick that one.

The existing "-w" and "-b" tests continue to pass, and a new
"--ignore-space-at-eol" shows off the breakage we're fixing.

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 'jk/ref-filter-colors-fix'</title>
<updated>2017-10-18T01:19:08Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2017-10-18T01:19:08Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=1c0b983a777bf283250aaf00c94a9a9d4bf8bc9c'/>
<id>urn:sha1:1c0b983a777bf283250aaf00c94a9a9d4bf8bc9c</id>
<content type='text'>
This is the "theoretically more correct" approach of simply
stepping back to the state before plumbing commands started paying
attention to "color.ui" configuration variable.

Let's run with this one.

* jk/ref-filter-colors-fix:
  tag: respect color.ui config
  Revert "color: check color.ui in git_default_config()"
  Revert "t6006: drop "always" color config tests"
  Revert "color: make "always" the same as "auto" in config"
</content>
</entry>
<entry>
<title>Revert "color: check color.ui in git_default_config()"</title>
<updated>2017-10-17T06:09:52Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2017-10-13T17:24:31Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=33c643bb083133376f3fdcb190ebc58f9eef12bb'/>
<id>urn:sha1:33c643bb083133376f3fdcb190ebc58f9eef12bb</id>
<content type='text'>
This reverts commit 136c8c8b8fa39f1315713248473dececf20f8fe7.

That commit was trying to address a bug caused by 4c7f1819b3
(make color.ui default to 'auto', 2013-06-10), in which
plumbing like diff-tree defaulted to "auto" color, but did
not respect a "color.ui" directive to disable it.

But it also meant that we started respecting "color.ui" set
to "always". This was a known problem, but 4c7f1819b3 argued
that nobody ought to be doing that. However, that turned out
to be wrong, and we got a number of bug reports related to
"add -p" regressing in v2.14.2.

Let's revert 136c8c8b8, fixing the regression to "add -p".
This leaves the problem from 4c7f1819b3 unfixed, but:

  1. It's a pretty obscure problem in the first place. I
     only noticed it while working on the color code, and we
     haven't got a single bug report or complaint about it.

  2. We can make a more moderate fix on top by respecting
     "never" but not "always" for plumbing commands. This
     is just the minimal fix to go back to the working state
     we had before v2.14.2.

Note that this isn't a pure revert. We now have a test in
t3701 which shows off the "add -p" regression. This can be
flipped to success.

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 'sb/diff-color-move'</title>
<updated>2017-10-17T04:29:19Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2017-10-17T04:29:19Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=91ccfb85176fbe2ed416751ff7884cdaf61311cb'/>
<id>urn:sha1:91ccfb85176fbe2ed416751ff7884cdaf61311cb</id>
<content type='text'>
A recently added "--color-moved" feature of "diff" fell into
infinite loop when ignoring whitespace changes, which has been
fixed.

* sb/diff-color-move:
  diff: fix infinite loop with --color-moved --ignore-space-change
</content>
</entry>
<entry>
<title>diff: fix infinite loop with --color-moved --ignore-space-change</title>
<updated>2017-10-16T02:57:45Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2017-10-13T00:18:37Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=fa5ba2c1dd0ce1bd060f423e7b1eb39d06fcd2cd'/>
<id>urn:sha1:fa5ba2c1dd0ce1bd060f423e7b1eb39d06fcd2cd</id>
<content type='text'>
The --color-moved code uses next_byte() to advance through
the blob contents. When the user has asked to ignore
whitespace changes, we try to collapse any whitespace change
down to a single space.

However, we enter the conditional block whenever we see the
IGNORE_WHITESPACE_CHANGE flag, even if the next byte isn't
whitespace.

This means that the combination of "--color-moved and
--ignore-space-change" was completely broken. Worse, because
we return from next_byte() without having advanced our
pointer, the function makes no forward progress in the
buffer and loops infinitely.

Fix this by entering the conditional only when we actually
see whitespace. We can apply this also to the
IGNORE_WHITESPACE change. That code path isn't buggy
(because it falls through to returning the next
non-whitespace byte), but it makes the logic more clear if
we only bother to look at whitespace flags after seeing that
the next byte is whitespace.

Reported-by: Orgad Shaneh &lt;orgads@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>Merge branch 'sb/diff-color-move'</title>
<updated>2017-10-03T06:42:49Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2017-10-03T06:42:49Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=98c57ea6f00282ed6ab245cf6842972b07c5a6fd'/>
<id>urn:sha1:98c57ea6f00282ed6ab245cf6842972b07c5a6fd</id>
<content type='text'>
The output from "git diff --summary" was broken in a recent topic
that has been merged to 'master' and lost a LF after reporting of
mode change.  This has been fixed.

* sb/diff-color-move:
  diff: correct newline in summary for renamed files
</content>
</entry>
</feed>
