Git development
 help / color / mirror / Atom feed
From: Junio C Hamano <junkio@cox.net>
To: Linus Torvalds <torvalds@osdl.org>
Cc: git@vger.kernel.org
Subject: [RFC] diff-cache buglet
Date: Tue, 26 Apr 2005 09:51:41 -0700	[thread overview]
Message-ID: <7v7jippjky.fsf@assigned-by-dhcp.cox.net> (raw)

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)




             reply	other threads:[~2005-04-26 16:49 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-26 16:51 Junio C Hamano [this message]
2005-04-26 17:11 ` [RFC] diff-cache buglet 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

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

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

  git send-email \
    --in-reply-to=7v7jippjky.fsf@assigned-by-dhcp.cox.net \
    --to=junkio@cox.net \
    --cc=git@vger.kernel.org \
    --cc=torvalds@osdl.org \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox