Skip to content

Commit 7ceacdf

Browse files
committed
"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>
1 parent f88d225 commit 7ceacdf

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

builtin-blame.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ static int show_root;
3838
static int reverse;
3939
static int blank_boundary;
4040
static int incremental;
41-
static int cmd_is_annotate;
4241
static int xdl_opts = XDF_NEED_MINIMAL;
4342
static struct string_list mailmap;
4443

@@ -1686,7 +1685,7 @@ static void emit_other(struct scoreboard *sb, struct blame_entry *ent, int opt)
16861685
if (suspect->commit->object.flags & UNINTERESTING) {
16871686
if (blank_boundary)
16881687
memset(hex, ' ', length);
1689-
else if (!cmd_is_annotate) {
1688+
else if (!(opt & OUTPUT_ANNOTATE_COMPAT)) {
16901689
length--;
16911690
putchar('^');
16921691
}
@@ -2317,8 +2316,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
23172316
};
23182317

23192318
struct parse_opt_ctx_t ctx;
2320-
2321-
cmd_is_annotate = !strcmp(argv[0], "annotate");
2319+
int cmd_is_annotate = !strcmp(argv[0], "annotate");
23222320

23232321
git_config(git_blame_config, NULL);
23242322
init_revisions(&revs, NULL);
@@ -2346,6 +2344,9 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
23462344
parse_done:
23472345
argc = parse_options_end(&ctx);
23482346

2347+
if (cmd_is_annotate)
2348+
output_option |= OUTPUT_ANNOTATE_COMPAT;
2349+
23492350
if (DIFF_OPT_TST(&revs.diffopt, FIND_COPIES_HARDER))
23502351
opt |= (PICKAXE_BLAME_COPY | PICKAXE_BLAME_MOVE |
23512352
PICKAXE_BLAME_COPY_HARDER);

t/t9400-git-cvsserver-server.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,4 +488,17 @@ test_expect_success 'cvs co -c (shows module database)' '
488488
! grep -v "^master[ ]\+master$" < out
489489
'
490490

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+
491504
test_done

0 commit comments

Comments
 (0)