{"thread":{"id":"61608","subject":"[PATCH] worktree_git_path(): move the declaration to path.h","startedAt":"2024-06-08T18:39:05Z","lastAt":"2024-06-14T19:21:42Z","messageCount":3,"participants":["Junio C Hamano","Elijah Newren"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"496719","messageId":"20240608183901.2084546-1-gitster@pobox.com","threadId":"61608","inReplyTo":null,"subject":"[PATCH] worktree_git_path(): move the declaration to path.h","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2024-06-08T18:39:01Z","receivedAt":"2024-06-08T18:39:05Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"The definition of this function is in path.c but its declaration is\nin worktree.h, which is something unexpected.  The function is\nexplained as \"Similar to git_path()\"; declaring it next to where\ngit_path() is declared would make more sense.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n path.h     | 9 +++++++++\n revision.c | 1 +\n worktree.h | 8 --------\n 3 files changed, 10 insertions(+), 8 deletions(-)\n\ndiff --git a/path.h b/path.h\nindex c3bc8617bd..a6f0b70692 100644\n--- a/path.h\n+++ b/path.h\n@@ -4,6 +4,7 @@\n struct repository;\n struct strbuf;\n struct string_list;\n+struct worktree;\n \n /*\n  * The result to all functions which return statically allocated memory may be\n@@ -81,6 +82,14 @@ void strbuf_repo_git_path(struct strbuf *sb,\n const char *git_path(const char *fmt, ...)\n \t__attribute__((format (printf, 1, 2)));\n \n+/*\n+ * Similar to git_path() but can produce paths for a specified\n+ * worktree instead of current one\n+ */\n+const char *worktree_git_path(const struct worktree *wt,\n+\t\t\t      const char *fmt, ...)\n+\t__attribute__((format (printf, 2, 3)));\n+\n /*\n  * Return a path into the main repository's (the_repository) git directory.\n  */\ndiff --git a/revision.c b/revision.c\nindex 7ddf0f151a..09024cf4aa 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -29,6 +29,7 @@\n #include \"bisect.h\"\n #include \"packfile.h\"\n #include \"worktree.h\"\n+#include \"path.h\"\n #include \"read-cache.h\"\n #include \"setup.h\"\n #include \"sparse-index.h\"\ndiff --git a/worktree.h b/worktree.h\nindex 7cc6d90e66..11279d0c8f 100644\n--- a/worktree.h\n+++ b/worktree.h\n@@ -177,14 +177,6 @@ int other_head_refs(each_ref_fn fn, void *cb_data);\n int is_worktree_being_rebased(const struct worktree *wt, const char *target);\n int is_worktree_being_bisected(const struct worktree *wt, const char *target);\n \n-/*\n- * Similar to git_path() but can produce paths for a specified\n- * worktree instead of current one\n- */\n-const char *worktree_git_path(const struct worktree *wt,\n-\t\t\t      const char *fmt, ...)\n-\t__attribute__((format (printf, 2, 3)));\n-\n /*\n  * Return a refname suitable for access from the current ref store.\n  */\n-- \n2.45.2-445-g1b76f06508\n\n"},{"id":"497186","messageId":"CABPp-BEnhJt_5mJ2rY3FFU-4_v41zt2NHOkf_Xp8DYxUsGgYPQ@mail.gmail.com","threadId":"61608","inReplyTo":"20240608183901.2084546-1-gitster@pobox.com","subject":"Re: [PATCH] worktree_git_path(): move the declaration to path.h","fromName":"Elijah Newren","fromEmail":"newren@gmail.com","sentAt":"2024-06-14T18:50:43Z","receivedAt":"2024-06-14T18:50:55Z","isPatch":true,"sender":{"key":"newren@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5455730?v=4"},"body":"On Sat, Jun 8, 2024 at 6:39 PM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> The definition of this function is in path.c but its declaration is\n> in worktree.h, which is something unexpected.  The function is\n> explained as \"Similar to git_path()\"; declaring it next to where\n> git_path() is declared would make more sense.\n>\n> Signed-off-by: Junio C Hamano <gitster@pobox.com>\n> ---\n>  path.h     | 9 +++++++++\n>  revision.c | 1 +\n>  worktree.h | 8 --------\n>  3 files changed, 10 insertions(+), 8 deletions(-)\n>\n> diff --git a/path.h b/path.h\n> index c3bc8617bd..a6f0b70692 100644\n> --- a/path.h\n> +++ b/path.h\n> @@ -4,6 +4,7 @@\n>  struct repository;\n>  struct strbuf;\n>  struct string_list;\n> +struct worktree;\n>\n>  /*\n>   * The result to all functions which return statically allocated memory may be\n> @@ -81,6 +82,14 @@ void strbuf_repo_git_path(struct strbuf *sb,\n>  const char *git_path(const char *fmt, ...)\n>         __attribute__((format (printf, 1, 2)));\n>\n> +/*\n> + * Similar to git_path() but can produce paths for a specified\n> + * worktree instead of current one\n> + */\n> +const char *worktree_git_path(const struct worktree *wt,\n> +                             const char *fmt, ...)\n> +       __attribute__((format (printf, 2, 3)));\n> +\n>  /*\n>   * Return a path into the main repository's (the_repository) git directory.\n>   */\n> diff --git a/revision.c b/revision.c\n> index 7ddf0f151a..09024cf4aa 100644\n> --- a/revision.c\n> +++ b/revision.c\n> @@ -29,6 +29,7 @@\n>  #include \"bisect.h\"\n>  #include \"packfile.h\"\n>  #include \"worktree.h\"\n> +#include \"path.h\"\n>  #include \"read-cache.h\"\n>  #include \"setup.h\"\n>  #include \"sparse-index.h\"\n> diff --git a/worktree.h b/worktree.h\n> index 7cc6d90e66..11279d0c8f 100644\n> --- a/worktree.h\n> +++ b/worktree.h\n> @@ -177,14 +177,6 @@ int other_head_refs(each_ref_fn fn, void *cb_data);\n>  int is_worktree_being_rebased(const struct worktree *wt, const char *target);\n>  int is_worktree_being_bisected(const struct worktree *wt, const char *target);\n>\n> -/*\n> - * Similar to git_path() but can produce paths for a specified\n> - * worktree instead of current one\n> - */\n> -const char *worktree_git_path(const struct worktree *wt,\n> -                             const char *fmt, ...)\n> -       __attribute__((format (printf, 2, 3)));\n> -\n>  /*\n>   * Return a refname suitable for access from the current ref store.\n>   */\n> --\n> 2.45.2-445-g1b76f06508\n\nSimple and straightforward, and the rationale makes sense to me.\n"},{"id":"497188","messageId":"xmqqwmmre3ek.fsf@gitster.g","threadId":"61608","inReplyTo":"CABPp-BEnhJt_5mJ2rY3FFU-4_v41zt2NHOkf_Xp8DYxUsGgYPQ@mail.gmail.com","subject":"Re: [PATCH] worktree_git_path(): move the declaration to path.h","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2024-06-14T19:21:39Z","receivedAt":"2024-06-14T19:21:42Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Elijah Newren <newren@gmail.com> writes:\n\n> On Sat, Jun 8, 2024 at 6:39 PM Junio C Hamano <gitster@pobox.com> wrote:\n>>\n>> The definition of this function is in path.c but its declaration is\n>> in worktree.h, which is something unexpected.  The function is\n>> explained as \"Similar to git_path()\"; declaring it next to where\n>> git_path() is declared would make more sense.\n>>\n>> Signed-off-by: Junio C Hamano <gitster@pobox.com>\n>> ---\n>>  path.h     | 9 +++++++++\n>>  revision.c | 1 +\n>>  worktree.h | 8 --------\n>>  3 files changed, 10 insertions(+), 8 deletions(-)\n>\n> Simple and straightforward, and the rationale makes sense to me.\n\nThanks.  It helped that there was only one customer that needed\nadjustment.  Will merge to 'next'.\n"}]}