Re: [PATCH 14/13] test-wildmatch: avoid Windows path mangling

2012-11-20 Thread Junio C Hamano
Johannes Sixt j.s...@viscovery.net writes:

 From: Nguyễn Thái Ngọc Duy pclo...@gmail.com

 The MSYS bash mangles arguments that begin with a forward slash
 when they are passed to test-wildmatch. This causes tests to fail.
 Avoid mangling by prepending XXX, which is removed by
 test-wildmatch before further processing.

 [J6t: reworded commit message]

 Reported-by: Johannes Sixt j...@kdbg.org
 Signed-off-by: Nguyễn Thái Ngọc Duy pclo...@gmail.com
 Signed-off-by: Johannes Sixt j...@kdbg.org
 ---
  Works well, and I'm fine with this work-around.

  -- Hannes

Thanks, but you need to fix your format-patch somehow.

 @@ -187,8 +187,8 @@ match 0 0 '-' '[[-\]]'
  match 1 1 '-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1' 
 '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'
  match 0 0 '-adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1' 
 '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'
  match 0 0 '-adobe-courier-bold-o-normal--12-120-75-75-/-70-iso8859-1' 
 '-*-*-*-*-*-*-12-*-*-*-m-*-*-*'
 -match 1 1 '/adobe/courier/bold/o/normal//12/120/75/75/m/70/iso8859/1' 
 '/*/*/*/*/*/*/12/*/*/*/m/*/*/*'
 -match 0 0 '/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1' 
 '/*/*/*/*/*/*/12/*/*/*/m/*/*/*'
 +match 1 1 'XXX/adobe/courier/bold/o/normal//12/120/75/75/m/70/iso8859/1' 
 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'
 +match 0 0 'XXX/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1' 
 'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'
  match 1 0 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt' '**/*a*b*g*n*t'
  match 0 0 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txtz' '**/*a*b*g*n*t'
  diff --git a/test-wildmatch.c b/test-wildmatch.c

This hunk claims that there are 8 lines in preimage and postimage,
but it is not the case.  It has only 7 lines each.

You also have the first line of the next patch diff --git somehow
indented.  How did this happen?


 index 74c0864..e384c8e 100644
 --- a/test-wildmatch.c
 +++ b/test-wildmatch.c
 @@ -3,6 +3,14 @@
   int main(int argc, char **argv)
  {
 + int i;
 + for (i = 2; i  argc; i++) {
 + if (argv[i][0] == '/')
 + die(Forward slash is not allowed at the beginning of 
 the\n
 + pattern because Windows does not like it. Use 
 `XXX/' instead.);
 + else if (!strncmp(argv[i], XXX/, 4))
 + argv[i] += 3;
 + }
   if (!strcmp(argv[1], wildmatch))
   return !!wildmatch(argv[3], argv[2], 0);
   else if (!strcmp(argv[1], iwildmatch))

And again this claims that the preimage has 6 lines while the
postimage has 14.  Somebody is overcounting, or perhaps you removed
the first pre-context by hand without adjusting the line number?

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 14/13] test-wildmatch: avoid Windows path mangling

2012-11-20 Thread Johannes Sixt
From: Nguyễn Thái Ngọc Duy pclo...@gmail.com

The MSYS bash mangles arguments that begin with a forward slash
when they are passed to test-wildmatch. This causes tests to fail.
Avoid mangling by prepending XXX, which is removed by
test-wildmatch before further processing.

[J6t: reworded commit message]

Reported-by: Johannes Sixt j...@kdbg.org
Signed-off-by: Nguyễn Thái Ngọc Duy pclo...@gmail.com
Signed-off-by: Johannes Sixt j...@kdbg.org
---
Am 11/20/2012 21:11, schrieb Junio C Hamano:
 Thanks, but you need to fix your format-patch somehow.

No, it was Thunderbird. It ate the blank lines when I said Edit as new
to forward the patch directly from the mailbox.

Sorry for the inconvenience.

 t/t3070-wildmatch.sh | 10 +-
 test-wildmatch.c |  8 
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh
index e6ad6f4..3155eab 100755
--- a/t/t3070-wildmatch.sh
+++ b/t/t3070-wildmatch.sh
@@ -74,7 +74,7 @@ match 0 0 'foo/bar' 'foo[/]bar'
 match 0 0 'foo/bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'
 match 1 1 'foo-bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'
 match 1 0 'foo' '**/foo'
-match 1 x '/foo' '**/foo'
+match 1 x 'XXX/foo' '**/foo'
 match 1 0 'bar/baz/foo' '**/foo'
 match 0 0 'bar/baz/foo' '*/foo'
 match 0 0 'foo/bar/baz' '**/bar*'
@@ -95,8 +95,8 @@ match 0 0 ']' '[!]-]'
 match 1 x 'a' '[!]-]'
 match 0 0 '' '\'
 match 0 x '\' '\'
-match 0 x '/\' '*/\'
-match 1 x '/\' '*/\\'
+match 0 x 'XXX/\' '*/\'
+match 1 x 'XXX/\' '*/\\'
 match 1 1 'foo' 'foo'
 match 1 1 '@foo' '@foo'
 match 0 0 'foo' '@foo'
@@ -187,8 +187,8 @@ match 0 0 '-' '[[-\]]'
 match 1 1 '-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1' 
'-*-*-*-*-*-*-12-*-*-*-m-*-*-*'
 match 0 0 '-adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1' 
'-*-*-*-*-*-*-12-*-*-*-m-*-*-*'
 match 0 0 '-adobe-courier-bold-o-normal--12-120-75-75-/-70-iso8859-1' 
'-*-*-*-*-*-*-12-*-*-*-m-*-*-*'
-match 1 1 '/adobe/courier/bold/o/normal//12/120/75/75/m/70/iso8859/1' 
'/*/*/*/*/*/*/12/*/*/*/m/*/*/*'
-match 0 0 '/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1' 
'/*/*/*/*/*/*/12/*/*/*/m/*/*/*'
+match 1 1 'XXX/adobe/courier/bold/o/normal//12/120/75/75/m/70/iso8859/1' 
'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'
+match 0 0 'XXX/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1' 
'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'
 match 1 0 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt' '**/*a*b*g*n*t'
 match 0 0 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txtz' '**/*a*b*g*n*t'
 
diff --git a/test-wildmatch.c b/test-wildmatch.c
index 74c0864..e384c8e 100644
--- a/test-wildmatch.c
+++ b/test-wildmatch.c
@@ -3,6 +3,14 @@
 
 int main(int argc, char **argv)
 {
+   int i;
+   for (i = 2; i  argc; i++) {
+   if (argv[i][0] == '/')
+   die(Forward slash is not allowed at the beginning of 
the\n
+   pattern because Windows does not like it. Use 
`XXX/' instead.);
+   else if (!strncmp(argv[i], XXX/, 4))
+   argv[i] += 3;
+   }
if (!strcmp(argv[1], wildmatch))
return !!wildmatch(argv[3], argv[2], 0);
else if (!strcmp(argv[1], iwildmatch))
-- 
1.8.0.1417.gf6038d8
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 14/13] test-wildmatch: avoid Windows path mangling

2012-11-19 Thread Johannes Sixt
From: Nguyễn Thái Ngọc Duy pclo...@gmail.com

The MSYS bash mangles arguments that begin with a forward slash
when they are passed to test-wildmatch. This causes tests to fail.
Avoid mangling by prepending XXX, which is removed by
test-wildmatch before further processing.

[J6t: reworded commit message]

Reported-by: Johannes Sixt j...@kdbg.org
Signed-off-by: Nguyễn Thái Ngọc Duy pclo...@gmail.com
Signed-off-by: Johannes Sixt j...@kdbg.org
---
 Works well, and I'm fine with this work-around.

 -- Hannes

 t/t3070-wildmatch.sh | 10 +-
 test-wildmatch.c |  8 
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh
index e6ad6f4..3155eab 100755
--- a/t/t3070-wildmatch.sh
+++ b/t/t3070-wildmatch.sh
@@ -74,7 +74,7 @@ match 0 0 'foo/bar' 'foo[/]bar'
 match 0 0 'foo/bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'
 match 1 1 'foo-bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'
 match 1 0 'foo' '**/foo'
-match 1 x '/foo' '**/foo'
+match 1 x 'XXX/foo' '**/foo'
 match 1 0 'bar/baz/foo' '**/foo'
 match 0 0 'bar/baz/foo' '*/foo'
 match 0 0 'foo/bar/baz' '**/bar*'
@@ -95,8 +95,8 @@ match 0 0 ']' '[!]-]'
 match 1 x 'a' '[!]-]'
 match 0 0 '' '\'
 match 0 x '\' '\'
-match 0 x '/\' '*/\'
-match 1 x '/\' '*/\\'
+match 0 x 'XXX/\' '*/\'
+match 1 x 'XXX/\' '*/\\'
 match 1 1 'foo' 'foo'
 match 1 1 '@foo' '@foo'
 match 0 0 'foo' '@foo'
@@ -187,8 +187,8 @@ match 0 0 '-' '[[-\]]'
 match 1 1 '-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1' 
'-*-*-*-*-*-*-12-*-*-*-m-*-*-*'
 match 0 0 '-adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1' 
'-*-*-*-*-*-*-12-*-*-*-m-*-*-*'
 match 0 0 '-adobe-courier-bold-o-normal--12-120-75-75-/-70-iso8859-1' 
'-*-*-*-*-*-*-12-*-*-*-m-*-*-*'
-match 1 1 '/adobe/courier/bold/o/normal//12/120/75/75/m/70/iso8859/1' 
'/*/*/*/*/*/*/12/*/*/*/m/*/*/*'
-match 0 0 '/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1' 
'/*/*/*/*/*/*/12/*/*/*/m/*/*/*'
+match 1 1 'XXX/adobe/courier/bold/o/normal//12/120/75/75/m/70/iso8859/1' 
'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'
+match 0 0 'XXX/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1' 
'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'
 match 1 0 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt' '**/*a*b*g*n*t'
 match 0 0 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txtz' '**/*a*b*g*n*t'
 diff --git a/test-wildmatch.c b/test-wildmatch.c
index 74c0864..e384c8e 100644
--- a/test-wildmatch.c
+++ b/test-wildmatch.c
@@ -3,6 +3,14 @@
  int main(int argc, char **argv)
 {
+   int i;
+   for (i = 2; i  argc; i++) {
+   if (argv[i][0] == '/')
+   die(Forward slash is not allowed at the beginning of 
the\n
+   pattern because Windows does not like it. Use 
`XXX/' instead.);
+   else if (!strncmp(argv[i], XXX/, 4))
+   argv[i] += 3;
+   }
if (!strcmp(argv[1], wildmatch))
return !!wildmatch(argv[3], argv[2], 0);
else if (!strcmp(argv[1], iwildmatch))
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 14/13] test-wildmatch: avoid Windows path mangling

2012-11-13 Thread Nguyễn Thái Ngọc Duy
On Windows, arguments starting with a forward slash is mangled as if
it were full pathname. This causes the patterns beginning with a slash
not to be passed to test-wildmatch correctly. Avoid mangling by never
accepting patterns starting with a slash. Those arguments must be
rewritten with a leading XXX (e.g. /abc becomes XXX/abc), which
will be removed by test-wildmatch itself before feeding the patterns
to wildmatch() or fnmatch().

Reported-by: Johannes Sixt j...@kdbg.org
Signed-off-by: Nguyễn Thái Ngọc Duy pclo...@gmail.com
---
 On Sun, Nov 11, 2012 at 5:47 PM, Junio C Hamano gits...@pobox.com wrote:
  The title taken together with the above explanation makes it sound
  as if wildmatch code does not work with the pattern /foo on Windows
  at all and to avoid the issue (instead of fixing the breakage) this
  patch removes such tests

 OK how about this?

 t/t3070-wildmatch.sh | 10 +-
 test-wildmatch.c |  8 
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/t/t3070-wildmatch.sh b/t/t3070-wildmatch.sh
index e6ad6f4..3155eab 100755
--- a/t/t3070-wildmatch.sh
+++ b/t/t3070-wildmatch.sh
@@ -74,7 +74,7 @@ match 0 0 'foo/bar' 'foo[/]bar'
 match 0 0 'foo/bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'
 match 1 1 'foo-bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'
 match 1 0 'foo' '**/foo'
-match 1 x '/foo' '**/foo'
+match 1 x 'XXX/foo' '**/foo'
 match 1 0 'bar/baz/foo' '**/foo'
 match 0 0 'bar/baz/foo' '*/foo'
 match 0 0 'foo/bar/baz' '**/bar*'
@@ -95,8 +95,8 @@ match 0 0 ']' '[!]-]'
 match 1 x 'a' '[!]-]'
 match 0 0 '' '\'
 match 0 x '\' '\'
-match 0 x '/\' '*/\'
-match 1 x '/\' '*/\\'
+match 0 x 'XXX/\' '*/\'
+match 1 x 'XXX/\' '*/\\'
 match 1 1 'foo' 'foo'
 match 1 1 '@foo' '@foo'
 match 0 0 'foo' '@foo'
@@ -187,8 +187,8 @@ match 0 0 '-' '[[-\]]'
 match 1 1 '-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1' 
'-*-*-*-*-*-*-12-*-*-*-m-*-*-*'
 match 0 0 '-adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1' 
'-*-*-*-*-*-*-12-*-*-*-m-*-*-*'
 match 0 0 '-adobe-courier-bold-o-normal--12-120-75-75-/-70-iso8859-1' 
'-*-*-*-*-*-*-12-*-*-*-m-*-*-*'
-match 1 1 '/adobe/courier/bold/o/normal//12/120/75/75/m/70/iso8859/1' 
'/*/*/*/*/*/*/12/*/*/*/m/*/*/*'
-match 0 0 '/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1' 
'/*/*/*/*/*/*/12/*/*/*/m/*/*/*'
+match 1 1 'XXX/adobe/courier/bold/o/normal//12/120/75/75/m/70/iso8859/1' 
'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'
+match 0 0 'XXX/adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1' 
'XXX/*/*/*/*/*/*/12/*/*/*/m/*/*/*'
 match 1 0 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt' '**/*a*b*g*n*t'
 match 0 0 'abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txtz' '**/*a*b*g*n*t'
 
diff --git a/test-wildmatch.c b/test-wildmatch.c
index 74c0864..e384c8e 100644
--- a/test-wildmatch.c
+++ b/test-wildmatch.c
@@ -3,6 +3,14 @@
 
 int main(int argc, char **argv)
 {
+   int i;
+   for (i = 2; i  argc; i++) {
+   if (argv[i][0] == '/')
+   die(Forward slash is not allowed at the beginning of 
the\n
+   pattern because Windows does not like it. Use 
`XXX/' instead.);
+   else if (!strncmp(argv[i], XXX/, 4))
+   argv[i] += 3;
+   }
if (!strcmp(argv[1], wildmatch))
return !!wildmatch(argv[3], argv[2], 0);
else if (!strcmp(argv[1], iwildmatch))
-- 
1.8.0.rc2.23.g1fb49df

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 14/13] test-wildmatch: avoid Windows path mangling

2012-11-13 Thread Johannes Sixt
Am 13.11.2012 11:06, schrieb Nguyễn Thái Ngọc Duy:
 On Windows, arguments starting with a forward slash is mangled as if
 it were full pathname. This causes the patterns beginning with a slash
 not to be passed to test-wildmatch correctly. Avoid mangling by never
 accepting patterns starting with a slash. Those arguments must be
 rewritten with a leading XXX (e.g. /abc becomes XXX/abc), which
 will be removed by test-wildmatch itself before feeding the patterns
 to wildmatch() or fnmatch().
 
 Reported-by: Johannes Sixt j...@kdbg.org
 Signed-off-by: Nguyễn Thái Ngọc Duy pclo...@gmail.com
 ---
  On Sun, Nov 11, 2012 at 5:47 PM, Junio C Hamano gits...@pobox.com wrote:
   The title taken together with the above explanation makes it sound
   as if wildmatch code does not work with the pattern /foo on Windows
   at all and to avoid the issue (instead of fixing the breakage) this
   patch removes such tests
 
  OK how about this?

Thanks, the patch lets the tests pass on Windows.

-- Hannes
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html