{"thread":{"id":"18615","subject":"[PATCH 2/2] bisect--helper: string output variables together with \"&&\"","startedAt":"2009-03-29T09:55:47Z","lastAt":"2009-03-30T04:18:18Z","messageCount":2,"participants":["Christian Couder"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"109762","messageId":"20090329115547.91e2de5b.chriscool@tuxfamily.org","threadId":"18615","inReplyTo":null,"subject":"[PATCH 2/2] bisect--helper: string output variables together with \"&&\"","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2009-03-29T09:55:47Z","receivedAt":"2009-03-29T09:55:47Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"When doing:\n\neval \"git bisect--helper --next-vars\" | {\n        while read line\n        do\n                echo \"$line &&\"\n        done\n        echo ':'\n}\n\nthe result code comes from the last \"echo ':'\", not from running\n\"git bisect--helper --next-vars\".\n\nThis patch get rid of the need to string the line from the output\nof \"git bisect--helper\" by making \"git bisect--helper --next-vars\"\nreturn output variables stringed together with \"&&\".\n\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n bisect.c           |    3 ++-\n bisect.h           |    1 +\n builtin-rev-list.c |   31 +++++++++++++++++++++----------\n git-bisect.sh      |   15 +--------------\n 4 files changed, 25 insertions(+), 25 deletions(-)\n\ndiff --git a/bisect.c b/bisect.c\nindex 64a5ad5..df0ab4d 100644\n--- a/bisect.c\n+++ b/bisect.c\n@@ -554,5 +554,6 @@ int bisect_next_vars(const char *prefix)\n \trevs.commits = find_bisection(revs.commits, &reaches, &all,\n \t\t\t\t      !!skipped_sha1_nr);\n \n-\treturn show_bisect_vars(&revs, reaches, all, SHOW_TRIED);\n+\treturn show_bisect_vars(&revs, reaches, all,\n+\t\t\t\tSHOW_TRIED | SHOW_STRINGED);\n }\ndiff --git a/bisect.h b/bisect.h\nindex 4cff2ba..2e4b2af 100644\n--- a/bisect.h\n+++ b/bisect.h\n@@ -12,6 +12,7 @@ extern struct commit_list *filter_skipped(struct commit_list *list,\n /* show_bisect_vars flags */\n #define SHOW_ALL\t1\n #define SHOW_TRIED\t2\n+#define SHOW_STRINGED\t4\n \n /*\n  * The flag SHOW_ALL should not be set if this function is called\ndiff --git a/builtin-rev-list.c b/builtin-rev-list.c\nindex c1c4a18..83b2214 100644\n--- a/builtin-rev-list.c\n+++ b/builtin-rev-list.c\n@@ -226,11 +226,13 @@ static int estimate_bisect_steps(int all)\n \treturn (e < 3 * x) ? n : n - 1;\n }\n \n-static void show_tried_revs(struct commit_list *tried)\n+static void show_tried_revs(struct commit_list *tried, int stringed)\n {\n+\tchar *last_format = stringed ? \"%s &&\" : \"%s\";\n+\n \tprintf(\"bisect_tried='\");\n \tfor (;tried; tried = tried->next) {\n-\t\tchar *format = tried->next ? \"%s|\" : \"%s\";\n+\t\tchar *format = tried->next ? \"%s|\" : last_format;\n \t\tprintf(format, sha1_to_hex(tried->item->object.sha1));\n \t}\n \tprintf(\"'\\n\");\n@@ -239,7 +241,7 @@ static void show_tried_revs(struct commit_list *tried)\n int show_bisect_vars(struct rev_info *revs, int reaches, int all, int flags)\n {\n \tint cnt;\n-\tchar hex[41] = \"\";\n+\tchar hex[41] = \"\", *format;\n \tstruct commit_list *tried;\n \n \tif (!revs->commits && !(flags & SHOW_TRIED))\n@@ -269,13 +271,22 @@ int show_bisect_vars(struct rev_info *revs, int reaches, int all, int flags)\n \t}\n \n \tif (flags & SHOW_TRIED)\n-\t\tshow_tried_revs(tried);\n-\tprintf(\"bisect_rev=%s\\n\"\n-\t       \"bisect_nr=%d\\n\"\n-\t       \"bisect_good=%d\\n\"\n-\t       \"bisect_bad=%d\\n\"\n-\t       \"bisect_all=%d\\n\"\n-\t       \"bisect_steps=%d\\n\",\n+\t\tshow_tried_revs(tried, flags & SHOW_STRINGED);\n+\tformat = (flags & SHOW_STRINGED) ?\n+\t\t\"bisect_rev=%s &&\\n\"\n+\t\t\"bisect_nr=%d &&\\n\"\n+\t\t\"bisect_good=%d &&\\n\"\n+\t\t\"bisect_bad=%d &&\\n\"\n+\t\t\"bisect_all=%d &&\\n\"\n+\t\t\"bisect_steps=%d\\n\"\n+\t\t:\n+\t\t\"bisect_rev=%s\\n\"\n+\t\t\"bisect_nr=%d\\n\"\n+\t\t\"bisect_good=%d\\n\"\n+\t\t\"bisect_bad=%d\\n\"\n+\t\t\"bisect_all=%d\\n\"\n+\t\t\"bisect_steps=%d\\n\";\n+\tprintf(format,\n \t       hex,\n \t       cnt - 1,\n \t       all - reaches - 1,\ndiff --git a/git-bisect.sh b/git-bisect.sh\nindex 0f7590d..5074dda 100755\n--- a/git-bisect.sh\n+++ b/git-bisect.sh\n@@ -279,18 +279,6 @@ bisect_auto_next() {\n \tbisect_next_check && bisect_next || :\n }\n \n-eval_and_string_together() {\n-\t_eval=\"$1\"\n-\n-\teval \"$_eval\" | {\n-\t\twhile read line\n-\t\tdo\n-\t\t\techo \"$line &&\"\n-\t\tdone\n-\t\techo ':'\n-\t}\n-}\n-\n exit_if_skipped_commits () {\n \t_tried=$1\n \t_bad=$2\n@@ -429,8 +417,7 @@ bisect_next() {\n \ttest \"$?\" -eq \"1\" && return\n \n \t# Get bisection information\n-\teval=\"git bisect--helper --next-vars\" &&\n-\teval=$(eval_and_string_together \"$eval\") &&\n+\teval=$(eval \"git bisect--helper --next-vars\") &&\n \teval \"$eval\" || exit\n \n \tif [ -z \"$bisect_rev\" ]; then\n-- \n1.6.2.1.404.gb0085.dirty\n"},{"id":"109809","messageId":"200903300618.19041.chriscool@tuxfamily.org","threadId":"18615","inReplyTo":"20090329115547.91e2de5b.chriscool@tuxfamily.org","subject":"Re: [PATCH 2/2] bisect--helper: string output variables together with \"&&\"","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2009-03-30T04:18:18Z","receivedAt":"2009-03-30T04:18:18Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Le dimanche 29 mars 2009, Christian Couder a écrit :\n\n> -static void show_tried_revs(struct commit_list *tried)\n> +static void show_tried_revs(struct commit_list *tried, int stringed)\n>  {\n> +\tchar *last_format = stringed ? \"%s &&\" : \"%s\";\n> +\n>  \tprintf(\"bisect_tried='\");\n>  \tfor (;tried; tried = tried->next) {\n> -\t\tchar *format = tried->next ? \"%s|\" : \"%s\";\n> +\t\tchar *format = tried->next ? \"%s|\" : last_format;\n>  \t\tprintf(format, sha1_to_hex(tried->item->object.sha1));\n>  \t}\n>  \tprintf(\"'\\n\");\n\nOoops, sorry, this is wrong I will send an updaed series.\n\nBest regards,\nChristian.\n"}]}