pretty: allow tweaking tabwidth in --expand-tabs

When the local convention of the project is to use tab width that is
not 8, it may make sense to allow "git log --expand-tabs=<n>" to
tweak the output to match it.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Junio C Hamano
2016-03-29 16:05:39 -07:00
parent 0893eec85f
commit fe37a9c586
4 changed files with 22 additions and 13 deletions

View File

@ -1415,7 +1415,7 @@ void init_revisions(struct rev_info *revs, const char *prefix)
revs->expand_tabs_in_log = -1;
revs->commit_format = CMIT_FMT_DEFAULT;
revs->expand_tabs_in_log_default = 1;
revs->expand_tabs_in_log_default = 8;
init_grep_defaults();
grep_init(&revs->grep_filter, prefix);
@ -1918,9 +1918,14 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
revs->pretty_given = 1;
get_commit_format(arg+9, revs);
} else if (!strcmp(arg, "--expand-tabs")) {
revs->expand_tabs_in_log = 1;
revs->expand_tabs_in_log = 8;
} else if (!strcmp(arg, "--no-expand-tabs")) {
revs->expand_tabs_in_log = 0;
} else if (skip_prefix(arg, "--expand-tabs=", &arg)) {
int val;
if (strtol_i(arg, 10, &val) < 0 || val < 0)
die("'%s': not a non-negative integer", arg);
revs->expand_tabs_in_log = val;
} else if (!strcmp(arg, "--show-notes") || !strcmp(arg, "--notes")) {
revs->show_notes = 1;
revs->show_notes_given = 1;