{"thread":{"id":"65235","subject":"[PATCH GSOC] diff: use conventional comparison order","startedAt":"2026-03-13T14:04:19Z","lastAt":"2026-03-14T12:27:39Z","messageCount":5,"participants":["aum2357","Tian Yuchen","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"538894","messageId":"20260313140440.564201-1-ahambrahmasmi2357@gmail.com","threadId":"65235","inReplyTo":null,"subject":"[PATCH GSOC] diff: use conventional comparison order","fromName":"aum2357","fromEmail":"ahambrahmasmi2357@gmail.com","sentAt":"2026-03-13T14:04:40Z","receivedAt":"2026-03-13T14:04:19Z","isPatch":true,"sender":{"key":"ahambrahmasmi2357@gmail.com","avatar":null},"body":"diff: use conventional comparison order\n\nReplace `0 <= addremove_explicit` with `addremove_explicit >= 0`\nto follow the common coding style where variables appear on the\nleft side of comparisons.\n---\n builtin/add.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/builtin/add.c b/builtin/add.c\nindex 0ee21692c2..ad0d6047af 100644\n--- a/builtin/add.c\n+++ b/builtin/add.c\n@@ -432,7 +432,7 @@ int cmd_add(int argc,\n \targc--;\n \targv++;\n \n-\tif (0 <= addremove_explicit)\n+\tif ( addremove_explicit >= 0 )\n \t\taddremove = addremove_explicit;\n \telse if (take_worktree_changes && ADDREMOVE_DEFAULT)\n \t\taddremove = 0; /* \"-u\" was given but not \"-A\" */\n-- \n2.53.0\n\n"},{"id":"538921","messageId":"9afe48e3-8348-4e2c-8e5f-bbdc3b2951f8@malon.dev","threadId":"65235","inReplyTo":"20260313140440.564201-1-ahambrahmasmi2357@gmail.com","subject":"Re: [PATCH GSOC] diff: use conventional comparison order","fromName":"Tian Yuchen","fromEmail":"cat@malon.dev","sentAt":"2026-03-13T17:59:28Z","receivedAt":"2026-03-13T17:59:34Z","isPatch":true,"sender":{"key":"cat@malon.dev","avatar":"https://avatars.githubusercontent.com/u/232002048?v=4"},"body":"Hi aum2357,\n\nOn 3/13/26 22:04, aum2357 wrote:\n> diff: use conventional comparison order\n> \n> Replace `0 <= addremove_explicit` with `addremove_explicit >= 0`\n> to follow the common coding style where variables appear on the\n> left side of comparisons.\n> ---\n>   builtin/add.c | 2 +-\n>   1 file changed, 1 insertion(+), 1 deletion(-)\n> \n> diff --git a/builtin/add.c b/builtin/add.c\n> index 0ee21692c2..ad0d6047af 100644\n> --- a/builtin/add.c\n> +++ b/builtin/add.c\n> @@ -432,7 +432,7 @@ int cmd_add(int argc,\n>   \targc--;\n>   \targv++;\n>   \n> -\tif (0 <= addremove_explicit)\n> +\tif ( addremove_explicit >= 0 )\n>   \t\taddremove = addremove_explicit;\n>   \telse if (take_worktree_changes && ADDREMOVE_DEFAULT)\n>   \t\taddremove = 0; /* \"-u\" was given but not \"-A\" */\n\nI guess this syntax is probably intended to prevent the compiler from \nnot reporting an error when someone accidentally types '='. But since \nthe code is already written and runs fine, isn't it a bit unnecessary to \nchange it?\n\nYou can try a command like\n\n> git grep -E ‘\\(.*<=.*\\)’\n\nto see what happens. The codebase actually includes both, right?\n\n\n\nBy the way, as far as I know, no country allows numbers to be part of a \nname. In other word, I don't think 'aum2357' is your real name ;)\nIf you've browsed the mailing list, you'll notice that everyone submits \npatches using their real names. Please adjust yours accordingly.\n\nRegards,\n\nYuchen\n"},{"id":"538929","messageId":"xmqqldfv4h6k.fsf@gitster.g","threadId":"65235","inReplyTo":"9afe48e3-8348-4e2c-8e5f-bbdc3b2951f8@malon.dev","subject":"Re: [PATCH GSOC] diff: use conventional comparison order","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-03-13T20:18:11Z","receivedAt":"2026-03-13T20:18:14Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Tian Yuchen <cat@malon.dev> writes:\n\n> I guess this syntax is probably intended to prevent the compiler from \n> not reporting an error when someone accidentally types '='.\n\nYou guessed wrong.  See CodingGuidelines.\n"},{"id":"538950","messageId":"405c075b-731b-47e3-9e9c-70aaa0efe1cc@malon.dev","threadId":"65235","inReplyTo":"xmqqldfv4h6k.fsf@gitster.g","subject":"Re: [PATCH GSOC] diff: use conventional comparison order","fromName":"Tian Yuchen","fromEmail":"cat@malon.dev","sentAt":"2026-03-14T03:59:43Z","receivedAt":"2026-03-14T03:59:52Z","isPatch":true,"sender":{"key":"cat@malon.dev","avatar":"https://avatars.githubusercontent.com/u/232002048?v=4"},"body":"On 3/14/26 04:18, Junio C Hamano wrote:\n\n> You guessed wrong.  See CodingGuidelines.\n\nIt does have nothing to do with the compiler. Thanks for pointing out.\n\nHowever, the coding guidelines state:\n\n> Both are valid, and we use both.\n\nSo, the real key is this sentence:\n\n> Just do not mix styles in the same part of the code and mimic\n> existing styles in the neighbourhood.\n\nHowever, in builtin/add.c before the patch, there isn't even a single \n“>” symbol used for comparison. The “<” symbol is used throughout the \ncomparison sections.\n\nI find it quite strange because the author says:\n\n> to follow the common coding style\n\nThis patch seems more like it breaks the common coding style.\n\nRegards,\n\nYuchen\n"},{"id":"538969","messageId":"xmqqbjgqy4sn.fsf@gitster.g","threadId":"65235","inReplyTo":"405c075b-731b-47e3-9e9c-70aaa0efe1cc@malon.dev","subject":"Re: [PATCH GSOC] diff: use conventional comparison order","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-03-14T12:27:36Z","receivedAt":"2026-03-14T12:27:39Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Tian Yuchen <cat@malon.dev> writes:\n> However, in builtin/add.c before the patch, there isn't even a single \n> “>” symbol used for comparison. The “<” symbol is used throughout the \n> comparison sections.\n\nLook a bit harder.  I think there is one comparison that uses a\ncomparison that does not follow \"textual order reflects actual\norder\" convention.\n\n\twhile (--i >= 0) {\n\n> I find it quite strange because the author says:\n>\n>> to follow the common coding style\n>\n> This patch seems more like it breaks the common coding style.\n\nTo somebody who does not know both conventions and understand that\nboth are valid, the only one that is familiar to the person would be\nthe only common one.\n"}]}