{"thread":{"id":"11158","subject":"[PATCH] for-each-ref: Fix quoting style constants.","startedAt":"2007-12-06T12:11:46Z","lastAt":"2007-12-06T12:24:39Z","messageCount":3,"participants":["Johannes Sixt","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"62137","messageId":"1196943106-4559-1-git-send-email-johannes.sixt@telecom.at","threadId":"11158","inReplyTo":null,"subject":"[PATCH] for-each-ref: Fix quoting style constants.","fromName":"Johannes Sixt","fromEmail":"johannes.sixt@telecom.at","sentAt":"2007-12-06T12:11:46Z","receivedAt":"2007-12-06T12:11:46Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"for-each-ref can accept only one quoting style. For this reason it uses\nOPT_BIT for the quoting style switches so that it is easy to check for\nmore than one bit being set. However, not all symbolic constants were\nactually single bit values. In particular:\n\n    $ git for-each-ref --python\n    error: more than one quoting style ?\n\nThis fixes it.\n\nWhile we are here, let's also remove the space before the question mark.\n\nSigned-off-by: Johannes Sixt <johannes.sixt@telecom.at>\n---\n builtin-for-each-ref.c  |    6 +++---\n t/t6300-for-each-ref.sh |   44 ++++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 47 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin-for-each-ref.c b/builtin-for-each-ref.c\nindex daf3a08..f36a43c 100644\n--- a/builtin-for-each-ref.c\n+++ b/builtin-for-each-ref.c\n@@ -13,8 +13,8 @@\n #define QUOTE_NONE 0\n #define QUOTE_SHELL 1\n #define QUOTE_PERL 2\n-#define QUOTE_PYTHON 3\n-#define QUOTE_TCL 4\n+#define QUOTE_PYTHON 4\n+#define QUOTE_TCL 8\n \n typedef enum { FIELD_STR, FIELD_ULONG, FIELD_TIME } cmp_type;\n \n@@ -861,7 +861,7 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix)\n \t\tusage_with_options(for_each_ref_usage, opts);\n \t}\n \tif (HAS_MULTI_BITS(quote_style)) {\n-\t\terror(\"more than one quoting style ?\");\n+\t\terror(\"more than one quoting style?\");\n \t\tusage_with_options(for_each_ref_usage, opts);\n \t}\n \tif (verify_format(format))\ndiff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh\nindex c722635..c5d0721 100755\n--- a/t/t6300-for-each-ref.sh\n+++ b/t/t6300-for-each-ref.sh\n@@ -169,5 +169,49 @@ test_expect_success 'Verify descending sort' '\n \tgit diff expected actual\n '\n \n+cat >expected <<\\EOF\n+'refs/heads/master'\n+'refs/tags/testtag'\n+EOF\n+\n+test_expect_success 'Quoting style: shell' '\n+\tgit for-each-ref --shell --format=\"%(refname)\" >actual &&\n+\tgit diff expected actual\n+'\n+\n+test_expect_success 'Quoting style: perl' '\n+\tgit for-each-ref --perl --format=\"%(refname)\" >actual &&\n+\tgit diff expected actual\n+'\n+\n+test_expect_success 'Quoting style: python' '\n+\tgit for-each-ref --python --format=\"%(refname)\" >actual &&\n+\tgit diff expected actual\n+'\n+\n+test_expect_success 'Quoting style: tcl' '\n+\tgit for-each-ref --python --format=\"%(refname)\" >actual &&\n+\tgit diff expected actual\n+'\n+\n+cat >expected <<\\EOF\n+\"refs/heads/master\"\n+\"refs/tags/testtag\"\n+EOF\n+\n+test_expect_success 'Quoting style: shell' '\n+\tgit for-each-ref --tcl --format=\"%(refname)\" >actual &&\n+\tgit diff expected actual\n+'\n+\n+for i in \"--perl --shell\" \"-s --python\" \"--python --tcl\" \"--tcl --perl\"; do\n+\ttest_expect_success \"more than one quoting style: $i\" \"\n+\t\tgit for-each-ref $i 2>&1 | (read line &&\n+\t\tcase \\$line in\n+\t\t\\\"error: more than one quoting style\\\"*) : happy;;\n+\t\t*) false\n+\t\tesac)\n+\t\"\n+done\n \n test_done\n-- \n1.5.3.7.1079.gecca\n"},{"id":"62141","messageId":"Pine.LNX.4.64.0712061219280.27959@racer.site","threadId":"11158","inReplyTo":"1196943106-4559-1-git-send-email-johannes.sixt@telecom.at","subject":"Re: [PATCH] for-each-ref: Fix quoting style constants.","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-12-06T12:19:58Z","receivedAt":"2007-12-06T12:19:58Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Thu, 6 Dec 2007, Johannes Sixt wrote:\n\n>     $ git for-each-ref --python\n>     error: more than one quoting style ?\n> \n> While we are here, let's also remove the space before the question mark.\n\nDoesn't python need that piece of whitespace? *ducks*\n\nCiao,\nDscho\n"},{"id":"62142","messageId":"1196943879-6214-1-git-send-email-johannes.sixt@telecom.at","threadId":"11158","inReplyTo":"1196943106-4559-1-git-send-email-johannes.sixt@telecom.at","subject":"[PATCH amended] for-each-ref: Fix quoting style constants.","fromName":"Johannes Sixt","fromEmail":"johannes.sixt@telecom.at","sentAt":"2007-12-06T12:24:39Z","receivedAt":"2007-12-06T12:24:39Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"for-each-ref can accept only one quoting style. For this reason it uses\nOPT_BIT for the quoting style switches so that it is easy to check for\nmore than one bit being set. However, not all symbolic constants were\nactually single bit values. In particular:\n\n    $ git for-each-ref --python\n    error: more than one quoting style ?\n\nThis fixes it.\n\nWhile we are here, let's also remove the space before the question mark.\n\nSigned-off-by: Johannes Sixt <johannes.sixt@telecom.at>\n---\n\tThis fixes the test cases so that the headlines tell what the\n\ttests cases actually test.\n\n\tDon't know what I was smoking when I submitted the first version.\n\n\t-- Hannes\n\n builtin-for-each-ref.c  |    6 +++---\n t/t6300-for-each-ref.sh |   39 +++++++++++++++++++++++++++++++++++++++\n 2 files changed, 42 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin-for-each-ref.c b/builtin-for-each-ref.c\nindex daf3a08..f36a43c 100644\n--- a/builtin-for-each-ref.c\n+++ b/builtin-for-each-ref.c\n@@ -13,8 +13,8 @@\n #define QUOTE_NONE 0\n #define QUOTE_SHELL 1\n #define QUOTE_PERL 2\n-#define QUOTE_PYTHON 3\n-#define QUOTE_TCL 4\n+#define QUOTE_PYTHON 4\n+#define QUOTE_TCL 8\n \n typedef enum { FIELD_STR, FIELD_ULONG, FIELD_TIME } cmp_type;\n \n@@ -861,7 +861,7 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix)\n \t\tusage_with_options(for_each_ref_usage, opts);\n \t}\n \tif (HAS_MULTI_BITS(quote_style)) {\n-\t\terror(\"more than one quoting style ?\");\n+\t\terror(\"more than one quoting style?\");\n \t\tusage_with_options(for_each_ref_usage, opts);\n \t}\n \tif (verify_format(format))\ndiff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh\nindex c722635..8a23aaf 100755\n--- a/t/t6300-for-each-ref.sh\n+++ b/t/t6300-for-each-ref.sh\n@@ -169,5 +169,44 @@ test_expect_success 'Verify descending sort' '\n \tgit diff expected actual\n '\n \n+cat >expected <<\\EOF\n+'refs/heads/master'\n+'refs/tags/testtag'\n+EOF\n+\n+test_expect_success 'Quoting style: shell' '\n+\tgit for-each-ref --shell --format=\"%(refname)\" >actual &&\n+\tgit diff expected actual\n+'\n+\n+test_expect_success 'Quoting style: perl' '\n+\tgit for-each-ref --perl --format=\"%(refname)\" >actual &&\n+\tgit diff expected actual\n+'\n+\n+test_expect_success 'Quoting style: python' '\n+\tgit for-each-ref --python --format=\"%(refname)\" >actual &&\n+\tgit diff expected actual\n+'\n+\n+cat >expected <<\\EOF\n+\"refs/heads/master\"\n+\"refs/tags/testtag\"\n+EOF\n+\n+test_expect_success 'Quoting style: tcl' '\n+\tgit for-each-ref --tcl --format=\"%(refname)\" >actual &&\n+\tgit diff expected actual\n+'\n+\n+for i in \"--perl --shell\" \"-s --python\" \"--python --tcl\" \"--tcl --perl\"; do\n+\ttest_expect_success \"more than one quoting style: $i\" \"\n+\t\tgit for-each-ref $i 2>&1 | (read line &&\n+\t\tcase \\$line in\n+\t\t\\\"error: more than one quoting style\\\"*) : happy;;\n+\t\t*) false\n+\t\tesac)\n+\t\"\n+done\n \n test_done\n-- \n1.5.3.7.1079.gecca\n"}]}