git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: Steffen Prohaska <prohaska@zib.de>,
	Junio C Hamano <gitster@pobox.com>,
	Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH] Also use unpack_trees() in do_diff_cache()
Date: Sun, 20 Jan 2008 12:32:56 -0800 (PST)	[thread overview]
Message-ID: <alpine.LFD.1.00.0801201144300.2957@woody.linux-foundation.org> (raw)
In-Reply-To: <alpine.LSU.1.00.0801201519320.5731@racer.site>



On Sun, 20 Jan 2008, Johannes Schindelin wrote:
> 
> As in run_diff_index(), we call unpack_trees() with the oneway_diff()
> function in do_diff_cache() now.  This makes the function diff_cache()
> obsolete.

Sadly, this doesn't work yet.

diiff_cache() does magic things with different stages. 

The new unpack_trees() model *should* make it possible to do an even 
better job at this (we should really approximate the diff_files() 
behaviour), but oneway_diff() currently doesn't do it right.

Try

	git diff-index [-p] [--cached] -m HEAD

in a tree with unmerged entries (or just "git diff HEAD", which does the 
same thing).

The following patch gets us closer, but really only for the "--cached" 
case (for the non-cached case, it should use the working tree entry ratehr 
than generate a unmerged entry), and I also suspect there's a case it gets 
wrong for the case of the unmerged path not existign in the tree at all 
(the "if (tree)" entry basically ends up being a stand-in for the "is this 
the first index entry for this path we see" case).

The really nice thing would be to do what "diff_files()" does for this 
all, something that the old model couldn't do at all (that's why it 
currently prints out that "* Unmerged path xyzzy" thing - the *correct* 
thing to do would be to generate the same combined diff that diff_files() 
does).

So some more work is needed - either to get back the old (arguably 
quite broken) behaviour, or to go the whole way and do it right.

Anyway, my point with this all is that even without any of this set of 
fixes, git doesn't do this optimally. Try this with the current stable git 
master:

	git diff --cached HEAD

with a unmerged file, and compare it to the much more useful "git diff" 
output. But right now, this patch series makes this case behave even 
worse, I think.

		Linus

---
 diff-lib.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/diff-lib.c b/diff-lib.c
index 23d0fa6..3ac4d1f 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -685,6 +685,12 @@ static int oneway_diff(struct cache_entry **src,
 	if (tree == o->df_conflict_entry)
 		tree = NULL;
 
+	if (ce_stage(idx)) {
+		if (tree)
+			diff_unmerge(&revs->diffopt, idx->name, idx->ce_mode, idx->sha1);
+		return 1;
+	}
+
 	/*
 	 * Something added to the tree?
 	 */

  reply	other threads:[~2008-01-20 20:33 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-19  3:25 Updated in-memory index cleanup Linus Torvalds
2008-01-19  7:42 ` [PATCH] index: be careful when handling long names Junio C Hamano
2008-01-19  7:45 ` [PATCH] Avoid running lstat(2) on the same cache entry Junio C Hamano
2008-01-19 19:47   ` Linus Torvalds
2008-01-19 19:58     ` Linus Torvalds
2008-01-20  1:22     ` Linus Torvalds
2008-01-20  1:34       ` Linus Torvalds
2008-01-20  1:48       ` Johannes Schindelin
2008-01-20  2:02         ` Linus Torvalds
2008-01-20 10:33         ` Steffen Prohaska
2008-01-20 14:15           ` Johannes Schindelin
2008-01-21  0:18           ` Junio C Hamano
2008-01-20 15:10         ` Steffen Prohaska
2008-01-20 15:18           ` Johannes Schindelin
2008-01-20 15:19             ` [PATCH] Also use unpack_trees() in do_diff_cache() Johannes Schindelin
2008-01-20 20:32               ` Linus Torvalds [this message]
2008-01-20 21:53                 ` Linus Torvalds
2008-01-20 23:34                   ` Johannes Schindelin
2008-01-20 23:58                     ` Linus Torvalds
2008-01-21  0:19                       ` Johannes Schindelin
2008-01-20 15:21             ` [PATCH] Try to resurrect the handling for 'diff-index -m' Johannes Schindelin
2008-01-20 18:20           ` [PATCH] Avoid running lstat(2) on the same cache entry Linus Torvalds
2008-01-20 20:03             ` Brian Downing
2008-01-20 21:40             ` Steffen Prohaska
2008-01-20 22:09               ` Linus Torvalds
2008-01-20  2:42       ` Johannes Schindelin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LFD.1.00.0801201144300.2957@woody.linux-foundation.org \
    --to=torvalds@linux-foundation.org \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=prohaska@zib.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).