* [PATCH] for-each-ref: Fix quoting style constants.
@ 2007-12-06 12:11 Johannes Sixt
2007-12-06 12:19 ` Johannes Schindelin
2007-12-06 12:24 ` [PATCH amended] " Johannes Sixt
0 siblings, 2 replies; 3+ messages in thread
From: Johannes Sixt @ 2007-12-06 12:11 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Git Mailing List, Johannes Sixt
for-each-ref can accept only one quoting style. For this reason it uses
OPT_BIT for the quoting style switches so that it is easy to check for
more than one bit being set. However, not all symbolic constants were
actually single bit values. In particular:
$ git for-each-ref --python
error: more than one quoting style ?
This fixes it.
While we are here, let's also remove the space before the question mark.
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
---
builtin-for-each-ref.c | 6 +++---
t/t6300-for-each-ref.sh | 44 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 47 insertions(+), 3 deletions(-)
diff --git a/builtin-for-each-ref.c b/builtin-for-each-ref.c
index daf3a08..f36a43c 100644
--- a/builtin-for-each-ref.c
+++ b/builtin-for-each-ref.c
@@ -13,8 +13,8 @@
#define QUOTE_NONE 0
#define QUOTE_SHELL 1
#define QUOTE_PERL 2
-#define QUOTE_PYTHON 3
-#define QUOTE_TCL 4
+#define QUOTE_PYTHON 4
+#define QUOTE_TCL 8
typedef enum { FIELD_STR, FIELD_ULONG, FIELD_TIME } cmp_type;
@@ -861,7 +861,7 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix)
usage_with_options(for_each_ref_usage, opts);
}
if (HAS_MULTI_BITS(quote_style)) {
- error("more than one quoting style ?");
+ error("more than one quoting style?");
usage_with_options(for_each_ref_usage, opts);
}
if (verify_format(format))
diff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh
index c722635..c5d0721 100755
--- a/t/t6300-for-each-ref.sh
+++ b/t/t6300-for-each-ref.sh
@@ -169,5 +169,49 @@ test_expect_success 'Verify descending sort' '
git diff expected actual
'
+cat >expected <<\EOF
+'refs/heads/master'
+'refs/tags/testtag'
+EOF
+
+test_expect_success 'Quoting style: shell' '
+ git for-each-ref --shell --format="%(refname)" >actual &&
+ git diff expected actual
+'
+
+test_expect_success 'Quoting style: perl' '
+ git for-each-ref --perl --format="%(refname)" >actual &&
+ git diff expected actual
+'
+
+test_expect_success 'Quoting style: python' '
+ git for-each-ref --python --format="%(refname)" >actual &&
+ git diff expected actual
+'
+
+test_expect_success 'Quoting style: tcl' '
+ git for-each-ref --python --format="%(refname)" >actual &&
+ git diff expected actual
+'
+
+cat >expected <<\EOF
+"refs/heads/master"
+"refs/tags/testtag"
+EOF
+
+test_expect_success 'Quoting style: shell' '
+ git for-each-ref --tcl --format="%(refname)" >actual &&
+ git diff expected actual
+'
+
+for i in "--perl --shell" "-s --python" "--python --tcl" "--tcl --perl"; do
+ test_expect_success "more than one quoting style: $i" "
+ git for-each-ref $i 2>&1 | (read line &&
+ case \$line in
+ \"error: more than one quoting style\"*) : happy;;
+ *) false
+ esac)
+ "
+done
test_done
--
1.5.3.7.1079.gecca
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] for-each-ref: Fix quoting style constants.
2007-12-06 12:11 [PATCH] for-each-ref: Fix quoting style constants Johannes Sixt
@ 2007-12-06 12:19 ` Johannes Schindelin
2007-12-06 12:24 ` [PATCH amended] " Johannes Sixt
1 sibling, 0 replies; 3+ messages in thread
From: Johannes Schindelin @ 2007-12-06 12:19 UTC (permalink / raw)
To: Johannes Sixt; +Cc: Junio C Hamano, Git Mailing List
Hi,
On Thu, 6 Dec 2007, Johannes Sixt wrote:
> $ git for-each-ref --python
> error: more than one quoting style ?
>
> While we are here, let's also remove the space before the question mark.
Doesn't python need that piece of whitespace? *ducks*
Ciao,
Dscho
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH amended] for-each-ref: Fix quoting style constants.
2007-12-06 12:11 [PATCH] for-each-ref: Fix quoting style constants Johannes Sixt
2007-12-06 12:19 ` Johannes Schindelin
@ 2007-12-06 12:24 ` Johannes Sixt
1 sibling, 0 replies; 3+ messages in thread
From: Johannes Sixt @ 2007-12-06 12:24 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Git Mailing List, Johannes Sixt
for-each-ref can accept only one quoting style. For this reason it uses
OPT_BIT for the quoting style switches so that it is easy to check for
more than one bit being set. However, not all symbolic constants were
actually single bit values. In particular:
$ git for-each-ref --python
error: more than one quoting style ?
This fixes it.
While we are here, let's also remove the space before the question mark.
Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
---
This fixes the test cases so that the headlines tell what the
tests cases actually test.
Don't know what I was smoking when I submitted the first version.
-- Hannes
builtin-for-each-ref.c | 6 +++---
t/t6300-for-each-ref.sh | 39 +++++++++++++++++++++++++++++++++++++++
2 files changed, 42 insertions(+), 3 deletions(-)
diff --git a/builtin-for-each-ref.c b/builtin-for-each-ref.c
index daf3a08..f36a43c 100644
--- a/builtin-for-each-ref.c
+++ b/builtin-for-each-ref.c
@@ -13,8 +13,8 @@
#define QUOTE_NONE 0
#define QUOTE_SHELL 1
#define QUOTE_PERL 2
-#define QUOTE_PYTHON 3
-#define QUOTE_TCL 4
+#define QUOTE_PYTHON 4
+#define QUOTE_TCL 8
typedef enum { FIELD_STR, FIELD_ULONG, FIELD_TIME } cmp_type;
@@ -861,7 +861,7 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix)
usage_with_options(for_each_ref_usage, opts);
}
if (HAS_MULTI_BITS(quote_style)) {
- error("more than one quoting style ?");
+ error("more than one quoting style?");
usage_with_options(for_each_ref_usage, opts);
}
if (verify_format(format))
diff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh
index c722635..8a23aaf 100755
--- a/t/t6300-for-each-ref.sh
+++ b/t/t6300-for-each-ref.sh
@@ -169,5 +169,44 @@ test_expect_success 'Verify descending sort' '
git diff expected actual
'
+cat >expected <<\EOF
+'refs/heads/master'
+'refs/tags/testtag'
+EOF
+
+test_expect_success 'Quoting style: shell' '
+ git for-each-ref --shell --format="%(refname)" >actual &&
+ git diff expected actual
+'
+
+test_expect_success 'Quoting style: perl' '
+ git for-each-ref --perl --format="%(refname)" >actual &&
+ git diff expected actual
+'
+
+test_expect_success 'Quoting style: python' '
+ git for-each-ref --python --format="%(refname)" >actual &&
+ git diff expected actual
+'
+
+cat >expected <<\EOF
+"refs/heads/master"
+"refs/tags/testtag"
+EOF
+
+test_expect_success 'Quoting style: tcl' '
+ git for-each-ref --tcl --format="%(refname)" >actual &&
+ git diff expected actual
+'
+
+for i in "--perl --shell" "-s --python" "--python --tcl" "--tcl --perl"; do
+ test_expect_success "more than one quoting style: $i" "
+ git for-each-ref $i 2>&1 | (read line &&
+ case \$line in
+ \"error: more than one quoting style\"*) : happy;;
+ *) false
+ esac)
+ "
+done
test_done
--
1.5.3.7.1079.gecca
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-12-06 12:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-06 12:11 [PATCH] for-each-ref: Fix quoting style constants Johannes Sixt
2007-12-06 12:19 ` Johannes Schindelin
2007-12-06 12:24 ` [PATCH amended] " Johannes Sixt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).