diff options
author | Jim Meyering <meyering@redhat.com> | 2008-08-15 13:39:26 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2008-08-19 18:09:37 -0700 |
commit | a624eaa7820f4f9814e41e911c665a0aba2fce34 (patch) | |
tree | 315d6c0ea6c2e4bb2b2f2de40a1468c58825a0e4 /diff.c | |
parent | c6670b348cb19c74a6d7f6943df4871eb0d8295f (diff) | |
download | git-a624eaa7820f4f9814e41e911c665a0aba2fce34.tar.gz git-a624eaa7820f4f9814e41e911c665a0aba2fce34.tar.xz |
add boolean diff.suppress-blank-empty config option
GNU diff's --suppress-blank-empty option makes it so that diff no
longer outputs trailing white space unless the input data has it.
With this option, empty context lines are now empty also in diff -u output.
Before, they would have a single trailing space.
* diff.c (diff_suppress_blank_empty): New global.
(git_diff_basic_config): Set it.
(fn_out_consume): Honor it.
* t/t4029-diff-trailing-space.sh: New file.
* Documentation/config.txt: Document it.
Signed-off-by: Jim Meyering <meyering@redhat.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diff.c')
-rw-r--r-- | diff.c | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -20,6 +20,7 @@ static int diff_detect_rename_default; static int diff_rename_limit_default = 200; +static int diff_suppress_blank_empty; int diff_use_color_default = -1; static const char *external_diff_cmd_cfg; int diff_auto_refresh_index = 1; @@ -176,6 +177,12 @@ int git_diff_basic_config(const char *var, const char *value, void *cb) return 0; } + /* like GNU diff's --suppress-blank-empty option */ + if (!strcmp(var, "diff.suppress-blank-empty")) { + diff_suppress_blank_empty = git_config_bool(var, value); + return 0; + } + if (!prefixcmp(var, "diff.")) { const char *ep = strrchr(var, '.'); if (ep != var + 4) { @@ -580,6 +587,12 @@ static void fn_out_consume(void *priv, char *line, unsigned long len) ecbdata->label_path[0] = ecbdata->label_path[1] = NULL; } + if (diff_suppress_blank_empty + && len == 2 && line[0] == ' ' && line[1] == '\n') { + line[0] = '\n'; + len = 1; + } + /* This is not really necessary for now because * this codepath only deals with two-way diffs. */ |