git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] MinGW: fix diff --no-index /dev/null ...
       [not found] <cover.1236441065u.git.johannes.schindelin@gmx.de>
@ 2009-03-07 15:51 ` Johannes Schindelin
  2009-03-07 19:56   ` Johannes Sixt
  2009-03-07 20:15   ` Junio C Hamano
  0 siblings, 2 replies; 6+ messages in thread
From: Johannes Schindelin @ 2009-03-07 15:51 UTC (permalink / raw)
  To: git, gitster; +Cc: Johannes Sixt

When launching "diff --no-index" with a parameter "/dev/null", the MSys
bash converts the "/dev/null" to a "nul", which usually makes sense.  But
diff --no-index got confused and tried to access a _file_ called "nul".

While at it, the comment in t4012, expressed as ":# <text>" was turned
into ": <text>" so that MSys' path name mangling does not kick in.

With this patch, t4012 passes in msysGit.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 diff-no-index.c        |    4 ++++
 t/t4012-diff-binary.sh |    2 +-
 2 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/diff-no-index.c b/diff-no-index.c
index 0a14268..598687b 100644
--- a/diff-no-index.c
+++ b/diff-no-index.c
@@ -38,6 +38,10 @@ static int get_mode(const char *path, int *mode)
 
 	if (!path || !strcmp(path, "/dev/null"))
 		*mode = 0;
+#ifdef _WIN32
+	else if (!strcasecmp(path, "nul"))
+		*mode = 0;
+#endif
 	else if (!strcmp(path, "-"))
 		*mode = create_ce_mode(0666);
 	else if (lstat(path, &st))
diff --git a/t/t4012-diff-binary.sh b/t/t4012-diff-binary.sh
index 3cf5b5c..f64aa48 100755
--- a/t/t4012-diff-binary.sh
+++ b/t/t4012-diff-binary.sh
@@ -87,7 +87,7 @@ nul_to_q() {
 
 test_expect_success 'diff --no-index with binary creation' '
 	echo Q | q_to_nul >binary &&
-	(:# hide error code from diff, which just indicates differences
+	(: hide error code from diff, which just indicates differences
 	 git diff --binary --no-index /dev/null binary >current ||
 	 true
 	) &&
-- 
1.6.2.327.g0fa6c

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] MinGW: fix diff --no-index /dev/null ...
  2009-03-07 15:51 ` [PATCH] MinGW: fix diff --no-index /dev/null Johannes Schindelin
@ 2009-03-07 19:56   ` Johannes Sixt
  2009-03-07 20:15   ` Junio C Hamano
  1 sibling, 0 replies; 6+ messages in thread
From: Johannes Sixt @ 2009-03-07 19:56 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git, gitster

On Samstag, 7. März 2009, Johannes Schindelin wrote:
> --- a/diff-no-index.c
> +++ b/diff-no-index.c
> @@ -38,6 +38,10 @@ static int get_mode(const char *path, int *mode)
>
>  	if (!path || !strcmp(path, "/dev/null"))
>  		*mode = 0;
> +#ifdef _WIN32
> +	else if (!strcasecmp(path, "nul"))
> +		*mode = 0;
> +#endif
>  	else if (!strcmp(path, "-"))
>  		*mode = create_ce_mode(0666);
>  	else if (lstat(path, &st))

IMO this #ifdef is a reasonable compromise. Trying to move this into 
git-compat-util.h or mingw.h somehow would only obfuscate the code.

Tested-by: Johannes Sixt <j6t@kdbg.org>

-- Hannes

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] MinGW: fix diff --no-index /dev/null ...
  2009-03-07 15:51 ` [PATCH] MinGW: fix diff --no-index /dev/null Johannes Schindelin
  2009-03-07 19:56   ` Johannes Sixt
@ 2009-03-07 20:15   ` Junio C Hamano
  2009-03-07 20:47     ` Johannes Schindelin
  2009-03-07 21:18     ` Johannes Sixt
  1 sibling, 2 replies; 6+ messages in thread
From: Junio C Hamano @ 2009-03-07 20:15 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git, gitster, Johannes Sixt

Johannes Schindelin <johannes.schindelin@gmx.de> writes:

> diff --git a/diff-no-index.c b/diff-no-index.c
> index 0a14268..598687b 100644
> --- a/diff-no-index.c
> +++ b/diff-no-index.c
> @@ -38,6 +38,10 @@ static int get_mode(const char *path, int *mode)
>  
>  	if (!path || !strcmp(path, "/dev/null"))
>  		*mode = 0;
> +#ifdef _WIN32
> +	else if (!strcasecmp(path, "nul"))
> +		*mode = 0;
> +#endif
>  	else if (!strcmp(path, "-"))
>  		*mode = create_ce_mode(0666);
>  	else if (lstat(path, &st))

I had a brief "Huh? -- doesn't this call for an is_dev_null() helper"
moment, but I think you are right that diff-no-index.c is the right place
to special case it.

Should this go to 'maint'?

> diff --git a/t/t4012-diff-binary.sh b/t/t4012-diff-binary.sh
> index 3cf5b5c..f64aa48 100755
> --- a/t/t4012-diff-binary.sh
> +++ b/t/t4012-diff-binary.sh
> @@ -87,7 +87,7 @@ nul_to_q() {
>  
>  test_expect_success 'diff --no-index with binary creation' '
>  	echo Q | q_to_nul >binary &&
> -	(:# hide error code from diff, which just indicates differences
> +	(: hide error code from diff, which just indicates differences
>  	 git diff --binary --no-index /dev/null binary >current ||
>  	 true
>  	) &&
> -- 
> 1.6.2.327.g0fa6c

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] MinGW: fix diff --no-index /dev/null ...
  2009-03-07 20:15   ` Junio C Hamano
@ 2009-03-07 20:47     ` Johannes Schindelin
  2009-03-07 21:40       ` Junio C Hamano
  2009-03-07 21:18     ` Johannes Sixt
  1 sibling, 1 reply; 6+ messages in thread
From: Johannes Schindelin @ 2009-03-07 20:47 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Johannes Sixt

Hi,

On Sat, 7 Mar 2009, Junio C Hamano wrote:

> Johannes Schindelin <johannes.schindelin@gmx.de> writes:
> 
> > diff --git a/diff-no-index.c b/diff-no-index.c
> > index 0a14268..598687b 100644
> > --- a/diff-no-index.c
> > +++ b/diff-no-index.c
> > @@ -38,6 +38,10 @@ static int get_mode(const char *path, int *mode)
> >  
> >  	if (!path || !strcmp(path, "/dev/null"))
> >  		*mode = 0;
> > +#ifdef _WIN32
> > +	else if (!strcasecmp(path, "nul"))
> > +		*mode = 0;
> > +#endif
> >  	else if (!strcmp(path, "-"))
> >  		*mode = create_ce_mode(0666);
> >  	else if (lstat(path, &st))
> 
> I had a brief "Huh? -- doesn't this call for an is_dev_null() helper"
> moment, but I think you are right that diff-no-index.c is the right place
> to special case it.

You're right, it needs to be explained in the commit message.  So how 
about this:

-- snip --
Unlike other places where a string is compared to /dev/null, in this case 
do not parse a diff, but rather command line parameters that have 
possibly been transformed from /dev/null to nul, so that the file can be 
opened.
-- snap --

If you like it, may I ask you to amend the message?

> Should this go to 'maint'?

Technically, yes, as it is a fix.

However, it might not be necessary, as literally all Windows work on Git 
happens in git/mingw.git, git/mingw/j6t.git and git/mingw/4msysgit.git.

Your call.

Thanks,
Dscho

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] MinGW: fix diff --no-index /dev/null ...
  2009-03-07 20:15   ` Junio C Hamano
  2009-03-07 20:47     ` Johannes Schindelin
@ 2009-03-07 21:18     ` Johannes Sixt
  1 sibling, 0 replies; 6+ messages in thread
From: Johannes Sixt @ 2009-03-07 21:18 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Johannes Schindelin, git

On Samstag, 7. März 2009, Junio C Hamano wrote:
> Should this go to 'maint'?

I don't think that's necessary. It fixes only that someone literally writes on 
the Windows command line

   git diff --no-index nul foo.c

when on Unix one would have written

   git diff --no-index /dev/null foo.c

In practice, only the test suite does this ;)

-- Hannes

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] MinGW: fix diff --no-index /dev/null ...
  2009-03-07 20:47     ` Johannes Schindelin
@ 2009-03-07 21:40       ` Junio C Hamano
  0 siblings, 0 replies; 6+ messages in thread
From: Junio C Hamano @ 2009-03-07 21:40 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git, Johannes Sixt

Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:

> Unlike other places where a string is compared to /dev/null, in this case 
> do not parse a diff, but rather command line parameters that have 
> possibly been transformed from /dev/null to nul, so that the file can be 
> opened.
> -- snap --
>
> If you like it, may I ask you to amend the message?
>
>> Should this go to 'maint'?
>
> Technically, yes, as it is a fix.
>
> However, it might not be necessary, as literally all Windows work on Git 
> happens in git/mingw.git, git/mingw/j6t.git and git/mingw/4msysgit.git.

Yeah, I should have been clearer.  Unless msysgit will have a maintenance
track for 1.6.1.X, there is no point.

Thanks for reading my mind and a clarified message I can use for amending.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-03-07 21:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <cover.1236441065u.git.johannes.schindelin@gmx.de>
2009-03-07 15:51 ` [PATCH] MinGW: fix diff --no-index /dev/null Johannes Schindelin
2009-03-07 19:56   ` Johannes Sixt
2009-03-07 20:15   ` Junio C Hamano
2009-03-07 20:47     ` Johannes Schindelin
2009-03-07 21:40       ` Junio C Hamano
2009-03-07 21:18     ` 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).