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

* Re: [PATCH] diff: update conflict handling for whitespace to issue a warning
  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
  1 sibling, 0 replies; 11+ messages in thread
From: Junio C Hamano @ 2024-11-11 23:59 UTC (permalink / raw)
  To: Usman Akinyemi via GitGitGadget; +Cc: git, Usman Akinyemi

"Usman Akinyemi via GitGitGadget" <gitgitgadget@gmail.com> writes:

> 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.

Hmph, giving a warning against these conflicting setting (instead of
dying) and continuing _may_ make sense sometimes, but it is unclear
which one should survive.

I do not think of a scenario in which it makes much sense to let the
program warn only on one but not the other one.  Perhaps disabling
both, if we were to do the "warn and keep going, instead of dying",
may make some more sense than that.  I dunno.



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

* [PATCH v2] diff: update conflict handling for whitespace to issue a warning
  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 ` Usman Akinyemi via GitGitGadget
  2024-11-14  2:15   ` Junio C Hamano
  1 sibling, 1 reply; 11+ messages in thread
From: Usman Akinyemi via GitGitGadget @ 2024-11-13 19:01 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
    
    Changes from V1
    
     * Disable both WS_TAB_IN_INDENT and WS_INDENT_WITH_NON_TAB when both
       are set.

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

Range-diff vs v1:

 1:  dfb80a7ff2d ! 1:  8531e80811c diff: update conflict handling for whitespace to issue a warning
     @@ t/t4015-diff-whitespace.sh: test_expect_success 'ditto, but tabwidth=1 (must be
       	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_grep "warning: cannot enforce both tab-in-indent and indent-with-non-tab, disabling both" error
       '
       
       test_expect_success 'check tab-in-indent excluded from wildcard whitespace attribute' '
     @@ ws.c: unsigned parse_whitespace_rule(const char *string)
      -	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"));
     ++		warning(_("cannot enforce both tab-in-indent and indent-with-non-tab, disabling both"));
      +		rule &= ~WS_TAB_IN_INDENT;
     ++		rule &= ~WS_INDENT_WITH_NON_TAB;
      +	}
       	return rule;
       }


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

diff --git a/t/t4015-diff-whitespace.sh b/t/t4015-diff-whitespace.sh
index 851cfe4f32c..849f1854fb9 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, disabling both" error
 '
 
 test_expect_success 'check tab-in-indent excluded from wildcard whitespace attribute' '
diff --git a/ws.c b/ws.c
index 9456e2fdbe3..3e9ce55d095 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,11 @@ 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, disabling both"));
+		rule &= ~WS_TAB_IN_INDENT;
+		rule &= ~WS_INDENT_WITH_NON_TAB;
+	}
 	return rule;
 }
 

base-commit: facbe4f633e4ad31e641f64617bc88074c659959
-- 
gitgitgadget

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

* Re: [PATCH v2] diff: update conflict handling for whitespace to issue a warning
  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
  0 siblings, 1 reply; 11+ messages in thread
From: Junio C Hamano @ 2024-11-14  2:15 UTC (permalink / raw)
  To: Usman Akinyemi, Phillip Wood; +Cc: Usman Akinyemi via GitGitGadget, git

"Usman Akinyemi via GitGitGadget" <gitgitgadget@gmail.com> writes:

[jc: As Phillip is blamed for suggesting this addition, I added him
to the recipient of this message.]

> 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>
> ---

If the settings requires an impossible way to use whitespaces, the
settings is buggy, and it generally would be better to correct the
setting before moving on.

I am curious to know in what situations this new behaviour can be
seen as an improvement.  It may allow you to go on _without_ fixing
such a broken setting, but how would it help the end user?  If the
user set both of these mutually-incompatible options A and B by
mistake, but what the user really wanted to check for was A, picking
just one of A or B arbitrarily and disabling it would not help, and
disabling both would not help, either.  But wouldn't the real source
of the problem be that we are trying to demote die() to force the
user to correct contradictiong setting into warning()?

Thanks.

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

* Re: [PATCH v2] diff: update conflict handling for whitespace to issue a warning
  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
  0 siblings, 2 replies; 11+ messages in thread
From: Phillip Wood @ 2024-11-14 10:06 UTC (permalink / raw)
  To: Junio C Hamano, Usman Akinyemi; +Cc: Usman Akinyemi via GitGitGadget, git

On 14/11/2024 02:15, Junio C Hamano wrote:
> "Usman Akinyemi via GitGitGadget" <gitgitgadget@gmail.com> writes:
> 
> [jc: As Phillip is blamed for suggesting this addition, I added him
> to the recipient of this message.]

Thanks

>> 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.

Usman - when you're writing a commit message it is important to explain 
the reason for making the changes contained in the patch so others can 
understand why it is a good idea. In this case the idea is to avoid 
breaking "git diff" for everyone who clones a repository containing a 
.gitattributes file with bad whitespace attributes [1]. As I mentioned 
in [2] I think we only want to change the behavior when parsing 
whitespace attributes - we still want the other callers of 
parse_whitespace_rule() to die() so the user can fix their config or 
commandline. We can do that by adding a boolean parameter called 
"gentle" that determines whether we call warning() or die().

Best Wishes

Phillip

[1] 
https://lore.kernel.org/git/e4a70501-af2d-450a-a232-4c7952196a74@gmail.com
[2] 
https://lore.kernel.org/git/3c081d3c-3f6f-45ff-b254-09f1cd6b7de5@gmail.com

>> Suggested-by: Phillip Wood <phillip.wood123@gmail.com>
>> Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
>> ---
> 
> If the settings requires an impossible way to use whitespaces, the
> settings is buggy, and it generally would be better to correct the
> setting before moving on.
> 
> I am curious to know in what situations this new behaviour can be
> seen as an improvement.  It may allow you to go on _without_ fixing
> such a broken setting, but how would it help the end user?  If the
> user set both of these mutually-incompatible options A and B by
> mistake, but what the user really wanted to check for was A, picking
> just one of A or B arbitrarily and disabling it would not help, and
> disabling both would not help, either.  But wouldn't the real source
> of the problem be that we are trying to demote die() to force the
> user to correct contradictiong setting into warning()?
> 
> Thanks.


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

* Re: [PATCH v2] diff: update conflict handling for whitespace to issue a warning
  2024-11-14 10:06     ` Phillip Wood
@ 2024-11-14 11:29       ` Usman Akinyemi
  2024-11-15  0:11       ` Junio C Hamano
  1 sibling, 0 replies; 11+ messages in thread
From: Usman Akinyemi @ 2024-11-14 11:29 UTC (permalink / raw)
  To: phillip.wood; +Cc: Junio C Hamano, Usman Akinyemi via GitGitGadget, git

On Thu, Nov 14, 2024 at 5:06 AM Phillip Wood <phillip.wood123@gmail.com> wrote:
>
> On 14/11/2024 02:15, Junio C Hamano wrote:
> > "Usman Akinyemi via GitGitGadget" <gitgitgadget@gmail.com> writes:
> >
> > [jc: As Phillip is blamed for suggesting this addition, I added him
> > to the recipient of this message.]
>
> Thanks
Hi Philip and Junio,

>
> >> 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.
>
> Usman - when you're writing a commit message it is important to explain
> the reason for making the changes contained in the patch so others can
> understand why it is a good idea. In this case the idea is to avoid
> breaking "git diff" for everyone who clones a repository containing a
> .gitattributes file with bad whitespace attributes [1]. As I mentioned
> in [2] I think we only want to change the behavior when parsing
> whitespace attributes - we still want the other callers of
> parse_whitespace_rule() to die() so the user can fix their config or
> commandline. We can do that by adding a boolean parameter called
> "gentle" that determines whether we call warning() or die().

I am very sorry for the confusion. I will take this into consideration
next time and always give more explanation
in commit messages.

I will make the necessary changes.

Thank you very much.
Usman.

>
> Best Wishes
>
> Phillip
>
> [1]
> https://lore.kernel.org/git/e4a70501-af2d-450a-a232-4c7952196a74@gmail.com
> [2]
> https://lore.kernel.org/git/3c081d3c-3f6f-45ff-b254-09f1cd6b7de5@gmail.com
>
> >> Suggested-by: Phillip Wood <phillip.wood123@gmail.com>
> >> Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
> >> ---
> >
> > If the settings requires an impossible way to use whitespaces, the
> > settings is buggy, and it generally would be better to correct the
> > setting before moving on.
> >
> > I am curious to know in what situations this new behaviour can be
> > seen as an improvement.  It may allow you to go on _without_ fixing
> > such a broken setting, but how would it help the end user?  If the
> > user set both of these mutually-incompatible options A and B by
> > mistake, but what the user really wanted to check for was A, picking
> > just one of A or B arbitrarily and disabling it would not help, and
> > disabling both would not help, either.  But wouldn't the real source
> > of the problem be that we are trying to demote die() to force the
> > user to correct contradictiong setting into warning()?
> >
> > Thanks.
>

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

* Re: [PATCH v2] diff: update conflict handling for whitespace to issue a warning
  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 16:49         ` Phillip Wood
  1 sibling, 2 replies; 11+ messages in thread
From: Junio C Hamano @ 2024-11-15  0:11 UTC (permalink / raw)
  To: Phillip Wood; +Cc: Usman Akinyemi, Usman Akinyemi via GitGitGadget, git

Phillip Wood <phillip.wood123@gmail.com> writes:

> Usman - when you're writing a commit message it is important to
> explain the reason for making the changes contained in the patch so
> others can understand why it is a good idea. In this case the idea is
> to avoid breaking "git diff" for everyone who clones a repository
> containing a .gitattributes file with bad whitespace attributes
> [1].

Hmph, it would certainly be a problem, but the right solution is not
to butcher Git, but to make it easier for the participants of such a
project to know what is broken *and* what needs to be updated, to let
them move forward, no?

> As I mentioned in [2] I think we only want to change the behavior
> when parsing whitespace attributes - we still want the other callers
> of parse_whitespace_rule() to die() so the user can fix their config
> or commandline. We can do that by adding a boolean parameter called
> "gentle" that determines whether we call warning() or die().

I doubt that such a complexity is warranted.

It depends on the size of diff you are showing, but if it is large,
then giving a small warning that gets buried in the large diff is a
conter-productive way to encourage users to correct such broken
setting.  If it is small, then the damage may not be too bad, but
still, we are showing what the user did not really request.

If we were to fix anything, it is to make sure that we die() before
producing a single line of output.  If you have a change to a path
whose "type" is without such a misconfigured attribute, that sorts
lexicographically earlier than another path with a change, with a
conflicting whitespace attribute, I suspect that with the way the
code is structured currently, we show the diff for the first path,
before realizing that the second path has an issue and then die.

If we fix it, and then make sure that the die() message shows
clearly what attribute setting we did not like, that would be
sufficient to help users to locate the problem, fix it, and quickly
move on, no?

Thanks.

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

* Re: [PATCH v2] diff: update conflict handling for whitespace to issue a warning
  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
  1 sibling, 1 reply; 11+ messages in thread
From: Usman Akinyemi @ 2024-11-18 21:03 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Phillip Wood, Usman Akinyemi via GitGitGadget, git

On Fri, Nov 15, 2024 at 12:11 AM Junio C Hamano <gitster@pobox.com> wrote:
>
> Phillip Wood <phillip.wood123@gmail.com> writes:
>
> > Usman - when you're writing a commit message it is important to
> > explain the reason for making the changes contained in the patch so
> > others can understand why it is a good idea. In this case the idea is
> > to avoid breaking "git diff" for everyone who clones a repository
> > containing a .gitattributes file with bad whitespace attributes
> > [1].
>
> Hmph, it would certainly be a problem, but the right solution is not
> to butcher Git, but to make it easier for the participants of such a
> project to know what is broken *and* what needs to be updated, to let
> them move forward, no?
>
> > As I mentioned in [2] I think we only want to change the behavior
> > when parsing whitespace attributes - we still want the other callers
> > of parse_whitespace_rule() to die() so the user can fix their config
> > or commandline. We can do that by adding a boolean parameter called
> > "gentle" that determines whether we call warning() or die().
>
> I doubt that such a complexity is warranted.
>
> It depends on the size of diff you are showing, but if it is large,
> then giving a small warning that gets buried in the large diff is a
> conter-productive way to encourage users to correct such broken
> setting.  If it is small, then the damage may not be too bad, but
> still, we are showing what the user did not really request.
>
> If we were to fix anything, it is to make sure that we die() before
> producing a single line of output.  If you have a change to a path
> whose "type" is without such a misconfigured attribute, that sorts
> lexicographically earlier than another path with a change, with a
> conflicting whitespace attribute, I suspect that with the way the
> code is structured currently, we show the diff for the first path,
> before realizing that the second path has an issue and then die.
>
> If we fix it, and then make sure that the die() message shows
> clearly what attribute setting we did not like, that would be
> sufficient to help users to locate the problem, fix it, and quickly
> move on, no?
Hi Junio,

Thanks for the review. From what I understand from your comment,
we should leave it the way it was which was die right ?

Thanks.
Usman.
>
> Thanks.

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

* Re: [PATCH v2] diff: update conflict handling for whitespace to issue a warning
  2024-11-18 21:03         ` Usman Akinyemi
@ 2024-11-19  0:36           ` Junio C Hamano
  0 siblings, 0 replies; 11+ messages in thread
From: Junio C Hamano @ 2024-11-19  0:36 UTC (permalink / raw)
  To: Usman Akinyemi; +Cc: Phillip Wood, Usman Akinyemi via GitGitGadget, git

Usman Akinyemi <usmanakinyemi202@gmail.com> writes:

> On Fri, Nov 15, 2024 at 12:11 AM Junio C Hamano <gitster@pobox.com> wrote:
>> ...
>> If we were to fix anything, it is to make sure that we die() before
>> producing a single line of output.  If you have a change to a path
>> whose "type" is without such a misconfigured attribute, that sorts
>> lexicographically earlier than another path with a change, with a
>> conflicting whitespace attribute, I suspect that with the way the
>> code is structured currently, we show the diff for the first path,
>> before realizing that the second path has an issue and then die.
>>
>> If we fix it, and then make sure that the die() message shows
>> clearly what attribute setting we did not like, that would be
>> sufficient to help users to locate the problem, fix it, and quickly
>> move on, no?
>
> Thanks for the review. From what I understand from your comment,
> we should leave it the way it was which was die right ?

Correct.  I do not think replacing die() with warning() without
doing anything else makes sense.  Making sure that we detect the
breakage before going half-way while producing a patch that touches
many paths may improve the end-user experience, though.

Thanks.

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

* Re: [PATCH v2] diff: update conflict handling for whitespace to issue a warning
  2024-11-15  0:11       ` Junio C Hamano
  2024-11-18 21:03         ` Usman Akinyemi
@ 2024-11-19 16:49         ` Phillip Wood
  2024-11-20  1:23           ` Junio C Hamano
  1 sibling, 1 reply; 11+ messages in thread
From: Phillip Wood @ 2024-11-19 16:49 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: Usman Akinyemi, Usman Akinyemi via GitGitGadget, git,
	Patrick Steinhardt

On 15/11/2024 00:11, Junio C Hamano wrote:
> Phillip Wood <phillip.wood123@gmail.com> writes:
> 
>> Usman - when you're writing a commit message it is important to
>> explain the reason for making the changes contained in the patch so
>> others can understand why it is a good idea. In this case the idea is
>> to avoid breaking "git diff" for everyone who clones a repository
>> containing a .gitattributes file with bad whitespace attributes
>> [1].
> 
> Hmph, it would certainly be a problem, but the right solution is not
> to butcher Git, but to make it easier for the participants of such a
> project to know what is broken *and* what needs to be updated, to let
> them move forward, no?

Arguably yes, but that's not the approach we take when the attributes 
file is too large, a line in the file is is too long or the file 
contains a negative filename pattern. For those cases we print a warning 
and continue. The recently merged e36f009e69b (merge: replace atoi() 
with strtol_i() for marker size validation, 2024-10-24) followed suit 
and warns rather than dies for an invalid marker size. It would be nice 
to be consistent in the way we treat invalid attributes. Consistently 
dying and telling the user how to fix the problem would be a reasonable 
approach on the client side but I wonder if it could cause problems for 
forges running "git diff" and "git merge-tree" on a server though.

> [...]
> If we were to fix anything, it is to make sure that we die() before
> producing a single line of output.

That would certainly be a good idea

Best Wishes

Phillip


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

* Re: [PATCH v2] diff: update conflict handling for whitespace to issue a warning
  2024-11-19 16:49         ` Phillip Wood
@ 2024-11-20  1:23           ` Junio C Hamano
  0 siblings, 0 replies; 11+ messages in thread
From: Junio C Hamano @ 2024-11-20  1:23 UTC (permalink / raw)
  To: Phillip Wood
  Cc: Usman Akinyemi, Usman Akinyemi via GitGitGadget, git,
	Patrick Steinhardt

Phillip Wood <phillip.wood123@gmail.com> writes:

> Arguably yes, but that's not the approach we take when the attributes
> file is too large, a line in the file is is too long or the file
> contains a negative filename pattern. For those cases we print a
> warning and continue. The recently merged e36f009e69b (merge: replace
> atoi() with strtol_i() for marker size validation, 2024-10-24)
> followed suit and warns rather than dies for an invalid marker
> size. It would be nice to be consistent in the way we treat invalid
> attributes.

Arguably yes, but being careful when adding a new check and changing
established behaviour, risking to break existing users, are different.

> Consistently dying and telling the user how to fix the
> problem would be a reasonable approach on the client side but I wonder
> if it could cause problems for forges running "git diff" and "git
> merge-tree" on a server though.

That's an interesting aspect.  I wonder what happens when somebody
pushes a project with a .gitattributes with such a conflicting
setting to GitHub or GitLab.

Would that bring the world to its end ;-)?


^ permalink raw reply	[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).