Thanks to visit codestin.com
Credit goes to Github.com

Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -5290,6 +5290,19 @@ static int diff_opt_char(const struct option *opt,
return 0;
}

static int diff_opt_no_indicators(const struct option *opt,
const char *arg, int unset)
{
struct diff_options *options = opt->value;

BUG_ON_OPT_NEG(unset);
BUG_ON_OPT_ARG(arg);

options->output_indicators[OUTPUT_INDICATOR_NEW] = ' ';
options->output_indicators[OUTPUT_INDICATOR_OLD] = ' ';
return 0;
}

static int diff_opt_color_moved(const struct option *opt,
const char *arg, int unset)
{
Expand Down Expand Up @@ -5828,6 +5841,9 @@ struct option *add_diff_options(const struct option *opts,
OPT_INTEGER_F(0, "inter-hunk-context", &options->interhunkcontext,
N_("show context between diff hunks up to the specified number of lines"),
PARSE_OPT_NONEG),
OPT_CALLBACK_F(0, "no-indicators", options, NULL,
N_("do not show '+', '-' and ' ' indicators in the left margin"),
PARSE_OPT_NONEG | PARSE_OPT_NOARG, diff_opt_no_indicators),
OPT_CALLBACK_F(0, "output-indicator-new",
&options->output_indicators[OUTPUT_INDICATOR_NEW],
N_("<char>"),
Expand Down
32 changes: 32 additions & 0 deletions t/t4000-diff-format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,38 @@ test_expect_success 'git diff-files --patch --no-patch does not show the patch'
test_must_be_empty err
'

cat >expected_no_indicators <<\EOF
diff --git a/path0 b/path0
old mode 100644
new mode 100755
--- a/path0
+++ b/path0
@@ -1,3 +1,3 @@
Line 1
Line 2
line 3
Line 3
diff --git a/path1 b/path1
deleted file mode 100755
--- a/path1
+++ /dev/null
@@ -1,3 +0,0 @@
Line 1
Line 2
line 3
EOF

test_expect_success 'git diff-files --no-indicators replaces +/- with spaces' '
git diff-files -p --no-indicators >actual &&
compare_diff_patch expected_no_indicators actual
'

test_expect_success 'git diff-files --no-indicators --color preserves colors' '
git diff-files -p --no-indicators --color --ws-error-highlight=none >actual.raw &&
test_decode_color <actual.raw >actual &&
grep -F "<RED> line 3<RESET>" actual &&
grep -F "<GREEN> Line 3<RESET>" actual
'

# Smudge path2/path3 so that dirstat has something to show
date >path2/path3
Expand Down
Loading