[RFC] diff-cache buglet
- From
Junio C Hamano <junkio@cox.net>
- Date
- Apr 26, 2005, 16:51 UTC
- Message-ID
- <7v7jippjky.fsf@assigned-by-dhcp.cox.net>
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)