@matheusbsbs / matheus-bagliano / commits / 7ceacdffc5
Fork 0

"blame -c" should be compatible with "annotate"

There is no reason to have a separate variable cmd_is_annotate; OUTPUT_ANNOTATE_COMPAT option is supposed to produce the compatibility output, and we should produce the same output even when the command was not invoked as "annotate" but as "blame -c". Noticed by Pasky. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Sep 5, 2008 at 00:57 UTC 7ceacdffc5c05f9a763b4cb6ea7cb528004643c3
2 files changed +18 -4
builtin-blame.c
+5 -4
@@ -38,7 +38,6 @@ static int show_root;
38 static int reverse;
39 static int blank_boundary;
40 static int incremental;
41 -static int cmd_is_annotate;
41 static int xdl_opts = XDF_NEED_MINIMAL;
42 static struct string_list mailmap;
43
@@ -1686,7 +1685,7 @@ static void emit_other(struct scoreboard *sb, struct blame_entry *ent, int opt)
1685 if (suspect->commit->object.flags & UNINTERESTING) {
1686 if (blank_boundary)
1687 memset(hex, ' ', length);
1689 - else if (!cmd_is_annotate) {
1688 + else if (!(opt & OUTPUT_ANNOTATE_COMPAT)) {
1689 length--;
1690 putchar('^');
1691 }
@@ -2317,8 +2316,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
2316 };
2317
2318 struct parse_opt_ctx_t ctx;
2320 -
2321 - cmd_is_annotate = !strcmp(argv[0], "annotate");
2319 + int cmd_is_annotate = !strcmp(argv[0], "annotate");
2320
2321 git_config(git_blame_config, NULL);
2322 init_revisions(&revs, NULL);
@@ -2346,6 +2344,9 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
2344 parse_done:
2345 argc = parse_options_end(&ctx);
2346
2347 + if (cmd_is_annotate)
2348 + output_option |= OUTPUT_ANNOTATE_COMPAT;
2349 +
2350 if (DIFF_OPT_TST(&revs.diffopt, FIND_COPIES_HARDER))
2351 opt |= (PICKAXE_BLAME_COPY | PICKAXE_BLAME_MOVE |
2352 PICKAXE_BLAME_COPY_HARDER);
t/t9400-git-cvsserver-server.sh
+13
@@ -488,4 +488,17 @@ test_expect_success 'cvs co -c (shows module database)' '
488 ! grep -v "^master[ ]\+master$" < out
489 '
490
491 +#------------
492 +# CVS ANNOTATE
493 +#------------
494 +
495 +cd "$WORKDIR"
496 +test_expect_success 'cvs annotate' '
497 + cd cvswork &&
498 + GIT_CONFIG="$git_config" cvs annotate merge >../out &&
499 + sed -e "s/ .*//" ../out >../actual &&
500 + for i in 3 1 1 1 1 1 1 1 2 4; do echo 1.$i; done >../expect &&
501 + test_cmp ../expect ../actual
502 +'
503 +
504 test_done