diff options
author | Junio C Hamano <gitster@pobox.com> | 2016-04-13 14:12:36 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-04-13 14:12:36 -0700 |
commit | cafef3d7ad3ed58d9c976bdeb604cff6b4c1f82b (patch) | |
tree | f16d708c5ce5391423a4747535bac46bbfb1c860 /revision.c | |
parent | 7c137bb5316fbd82e816c2dabebc1d347261c93e (diff) | |
parent | 915c96df3822f968332f6bf3642e5195b52201c9 (diff) | |
download | git-cafef3d7ad3ed58d9c976bdeb604cff6b4c1f82b.tar.gz |
Merge branch 'lt/pretty-expand-tabs'
When "git log" shows the log message indented by 4-spaces, the
remainder of a line after a HT does not align in the way the author
originally intended. The command now expands tabs by default in
such a case, and allows the users to override it with a new option,
'--no-expand-tabs'.
* lt/pretty-expand-tabs:
pretty: test --expand-tabs
pretty: allow tweaking tabwidth in --expand-tabs
pretty: enable --expand-tabs by default for selected pretty formats
pretty: expand tabs in indented logs to make things line up properly
Diffstat (limited to 'revision.c')
-rw-r--r-- | revision.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/revision.c b/revision.c index 8b2dfe3160..b683476b9c 100644 --- a/revision.c +++ b/revision.c @@ -1356,8 +1356,10 @@ void init_revisions(struct rev_info *revs, const char *prefix) revs->skip_count = -1; revs->max_count = -1; revs->max_parents = -1; + revs->expand_tabs_in_log = -1; revs->commit_format = CMIT_FMT_DEFAULT; + revs->expand_tabs_in_log_default = 8; init_grep_defaults(); grep_init(&revs->grep_filter, prefix); @@ -1854,6 +1856,15 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg revs->verbose_header = 1; revs->pretty_given = 1; get_commit_format(arg+9, revs); + } else if (!strcmp(arg, "--expand-tabs")) { + 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; @@ -2327,6 +2338,9 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s if (revs->first_parent_only && revs->bisect) die(_("--first-parent is incompatible with --bisect")); + if (revs->expand_tabs_in_log < 0) + revs->expand_tabs_in_log = revs->expand_tabs_in_log_default; + return left; } |