git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [RFC] diff-cache buglet

From
Junio C Hamano <junkio@cox.net>
Date
Apr 26, 2005, 18:56 UTC
Message-ID
<7vk6mpnz96.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<Pine.LNX.4.58.0504261137350.18901@ppc970.osdl.org>
>>>>> "LT" == Linus Torvalds <torvalds@osdl.org> writes:
LT> On Tue, 26 Apr 2005, Junio C Hamano wrote:
Show 11 quoted lines
>> 
>> 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)
Previous: Linus TorvaldsNext: Linus Torvalds
Message 7 of 9 in “[RFC] diff-cache buglet”
  1. Junio C HamanoApr 26, 2005
  2. Linus TorvaldsApr 26, 2005
  3. Junio C HamanoApr 26, 2005
  4. Linus TorvaldsApr 26, 2005
  5. Junio C HamanoApr 26, 2005
  6. Linus TorvaldsApr 26, 2005
  7. Junio C HamanoApr 26, 2005
  8. Linus TorvaldsApr 26, 2005
  9. Junio C HamanoApr 26, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.