mirror of
https://github.com/git-for-windows/git.git
synced 2026-02-04 03:33:01 -06:00
diff: stop output garbled message in dry run mode
In dry run mode, diff_flush_patch() should not produce any output. However, in commit b55e6d36eb (diff: ensure consistent diff behavior with ignore options, 2025-08-08), only the output during the comparison of two file contents was suppressed. For file deletions or mode changes, diff_flush_patch() still produces output. In run_extern_diff(), set quiet to true if in dry run mode. In emit_diff_symbol_from_struct(), directly return if in dry run mode. Signed-off-by: Lidong Yan <yldhome2d2@gmail.com> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
parent
2755072927
commit
bd2ecbae58
5
diff.c
5
diff.c
@ -1357,6 +1357,9 @@ static void emit_diff_symbol_from_struct(struct diff_options *o,
|
||||
int len = eds->len;
|
||||
unsigned flags = eds->flags;
|
||||
|
||||
if (o->dry_run)
|
||||
return;
|
||||
|
||||
switch (s) {
|
||||
case DIFF_SYMBOL_NO_LF_EOF:
|
||||
context = diff_get_color_opt(o, DIFF_CONTEXT);
|
||||
@ -4426,7 +4429,7 @@ static void run_external_diff(const struct external_diff *pgm,
|
||||
{
|
||||
struct child_process cmd = CHILD_PROCESS_INIT;
|
||||
struct diff_queue_struct *q = &diff_queued_diff;
|
||||
int quiet = !(o->output_format & DIFF_FORMAT_PATCH);
|
||||
int quiet = !(o->output_format & DIFF_FORMAT_PATCH) || o->dry_run;
|
||||
int rc;
|
||||
|
||||
/*
|
||||
|
||||
@ -661,6 +661,27 @@ test_expect_success 'diff -I<regex>: ignore matching file' '
|
||||
test_grep ! "file1" actual
|
||||
'
|
||||
|
||||
test_expect_success 'diff -I<regex>: ignore all content changes' '
|
||||
test_when_finished "git rm -f file1 file2" &&
|
||||
: >file1 &&
|
||||
git add file1 &&
|
||||
: >file2 &&
|
||||
git add file2 &&
|
||||
|
||||
rm -f file1 file2 &&
|
||||
mkdir file2 &&
|
||||
test_diff_no_content_changes () {
|
||||
git diff $1 --ignore-blank-lines -I".*" >actual &&
|
||||
test_line_count = 2 actual &&
|
||||
test_grep "file1" actual &&
|
||||
test_grep "file2" actual &&
|
||||
test_grep ! "diff --git" actual
|
||||
} &&
|
||||
test_diff_no_content_changes "--raw" &&
|
||||
test_diff_no_content_changes "--name-only" &&
|
||||
test_diff_no_content_changes "--name-status"
|
||||
'
|
||||
|
||||
# check_prefix <patch> <src> <dst>
|
||||
# check only lines with paths to avoid dependency on exact oid/contents
|
||||
check_prefix () {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user