{"thread":{"id":"18295","subject":"[PATCH 8/7] rev-list: make \"--bisect-skip\" read skipped revisions from stdin","startedAt":"2009-03-13T05:29:46Z","lastAt":"2009-03-13T05:29:46Z","messageCount":1,"participants":["Christian Couder"],"isPatch":true,"patchVersion":1,"patchTotal":7},"messages":[{"id":"107903","messageId":"20090313062946.440e2ed7.chriscool@tuxfamily.org","threadId":"18295","inReplyTo":null,"subject":"[PATCH 8/7] rev-list: make \"--bisect-skip\" read skipped revisions from stdin","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2009-03-13T05:29:46Z","receivedAt":"2009-03-13T05:29:46Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Previously, skipped revisions should be passed like this:\n\n$ git rev-list --bisect-skip=<rev1>,<rev2>,<rev3> ...\n\nbut there could be problems on systems where there is a tight limit\non command line lenght.\n\nAs the \"--bisect-skip\" option will be mostly used by porcelain\ncommands, and as the current \"git-bisect.sh\" porcelain does not use\nstdin to pass good or bad revisions, it is acceptable to have\n\"--bisect-skip\" now read skipped commits from stdin.\n\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n bisect-skip.c      |   19 +++++++++++++++++--\n bisect.h           |    2 +-\n builtin-rev-list.c |   11 ++++++++---\n git-bisect.sh      |    4 ++--\n 4 files changed, 28 insertions(+), 8 deletions(-)\n\ndiff --git a/bisect-skip.c b/bisect-skip.c\nindex 789ee09..079e787 100644\n--- a/bisect-skip.c\n+++ b/bisect-skip.c\n@@ -7,7 +7,8 @@ static unsigned char (*skipped_sha1)[20];\n static int skipped_sha1_nr;\n static int skipped_sha1_alloc;\n \n-void register_skipped(const char *skipped)\n+\n+static void register_skipped(const char *skipped)\n {\n \tstruct strbuf sb, **list, **it, *cur;\n \tint len = strlen(skipped);\n@@ -15,7 +16,7 @@ void register_skipped(const char *skipped)\n \tstrbuf_init(&sb, len);\n \tstrbuf_add(&sb, skipped, len);\n \n-\tlist = strbuf_split(&sb, ',', 0);\n+\tlist = strbuf_split(&sb, ' ', 0);\n \n \tfor (it = list; (cur = *it); it++) {\n \t\tALLOC_GROW(skipped_sha1, skipped_sha1_nr + 1,\n@@ -28,6 +29,20 @@ void register_skipped(const char *skipped)\n \tstrbuf_release(&sb);\n }\n \n+void read_skipped_revisions_from_stdin(void)\n+{\n+\tchar line[1000];\n+\n+\twhile (fgets(line, sizeof(line), stdin) != NULL) {\n+\t\tint len = strlen(line);\n+\t\tif (len && line[len - 1] == '\\n')\n+\t\t\tline[--len] = '\\0';\n+\t\tif (!len)\n+\t\t\tbreak;\n+\t\tregister_skipped(line);\n+\t}\n+}\n+\n int skipped_nr(void)\n {\n \treturn skipped_sha1_nr;\ndiff --git a/bisect.h b/bisect.h\nindex ff9c781..c41b568 100644\n--- a/bisect.h\n+++ b/bisect.h\n@@ -1,7 +1,7 @@\n #ifndef BISECT_H\n #define BISECT_H\n \n-void register_skipped(const char *skipped);\n+void read_skipped_revisions_from_stdin(void);\n int skipped_nr(void);\n struct commit_list *filter_skipped(struct commit_list *list,\n \t\t\t\t   struct commit_list **tried,\ndiff --git a/builtin-rev-list.c b/builtin-rev-list.c\nindex 4af70d7..bf16197 100644\n--- a/builtin-rev-list.c\n+++ b/builtin-rev-list.c\n@@ -334,16 +334,21 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)\n \t\t\tbisect_show_vars = 1;\n \t\t\tcontinue;\n \t\t}\n-\t\tif (!prefixcmp(arg, \"--bisect-skip=\")) {\n+\t\tif (!prefixcmp(arg, \"--bisect-skip\")) {\n \t\t\tbisect_list = 1;\n \t\t\tbisect_show_vars = 1;\n-\t\t\tbisect_skip = 1;\n-\t\t\tregister_skipped(arg + 14);\n+\t\t\tif (bisect_skip++)\n+\t\t\t\tdie(\"--bisect-skip given twice?\");\n+\t\t\tif (read_from_stdin)\n+\t\t\t\tdie(\"--bisect-skip cannot work with --stdin\");\n+\t\t\tread_skipped_revisions_from_stdin();\n \t\t\tcontinue;\n \t\t}\n \t\tif (!strcmp(arg, \"--stdin\")) {\n \t\t\tif (read_from_stdin++)\n \t\t\t\tdie(\"--stdin given twice?\");\n+\t\t\tif (bisect_skip)\n+\t\t\t\tdie(\"--stdin cannot work with --bisect-skip\");\n \t\t\tread_revisions_from_stdin(&revs);\n \t\t\tcontinue;\n \t\t}\ndiff --git a/git-bisect.sh b/git-bisect.sh\nindex 31e7cff..da3c077 100755\n--- a/git-bisect.sh\n+++ b/git-bisect.sh\n@@ -429,8 +429,8 @@ bisect_next() {\n \ttest \"$?\" -eq \"1\" && return\n \n \t# Get bisection information\n-\tskip=$(echo $skip | tr ' ' ',')\n-\teval=\"git rev-list --bisect-skip=$skip $good $bad --\" &&\n+\teval=\"echo $skip | tr ' ' '\\012'\" &&\n+\teval=\"$eval | git rev-list --bisect-skip $good $bad --\" &&\n \teval=\"$eval $(cat \"$GIT_DIR/BISECT_NAMES\")\" &&\n \teval=$(eval_and_string_together \"$eval\") &&\n \teval \"$eval\" || exit\n-- \n1.6.2.84.gcd0b4.dirty\n"}]}