{"thread":{"id":"65119","subject":"[PATCH 0/3] path: clean up few things","startedAt":"2026-03-02T14:22:01Z","lastAt":"2026-03-06T21:58:58Z","messageCount":21,"participants":["K Jayatheerth","Patrick Steinhardt","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"537522","messageId":"20260302142138.712273-1-jayatheerthkulkarni2005@gmail.com","threadId":"65119","inReplyTo":null,"subject":"[PATCH 0/3] path: clean up few things","fromName":"K Jayatheerth","fromEmail":"jayatheerthkulkarni2005@gmail.com","sentAt":"2026-03-02T14:21:35Z","receivedAt":"2026-03-02T14:22:01Z","isPatch":true,"sender":{"key":"jayatheerthkulkarni2005@gmail.com","avatar":"https://avatars.githubusercontent.com/u/148841023?v=4"},"body":"While reviewing path.c in preparation for the upcoming git repo info path expansions,\nI noticed a few areas of accumulated technical debt.\n\nThis series cleans up the file by removing an unused header, enforcing proper\nsize_t typing for path lengths, and eliminating redundant settings evaluations\nto keep the underlying path API clean.\n\nK Jayatheerth (3):\n  path: remove unused header\n  path: use the right datatype\n  path: remove redundant function calls\n\n path.c | 13 ++++++-------\n 1 file changed, 6 insertions(+), 7 deletions(-)\n\n-- \n2.53.0\n"},{"id":"537523","messageId":"20260302142138.712273-2-jayatheerthkulkarni2005@gmail.com","threadId":"65119","inReplyTo":"20260302142138.712273-1-jayatheerthkulkarni2005@gmail.com","subject":"[PATCH 1/3] path: remove unused header","fromName":"K Jayatheerth","fromEmail":"jayatheerthkulkarni2005@gmail.com","sentAt":"2026-03-02T14:21:36Z","receivedAt":"2026-03-02T14:22:10Z","isPatch":true,"sender":{"key":"jayatheerthkulkarni2005@gmail.com","avatar":"https://avatars.githubusercontent.com/u/148841023?v=4"},"body":"The \"environment.h\" header is included in \"path.c\", but none of the\nfunctions or macros it provides are used in this file.\n\nSigned-off-by: K Jayatheerth <jayatheerthkulkarni2005@gmail.com>\n---\n path.c | 1 -\n 1 file changed, 1 deletion(-)\n\ndiff --git a/path.c b/path.c\nindex d726537622..f613d8bbd1 100644\n--- a/path.c\n+++ b/path.c\n@@ -4,7 +4,6 @@\n \n #include \"git-compat-util.h\"\n #include \"abspath.h\"\n-#include \"environment.h\"\n #include \"gettext.h\"\n #include \"repository.h\"\n #include \"strbuf.h\"\n-- \n2.53.0\n\n"},{"id":"537524","messageId":"20260302142138.712273-3-jayatheerthkulkarni2005@gmail.com","threadId":"65119","inReplyTo":"20260302142138.712273-1-jayatheerthkulkarni2005@gmail.com","subject":"[PATCH 2/3] path: use the right datatype","fromName":"K Jayatheerth","fromEmail":"jayatheerthkulkarni2005@gmail.com","sentAt":"2026-03-02T14:21:37Z","receivedAt":"2026-03-02T14:22:15Z","isPatch":true,"sender":{"key":"jayatheerthkulkarni2005@gmail.com","avatar":"https://avatars.githubusercontent.com/u/148841023?v=4"},"body":"The strlen() function returns a size_t\nStoring this in a standard signed int is a bad practice\nthat invites overflow vulnerabilities if paths get absurdly long.\n\nSigned-off-by: K Jayatheerth <jayatheerthkulkarni2005@gmail.com>\n---\n path.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/path.c b/path.c\nindex f613d8bbd1..56be5e1726 100644\n--- a/path.c\n+++ b/path.c\n@@ -58,7 +58,7 @@ static void strbuf_cleanup_path(struct strbuf *sb)\n \n static int dir_prefix(const char *buf, const char *dir)\n {\n-\tint len = strlen(dir);\n+\tsize_t len = strlen(dir);\n \treturn !strncmp(buf, dir, len) &&\n \t\t(is_dir_sep(buf[len]) || buf[len] == '\\0');\n }\n-- \n2.53.0\n\n"},{"id":"537525","messageId":"20260302142138.712273-4-jayatheerthkulkarni2005@gmail.com","threadId":"65119","inReplyTo":"20260302142138.712273-1-jayatheerthkulkarni2005@gmail.com","subject":"[PATCH 3/3] path: remove redundant function calls","fromName":"K Jayatheerth","fromEmail":"jayatheerthkulkarni2005@gmail.com","sentAt":"2026-03-02T14:21:38Z","receivedAt":"2026-03-02T14:22:19Z","isPatch":true,"sender":{"key":"jayatheerthkulkarni2005@gmail.com","avatar":"https://avatars.githubusercontent.com/u/148841023?v=4"},"body":"We fetch the exact same setting up to four times.\nWe fix this by evaluating it once, storing it in a local variable,\nand referencing that variable.\n\nSigned-off-by: K Jayatheerth <jayatheerthkulkarni2005@gmail.com>\n---\n path.c | 10 +++++-----\n 1 file changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/path.c b/path.c\nindex 56be5e1726..5cd38b2a16 100644\n--- a/path.c\n+++ b/path.c\n@@ -741,18 +741,18 @@ int calc_shared_perm(struct repository *repo,\n \t\t     int mode)\n {\n \tint tweak;\n-\n-\tif (repo_settings_get_shared_repository(repo) < 0)\n-\t\ttweak = -repo_settings_get_shared_repository(repo);\n+\tint shared_repo = repo_settings_get_shared_repository(repo);\n+\tif (shared_repo < 0)\n+\t\ttweak = -shared_repo;\n \telse\n-\t\ttweak = repo_settings_get_shared_repository(repo);\n+\t\ttweak = shared_repo;\n \n \tif (!(mode & S_IWUSR))\n \t\ttweak &= ~0222;\n \tif (mode & S_IXUSR)\n \t\t/* Copy read bits to execute bits */\n \t\ttweak |= (tweak & 0444) >> 2;\n-\tif (repo_settings_get_shared_repository(repo) < 0)\n+\tif (shared_repo < 0)\n \t\tmode = (mode & ~0777) | tweak;\n \telse\n \t\tmode |= tweak;\n-- \n2.53.0\n\n"},{"id":"537664","messageId":"aablPlaCY-TAoCi-@pks.im","threadId":"65119","inReplyTo":"20260302142138.712273-3-jayatheerthkulkarni2005@gmail.com","subject":"Re: [PATCH 2/3] path: use the right datatype","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-03-03T13:42:22Z","receivedAt":"2026-03-03T13:42:28Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Mon, Mar 02, 2026 at 07:51:37PM +0530, K Jayatheerth wrote:\n> The strlen() function returns a size_t\n\nMicronit: missing punctuation.\n\n> Storing this in a standard signed int is a bad practice\n> that invites overflow vulnerabilities if paths get absurdly long.\n> \n> Signed-off-by: K Jayatheerth <jayatheerthkulkarni2005@gmail.com>\n> ---\n>  path.c | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n> \n> diff --git a/path.c b/path.c\n> index f613d8bbd1..56be5e1726 100644\n> --- a/path.c\n> +++ b/path.c\n> @@ -58,7 +58,7 @@ static void strbuf_cleanup_path(struct strbuf *sb)\n>  \n>  static int dir_prefix(const char *buf, const char *dir)\n>  {\n> -\tint len = strlen(dir);\n> +\tsize_t len = strlen(dir);\n>  \treturn !strncmp(buf, dir, len) &&\n>  \t\t(is_dir_sep(buf[len]) || buf[len] == '\\0');\n\nMakes sense. What's left out in the commit message is an explanation\nthat this change is safe to do without any further changes. But judging\nby the diff it's used in contexts where we already expect a `size_t`\nanyway, so it is.\n\nPatrick\n"},{"id":"537665","messageId":"aablRKlhQZUTct56@pks.im","threadId":"65119","inReplyTo":"20260302142138.712273-4-jayatheerthkulkarni2005@gmail.com","subject":"Re: [PATCH 3/3] path: remove redundant function calls","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-03-03T13:42:28Z","receivedAt":"2026-03-03T13:42:32Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Mon, Mar 02, 2026 at 07:51:38PM +0530, K Jayatheerth wrote:\n> We fetch the exact same setting up to four times.\n> We fix this by evaluating it once, storing it in a local variable,\n\nMicronit: we typically write this as if instructing the code itself to\nchange. So this would rather be something like \"Fix this by storing it\nin a local variable.\".\n\n> and referencing that variable.\n> \n> Signed-off-by: K Jayatheerth <jayatheerthkulkarni2005@gmail.com>\n> ---\n>  path.c | 10 +++++-----\n>  1 file changed, 5 insertions(+), 5 deletions(-)\n> \n> diff --git a/path.c b/path.c\n> index 56be5e1726..5cd38b2a16 100644\n> --- a/path.c\n> +++ b/path.c\n> @@ -741,18 +741,18 @@ int calc_shared_perm(struct repository *repo,\n>  \t\t     int mode)\n>  {\n>  \tint tweak;\n> -\n> -\tif (repo_settings_get_shared_repository(repo) < 0)\n> -\t\ttweak = -repo_settings_get_shared_repository(repo);\n> +\tint shared_repo = repo_settings_get_shared_repository(repo);\n> +\tif (shared_repo < 0)\n> +\t\ttweak = -shared_repo;\n>  \telse\n> -\t\ttweak = repo_settings_get_shared_repository(repo);\n> +\t\ttweak = shared_repo;\n>  \n>  \tif (!(mode & S_IWUSR))\n>  \t\ttweak &= ~0222;\n>  \tif (mode & S_IXUSR)\n>  \t\t/* Copy read bits to execute bits */\n>  \t\ttweak |= (tweak & 0444) >> 2;\n> -\tif (repo_settings_get_shared_repository(repo) < 0)\n> +\tif (shared_repo < 0)\n>  \t\tmode = (mode & ~0777) | tweak;\n>  \telse\n>  \t\tmode |= tweak;\n\nI agree with the fix itself though. Probably doesn't matter much as we\nsimply retrieve a value from the repo settings, but this also removes\nsome mental overhead in my mind.\n\nThanks!\n\nPatrick\n"},{"id":"537693","messageId":"xmqq4imwg9y5.fsf@gitster.g","threadId":"65119","inReplyTo":"20260302142138.712273-3-jayatheerthkulkarni2005@gmail.com","subject":"Re: [PATCH 2/3] path: use the right datatype","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-03-03T16:21:54Z","receivedAt":"2026-03-03T16:21:57Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"K Jayatheerth <jayatheerthkulkarni2005@gmail.com> writes:\n\n> The strlen() function returns a size_t\n> Storing this in a standard signed int is a bad practice\n> that invites overflow vulnerabilities if paths get absurdly long.\n>\n> Signed-off-by: K Jayatheerth <jayatheerthkulkarni2005@gmail.com>\n> ---\n>  path.c | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n>\n> diff --git a/path.c b/path.c\n> index f613d8bbd1..56be5e1726 100644\n> --- a/path.c\n> +++ b/path.c\n> @@ -58,7 +58,7 @@ static void strbuf_cleanup_path(struct strbuf *sb)\n>  \n>  static int dir_prefix(const char *buf, const char *dir)\n>  {\n> -\tint len = strlen(dir);\n> +\tsize_t len = strlen(dir);\n>  \treturn !strncmp(buf, dir, len) &&\n>  \t\t(is_dir_sep(buf[len]) || buf[len] == '\\0');\n>  }\n\nObviously correct.\n\nWe also could tell it to return \"bool\" without disrupting much else,\nas this is a file-scope static function that are only used inside\n\"if (...)\" conditions without its return value stored in any\nvariable, if we are interested in type kosherness.\n\nI have to wonder if it is easier to read if we used our standard\nhelper functions, e.g.,\n\n        const char *tail;\n\n        return (skip_prefix(buf, dir, &tail) &&\n\t\t(!*tail || is_dir_sep(*tail)));\n\nbut probably not.\n\nThanks.\n"},{"id":"537694","messageId":"xmqqwlzseukp.fsf@gitster.g","threadId":"65119","inReplyTo":"20260302142138.712273-4-jayatheerthkulkarni2005@gmail.com","subject":"Re: [PATCH 3/3] path: remove redundant function calls","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-03-03T16:39:18Z","receivedAt":"2026-03-03T16:39:20Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"K Jayatheerth <jayatheerthkulkarni2005@gmail.com> writes:\n\n> We fetch the exact same setting up to four times.\n> We fix this by evaluating it once, storing it in a local variable,\n> and referencing that variable.\n>\n> Signed-off-by: K Jayatheerth <jayatheerthkulkarni2005@gmail.com>\n> ---\n>  path.c | 10 +++++-----\n>  1 file changed, 5 insertions(+), 5 deletions(-)\n\nThe function body is guarded with \"we initialize this just once and\nreturn the value stored in a structure member\", so 3 among four of\nthese calls incur only cost for a no-op call/return, but using a\ntemporary variable on this caller's side makes it clear that we are\nnot expecting any recomputation in the callee.\n\n> diff --git a/path.c b/path.c\n> index 56be5e1726..5cd38b2a16 100644\n> --- a/path.c\n> +++ b/path.c\n> @@ -741,18 +741,18 @@ int calc_shared_perm(struct repository *repo,\n>  \t\t     int mode)\n>  {\n>  \tint tweak;\n> -\n> -\tif (repo_settings_get_shared_repository(repo) < 0)\n> -\t\ttweak = -repo_settings_get_shared_repository(repo);\n> +\tint shared_repo = repo_settings_get_shared_repository(repo);\n> +\tif (shared_repo < 0)\n> +\t\ttweak = -shared_repo;\n>  \telse\n> -\t\ttweak = repo_settings_get_shared_repository(repo);\n> +\t\ttweak = shared_repo;\n>  \n>  \tif (!(mode & S_IWUSR))\n>  \t\ttweak &= ~0222;\n>  \tif (mode & S_IXUSR)\n>  \t\t/* Copy read bits to execute bits */\n>  \t\ttweak |= (tweak & 0444) >> 2;\n> -\tif (repo_settings_get_shared_repository(repo) < 0)\n> +\tif (shared_repo < 0)\n>  \t\tmode = (mode & ~0777) | tweak;\n>  \telse\n>  \t\tmode |= tweak;\n"},{"id":"537774","messageId":"20260304130502.8475-1-jayatheerthkulkarni2005@gmail.com","threadId":"65119","inReplyTo":"20260302142138.712273-1-jayatheerthkulkarni2005@gmail.com","subject":"[PATCH v2 0/3] clean up a few things","fromName":"K Jayatheerth","fromEmail":"jayatheerthkulkarni2005@gmail.com","sentAt":"2026-03-04T13:04:59Z","receivedAt":"2026-03-04T13:05:38Z","isPatch":true,"sender":{"key":"jayatheerthkulkarni2005@gmail.com","avatar":"https://avatars.githubusercontent.com/u/148841023?v=4"},"body":"Changes since v1:\n - Update commit messages of patches 2 and 3 to better explain the changes\n\nWhile reviewing path.c in preparation for the upcoming git repo info path expansions,\nI noticed a few areas of accumulated technical debt.\n\nThis series cleans up the file by removing an unused header, enforcing proper\nsize_t typing for path lengths, and eliminating redundant settings evaluations\nto keep the underlying path API clean.\n\nK Jayatheerth (3):\n  path: remove unused header\n  path: use size_t for dir_prefix length\n  path: remove redundant function calls\n\n path.c | 13 ++++++-------\n 1 file changed, 6 insertions(+), 7 deletions(-)\n\n-- \n2.53.0\n"},{"id":"537775","messageId":"20260304130502.8475-2-jayatheerthkulkarni2005@gmail.com","threadId":"65119","inReplyTo":"20260304130502.8475-1-jayatheerthkulkarni2005@gmail.com","subject":"[PATCH v2 1/3] path: remove unused header","fromName":"K Jayatheerth","fromEmail":"jayatheerthkulkarni2005@gmail.com","sentAt":"2026-03-04T13:05:00Z","receivedAt":"2026-03-04T13:05:53Z","isPatch":true,"sender":{"key":"jayatheerthkulkarni2005@gmail.com","avatar":"https://avatars.githubusercontent.com/u/148841023?v=4"},"body":"The \"environment.h\" header is included in \"path.c\", but none of the\nfunctions or macros it provides are used in this file.\n\nSigned-off-by: K Jayatheerth <jayatheerthkulkarni2005@gmail.com>\n---\n path.c | 1 -\n 1 file changed, 1 deletion(-)\n\ndiff --git a/path.c b/path.c\nindex d726537622..f613d8bbd1 100644\n--- a/path.c\n+++ b/path.c\n@@ -4,7 +4,6 @@\n \n #include \"git-compat-util.h\"\n #include \"abspath.h\"\n-#include \"environment.h\"\n #include \"gettext.h\"\n #include \"repository.h\"\n #include \"strbuf.h\"\n-- \n2.53.0\n\n"},{"id":"537776","messageId":"20260304130502.8475-3-jayatheerthkulkarni2005@gmail.com","threadId":"65119","inReplyTo":"20260304130502.8475-1-jayatheerthkulkarni2005@gmail.com","subject":"[PATCH v2 2/3] path: use size_t for dir_prefix length","fromName":"K Jayatheerth","fromEmail":"jayatheerthkulkarni2005@gmail.com","sentAt":"2026-03-04T13:05:01Z","receivedAt":"2026-03-04T13:06:14Z","isPatch":true,"sender":{"key":"jayatheerthkulkarni2005@gmail.com","avatar":"https://avatars.githubusercontent.com/u/148841023?v=4"},"body":"The strlen() function returns a size_t. Storing this in a standard\nsigned int is a bad practice that invites overflow vulnerabilities if\npaths get absurdly long.\n\nSwitch the variable to size_t. This is safe to do because 'len' is\nstrictly used as an argument to strncmp() (which expects size_t) and\nas a positive array index, involving no signed arithmetic that could\nrely on negative values.\n\nSigned-off-by: K Jayatheerth <jayatheerthkulkarni2005@gmail.com>\n---\n path.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/path.c b/path.c\nindex f613d8bbd1..56be5e1726 100644\n--- a/path.c\n+++ b/path.c\n@@ -58,7 +58,7 @@ static void strbuf_cleanup_path(struct strbuf *sb)\n \n static int dir_prefix(const char *buf, const char *dir)\n {\n-\tint len = strlen(dir);\n+\tsize_t len = strlen(dir);\n \treturn !strncmp(buf, dir, len) &&\n \t\t(is_dir_sep(buf[len]) || buf[len] == '\\0');\n }\n-- \n2.53.0\n\n"},{"id":"537777","messageId":"20260304130502.8475-4-jayatheerthkulkarni2005@gmail.com","threadId":"65119","inReplyTo":"20260304130502.8475-1-jayatheerthkulkarni2005@gmail.com","subject":"[PATCH v2 3/3] path: remove redundant function calls","fromName":"K Jayatheerth","fromEmail":"jayatheerthkulkarni2005@gmail.com","sentAt":"2026-03-04T13:05:02Z","receivedAt":"2026-03-04T13:06:30Z","isPatch":true,"sender":{"key":"jayatheerthkulkarni2005@gmail.com","avatar":"https://avatars.githubusercontent.com/u/148841023?v=4"},"body":"repo_settings_get_shared_repository() is invoked multiple times in\ncalc_shared_perm(). While the function internally caches the value,\nrepeated calls still add unnecessary noise.\n\nStore the result in a local variable and reuse it instead. This makes\nit explicit that the value is expected to remain constant and avoids\nrepeated calls in the same scope.\n\nSigned-off-by: K Jayatheerth <jayatheerthkulkarni2005@gmail.com>\n---\n path.c | 10 +++++-----\n 1 file changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/path.c b/path.c\nindex 56be5e1726..5cd38b2a16 100644\n--- a/path.c\n+++ b/path.c\n@@ -741,18 +741,18 @@ int calc_shared_perm(struct repository *repo,\n \t\t     int mode)\n {\n \tint tweak;\n-\n-\tif (repo_settings_get_shared_repository(repo) < 0)\n-\t\ttweak = -repo_settings_get_shared_repository(repo);\n+\tint shared_repo = repo_settings_get_shared_repository(repo);\n+\tif (shared_repo < 0)\n+\t\ttweak = -shared_repo;\n \telse\n-\t\ttweak = repo_settings_get_shared_repository(repo);\n+\t\ttweak = shared_repo;\n \n \tif (!(mode & S_IWUSR))\n \t\ttweak &= ~0222;\n \tif (mode & S_IXUSR)\n \t\t/* Copy read bits to execute bits */\n \t\ttweak |= (tweak & 0444) >> 2;\n-\tif (repo_settings_get_shared_repository(repo) < 0)\n+\tif (shared_repo < 0)\n \t\tmode = (mode & ~0777) | tweak;\n \telse\n \t\tmode |= tweak;\n-- \n2.53.0\n\n"},{"id":"537793","messageId":"xmqqwlzr8qjs.fsf@gitster.g","threadId":"65119","inReplyTo":"20260304130502.8475-3-jayatheerthkulkarni2005@gmail.com","subject":"Re: [PATCH v2 2/3] path: use size_t for dir_prefix length","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-03-04T17:15:03Z","receivedAt":"2026-03-04T17:15:05Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"K Jayatheerth <jayatheerthkulkarni2005@gmail.com> writes:\n\n> The strlen() function returns a size_t. Storing this in a standard\n> signed int is a bad practice that invites overflow vulnerabilities if\n> paths get absurdly long.\n\n\"a standard signed int\" -> \"an int variable\".  There is no\n\"nonstandard signed int\" anyway ;-)\n\nIf we were doing malloc(len) using length truncated due to integer\nwraparound and then strcpy() the whole string, it would make us\nwrite beyond the end of the allocation, but in this case, the worst\nthing that can happen is that we stop comparing prematurely, which\nmay make us declare that buf is a path inside the directory dir when\nit isn't.  The two callers of this function do not use this\nmiscalculated len to carry out what they do, so there is no other\ndamage.  It indeed would be computing a wrong result, but \"overflow\nvulnerabilities\" is a slight exaggeration in the context of this\npatch, I think.\n\n\"overflow vulnerabilities\" -> \"bugs due to integer wraparound\".\n\n> Switch the variable to size_t. This is safe to do because 'len' is\n> strictly used as an argument to strncmp() (which expects size_t) and\n> as a positive array index, involving no signed arithmetic that could\n> rely on negative values.\n>\n> Signed-off-by: K Jayatheerth <jayatheerthkulkarni2005@gmail.com>\n> ---\n>  path.c | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n>\n> diff --git a/path.c b/path.c\n> index f613d8bbd1..56be5e1726 100644\n> --- a/path.c\n> +++ b/path.c\n> @@ -58,7 +58,7 @@ static void strbuf_cleanup_path(struct strbuf *sb)\n>  \n>  static int dir_prefix(const char *buf, const char *dir)\n>  {\n> -\tint len = strlen(dir);\n> +\tsize_t len = strlen(dir);\n>  \treturn !strncmp(buf, dir, len) &&\n>  \t\t(is_dir_sep(buf[len]) || buf[len] == '\\0');\n>  }\n"},{"id":"537933","messageId":"20260305125332.27600-1-jayatheerthkulkarni2005@gmail.com","threadId":"65119","inReplyTo":"20260304130502.8475-1-jayatheerthkulkarni2005@gmail.com","subject":"[PATCH v3 0/3] clean up a few things","fromName":"K Jayatheerth","fromEmail":"jayatheerthkulkarni2005@gmail.com","sentAt":"2026-03-05T12:53:29Z","receivedAt":"2026-03-05T12:54:26Z","isPatch":true,"sender":{"key":"jayatheerthkulkarni2005@gmail.com","avatar":"https://avatars.githubusercontent.com/u/148841023?v=4"},"body":"\nChanges since v2:\n - Update commit message of patch 2.\n\nWhile reviewing path.c in preparation for the upcoming git repo info path expansions,\nI noticed a few areas of accumulated technical debt.\n\nThis series cleans up the file by removing an unused header, enforcing proper\nsize_t typing for path lengths, and eliminating redundant settings evaluations\nto keep the underlying path API clean.\n\nK Jayatheerth (3):\n  path: remove unused header\n  path: use size_t for dir_prefix length\n  path: remove redundant function calls\n\n path.c | 13 ++++++-------\n 1 file changed, 6 insertions(+), 7 deletions(-)\n\n-- \n2.53.0\n"},{"id":"537934","messageId":"20260305125332.27600-2-jayatheerthkulkarni2005@gmail.com","threadId":"65119","inReplyTo":"20260305125332.27600-1-jayatheerthkulkarni2005@gmail.com","subject":"[PATCH v3 1/3] path: remove unused header","fromName":"K Jayatheerth","fromEmail":"jayatheerthkulkarni2005@gmail.com","sentAt":"2026-03-05T12:53:30Z","receivedAt":"2026-03-05T12:54:32Z","isPatch":true,"sender":{"key":"jayatheerthkulkarni2005@gmail.com","avatar":"https://avatars.githubusercontent.com/u/148841023?v=4"},"body":"The \"environment.h\" header is included in \"path.c\", but none of the\nfunctions or macros it provides are used in this file.\n\nSigned-off-by: K Jayatheerth <jayatheerthkulkarni2005@gmail.com>\n---\n path.c | 1 -\n 1 file changed, 1 deletion(-)\n\ndiff --git a/path.c b/path.c\nindex d726537622..f613d8bbd1 100644\n--- a/path.c\n+++ b/path.c\n@@ -4,7 +4,6 @@\n \n #include \"git-compat-util.h\"\n #include \"abspath.h\"\n-#include \"environment.h\"\n #include \"gettext.h\"\n #include \"repository.h\"\n #include \"strbuf.h\"\n-- \n2.53.0\n\n"},{"id":"537935","messageId":"20260305125332.27600-3-jayatheerthkulkarni2005@gmail.com","threadId":"65119","inReplyTo":"20260305125332.27600-1-jayatheerthkulkarni2005@gmail.com","subject":"[PATCH v3 2/3] path: use size_t for dir_prefix length","fromName":"K Jayatheerth","fromEmail":"jayatheerthkulkarni2005@gmail.com","sentAt":"2026-03-05T12:53:31Z","receivedAt":"2026-03-05T12:54:37Z","isPatch":true,"sender":{"key":"jayatheerthkulkarni2005@gmail.com","avatar":"https://avatars.githubusercontent.com/u/148841023?v=4"},"body":"The strlen() function returns a size_t. Storing this in a standard\nsigned int is a bad practice that invites overflow vulnerabilities if\npaths get absurdly long.\n\nSwitch the variable to size_t. This is safe to do because 'len' is\nstrictly used as an argument to strncmp() (which expects size_t) and\nas a positive array index, involving no signed arithmetic that could\nrely on negative values.\n\nSigned-off-by: K Jayatheerth <jayatheerthkulkarni2005@gmail.com>\n---\n path.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/path.c b/path.c\nindex f613d8bbd1..56be5e1726 100644\n--- a/path.c\n+++ b/path.c\n@@ -58,7 +58,7 @@ static void strbuf_cleanup_path(struct strbuf *sb)\n \n static int dir_prefix(const char *buf, const char *dir)\n {\n-\tint len = strlen(dir);\n+\tsize_t len = strlen(dir);\n \treturn !strncmp(buf, dir, len) &&\n \t\t(is_dir_sep(buf[len]) || buf[len] == '\\0');\n }\n-- \n2.53.0\n\n"},{"id":"537936","messageId":"20260305125332.27600-4-jayatheerthkulkarni2005@gmail.com","threadId":"65119","inReplyTo":"20260305125332.27600-1-jayatheerthkulkarni2005@gmail.com","subject":"[PATCH v3 3/3] path: remove redundant function calls","fromName":"K Jayatheerth","fromEmail":"jayatheerthkulkarni2005@gmail.com","sentAt":"2026-03-05T12:53:32Z","receivedAt":"2026-03-05T12:54:41Z","isPatch":true,"sender":{"key":"jayatheerthkulkarni2005@gmail.com","avatar":"https://avatars.githubusercontent.com/u/148841023?v=4"},"body":"repo_settings_get_shared_repository() is invoked multiple times in\ncalc_shared_perm(). While the function internally caches the value,\nrepeated calls still add unnecessary noise.\n\nStore the result in a local variable and reuse it instead. This makes\nit explicit that the value is expected to remain constant and avoids\nrepeated calls in the same scope.\n\nSigned-off-by: K Jayatheerth <jayatheerthkulkarni2005@gmail.com>\n---\n path.c | 10 +++++-----\n 1 file changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/path.c b/path.c\nindex 56be5e1726..5cd38b2a16 100644\n--- a/path.c\n+++ b/path.c\n@@ -741,18 +741,18 @@ int calc_shared_perm(struct repository *repo,\n \t\t     int mode)\n {\n \tint tweak;\n-\n-\tif (repo_settings_get_shared_repository(repo) < 0)\n-\t\ttweak = -repo_settings_get_shared_repository(repo);\n+\tint shared_repo = repo_settings_get_shared_repository(repo);\n+\tif (shared_repo < 0)\n+\t\ttweak = -shared_repo;\n \telse\n-\t\ttweak = repo_settings_get_shared_repository(repo);\n+\t\ttweak = shared_repo;\n \n \tif (!(mode & S_IWUSR))\n \t\ttweak &= ~0222;\n \tif (mode & S_IXUSR)\n \t\t/* Copy read bits to execute bits */\n \t\ttweak |= (tweak & 0444) >> 2;\n-\tif (repo_settings_get_shared_repository(repo) < 0)\n+\tif (shared_repo < 0)\n \t\tmode = (mode & ~0777) | tweak;\n \telse\n \t\tmode |= tweak;\n-- \n2.53.0\n\n"},{"id":"537992","messageId":"xmqqms0m2hn1.fsf@gitster.g","threadId":"65119","inReplyTo":"20260305125332.27600-1-jayatheerthkulkarni2005@gmail.com","subject":"Re: [PATCH v3 0/3] clean up a few things","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-03-05T19:36:18Z","receivedAt":"2026-03-05T19:36:20Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"K Jayatheerth <jayatheerthkulkarni2005@gmail.com> writes:\n\n> Changes since v2:\n>  - Update commit message of patch 2.\n\nHmph, they look identical to me, and more importantly, the previous\nround has already been merged to 'next'.\n\nThanks.\n"},{"id":"538041","messageId":"CA+rGoLfpyiKjLMOOHBoGoQAO2eLraejRGgpEpMGqP7+=VDQSkQ@mail.gmail.com","threadId":"65119","inReplyTo":"xmqqms0m2hn1.fsf@gitster.g","subject":"Re: [PATCH v3 0/3] clean up a few things","fromName":"K Jayatheerth","fromEmail":"jayatheerthkulkarni2005@gmail.com","sentAt":"2026-03-06T01:47:40Z","receivedAt":"2026-03-06T01:47:52Z","isPatch":true,"sender":{"key":"jayatheerthkulkarni2005@gmail.com","avatar":"https://avatars.githubusercontent.com/u/148841023?v=4"},"body":"On Fri, Mar 6, 2026 at 1:06 AM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> K Jayatheerth <jayatheerthkulkarni2005@gmail.com> writes:\n>\n> > Changes since v2:\n> >  - Update commit message of patch 2.\n>\n> Hmph, they look identical to me, and more importantly, the previous\n\nThe only change was the words \"a standard signed int\" -> \"an int variable\"\n\"overflow vulnerabilities\" -> \"bugs due to integer wraparound\"\n\n\n> round has already been merged to 'next'.\n>\n\nWhoops, I didn't check the what's cooking chart,\nThanks for the info Junio ;-)\n\nRegards\n- Jayatheerth\n"},{"id":"538044","messageId":"CA+rGoLdzfPiKx8=4qboU1h0hg6z=j904sesWV_6UvYrE2TvWVg@mail.gmail.com","threadId":"65119","inReplyTo":"xmqqms0m2hn1.fsf@gitster.g","subject":"Re: [PATCH v3 0/3] clean up a few things","fromName":"K Jayatheerth","fromEmail":"jayatheerthkulkarni2005@gmail.com","sentAt":"2026-03-06T01:59:58Z","receivedAt":"2026-03-06T02:00:12Z","isPatch":true,"sender":{"key":"jayatheerthkulkarni2005@gmail.com","avatar":"https://avatars.githubusercontent.com/u/148841023?v=4"},"body":"On Fri, Mar 6, 2026 at 1:06 AM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> K Jayatheerth <jayatheerthkulkarni2005@gmail.com> writes:\n>\n> > Changes since v2:\n> >  - Update commit message of patch 2.\n>\n> Hmph, they look identical to me, and more importantly, the previous\n> round has already been merged to 'next'.\n>\n> Thanks.\n\n\nI just noticed the commit message actually had not change,\nthat was a mistake.\n\nEither way, since it is already merged to next\nI will consider it acceptable.\n\nThanks again\n\nRegards\n- Jayatheerth\n"},{"id":"538120","messageId":"xmqqqzpwy5zz.fsf@gitster.g","threadId":"65119","inReplyTo":"CA+rGoLdzfPiKx8=4qboU1h0hg6z=j904sesWV_6UvYrE2TvWVg@mail.gmail.com","subject":"Re: [PATCH v3 0/3] clean up a few things","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-03-06T21:58:56Z","receivedAt":"2026-03-06T21:58:58Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"K Jayatheerth <jayatheerthkulkarni2005@gmail.com> writes:\n\n>> Hmph, they look identical to me, and more importantly, the previous\n>> round has already been merged to 'next'.\n> ...\n> I just noticed the commit message actually had not change,\n> that was a mistake.\n\nWhew.  I was afraid I was hallucinating.\n"}]}