Git development
 help / color / mirror / Atom feed
* [RFC] diff-cache buglet
@ 2005-04-26 16:51 Junio C Hamano
  2005-04-26 17:11 ` Linus Torvalds
  0 siblings, 1 reply; 9+ messages in thread
From: Junio C Hamano @ 2005-04-26 16:51 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: git

Linus,

	what do you want diff-cache to do upon finding an
unmerged path?  Currently your code says "undecided" to me.

The main() attempts to first remove all merge entries before
letting the diff_cache() do its work, but the diff_cache()
itself has also some code to deal with unmerged entries.

In the attached patch, the second hunk starting at ll 76 is a
pure and obvious bugfix.  The function is attempting to remove
all merge entries, but it stops in the middle; that's why I said
"attempts" in the above.

The patch lets you have it in both ways by adding --unmerged
flag.  Without it, unmerged entries are culled at the beginning;
with it, you will see diffs for all unmerged stages.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---

jit-snap -v 0
--- k/diff-cache.c
+++ l/diff-cache.c
@@ -1,5 +1,6 @@
 #include "cache.h"
 
+static int leave_unmerged = 0;
 static int cached_only = 0;
 static int line_termination = '\n';
 
@@ -76,7 +77,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]))
@@ -85,7 +86,8 @@ static void remove_merge_entries(void)
 	}
 }
 
-static char *diff_cache_usage = "diff-cache [-r] [-z] [--cached] <tree sha1>";
+static char *diff_cache_usage =
+"diff-cache [-r] [-z] [--cached] [--unmerged] <tree sha1>";
 
 int main(int argc, char **argv)
 {
@@ -110,13 +112,18 @@ 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);
 
-	remove_merge_entries();
+	if (!leave_unmerged)
+		remove_merge_entries();
 
 	tree = read_tree_with_tree_or_commit_sha1(tree_sha1, &size, 0);
 	if (!tree)




^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2005-04-26 20:30 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-04-26 16:51 [RFC] diff-cache buglet Junio C Hamano
2005-04-26 17:11 ` Linus Torvalds
2005-04-26 17:56   ` Junio C Hamano
2005-04-26 18:06     ` Linus Torvalds
2005-04-26 18:22       ` Junio C Hamano
2005-04-26 18:38         ` Linus Torvalds
2005-04-26 18:56           ` Junio C Hamano
2005-04-26 19:09             ` Linus Torvalds
2005-04-26 20:34               ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox