Skip to content

Commit

Permalink
rev-list: default to abbreviate merge parent names under --pretty.
Browse files Browse the repository at this point in the history
When we prettyprint commit log messages, merge parent names were
often very long and there was no way to abbreviate it.

This changes them to be abbreviated by default, and non-default
abbreviations can be specified with --no-abbrev or --abbrev=<n>
options.

Note that this affects only the prettyprinted parent names.  The
output from --show-parents is meant for machine consumption and
is not affected by this flag.
  • Loading branch information
Junio C Hamano committed Feb 10, 2006
1 parent 39556fb commit 9da5c2f
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion rev-list.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ static const char rev_list_usage[] =
" --objects\n"
" --unpacked\n"
" --header | --pretty\n"
" --abbrev=nr | --no-abbrev\n"
" special purpose:\n"
" --bisect"
;
Expand All @@ -43,6 +44,7 @@ static int tag_objects = 0;
static int tree_objects = 0;
static int blob_objects = 0;
static int verbose_header = 0;
static int abbrev = DEFAULT_ABBREV;
static int show_parents = 0;
static int hdr_termination = 0;
static const char *commit_prefix = "";
Expand Down Expand Up @@ -96,7 +98,7 @@ static void show_commit(struct commit *commit)

if (verbose_header) {
static char pretty_header[16384];
pretty_print_commit(commit_format, commit, ~0, pretty_header, sizeof(pretty_header), 0);
pretty_print_commit(commit_format, commit, ~0, pretty_header, sizeof(pretty_header), abbrev);
printf("%s%c", pretty_header, hdr_termination);
}
fflush(stdout);
Expand Down Expand Up @@ -795,6 +797,18 @@ int main(int argc, const char **argv)
verbose_header = 1;
continue;
}
if (!strcmp(arg, "--no-abbrev")) {
abbrev = 0;
continue;
}
if (!strncmp(arg, "--abbrev=", 9)) {
abbrev = strtoul(arg + 9, NULL, 10);
if (abbrev && abbrev < MINIMUM_ABBREV)
abbrev = MINIMUM_ABBREV;
else if (40 < abbrev)
abbrev = 40;
continue;
}
if (!strncmp(arg, "--pretty", 8)) {
commit_format = get_commit_format(arg+8);
verbose_header = 1;
Expand Down

0 comments on commit 9da5c2f

Please sign in to comment.