commit -v: add --word-diff opt to commit template
PATCH 1/1 commit -v: add --word-diff opt to commit template
From: kraktus <[email protected]>
--word-diff was available for the diff command, but not for the commit one, whereas it is very useful when updating column-based data-format like CSV for example.
Only support the PORCELAIN mode for now, but if deemed necessary can add plain too, I don't think COLOR makes sense when outputting a file.
---
commit -v: add --word-diff opt to commit template
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2276%2Fkraktus%2Fgdiff_word_commit-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2276/kraktus/gdiff_word_commit-v1
Pull-Request: https://github.com/git/git/pull/2276
Documentation/git-commit.adoc | 4 ++++ builtin/commit.c | 4 ++++ t/t7507-commit-verbose.sh | 45 +++++++++++++++++++++++++++++++++++ wt-status.c | 2 ++ wt-status.h | 1 + 5 files changed, 56 insertions(+)
Documentation/git-commit.adoc +4 -0
@@ -371,6 +371,10 @@ If specified twice, show in addition the unified diff between what would be committed and the worktree files, i.e. the unstaged changes to tracked files. +`--word-diff`:: + Show a word diff instead of a line diff in the verbose commit + template (requires `-v`). + `-q`:: `--quiet`:: Suppress commit summary message.
builtin/commit.c +4 -0
@@ -126,6 +126,7 @@ static int all, also, interactive, patch_interactive, only, amend, signoff;static struct interactive_options interactive_opts =INTERACTIVE_OPTIONS_INIT ;static int edit_flag =-1 ;/* unspecified */ static int quiet, verbose, no_verify, allow_empty, dry_run, renew_authorship; +static int commit_word_diff;static int config_commit_verbose =-1 ;/* unspecified */ static int no_post_rewrite, allow_empty_message, pathspec_file_nul;static const char *untracked_files_arg, *force_date, *ignore_submodule_arg, *ignored_arg;
@@ -573,6 +574,7 @@ static int run_status(FILE *fp, const char *index_file, const char *prefix, int s->reference ="HEAD^1" ; } s->verbose = verbose; + s->word_diff = commit_word_diff; s->index_file = index_file; s->fp = fp; s->nowarn = nowarn;
@@ -1705,6 +1707,8 @@ int cmd_commit(int argc,static struct option builtin_commit_options[] = {OPT__QUIET (&quiet,N_ ("suppress summary after successful commit" )),OPT__VERBOSE (&verbose,N_ ("show diff in commit message template" )), +OPT_BOOL (0 ,"word-diff" , &commit_word_diff, +N_ ("show word diff in verbose commit template" )),OPT_GROUP (N_ ("Commit message options" )),OPT_FILENAME ('F' ,"file" , &logfile,N_ ("read message from file" )),
t/t7507-commit-verbose.sh +45 -0
49 lines not on this page · raw message
wt-status.c +2 -0
@@ -1177,6 +1177,8 @@ static void wt_longstatus_print_verbose(struct wt_status *s) rev.diffopt.detect_rename = s->detect_rename >=0 ? s->detect_rename : rev.diffopt.detect_rename; rev.diffopt.rename_limit = s->rename_limit >=0 ? s->rename_limit : rev.diffopt.rename_limit; rev.diffopt.rename_score = s->rename_score >=0 ? s->rename_score : rev.diffopt.rename_score; +if (s->word_diff) + rev.diffopt.word_diff =DIFF_WORDS_PORCELAIN ; rev.diffopt.file = s->fp; rev.diffopt.close_file =0 ;/*
wt-status.h +1 -0
@@ -130,6 +130,7 @@ struct wt_status {int detect_rename;int rename_score;int rename_limit; +int word_diff;enum wt_status_format status_format;unsigned char added_cut_line;/* boolean */ struct wt_status_state state;
base-commit: e8955061076952cc5eab0300424fc48b601fe12d
Signature · 1 line
gitgitgadget