git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] MinGW: fix diff --no-index /dev/null ...

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Mar 7, 2009, 15:51 UTC
Message-ID
<dba002b9e521c639847650fbaeb8b87b66b9562e.1236441065u.git.johannes.schindelin@gmx.de>
In-Reply-To
<cover.1236441065u.git.johannes.schindelin@gmx.de>

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
Next: Johannes Sixt
Message 1 of 6 in “MinGW: fix diff --no-index /dev/null ...”
  1. MinGW: fix diff --no-index /dev/null ...Johannes Schindelin, Mar 7, 2009
  2. Johannes SixtMar 7, 2009
  3. Junio C HamanoMar 7, 2009
  4. Johannes SchindelinMar 7, 2009
  5. Junio C HamanoMar 7, 2009
  6. Johannes SixtMar 7, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.