{"thread":{"id":"25240","subject":"[PATCH v3 0/3] rev-parse: allow --flags to output rev-parse-like flags","startedAt":"2010-09-25T11:22:40Z","lastAt":"2010-09-25T11:22:43Z","messageCount":4,"participants":["Jon Seymour"],"isPatch":true,"patchVersion":3,"patchTotal":3},"messages":[{"id":"151634","messageId":"1285413763-25082-1-git-send-email-jon.seymour@gmail.com","threadId":"25240","inReplyTo":null,"subject":"[PATCH v3 0/3] rev-parse: allow --flags to output rev-parse-like flags","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2010-09-25T11:22:40Z","receivedAt":"2010-09-25T11:22:40Z","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  $\n\nNow:\n  $ git rev-parse --flags -q -X --no-flags -- Y -Z\n  -q -X --no-flags\n  $\n\nNote existing behaviour was:\n  $ git rev-parse --flags HEAD\n  HEAD\n  $\n\nThis behaviour is unchanged by this series, but the documentation has\nbeen updated to state that --flags:\n  Do not output non-flag parameters which are not also revisions.\n\nReviewers are invited to comment on whether current behaviour\nis reasonable or whether the implementation should be changed\nto match the current documentation. That is, to make the behaviour:\n\n  $ git rev-parse --flags HEAD\n  $ \n\nThis series differs from v2 in that 2/4 of the previous series\nwas actually unnecesssary since --no-flags --flags -X already\nproduced no output. The documentation has been reworded to\nrelect current behaviour more accurately.\n\nAevar's feedback has been incorporated.\n\nJon Seymour (3):\n  rev-parse: stop interpreting flags as options to rev-parse once\n    --flags is 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 |   14 ++++-\n builtin/rev-parse.c             |    8 +++\n t/t1510-rev-parse-flags.sh      |  109 +++++++++++++++++++++++++++++++++++++++\n 3 files changed, 129 insertions(+), 2 deletions(-)\n create mode 100755 t/t1510-rev-parse-flags.sh\n\n-- \n1.7.3.3.g262a8\n"},{"id":"151635","messageId":"1285413763-25082-2-git-send-email-jon.seymour@gmail.com","threadId":"25240","inReplyTo":"1285413763-25082-1-git-send-email-jon.seymour@gmail.com","subject":"[PATCH v3 1/3] 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-25T11:22:41Z","receivedAt":"2010-09-25T11:22:41Z","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\nSigned-off-by: Jon Seymour <jon.seymour@gmail.com>\n---\n builtin/rev-parse.c |    8 ++++++++\n 1 files changed, 8 insertions(+), 0 deletions(-)\n\ndiff --git a/builtin/rev-parse.c b/builtin/rev-parse.c\nindex a5a1c86..2ad269a 100644\n--- a/builtin/rev-parse.c\n+++ b/builtin/rev-parse.c\n@@ -497,8 +497,16 @@ 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/* once we see --flags, we stop interpreting other flags */\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.2.g216ca.dirty\n"},{"id":"151636","messageId":"1285413763-25082-3-git-send-email-jon.seymour@gmail.com","threadId":"25240","inReplyTo":"1285413763-25082-1-git-send-email-jon.seymour@gmail.com","subject":"[PATCH v3 2/3] rev-parse: add tests for git rev-parse --flags.","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2010-09-25T11:22:42Z","receivedAt":"2010-09-25T11:22:42Z","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 |  109 ++++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 109 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..53002df\n--- /dev/null\n+++ b/t/t1510-rev-parse-flags.sh\n@@ -0,0 +1,109 @@\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+\t: >expected &&\n+\tgit rev-parse --flags >actual &&\n+\ttest_cmp expected actual\n+'\n+\n+test_expect_success 'git rev-parse --flags X -> \"\"' \\\n+'\n+\t: >expected &&\n+\tgit rev-parse --flags X >actual &&\n+\ttest_cmp expected actual\n+'\n+\n+test_expect_success 'git rev-parse --no-revs --flags HEAD -> \"\"' \\\n+'\n+\t: >expected &&\n+\tgit rev-parse --no-revs --flags HEAD >actual &&\n+\ttest_cmp expected actual\n+'\n+\n+test_expect_success 'git rev-parse --symbolic --flags HEAD -> \"HEAD\"' \\\n+'\n+\techo HEAD > expected &&\n+\tgit rev-parse --symbolic --flags HEAD >actual &&\n+\ttest_cmp expected actual\n+'\n+\n+test_expect_success 'git rev-parse --flags -- -> \"\"' \\\n+'\n+\t: >expected &&\n+\tgit rev-parse --flags -- >actual &&\n+\ttest_cmp expected actual\n+'\n+\n+test_expect_success 'git rev-parse --flags -- X -> \"\"' \\\n+'\n+\t: >expected &&\n+\tgit rev-parse --flags -- X >actual &&\n+\ttest_cmp expected actual\n+'\n+\n+test_expect_success 'git rev-parse --flags -- -X -> \"\"' \\\n+'\n+\t: >expected &&\n+\tgit rev-parse --flags -- -X >actual &&\n+\ttest_cmp expected actual\n+'\n+\n+test_expect_success 'git rev-parse --flags -- -q --> \"\"' \\\n+'\n+\t: >expected &&\n+\tgit rev-parse --flags -- -q >actual &&\n+\ttest_cmp expected actual\n+'\n+\n+test_expect_success 'git rev-parse --flags -X -> \"-X\"' \\\n+'\n+\techo -X > expected &&\n+\tgit rev-parse --flags -X >actual &&\n+\ttest_cmp expected actual\n+'\n+\n+test_expect_success 'git rev-parse --flags -q -> \"-q\"' \\\n+'\n+\techo -q > expected &&\n+\tgit rev-parse --flags -q >actual &&\n+\ttest_cmp expected actual\n+'\n+\n+test_expect_success 'git rev-parse --flags -X -- Y -Z -> \"-X\"' \\\n+'\n+\techo -X > expected &&\n+\tgit rev-parse --flags -X -- Y -Z >actual &&\n+\ttest_cmp expected actual\n+'\n+\n+test_expect_success 'git rev-parse --flags --no-flags -> \"--no-flags\"' \\\n+'\n+\techo --no-flags > expected &&\n+\tgit rev-parse --flags --no-flags >actual &&\n+\ttest_cmp expected actual\n+'\n+\n+test_expect_success 'git rev-parse --no-flags --flags -X -> \"\"' \\\n+'\n+\t: >expected &&\n+\tgit rev-parse --no-flags --flags -X >actual &&\n+\ttest_cmp expected actual\n+'\n+\n+test_expect_success 'git rev-parse --symbolic --no-flags --flags HEAD -> \"HEAD\"' \\\n+'\n+\techo HEAD >expected &&\n+\tgit rev-parse --symbolic --no-flags --flags HEAD >actual &&\n+\ttest_cmp expected actual\n+'\n+\n+test_done\n-- \n1.7.3.2.g216ca.dirty\n"},{"id":"151637","messageId":"1285413763-25082-4-git-send-email-jon.seymour@gmail.com","threadId":"25240","inReplyTo":"1285413763-25082-1-git-send-email-jon.seymour@gmail.com","subject":"[PATCH v3 3/3] rev-parse: update documentation of --flags and --no-flags options","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2010-09-25T11:22:43Z","receivedAt":"2010-09-25T11:22:43Z","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 |   12 +++++++++++-\n 1 files changed, 11 insertions(+), 1 deletions(-)\n\ndiff --git a/Documentation/git-rev-parse.txt b/Documentation/git-rev-parse.txt\nindex 341ca90..f5e6637 100644\n--- a/Documentation/git-rev-parse.txt\n+++ b/Documentation/git-rev-parse.txt\n@@ -49,10 +49,20 @@ OPTIONS\n \t'git rev-list' command.\n \n --flags::\n-\tDo not output non-flag parameters.\n+\tDo not output non-flag parameters which are not also revisions.\n+\t+\n+\tIf specified, this option causes 'git rev-parse' to stop\n+\tinterpreting remaining arguments as options for its own\n+\tconsumption. As such, this option should be specified\n+\tafter all other options that 'git rev-parse' is expected\n+\tto interpret.\n \n --no-flags::\n \tDo not output flag parameters.\n+\t+\n+\tIf both `--flags` and `--no-flags` are specified, the first\n+\toption specified wins and the other option is treated like\n+\ta non-option argument.\n \n --default <arg>::\n \tIf there is no parameter given by the user, use `<arg>`\n-- \n1.7.3.2.g216ca.dirty\n"}]}