Re: [RFC] diff-cache buglet

From: Junio C Hamano <junkio@cox.net>
Date: 2005-04-27 04:56:05
>>>>> "LT" == Linus Torvalds <torvalds@osdl.org> writes:

LT> On Tue, 26 Apr 2005, Junio C Hamano wrote:
>> 
>> Well, I somehow thought these things are in fixed column format;
>> mode, ->, sha, stage, and filename are all seperated with either
>> ' ' or '\t'.  So if I copy MN to "1 MN", presumably you would
>> see this:
>> 
>> 100644 a716d58de4a570e0038f5c307bd8db34daea021f 0 MN
>> 100644 a716d58de4a570e0038f5c307bd8db34daea021f 0 1 MN
>> 
>> So while I agree that // would also work, I fail to see why you
>> would even need that.

LT> Because I'd rather _not_ have the 0 in there at all for the normal case.

LT> Yes, it's there for "show-files --stages", but it's certainly _not_ there 
LT> in "diff-tree" output right now.

I know.  But first let's step back a bit.

Running diff-cache when you have unmerged entries in your
GIT_INDEX_FILE is fundamentally broken.  You first read_cache(),
and then you read-tree into stage 1 of the named tree, and at
that point, you do not know what stage 1 means.

We should just fix "remove-merge-entries" and call that
unconditionally before the read-tree is called.  Once it is
fixed, we need to think about how to show this stage
information but that should be a separate discussion.

I have attached two versions of patch.  The first one is against
the original before my stupid question; the second one is
against the one if you applied my previous patch, to revert most
of its stupidity.

################################################################
--- Patch against the original before I asked that stupid question:

cd /opt/packrat/playpen/public/in-place/git/git.junio/
jit-snap -v 0
--- k/diff-cache.c
+++ l/diff-cache.c
@@ -76,7 +76,7 @@ static void remove_merge_entries(void)
 	for (i = 0; i < active_nr; i++) {
 		struct cache_entry *ce = active_cache[i];
 		if (!ce_stage(ce))
-			break;
+			continue;
 		printf("%s: unmerged\n", ce->name);
 		while (remove_entry_at(i)) {
 			if (!ce_stage(active_cache[i]))


################################################################
--- Patch to revert the stupidity:
cd /opt/packrat/playpen/public/in-place/git/git.junio/
jit-snap -v 2
--- k/diff-cache.c
+++ l/diff-cache.c
@@ -1,6 +1,5 @@
 #include "cache.h"
 
-static int leave_unmerged = 0;
 static int cached_only = 0;
 static int line_termination = '\n';
 
@@ -86,8 +85,7 @@ static void remove_merge_entries(void)
 	}
 }
 
-static char *diff_cache_usage =
-"diff-cache [-r] [-z] [--cached] [--unmerged] <tree sha1>";
+static char *diff_cache_usage = "diff-cache [-r] [-z] [--cached] <tree sha1>";
 
 int main(int argc, char **argv)
 {
@@ -112,18 +110,13 @@ int main(int argc, char **argv)
 			cached_only = 1;
 			continue;
 		}
-		if (!strcmp(arg, "--unmerged")) {
-			leave_unmerged = 1;
-			continue;
-		}
 		usage(diff_cache_usage);
 	}
 
 	if (argc != 2 || get_sha1_hex(argv[1], tree_sha1))
 		usage(diff_cache_usage);
 
-	if (!leave_unmerged)
-		remove_merge_entries();
+	remove_merge_entries();
 
 	tree = read_tree_with_tree_or_commit_sha1(tree_sha1, &size, 0);
 	if (!tree)

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Received on Wed Apr 27 04:56:48 2005

This archive was generated by hypermail 2.1.8 : 2005-04-27 04:56:48 EST