worktree: don't use C99 feature
PATCH 1/1 worktree: don't use C99 feature
Commits 9c0b9f6 ("worktree: add 'list' command", 18-09-2015) and 40ca3d3 ("worktree: add functions to get worktree details", 18-08-2015) both introduce the use of a C99 feature (declare the loop control variable in the loop header initializer section).
---
Hi Junio,
The pu branch doesn't build for me. Do you have -std=c99 set somewhere?
Could you please squash the relevant parts of this patch (or something like it) into the two commits mentioned above.
Thanks!
ATB,
Ramsay Jones
builtin/worktree.c | 6 +++--- worktree.c | 7 +++++-- 2 files changed, 8 insertions(+), 5 deletions(-)
builtin/worktree.c +3 -3
@@ -415,16 +415,16 @@ static int list(int ac, const char **av, const char *prefix)usage_with_options (worktree_usage, options); else {struct worktree **worktrees =get_worktrees (); -int path_maxlen =0 ; +int i, path_maxlen =0 ;if (!porcelain) { -for (int i =0 ; worktrees[i]; i++) { +for (i =0 ; worktrees[i]; i++) {int len =strlen (worktrees[i]->path);if (len > path_maxlen) path_maxlen = len; } } -for (int i =0 ; worktrees[i]; i++) { +for (i =0 ; worktrees[i]; i++) {if (porcelain)show_worktree_porcelain (worktrees[i]);else
worktree.c +5 -2
@@ -5,7 +5,9 @@void free_worktrees (struct worktree **worktrees) { -for (int i =0 ; worktrees[i]; i++) { +int i; + +for (i =0 ; worktrees[i]; i++) {free (worktrees[i]->path);free (worktrees[i]->git_dir);free (worktrees[i]->head_ref);
@@ -207,8 +209,9 @@ char *find_shared_symref(const char *symref, const char *target)struct strbuf sb =STRBUF_INIT ;struct worktree **worktrees =get_worktrees ();int symref_is_head = !strcmp ("HEAD" , symref); +int i; -for (int i =0 ; worktrees[i]; i++) { +for (i =0 ; worktrees[i]; i++) {if (!symref_is_head) {strbuf_reset (&path);strbuf_reset (&sb);
Signature · 1 line
2.5.0
Quoted 8 lines · Ramsay Jones
Commits 9c0b9f6 ("worktree: add 'list' command", 18-09-2015) and 40ca3d3 ("worktree: add functions to get worktree details", 18-08-2015) both introduce the use of a C99 feature (declare the loop control variable in the loop header initializer section).
Signed-off-by Ramsay Jones <[email protected]>---
Quoted 8 lines
Hi Junio,
The pu branch doesn't build for me. Do you have -std=c99 set somewhere?
Could you please squash the relevant parts of this patch (or something like it) into the two commits mentioned above.
Thanks!
Oh, this is embarrassing, as I do recall noticing this during the review (in my MUA before running "git am") but somehow it slipped my mind.
Thanks for catching.
Quoted 57 lines
ATB,
Ramsay Jonesbuiltin/worktree.c | 6 +++--- worktree.c | 7 +++++-- 2 files changed, 8 insertions(+), 5 deletions(-)builtin/worktree.c +3
-3@@ -415,16 +415,16 @@ static int list(int ac, const char **av, const char *prefix)usage_with_options (worktree_usage, options); else {struct worktree **worktrees =get_worktrees (); -int path_maxlen =0 ; +int i, path_maxlen =0 ;if (!porcelain) { -for (int i =0 ; worktrees[i]; i++) { +for (i =0 ; worktrees[i]; i++) {int len =strlen (worktrees[i]->path);if (len > path_maxlen) path_maxlen = len; } } -for (int i =0 ; worktrees[i]; i++) { +for (i =0 ; worktrees[i]; i++) {if (porcelain)show_worktree_porcelain (worktrees[i]);else worktree.c +5
-2@@ -5,7 +5,9 @@void free_worktrees (struct worktree **worktrees) { -for (int i =0 ; worktrees[i]; i++) { +int i; + +for (i =0 ; worktrees[i]; i++) {free (worktrees[i]->path);free (worktrees[i]->git_dir);free (worktrees[i]->head_ref);@@ -207,8 +209,9 @@ char *find_shared_symref(const char *symref, const char *target)struct strbuf sb =STRBUF_INIT ;struct worktree **worktrees =get_worktrees ();int symref_is_head = !strcmp ("HEAD" , symref); +int i; -for (int i =0 ; worktrees[i]; i++) { +for (i =0 ; worktrees[i]; i++) {if (!symref_is_head) {strbuf_reset (&path);strbuf_reset (&sb);