{"thread":{"id":"46595","subject":"[PATCH] sha1_file: make read_info_alternates static","startedAt":"2017-08-15T20:13:34Z","lastAt":"2017-08-15T21:34:28Z","messageCount":3,"participants":["Stefan Beller","Brandon Williams","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"326453","messageId":"20170815201319.32395-1-sbeller@google.com","threadId":"46595","inReplyTo":null,"subject":"[PATCH] sha1_file: make read_info_alternates static","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-08-15T20:13:19Z","receivedAt":"2017-08-15T20:13:34Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"read_info_alternates is not used from outside, so let's make it static.\n\nWe have to declare the function before link_alt_odb_entry instead of\nmoving the code around, link_alt_odb_entry calls read_info_alternates,\nwhich in turn calls link_alt_odb_entry.\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n\n  This helps in a later refactoring (moving the object\n  store to the_repository struct), too.\n  \n  Thanks,\n  Stefan\n\n cache.h     | 1 -\n sha1_file.c | 3 ++-\n 2 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/cache.h b/cache.h\nindex 1c69d2a05a..4109efcf24 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -1551,7 +1551,6 @@ extern struct alternate_object_database {\n \tchar path[FLEX_ARRAY];\n } *alt_odb_list;\n extern void prepare_alt_odb(void);\n-extern void read_info_alternates(const char * relative_base, int depth);\n extern char *compute_alternate_path(const char *path, struct strbuf *err);\n typedef int alt_odb_fn(struct alternate_object_database *, void *);\n extern int foreach_alt_odb(alt_odb_fn, void*);\ndiff --git a/sha1_file.c b/sha1_file.c\nindex b60ae15f70..9186e2c6c7 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -347,6 +347,7 @@ static int alt_odb_usable(struct strbuf *path, const char *normalized_objdir)\n  * SHA1, an extra slash for the first level indirection, and the\n  * terminating NUL.\n  */\n+static void read_info_alternates(const char * relative_base, int depth);\n static int link_alt_odb_entry(const char *entry, const char *relative_base,\n \tint depth, const char *normalized_objdir)\n {\n@@ -448,7 +449,7 @@ static void link_alt_odb_entries(const char *alt, int len, int sep,\n \tstrbuf_release(&objdirbuf);\n }\n \n-void read_info_alternates(const char * relative_base, int depth)\n+static void read_info_alternates(const char * relative_base, int depth)\n {\n \tchar *map;\n \tsize_t mapsz;\n-- \n2.14.0.rc0.3.g6c2e499285\n\n"},{"id":"326458","messageId":"20170815213116.GC21874@google.com","threadId":"46595","inReplyTo":"20170815201319.32395-1-sbeller@google.com","subject":"Re: [PATCH] sha1_file: make read_info_alternates static","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2017-08-15T21:31:16Z","receivedAt":"2017-08-15T21:31:24Z","isPatch":true,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"On 08/15, Stefan Beller wrote:\n> read_info_alternates is not used from outside, so let's make it static.\n> \n> We have to declare the function before link_alt_odb_entry instead of\n> moving the code around, link_alt_odb_entry calls read_info_alternates,\n> which in turn calls link_alt_odb_entry.\n> \n> Signed-off-by: Stefan Beller <sbeller@google.com>\n> ---\n> \n>   This helps in a later refactoring (moving the object\n>   store to the_repository struct), too.\n>   \n>   Thanks,\n>   Stefan\n> \n>  cache.h     | 1 -\n>  sha1_file.c | 3 ++-\n>  2 files changed, 2 insertions(+), 2 deletions(-)\n> \n> diff --git a/cache.h b/cache.h\n> index 1c69d2a05a..4109efcf24 100644\n> --- a/cache.h\n> +++ b/cache.h\n> @@ -1551,7 +1551,6 @@ extern struct alternate_object_database {\n>  \tchar path[FLEX_ARRAY];\n>  } *alt_odb_list;\n>  extern void prepare_alt_odb(void);\n> -extern void read_info_alternates(const char * relative_base, int depth);\n>  extern char *compute_alternate_path(const char *path, struct strbuf *err);\n>  typedef int alt_odb_fn(struct alternate_object_database *, void *);\n>  extern int foreach_alt_odb(alt_odb_fn, void*);\n> diff --git a/sha1_file.c b/sha1_file.c\n> index b60ae15f70..9186e2c6c7 100644\n> --- a/sha1_file.c\n> +++ b/sha1_file.c\n> @@ -347,6 +347,7 @@ static int alt_odb_usable(struct strbuf *path, const char *normalized_objdir)\n>   * SHA1, an extra slash for the first level indirection, and the\n>   * terminating NUL.\n>   */\n> +static void read_info_alternates(const char * relative_base, int depth);\n>  static int link_alt_odb_entry(const char *entry, const char *relative_base,\n>  \tint depth, const char *normalized_objdir)\n>  {\n> @@ -448,7 +449,7 @@ static void link_alt_odb_entries(const char *alt, int len, int sep,\n>  \tstrbuf_release(&objdirbuf);\n>  }\n>  \n> -void read_info_alternates(const char * relative_base, int depth)\n> +static void read_info_alternates(const char * relative_base, int depth)\n>  {\n>  \tchar *map;\n>  \tsize_t mapsz;\n> -- \n> 2.14.0.rc0.3.g6c2e499285\n> \n\nLooks good to me.  Only nit is I would fix the style to not have a space\nafter the '*' ;)\n\n-- \nBrandon Williams\n"},{"id":"326460","messageId":"20170815213421.amvtzyxfbbajvf4w@sigill.intra.peff.net","threadId":"46595","inReplyTo":"20170815201319.32395-1-sbeller@google.com","subject":"Re: [PATCH] sha1_file: make read_info_alternates static","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2017-08-15T21:34:22Z","receivedAt":"2017-08-15T21:34:28Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Aug 15, 2017 at 01:13:19PM -0700, Stefan Beller wrote:\n\n> read_info_alternates is not used from outside, so let's make it static.\n> \n> We have to declare the function before link_alt_odb_entry instead of\n> moving the code around, link_alt_odb_entry calls read_info_alternates,\n> which in turn calls link_alt_odb_entry.\n> \n> Signed-off-by: Stefan Beller <sbeller@google.com>\n\nThanks, this looks good. It should have been part of my series with\na5b34d2152 (alternates: provide helper for adding to alternates list,\n2016-10-03), which removed the last external call.\n\n-Peff\n"}]}