<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/diff-no-index.c, branch v1.8.2.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v1.8.2.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v1.8.2.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2012-08-27T18:54:28Z</updated>
<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://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>Merge branch 'tr/void-diff-setup-done'</title>
<updated>2012-08-22T18:52:27Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2012-08-22T18:52:26Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=9cd33bbc529bfa830c687d377433c46474d10e6a'/>
<id>urn:sha1:9cd33bbc529bfa830c687d377433c46474d10e6a</id>
<content type='text'>
Remove unnecessary code.

* tr/void-diff-setup-done:
  diff_setup_done(): return void
</content>
</entry>
<entry>
<title>diff_setup_done(): return void</title>
<updated>2012-08-03T19:11:07Z</updated>
<author>
<name>Thomas Rast</name>
<email>trast@student.ethz.ch</email>
</author>
<published>2012-08-03T12:16:24Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=28452655af988094792483a51d188c58137760cd'/>
<id>urn:sha1:28452655af988094792483a51d188c58137760cd</id>
<content type='text'>
diff_setup_done() has historically returned an error code, but lost
the last nonzero return in 943d5b7 (allow diff.renamelimit to be set
regardless of -M/-C, 2006-08-09).  The callers were in a pretty
confused state: some actually checked for the return code, and some
did not.

Let it return void, and patch all callers to take this into account.
This conveniently also gets rid of a handful of different(!) error
messages that could never be triggered anyway.

Note that the function can still die().

Signed-off-by: Thomas Rast &lt;trast@student.ethz.ch&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</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://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://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>
<entry>
<title>Merge branch 'th/diff-no-index-fixes'</title>
<updated>2012-07-05T06:40:38Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2012-07-05T06:40:38Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=60ad08bfdfe393fd86391e2f9e60e8ffccc78e5b'/>
<id>urn:sha1:60ad08bfdfe393fd86391e2f9e60e8ffccc78e5b</id>
<content type='text'>
"git diff --no-index" did not correctly handle relative paths and
did not give correct exit codes when run under "--quiet" option.

* th/diff-no-index-fixes:
  diff-no-index: exit(1) if 'diff --quiet &lt;repo file&gt; &lt;external file&gt;' finds changes
  diff: handle relative paths in no-index
</content>
</entry>
<entry>
<title>diff-index.c: "git diff" has no need to read blob from the standard input</title>
<updated>2012-06-28T23:18:19Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2012-06-28T03:14:47Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=4682d8521c3ce9d722bd214fd7d5fc92063fdacb'/>
<id>urn:sha1:4682d8521c3ce9d722bd214fd7d5fc92063fdacb</id>
<content type='text'>
Only "diff --no-index -" does.  Bolting the logic into the low-level
function diff_populate_filespec() was a layering violation from day
one.  Move populate_from_stdin() function out of the generic diff.c
to its only user, diff-index.c.

Also make sure "-" from the command line stays a special token "read
from the standard input", even if we later decide to sanitize the
result from prefix_filename() function in a few obvious ways,
e.g. removing unnecessary "./" prefix, duplicated slashes "//" in
the middle, etc.

Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>diff-index.c: unify handling of command line paths</title>
<updated>2012-06-28T23:09:40Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2012-06-27T19:05:52Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=3b069b1beba6d851401032260a8030448637ece5'/>
<id>urn:sha1:3b069b1beba6d851401032260a8030448637ece5</id>
<content type='text'>
Regardless of where in the directory hierarchy you are, "-" on the
command line means the standard input.  The old code knew too much
about how the low level machinery uses paths to read from the
working tree and did not bother to have the same check for "-" when
the command is run from the top-level.

Unify the codepaths for subdirectory case and toplevel case into one
and make it clearer.

Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>diff-index.c: do not pretend paths are pathspecs</title>
<updated>2012-06-28T23:09:40Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2012-06-27T18:51:15Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=c20f592611c2760a14d37fa1780afd2093159aeb'/>
<id>urn:sha1:c20f592611c2760a14d37fa1780afd2093159aeb</id>
<content type='text'>
"git diff --no-index" takes exactly two paths, not pathspecs, and
has its own way queue_diff() to populate the diff_queue.  Do not
call diff_tree_setup_paths(), pretending as it takes pathspecs.

Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>diff-no-index: exit(1) if 'diff --quiet &lt;repo file&gt; &lt;external file&gt;' finds changes</title>
<updated>2012-06-22T17:26:13Z</updated>
<author>
<name>Tim Henigan</name>
<email>tim.henigan@gmail.com</email>
</author>
<published>2012-06-21T18:09:51Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=304970dd5d9e542e70eca98932c1e9f26770678e'/>
<id>urn:sha1:304970dd5d9e542e70eca98932c1e9f26770678e</id>
<content type='text'>
When running 'git diff --quiet &lt;file1&gt; &lt;file2&gt;', if file1 or file2
is outside the repository, it will exit(0) even if the files differ.
It should exit(1) when they differ.

This happens because 'diff_no_index' looks at the 'found_changes'
member from 'diff_options' to determine if changes were made.  This
is the wrong thing to do, since it is only set if xdiff is actually
run and it finds a change (the diff machinery will optimize out the
xdiff call when it is not necessary) and in that case HAS_CHANGED
flag needs to be taken into account.

Use diff_result_code() that knows all these details for the correct
exit value instead.

Signed-off-by: Tim Henigan &lt;tim.henigan@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
