{"thread":{"id":"40411","subject":"[PATCH] worktree: don't use C99 feature","startedAt":"2015-09-23T10:33:00Z","lastAt":"2015-09-23T15:01:25Z","messageCount":2,"participants":["Ramsay Jones","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"270571","messageId":"56027FDC.1070905@ramsayjones.plus.com","threadId":"40411","inReplyTo":null,"subject":"[PATCH] worktree: don't use C99 feature","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2015-09-23T10:33:00Z","receivedAt":"2015-09-23T10:33:00Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\nCommits 9c0b9f6 (\"worktree: add 'list' command\", 18-09-2015) and\n40ca3d3 (\"worktree: add functions to get worktree details\", 18-08-2015)\nboth introduce the use of a C99 feature (declare the loop control\nvariable in the loop header initializer section).\n\nSigned-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n---\n\nHi Junio,\n\nThe pu branch doesn't build for me. Do you have -std=c99 set somewhere?\n\nCould you please squash the relevant parts of this patch (or something\nlike it) into the two commits mentioned above.\n\nThanks!\n\nATB,\nRamsay Jones\n\n builtin/worktree.c | 6 +++---\n worktree.c         | 7 +++++--\n 2 files changed, 8 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/worktree.c b/builtin/worktree.c\nindex e6e36ac..b318c39 100644\n--- a/builtin/worktree.c\n+++ b/builtin/worktree.c\n@@ -415,16 +415,16 @@ static int list(int ac, const char **av, const char *prefix)\n         usage_with_options(worktree_usage, options);\n     else {\n         struct worktree **worktrees = get_worktrees();\n-        int path_maxlen = 0;\n+        int i, path_maxlen = 0;\n \n         if (!porcelain) {\n-            for (int i = 0; worktrees[i]; i++) {\n+            for (i = 0; worktrees[i]; i++) {\n                 int len = strlen(worktrees[i]->path);\n                 if (len > path_maxlen)\n                     path_maxlen = len;\n             }\n         }\n-        for (int i = 0; worktrees[i]; i++) {\n+        for (i = 0; worktrees[i]; i++) {\n             if (porcelain)\n                 show_worktree_porcelain(worktrees[i]);\n             else\ndiff --git a/worktree.c b/worktree.c\nindex 41c229e..d17b5b6 100644\n--- a/worktree.c\n+++ b/worktree.c\n@@ -5,7 +5,9 @@\n \n void free_worktrees(struct worktree **worktrees)\n {\n-    for (int i = 0; worktrees[i]; i++) {\n+    int i;\n+\n+    for (i = 0; worktrees[i]; i++) {\n         free(worktrees[i]->path);\n         free(worktrees[i]->git_dir);\n         free(worktrees[i]->head_ref);\n@@ -207,8 +209,9 @@ char *find_shared_symref(const char *symref, const char *target)\n     struct strbuf sb = STRBUF_INIT;\n     struct worktree **worktrees = get_worktrees();\n     int symref_is_head = !strcmp(\"HEAD\", symref);\n+    int i;\n \n-    for (int i = 0; worktrees[i]; i++) {\n+    for (i = 0; worktrees[i]; i++) {\n         if (!symref_is_head) {\n             strbuf_reset(&path);\n             strbuf_reset(&sb);\n-- \n2.5.0\n"},{"id":"270578","messageId":"xmqq1tdpyybe.fsf@gitster.mtv.corp.google.com","threadId":"40411","inReplyTo":"56027FDC.1070905@ramsayjones.plus.com","subject":"Re: [PATCH] worktree: don't use C99 feature","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-09-23T15:01:25Z","receivedAt":"2015-09-23T15:01:25Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ramsay Jones <ramsay@ramsayjones.plus.com> writes:\n\n> Commits 9c0b9f6 (\"worktree: add 'list' command\", 18-09-2015) and\n> 40ca3d3 (\"worktree: add functions to get worktree details\", 18-08-2015)\n> both introduce the use of a C99 feature (declare the loop control\n> variable in the loop header initializer section).\n>\n> Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n> ---\n>\n> Hi Junio,\n>\n> The pu branch doesn't build for me. Do you have -std=c99 set somewhere?\n>\n> Could you please squash the relevant parts of this patch (or something\n> like it) into the two commits mentioned above.\n>\n> Thanks!\n\nOh, this is embarrassing, as I do recall noticing this during the\nreview (in my MUA before running \"git am\") but somehow it slipped my\nmind.\n\nThanks for catching.\n\n\n\n> ATB,\n> Ramsay Jones\n>\n>  builtin/worktree.c | 6 +++---\n>  worktree.c         | 7 +++++--\n>  2 files changed, 8 insertions(+), 5 deletions(-)\n>\n> diff --git a/builtin/worktree.c b/builtin/worktree.c\n> index e6e36ac..b318c39 100644\n> --- a/builtin/worktree.c\n> +++ b/builtin/worktree.c\n> @@ -415,16 +415,16 @@ static int list(int ac, const char **av, const char *prefix)\n>          usage_with_options(worktree_usage, options);\n>      else {\n>          struct worktree **worktrees = get_worktrees();\n> -        int path_maxlen = 0;\n> +        int i, path_maxlen = 0;\n>  \n>          if (!porcelain) {\n> -            for (int i = 0; worktrees[i]; i++) {\n> +            for (i = 0; worktrees[i]; i++) {\n>                  int len = strlen(worktrees[i]->path);\n>                  if (len > path_maxlen)\n>                      path_maxlen = len;\n>              }\n>          }\n> -        for (int i = 0; worktrees[i]; i++) {\n> +        for (i = 0; worktrees[i]; i++) {\n>              if (porcelain)\n>                  show_worktree_porcelain(worktrees[i]);\n>              else\n> diff --git a/worktree.c b/worktree.c\n> index 41c229e..d17b5b6 100644\n> --- a/worktree.c\n> +++ b/worktree.c\n> @@ -5,7 +5,9 @@\n>  \n>  void free_worktrees(struct worktree **worktrees)\n>  {\n> -    for (int i = 0; worktrees[i]; i++) {\n> +    int i;\n> +\n> +    for (i = 0; worktrees[i]; i++) {\n>          free(worktrees[i]->path);\n>          free(worktrees[i]->git_dir);\n>          free(worktrees[i]->head_ref);\n> @@ -207,8 +209,9 @@ char *find_shared_symref(const char *symref, const char *target)\n>      struct strbuf sb = STRBUF_INIT;\n>      struct worktree **worktrees = get_worktrees();\n>      int symref_is_head = !strcmp(\"HEAD\", symref);\n> +    int i;\n>  \n> -    for (int i = 0; worktrees[i]; i++) {\n> +    for (i = 0; worktrees[i]; i++) {\n>          if (!symref_is_head) {\n>              strbuf_reset(&path);\n>              strbuf_reset(&sb);\n"}]}