Skip to content

Commit df87381

Browse files
avargitster
authored andcommitted
doc txt & -h consistency: make "annotate" consistent
The cmd_blame() already detected whether it was processing "blame" or "annotate", but it didn't adjust its usage output accordingly. Let's do that. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 951ec74 commit df87381

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

Documentation/git-annotate.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ git-annotate - Annotate file lines with commit information
88
SYNOPSIS
99
--------
1010
[verse]
11-
'git annotate' [<options>] <file> [<revision>]
11+
'git annotate' [<options>] [<rev-opts>] [<rev>] [--] <file>
1212

1313
DESCRIPTION
1414
-----------

builtin/blame.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "tag.h"
3131

3232
static char blame_usage[] = N_("git blame [<options>] [<rev-opts>] [<rev>] [--] <file>");
33+
static char annotate_usage[] = N_("git annotate [<options>] [<rev-opts>] [<rev>] [--] <file>");
3334

3435
static const char *blame_opt_usage[] = {
3536
blame_usage,
@@ -38,6 +39,13 @@ static const char *blame_opt_usage[] = {
3839
NULL
3940
};
4041

42+
static const char *annotate_opt_usage[] = {
43+
annotate_usage,
44+
"",
45+
N_("<rev-opts> are documented in git-rev-list(1)"),
46+
NULL
47+
};
48+
4149
static int longest_file;
4250
static int longest_author;
4351
static int max_orig_digits;
@@ -899,6 +907,8 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
899907
long anchor;
900908
const int hexsz = the_hash_algo->hexsz;
901909
long num_lines = 0;
910+
const char *str_usage = cmd_is_annotate ? annotate_usage : blame_usage;
911+
const char **opt_usage = cmd_is_annotate ? annotate_opt_usage : blame_opt_usage;
902912

903913
setup_default_color_by_age();
904914
git_config(git_blame_config, &output_option);
@@ -914,7 +924,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
914924
parse_options_start(&ctx, argc, argv, prefix, options,
915925
PARSE_OPT_KEEP_DASHDASH | PARSE_OPT_KEEP_ARGV0);
916926
for (;;) {
917-
switch (parse_options_step(&ctx, options, blame_opt_usage)) {
927+
switch (parse_options_step(&ctx, options, opt_usage)) {
918928
case PARSE_OPT_NON_OPTION:
919929
case PARSE_OPT_UNKNOWN:
920930
break;
@@ -934,7 +944,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
934944
ctx.argv[0] = "--children";
935945
reverse = 1;
936946
}
937-
parse_revision_opt(&revs, &ctx, options, blame_opt_usage);
947+
parse_revision_opt(&revs, &ctx, options, opt_usage);
938948
}
939949
parse_done:
940950
revision_opts_finish(&revs);
@@ -1040,7 +1050,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
10401050
switch (argc - dashdash_pos - 1) {
10411051
case 2: /* (1b) */
10421052
if (argc != 4)
1043-
usage_with_options(blame_opt_usage, options);
1053+
usage_with_options(opt_usage, options);
10441054
/* reorder for the new way: <rev> -- <path> */
10451055
argv[1] = argv[3];
10461056
argv[3] = argv[2];
@@ -1051,11 +1061,11 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
10511061
argv[argc] = NULL;
10521062
break;
10531063
default:
1054-
usage_with_options(blame_opt_usage, options);
1064+
usage_with_options(opt_usage, options);
10551065
}
10561066
} else {
10571067
if (argc < 2)
1058-
usage_with_options(blame_opt_usage, options);
1068+
usage_with_options(opt_usage, options);
10591069
if (argc == 3 && is_a_rev(argv[argc - 1])) { /* (2b) */
10601070
path = add_prefix(prefix, argv[1]);
10611071
argv[1] = argv[2];
@@ -1113,7 +1123,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
11131123
nth_line_cb, &sb, lno, anchor,
11141124
&bottom, &top, sb.path,
11151125
the_repository->index))
1116-
usage(blame_usage);
1126+
usage(str_usage);
11171127
if ((!lno && (top || bottom)) || lno < bottom)
11181128
die(Q_("file %s has only %lu line",
11191129
"file %s has only %lu lines",

0 commit comments

Comments
 (0)