<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/diffcore.h, branch v1.9.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://www.git.shady.money/git/atom?h=v1.9.2</id>
<link rel='self' href='https://www.git.shady.money/git/atom?h=v1.9.2'/>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/'/>
<updated>2014-03-18T20:59:56Z</updated>
<entry>
<title>Merge branch 'nd/diff-quiet-stat-dirty' into maint</title>
<updated>2014-03-18T20:59:56Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2014-03-18T20:59:55Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=34120a5fb555a24904a85e64554bdcc7bcc17963'/>
<id>urn:sha1:34120a5fb555a24904a85e64554bdcc7bcc17963</id>
<content type='text'>
"git diff --quiet -- pathspec1 pathspec2" sometimes did not return
correct status value.

* nd/diff-quiet-stat-dirty:
  diff: do not quit early on stat-dirty files
  diff.c: move diffcore_skip_stat_unmatch core logic out for reuse later
</content>
</entry>
<entry>
<title>diff: do not quit early on stat-dirty files</title>
<updated>2014-02-24T22:50:14Z</updated>
<author>
<name>Nguyễn Thái Ngọc Duy</name>
<email>pclouds@gmail.com</email>
</author>
<published>2014-01-25T06:46:50Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=f34b205f6cc2c78cbed03a1582422cb59e36f729'/>
<id>urn:sha1:f34b205f6cc2c78cbed03a1582422cb59e36f729</id>
<content type='text'>
When QUICK is set (i.e. with --quiet) we try to do as little work as
possible, stopping after seeing the first change. stat-dirty is
considered a "change" but it may turn out not, if no actual content is
changed. The actual content test is performed too late in the process
and the shortcut may be taken prematurely, leading to incorrect return
code.

Assume we do "git diff --quiet". If we have a stat-dirty file "a" and
a really dirty file "b". We break the loop in run_diff_files() and
stop after "a" because we have got a "change". Later in
diffcore_skip_stat_unmatch() we find out "a" is actually not
changed. But there's nothing else in the diff queue, we incorrectly
declare "no change", ignoring the fact that "b" is changed.

This also happens to "git diff --quiet HEAD" when it hits
diff_can_quit_early() in oneway_diff().

This patch does the content test earlier in order to keep going if "a"
is unchanged. The test result is cached so that when
diffcore_skip_stat_unmatch() is done in the end, we spend no cycles on
re-testing "a".

Reported-by: IWAMOTO Toshihiro &lt;iwamoto@valinux.co.jp&gt;
Signed-off-by: Nguyễn Thái Ngọc Duy &lt;pclouds@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>diff_filespec: use only 2 bits for is_binary flag</title>
<updated>2014-01-17T18:50:14Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2014-01-17T01:25:40Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=cbfe47b67fc1072998c73e6d43cf6ad061a436f5'/>
<id>urn:sha1:cbfe47b67fc1072998c73e6d43cf6ad061a436f5</id>
<content type='text'>
The is_binary flag needs only three values: -1, 0, and 1.
However, we use a whole 32-bit int for it on most systems
(both 32- and 64- bit).

Instead, we can mark it to use only 2 bits. On 32-bit
systems, this lets it end up as part of the bitfield above
(saving 4 bytes). On 64-bit systems, we don't see any change
(because the savings end up as padding), but it does leave
room for another "free" 32-bit value to be added later.

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_filespec: reorder is_binary field</title>
<updated>2014-01-17T18:50:13Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2014-01-17T01:22:56Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=b38f70a82b9628d80f5a9bc938a8861ee4dcf49e'/>
<id>urn:sha1:b38f70a82b9628d80f5a9bc938a8861ee4dcf49e</id>
<content type='text'>
The middle of the diff_filespec struct contains a mixture of
ints, shorts, and bit-fields, followed by a pointer. On an
x86-64 system with an LP64 or LLP64 data model (i.e., most
of them), the integers and flags end up being padded out by
41 bits to put the pointer at an 8-byte boundary.

After the pointer, we have the "int is_binary" field, which
is only 32 bits. We end up wasting another 32 bits to pad
the struct size up to a multiple of 64 bits.

We can move the is_binary field before the pointer, which
lets the compiler store it where we used to have padding.
This shrinks the top padding to only 9 bits (from the
bit-fields), and eliminates the bottom padding entirely,
dropping the struct size from 88 to 80 bytes.

On a 32-bit system, there is no benefit, but nor should
there be any harm (we only need 4-byte alignment there, so
we were already using only 9 bits of padding).

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_filespec: drop xfrm_flags field</title>
<updated>2014-01-17T18:50:11Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2014-01-17T01:21:59Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=428d52a5a56f81d3a42871b51480cecafec58fdd'/>
<id>urn:sha1:428d52a5a56f81d3a42871b51480cecafec58fdd</id>
<content type='text'>
The only mention of this field in the code is by some
debugging code which prints it out (and it will always be
zero, since we never touch it otherwise). It was obsoleted
very early on by 25d5ea4 ([PATCH] Redo rename/copy detection
logic., 2005-05-24).

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_filespec: drop funcname_pattern_ident field</title>
<updated>2014-01-17T18:50:10Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2014-01-17T01:20:11Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=5b711b207fe78de59ebcba70e16886bffaffc73c'/>
<id>urn:sha1:5b711b207fe78de59ebcba70e16886bffaffc73c</id>
<content type='text'>
This struct field was obsoleted by be58e70 (diff: unify
external diff and funcname parsing code, 2008-10-05), but we
forgot to remove it.

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_filespec: reorder dirty_submodule macro definitions</title>
<updated>2014-01-17T18:50:03Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2014-01-17T01:19:46Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=b837f5d68da391f3a54817bb04f1e7ec04f9cdac'/>
<id>urn:sha1:b837f5d68da391f3a54817bb04f1e7ec04f9cdac</id>
<content type='text'>
diff_filespec has a 2-bit "dirty_submodule" field and
defines two flags as macros. Originally these were right
next to each other, but a new field was accidentally added
in between in commit 4682d85. This patch puts the field and
its flags back together.

Using an enum like:

  enum {
	  DIRTY_SUBMODULE_UNTRACKED = 1,
	  DIRTY_SUBMODULE_MODIFIED = 2
  } dirty_submodule;

would be more obvious, but it bloats the structure. Limiting
the enum size like:

  } dirty_submodule : 2;

might work, but it is not portable.

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/maint-null-in-trees'</title>
<updated>2012-08-27T18:54:28Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2012-08-27T18:54:28Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=3b753148b636be9dc821feebf85cd7f1739b07a1'/>
<id>urn:sha1:3b753148b636be9dc821feebf85cd7f1739b07a1</id>
<content type='text'>
We do not want a link to 0{40} object stored anywhere in our objects.

* jk/maint-null-in-trees:
  fsck: detect null sha1 in tree entries
  do not write null sha1s to on-disk index
  diff: do not use null sha1 as a sentinel value
</content>
</entry>
<entry>
<title>diff: do not use null sha1 as a sentinel value</title>
<updated>2012-07-29T22:04:32Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2012-07-28T15:03:01Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=e54501004abbd20fa8d813c1e5b82c3b50bb9361'/>
<id>urn:sha1:e54501004abbd20fa8d813c1e5b82c3b50bb9361</id>
<content type='text'>
The diff code represents paths using the diff_filespec
struct. This struct has a sha1 to represent the sha1 of the
content at that path, as well as a sha1_valid member which
indicates whether its sha1 field is actually useful. If
sha1_valid is not true, then the filespec represents a
working tree file (e.g., for the no-index case, or for when
the index is not up-to-date).

The diff_filespec is only used internally, though. At the
interfaces to the diff subsystem, callers feed the sha1
directly, and we create a diff_filespec from it. It's at
that point that we look at the sha1 and decide whether it is
valid or not; callers may pass the null sha1 as a sentinel
value to indicate that it is not.

We should not typically see the null sha1 coming from any
other source (e.g., in the index itself, or from a tree).
However, a corrupt tree might have a null sha1, which would
cause "diff --patch" to accidentally diff the working tree
version of a file instead of treating it as a blob.

This patch extends the edges of the diff interface to accept
a "sha1_valid" flag whenever we accept a sha1, and to use
that flag when creating a filespec. In some cases, this
means passing the flag through several layers, making the
code change larger than would be desirable.

One alternative would be to simply die() upon seeing
corrupted trees with null sha1s. However, this fix more
directly addresses the problem (while bogus sha1s in a tree
are probably a bad thing, it is really the sentinel
confusion sending us down the wrong code path that is what
makes it devastating). And it means that git is more capable
of examining and debugging these corrupted trees. For
example, you can still "diff --raw" such a tree to find out
when the bogus entry was introduced; you just cannot do a
"--patch" diff (just as you could not with any other
corrupted tree, as we do not have any content to diff).

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 'jc/refactor-diff-stdin'</title>
<updated>2012-07-13T22:38:05Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2012-07-13T22:38:05Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=d7afe648dcb188557173c239a337e123ec22cd1b'/>
<id>urn:sha1:d7afe648dcb188557173c239a337e123ec22cd1b</id>
<content type='text'>
Due to the way "git diff --no-index" is bolted onto by touching the
low level code that is shared with the rest of the "git diff" code,
even though it has to work in a very different way, any comparison
that involves a file "-" at the root level incorrectly tried to read
from the standard input.  This cleans up the no-index codepath
further to remove code that reads from the standard input from the
core side, which is never necessary when git is running its usual
diff operation.

* jc/refactor-diff-stdin:
  diff-index.c: "git diff" has no need to read blob from the standard input
  diff-index.c: unify handling of command line paths
  diff-index.c: do not pretend paths are pathspecs
</content>
</entry>
</feed>
