{"thread":{"id":"64010","subject":"[PATCH] config: add \"hostname\" condition to includeIf","startedAt":"2025-08-22T08:22:56Z","lastAt":"2025-08-22T08:23:02Z","messageCount":2,"participants":["monarch"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"524702","messageId":"20250822082249.93127-1-ayushoffinfo17@gmail.com","threadId":"64010","inReplyTo":null,"subject":"[PATCH] config: add \"hostname\" condition to includeIf","fromName":"monarch","fromEmail":"ayusharmagsoccontri@gmail.com","sentAt":"2025-08-22T08:22:48Z","receivedAt":"2025-08-22T08:22:56Z","isPatch":true,"sender":{"key":"ayusharmagsoccontri@gmail.com","avatar":null},"body":"Teach \"includeIf\" to include configuration based on the machine's hostname,\nas returned by gethostname(2).\n\nExample:\n\n    [includeIf \"hostname:work-laptop\"]\n        path = ~/.gitconfig.work\n\n    [includeIf \"hostname:home-pc\"]\n        path = ~/.gitconfig.home\n\nThis allows users to write host-specific configuration without separate branches.\n\nSigned-off-by: monarch <ayushoffinfo17@gmail.com>\n---\n config.c | 37 +++++++++++++++++++++++++++++++------\n 1 file changed, 31 insertions(+), 6 deletions(-)\n\ndiff --git a/config.c b/config.c\nindex e0ff35d426..dbc1a2bc75 100644\n--- a/config.c\n+++ b/config.c\n@@ -7,6 +7,7 @@\n  */\n \n #include \"git-compat-util.h\"\n+#include <unistd.h>\n #include \"abspath.h\"\n #include \"date.h\"\n #include \"branch.h\"\n@@ -391,23 +392,47 @@ static int include_by_remote_url(struct config_include_data *inc,\n \t\t\t\t\t     inc->remote_urls);\n }\n \n+static int include_by_hostname(const char *cond, size_t cond_len)\n+{\n+    char actual_hostname[1024];\n+    struct strbuf target_hostname = STRBUF_INIT;\n+    int ret = 0;\n+\n+    // Make sure the call to gethostname is correct and its return value is checked.\n+    if (gethostname(actual_hostname, sizeof(actual_hostname)) != 0)\n+        return 0; // If it fails, the condition is false.\n+\n+    strbuf_add(&target_hostname, cond, cond_len);\n+\n+    // The core of the logic: strcmp returns 0 when strings are equal.\n+    if (strcmp(actual_hostname, target_hostname.buf) == 0)\n+        ret = 1; // Success, the hostnames match!\n+\n+    strbuf_release(&target_hostname);\n+    return ret;\n+}\n+\n static int include_condition_is_true(const struct key_value_info *kvi,\n-\t\t\t\t     struct config_include_data *inc,\n-\t\t\t\t     const char *cond, size_t cond_len)\n+\tstruct config_include_data *inc,\n+\tconst char *cond, size_t cond_len)\n {\n-\tconst struct config_options *opts = inc->opts;\n+const struct config_options *opts = inc->opts;\n+\n+\n \n \tif (skip_prefix_mem(cond, cond_len, \"gitdir:\", &cond, &cond_len))\n \t\treturn include_by_gitdir(kvi, opts, cond, cond_len, 0);\n \telse if (skip_prefix_mem(cond, cond_len, \"gitdir/i:\", &cond, &cond_len))\n \t\treturn include_by_gitdir(kvi, opts, cond, cond_len, 1);\n-\telse if (skip_prefix_mem(cond, cond_len, \"onbranch:\", &cond, &cond_len))\n+\telse if (skip_prefix_mem(cond, cond_len, \"onbranch:\", &cond, cond_len))\n \t\treturn include_by_branch(inc, cond, cond_len);\n \telse if (skip_prefix_mem(cond, cond_len, \"hasconfig:remote.*.url:\", &cond,\n-\t\t\t\t   &cond_len))\n+  &cond_len))\n \t\treturn include_by_remote_url(inc, cond, cond_len);\n+\telse if (skip_prefix_mem(cond, cond_len, \"hostname:\", &cond, &cond_len))\n+\t\treturn include_by_hostname(cond, cond_len);\n \n-\t/* unknown conditionals are always false */\n+/* unknown conditionals are always false */\n \treturn 0;\n }\n \n-- \n2.43.0\n\n"},{"id":"524703","messageId":"20250822082249.93127-2-ayushoffinfo17@gmail.com","threadId":"64010","inReplyTo":"20250822082249.93127-1-ayushoffinfo17@gmail.com","subject":"[PATCH] Start 2.52 cycle, the first batch","fromName":"monarch","fromEmail":"ayusharmagsoccontri@gmail.com","sentAt":"2025-08-22T08:22:49Z","receivedAt":"2025-08-22T08:23:02Z","isPatch":true,"sender":{"key":"ayusharmagsoccontri@gmail.com","avatar":null},"body":"From: Junio C Hamano <gitster@pobox.com>\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n Documentation/RelNotes/2.52.0.adoc | 58 ++++++++++++++++++++++++++++++\n GIT-VERSION-GEN                    |  2 +-\n RelNotes                           |  2 +-\n 3 files changed, 60 insertions(+), 2 deletions(-)\n create mode 100644 Documentation/RelNotes/2.52.0.adoc\n\ndiff --git a/Documentation/RelNotes/2.52.0.adoc b/Documentation/RelNotes/2.52.0.adoc\nnew file mode 100644\nindex 0000000000..1919e039bd\n--- /dev/null\n+++ b/Documentation/RelNotes/2.52.0.adoc\n@@ -0,0 +1,58 @@\n+Git v2.52 Release Notes\n+=======================\n+\n+UI, Workflows & Features\n+------------------------\n+\n+\n+Performance, Internal Implementation, Development Support etc.\n+--------------------------------------------------------------\n+\n+ * string_list_split*() family of functions have been extended to\n+   simplify common use cases.\n+\n+ * Arrays of strbuf is often a wrong data structure to use, and\n+   strbuf_split*() family of functions that create them often have\n+   better alternatives.  Update several code paths and replace\n+   strbuf_split*().\n+\n+ * Revision traversal limited with pathspec, like \"git log dir/*\",\n+   used to ignore changed-paths Bloom filter when the pathspec\n+   contained wildcards; now they take advantage of the filter when\n+   they can.\n+\n+Fixes since v2.51\n+-----------------\n+\n+Unless otherwise noted, all the changes in 2.51.X maintenance track,\n+including security updates, are included in this release.\n+\n+ * During interactive rebase, using 'drop' on a merge commit lead to\n+   an error, which was incorrect.\n+   (merge 4d491ade8f js/rebase-i-allow-drop-on-a-merge later to maint).\n+\n+ * \"git refs migrate\" to migrate the reflog entries from a refs\n+   backend to another had a handful of bugs squashed.\n+   (merge 465eff81de ps/reflog-migrate-fixes later to maint).\n+\n+ * \"git remote rename origin upstream\" failed to move origin/HEAD to\n+   upstream/HEAD when origin/HEAD is unborn and performed other\n+   renames extremely inefficiently, which has been corrected.\n+   (merge 16c4fa26b9 ps/remote-rename-fix later to maint).\n+\n+ * \"git describe\" has been optimized by using better data structure.\n+   (merge 08bb69d70f rs/describe-with-prio-queue later to maint).\n+\n+ * \"git push\" had a code path that led to BUG() but it should have\n+   been a die(), as it is a response to a usual but invalid end-user\n+   action to attempt pushing an object that does not exist.\n+   (merge dfbfc2221b dl/push-missing-object-error later to maint).\n+\n+ * Various bugs about rename handling in \"ort\" merge strategy have\n+   been fixed.\n+   (merge f6ecb603ff en/ort-rename-fixes later to maint).\n+\n+ * Other code cleanup, docfix, build fix, etc.\n+   (merge 823d537fa7 kh/doc-git-log-markup-fix later to maint).\n+   (merge cf7efa4f33 rj/t6137-cygwin-fix later to maint).\n+   (merge 529a60a885 ua/t1517-short-help-tests later to maint).\ndiff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN\nindex 64cbc58335..b16db85e77 100755\n--- a/GIT-VERSION-GEN\n+++ b/GIT-VERSION-GEN\n@@ -1,6 +1,6 @@\n #!/bin/sh\n \n-DEF_VER=v2.51.0\n+DEF_VER=v2.51.GIT\n \n LF='\n '\ndiff --git a/RelNotes b/RelNotes\nindex 48f15770a4..6d16c0077a 120000\n--- a/RelNotes\n+++ b/RelNotes\n@@ -1 +1 @@\n-Documentation/RelNotes/2.51.0.adoc\n\\ No newline at end of file\n+Documentation/RelNotes/2.52.0.adoc\n\\ No newline at end of file\n-- \n2.43.0\n\n"}]}