git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] diff: update conflict handling for whitespace to issue a warning
@ 2024-11-11 17:49 Usman Akinyemi via GitGitGadget
  2024-11-11 23:59 ` Junio C Hamano
  2024-11-13 19:01 ` [PATCH v2] " Usman Akinyemi via GitGitGadget
  0 siblings, 2 replies; 11+ messages in thread
From: Usman Akinyemi via GitGitGadget @ 2024-11-11 17:49 UTC (permalink / raw)
  To: git; +Cc: Usman Akinyemi, Usman Akinyemi

From: Usman Akinyemi <usmanakinyemi202@gmail.com>

Modify the conflict resolution between tab-in-indent and
indent-with-non-tab to issue a warning instead of terminating
the operation with `die()`. Update the `git diff --check` test to
capture and verify the warning message output.

Suggested-by: Phillip Wood <phillip.wood123@gmail.com>
Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
---
    diff: update conflict handling for whitespace to issue a warning

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1828%2FUnique-Usman%2Fmaster-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1828/Unique-Usman/master-v1
Pull-Request: https://github.com/git/git/pull/1828

 t/t4015-diff-whitespace.sh | 3 ++-
 ws.c                       | 7 +++++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/t/t4015-diff-whitespace.sh b/t/t4015-diff-whitespace.sh
index 851cfe4f32c..ada3f90b288 100755
--- a/t/t4015-diff-whitespace.sh
+++ b/t/t4015-diff-whitespace.sh
@@ -808,7 +808,8 @@ test_expect_success 'ditto, but tabwidth=1 (must be irrelevant)' '
 test_expect_success 'check tab-in-indent and indent-with-non-tab conflict' '
 	git config core.whitespace "tab-in-indent,indent-with-non-tab" &&
 	echo "foo ();" >x &&
-	test_must_fail git diff --check
+	git diff --check 2>error &&
+	test_grep "warning: cannot enforce both tab-in-indent and indent-with-non-tab, removing tab-in-indent" error
 '
 
 test_expect_success 'check tab-in-indent excluded from wildcard whitespace attribute' '
diff --git a/ws.c b/ws.c
index 9456e2fdbe3..2c11715177e 100644
--- a/ws.c
+++ b/ws.c
@@ -6,6 +6,7 @@
 #include "git-compat-util.h"
 #include "attr.h"
 #include "strbuf.h"
+#include "gettext.h"
 #include "ws.h"
 
 unsigned whitespace_rule_cfg = WS_DEFAULT_RULE;
@@ -70,8 +71,10 @@ unsigned parse_whitespace_rule(const char *string)
 		string = ep;
 	}
 
-	if (rule & WS_TAB_IN_INDENT && rule & WS_INDENT_WITH_NON_TAB)
-		die("cannot enforce both tab-in-indent and indent-with-non-tab");
+	if (rule & WS_TAB_IN_INDENT && rule & WS_INDENT_WITH_NON_TAB) {
+		warning(_("cannot enforce both tab-in-indent and indent-with-non-tab, removing tab-in-indent"));
+		rule &= ~WS_TAB_IN_INDENT;
+	}
 	return rule;
 }
 

base-commit: facbe4f633e4ad31e641f64617bc88074c659959
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2024-11-20  1:23 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-11 17:49 [PATCH] diff: update conflict handling for whitespace to issue a warning Usman Akinyemi via GitGitGadget
2024-11-11 23:59 ` Junio C Hamano
2024-11-13 19:01 ` [PATCH v2] " Usman Akinyemi via GitGitGadget
2024-11-14  2:15   ` Junio C Hamano
2024-11-14 10:06     ` Phillip Wood
2024-11-14 11:29       ` Usman Akinyemi
2024-11-15  0:11       ` Junio C Hamano
2024-11-18 21:03         ` Usman Akinyemi
2024-11-19  0:36           ` Junio C Hamano
2024-11-19 16:49         ` Phillip Wood
2024-11-20  1:23           ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).