{"thread":{"id":"25238","subject":"[PATCH/RFC v2 0/4] rev-parse: allow --flags to output rev-parse-like flags","startedAt":"2010-09-25T09:04:09Z","lastAt":"2010-09-25T10:29:07Z","messageCount":8,"participants":["Jon Seymour","Ævar Arnfjörð Bjarmason"],"isPatch":true,"patchVersion":2,"patchTotal":4},"messages":[{"id":"151623","messageId":"1285405454-12521-1-git-send-email-jon.seymour@gmail.com","threadId":"25238","inReplyTo":null,"subject":"[PATCH/RFC v2 0/4] rev-parse: allow --flags to output rev-parse-like flags","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2010-09-25T09:04:09Z","receivedAt":"2010-09-25T09:04:09Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"This series allows git rev-parse --flags to output remaining flag-like arguments\neven if such arguments are valid options to git rev-parse itself.\n\nPreviously:\n  $> git rev-parse --flags -q -X --no-flags -- Y -Z\n  -X\n\nNow:\n  $> git rev-parse --flags -q -X --no-flags -- Y -Z\n  -q -X --no-flags\n\nAlso:\n  $> git rev-parse --symbolic --no-flags --flags -X HEAD\n  HEAD\n\nNote: git rev-parse --flags still seems broken w.r.t. documentation because:\n  $> git rev-parse --symbolic --flags HEAD\n  HEAD\neven though the documentation states that --flags does not output non-flag\narguments.\n\nJon Seymour (4):\n  rev-parse: stop interpreting flags as options to rev-parse once\n    --flags is specified\n  rev-parse: Don't recognise --flags as an option if --no-flags has\n    been specified.\n  rev-parse: add tests for git rev-parse --flags.\n  rev-parse: update documentation of --flags and --no-flags options\n\n Documentation/git-rev-parse.txt |   10 +++-\n builtin/rev-parse.c             |   11 ++++\n t/t1510-rev-parse-flags.sh      |  116 +++++++++++++++++++++++++++++++++++++++\n 3 files changed, 135 insertions(+), 2 deletions(-)\n create mode 100755 t/t1510-rev-parse-flags.sh\n\n-- \n1.7.3.1.gc81ce.dirty\n"},{"id":"151624","messageId":"1285405454-12521-2-git-send-email-jon.seymour@gmail.com","threadId":"25238","inReplyTo":"1285405454-12521-1-git-send-email-jon.seymour@gmail.com","subject":"[PATCH/RFC v2 0/4] *** SUBJECT HERE ***","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2010-09-25T09:04:10Z","receivedAt":"2010-09-25T09:04:10Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"*** BLURB HERE ***\n\nJon Seymour (4):\n  rev-parse: stop interpreting flags as options to rev-parse once\n    --flags is specified\n  rev-parse: Don't recognise --flags as an option if --no-flags has\n    been specified.\n  rev-parse: add tests for git rev-parse --flags.\n  rev-parse: update documentation of --flags and --no-flags options\n\n Documentation/git-rev-parse.txt |   10 +++-\n builtin/rev-parse.c             |   11 ++++\n t/t1510-rev-parse-flags.sh      |  116 +++++++++++++++++++++++++++++++++++++++\n 3 files changed, 135 insertions(+), 2 deletions(-)\n create mode 100755 t/t1510-rev-parse-flags.sh\n\n-- \n1.7.3.1.gc81ce.dirty\n"},{"id":"151625","messageId":"1285405454-12521-3-git-send-email-jon.seymour@gmail.com","threadId":"25238","inReplyTo":"1285405454-12521-1-git-send-email-jon.seymour@gmail.com","subject":"[PATCH/RFC v2 1/4] rev-parse: stop interpreting flags as options to rev-parse once --flags is specified","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2010-09-25T09:04:11Z","receivedAt":"2010-09-25T09:04:11Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"Current git rev-parse behaviour makes --flags hard to use if the remaining\narguments to git rev-parse contain an option that would otherwise be interpreted\nas an option by git rev-parse itself.\n\nSo, for example:\n\n  $> git rev-parse --flags -q -X\n  -X\n\nNormally one might expect to use -- to prevent -q being interpreted:\n\n  $> git rev-parse --flags -- -q -X\n  -q -X\n\nBut we can't really use -- in this way, because commands that use\ngit rev-parse might reasonably expect:\n\n  $> git rev-parse --flags -Y -- -q -X\n  -Y\n\nThat is, -Y to be regarded as a flag but everything after -- to be uninterpreted.\n\nThis proposed change modifies git rev-parse so that git rev-parse stops\ninterpreting flag arguments as options to git rev-parse once --flags is\ninterpreted. We also exit early once -- is found.\n\nTests will follow in subsequent iterations of this patch, if the consensus\nis that the approach is correct.\n\nSigned-off-by: Jon Seymour <jon.seymour@gmail.com>\n---\n builtin/rev-parse.c |    7 +++++++\n 1 files changed, 7 insertions(+), 0 deletions(-)\n\ndiff --git a/builtin/rev-parse.c b/builtin/rev-parse.c\nindex a5a1c86..9e340c7 100644\n--- a/builtin/rev-parse.c\n+++ b/builtin/rev-parse.c\n@@ -497,8 +497,15 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)\n \t\t\t\t/* Pass on the \"--\" if we show anything but files.. */\n \t\t\t\tif (filter & (DO_FLAGS | DO_REVS))\n \t\t\t\t\tshow_file(arg);\n+\t\t\t\tif (!(filter & DO_NONFLAGS)) {\n+\t\t\t\t\treturn 0;\n+\t\t\t\t}\n \t\t\t\tcontinue;\n \t\t\t}\n+\t\t\tif (!(filter & DO_NONFLAGS)) {\n+\t\t\t\t show_flag(arg);\n+\t\t\t\t continue;\n+\t\t\t}\n \t\t\tif (!strcmp(arg, \"--default\")) {\n \t\t\t\tdef = argv[i+1];\n \t\t\t\ti++;\n-- \n1.7.3.1.gc81ce.dirty\n"},{"id":"151626","messageId":"1285405454-12521-4-git-send-email-jon.seymour@gmail.com","threadId":"25238","inReplyTo":"1285405454-12521-1-git-send-email-jon.seymour@gmail.com","subject":"[PATCH/RFC v2 2/4] rev-parse: Don't recognise --flags as an option if --no-flags has been specified.","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2010-09-25T09:04:12Z","receivedAt":"2010-09-25T09:04:12Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"Previously:\n   $ git rev-parse --no-flags --flags -X\n   -X\n\nnow:\n   $ git rev-parse --no-flags --flags -X\n\n\nSigned-off-by: Jon Seymour <jon.seymour@gmail.com>\n---\n builtin/rev-parse.c |    4 ++++\n 1 files changed, 4 insertions(+), 0 deletions(-)\n\ndiff --git a/builtin/rev-parse.c b/builtin/rev-parse.c\nindex 9e340c7..d403d29 100644\n--- a/builtin/rev-parse.c\n+++ b/builtin/rev-parse.c\n@@ -520,6 +520,10 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)\n \t\t\t\tcontinue;\n \t\t\t}\n \t\t\tif (!strcmp(arg, \"--flags\")) {\n+\t\t\t\tif (!(filter & DO_FLAGS)) {\n+\t\t\t\t\t// --preceding --no-flags means --flags is ignored\n+\t\t\t\t\tcontinue;\n+\t\t\t\t}\n \t\t\t\tfilter &= ~DO_NONFLAGS;\n \t\t\t\tcontinue;\n \t\t\t}\n-- \n1.7.3.1.gc81ce.dirty\n"},{"id":"151627","messageId":"1285405454-12521-5-git-send-email-jon.seymour@gmail.com","threadId":"25238","inReplyTo":"1285405454-12521-1-git-send-email-jon.seymour@gmail.com","subject":"[PATCH/RFC v2 3/4] rev-parse: add tests for git rev-parse --flags.","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2010-09-25T09:04:13Z","receivedAt":"2010-09-25T09:04:13Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"Signed-off-by: Jon Seymour <jon.seymour@gmail.com>\n---\n t/t1510-rev-parse-flags.sh |  116 ++++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 116 insertions(+), 0 deletions(-)\n create mode 100755 t/t1510-rev-parse-flags.sh\n\ndiff --git a/t/t1510-rev-parse-flags.sh b/t/t1510-rev-parse-flags.sh\nnew file mode 100755\nindex 0000000..f41130d\n--- /dev/null\n+++ b/t/t1510-rev-parse-flags.sh\n@@ -0,0 +1,116 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2010 Jon Seymour\n+#\n+\n+test_description='test git rev-parse --flags'\n+. ./test-lib.sh\n+\n+test_commit \"A\"\n+\n+test_expect_success 'git rev-parse --flags -> \"\"' \\\n+'\n+\toutput=$(git rev-parse --flags) &&\n+\texpected=\"\" &&\n+\ttest \"${output}\" = \"${expected}\"\n+'\n+\n+test_expect_success 'git rev-parse --flags X -> \"\"' \\\n+'\n+\toutput=$(git rev-parse --flags X) &&\n+\texpected=\"\" &&\n+\ttest \"${output}\" = \"${expected}\"\n+'\n+\n+test_expect_success 'git rev-parse --no-revs --flags HEAD -> \"\"' \\\n+'\n+\toutput=$(git rev-parse --no-revs --flags HEAD) &&\n+\texpected=\"\" &&\n+\ttest \"${output}\" = \"${expected}\"\n+'\n+\n+test_expect_success 'git rev-parse --symbolic --flags HEAD -> \"HEAD\"' \\\n+'\n+\toutput=$(git rev-parse --symbolic --flags HEAD) &&\n+\texpected=\"HEAD\" &&\n+\ttest \"${output}\" = \"${expected}\"\n+'\n+\n+test_expect_success 'git rev-parse --flags -- -> \"\"' \\\n+'\n+\toutput=$(git rev-parse --flags --) &&\n+\texpected=\"\" &&\n+\ttest \"${output}\" = \"${expected}\"\n+'\n+\n+test_expect_success 'git rev-parse --flags -- X -> \"\"' \\\n+'\n+\toutput=$(git rev-parse --flags -- X) &&\n+\texpected=\"\" &&\n+\ttest \"${output}\" = \"${expected}\"\n+'\n+\n+test_expect_success 'git rev-parse --flags -- -X -> \"\"' \\\n+'\n+\toutput=$(git rev-parse --flags -- -X) &&\n+\texpected=\"\" &&\n+\ttest \"${output}\" = \"${expected}\"\n+'\n+\n+test_expect_success 'git rev-parse --flags -- -q --> \"\"' \\\n+'\n+\toutput=$(git rev-parse --flags -- -q) &&\n+\texpected=\"\" &&\n+\ttest \"${output}\" = \"${expected}\"\n+'\n+\n+test_expect_success 'git rev-parse --flags -X -> \"-X\"' \\\n+'\n+\toutput=\"$(git rev-parse --flags -X)\" &&\n+\texpected=\"-X\" &&\n+\ttest \"${output}\" = \"${expected}\"\n+'\n+\n+test_expect_success 'git rev-parse --flags -q -> \"-q\"' \\\n+'\n+\toutput=$(git rev-parse --flags -q) &&\n+\texpected=\"-q\" &&\n+\ttest \"${output}\" = \"${expected}\"\n+'\n+\n+test_expect_success 'git rev-parse --flags -X -- Y -Z -> \"-X\"' \\\n+'\n+\toutput=$(git rev-parse --flags -X -- Y -Z) &&\n+\texpected=\"-X\" &&\n+\ttest \"${output}\" = \"${expected}\"\n+'\n+\n+test_expect_success 'git rev-parse --flags --no-flags -> \"--no-flags\"' \\\n+'\n+\toutput=$(git rev-parse --flags --no-flags) &&\n+\texpected=\"--no-flags\" &&\n+\ttest \"${output}\" = \"${expected}\"\n+'\n+\n+test_expect_success 'git rev-parse --no-flags --flags -X -> \"\"' \\\n+'\n+\toutput=$(git rev-parse --no-flags --flags -X) &&\n+\texpected=\"\" &&\n+\ttest \"${output}\" = \"${expected}\"\n+'\n+\n+test_expect_success 'git rev-parse --symbolic --no-flags --flags HEAD -> \"HEAD\"' \\\n+'\n+\toutput=$(git rev-parse --symbolic --no-flags --flags HEAD) &&\n+\texpected=\"HEAD\" &&\n+\ttest \"${output}\" = \"${expected}\"\n+'\n+\n+test_expect_success 'git rev-parse --no-flags --flags -X -> \"\"' \\\n+'\n+\toutput=$(git rev-parse --no-flags --flags -X) &&\n+\texpected=\"\" &&\n+\ttest \"${output}\" = \"${expected}\"\n+'\n+\n+test_done\n-- \n1.7.3.1.gc81ce.dirty\n"},{"id":"151628","messageId":"1285405454-12521-6-git-send-email-jon.seymour@gmail.com","threadId":"25238","inReplyTo":"1285405454-12521-1-git-send-email-jon.seymour@gmail.com","subject":"[PATCH/RFC v2 4/4] rev-parse: update documentation of --flags and --no-flags options","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2010-09-25T09:04:14Z","receivedAt":"2010-09-25T09:04:14Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"Signed-off-by: Jon Seymour <jon.seymour@gmail.com>\n---\n Documentation/git-rev-parse.txt |   10 ++++++++--\n 1 files changed, 8 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-rev-parse.txt b/Documentation/git-rev-parse.txt\nindex 341ca90..8fb8f6b 100644\n--- a/Documentation/git-rev-parse.txt\n+++ b/Documentation/git-rev-parse.txt\n@@ -49,10 +49,16 @@ OPTIONS\n \t'git rev-list' command.\n \n --flags::\n-\tDo not output non-flag parameters.\n+\tDo not output non-flag parameters. All remaining\n+\targuments will not be interpreted as options\n+\tto 'git rev-parse' even if they match options that\n+\t'git rev-parse' might otherwise recognise. As such,\n+\tthis option, if specified, should always be the\n+\tlast option specified.\n \n --no-flags::\n-\tDo not output flag parameters.\n+\tDo not output flag parameters. If specified, this\n+\toption causes any subsequent `--flags` option to be ignored.\n \n --default <arg>::\n \tIf there is no parameter given by the user, use `<arg>`\n-- \n1.7.3.1.gc81ce.dirty\n"},{"id":"151632","messageId":"AANLkTi=1UJ+BJGE+-CXXGsfGeNcejPUT=0BA5MSXjjSv@mail.gmail.com","threadId":"25238","inReplyTo":"1285405454-12521-4-git-send-email-jon.seymour@gmail.com","subject":"Re: [PATCH/RFC v2 2/4] rev-parse: Don't recognise --flags as an option if --no-flags has been specified.","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2010-09-25T10:26:48Z","receivedAt":"2010-09-25T10:26:48Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Sat, Sep 25, 2010 at 09:04, Jon Seymour <jon.seymour@gmail.com> wrote:\n> +                               if (!(filter & DO_FLAGS)) {\n> +                                       // --preceding --no-flags means --flags is ignored\n> +                                       continue;\n> +                               }\n\nPlease use a /* C89 comment */, not the C++ / C99 style.\n"},{"id":"151633","messageId":"AANLkTin+tokb+kmbLWm6CH7T1eqNijNyGvjz6becpxD7@mail.gmail.com","threadId":"25238","inReplyTo":"1285405454-12521-5-git-send-email-jon.seymour@gmail.com","subject":"Re: [PATCH/RFC v2 3/4] rev-parse: add tests for git rev-parse --flags.","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2010-09-25T10:29:07Z","receivedAt":"2010-09-25T10:29:07Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"> +test_expect_success 'git rev-parse --flags -> \"\"' \\\n> +'\n> +       output=$(git rev-parse --flags) &&\n> +       expected=\"\" &&\n> +       test \"${output}\" = \"${expected}\"\n> +'\n> +\n> +test_expect_success 'git rev-parse --flags X -> \"\"' \\\n> +'\n> +       output=$(git rev-parse --flags X) &&\n> +       expected=\"\" &&\n> +       test \"${output}\" = \"${expected}\"\n> +'\n> +\n\nPlease use test_cmp throughout the test instead:\n\n    >expect &&\n    git rev-parse --flags >actual &&\n    test_cmp expect actual\n\netc.\n"}]}