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

[PATCH v2 1/2] diff: add test for --no-index executed outside repo

From
Thomas Gummerer <t.gummerer@gmail.com>
Date
Dec 16, 2013, 20:19 UTC
Message-ID
<1387225164-31747-1-git-send-email-t.gummerer@gmail.com>
In-Reply-To
<xmqqob4goa4t.fsf@gitster.dls.corp.google.co>

470faf9 diff: move no-index detection to builtin/diff.c breaks the error message for "git diff --no-index", when the command is executed outside of a git repository and the wrong number of arguments are given. 6df5762 diff: don't read index when --no-index is given fixes the problem.

Add a test to guard against similar breakages in the future.
Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
---
> Perhaps use CEILING, like this (untested)?
Thanks, this makes sense, here is the new version.
 t/t4053-diff-no-index.sh | 11 +++++++++++
 1 file changed, 11 insertions(+)
diff --git a/t/t4053-diff-no-index.sh b/t/t4053-diff-no-index.sh
index 077c775..2ab3c48 100755
--- a/t/t4053-diff-no-index.sh
+++ b/t/t4053-diff-no-index.sh
@@ -44,4 +44,15 @@ test_expect_success 'git diff outside repo with broken index' '
 	)
 '
 
+test_expect_success 'git diff --no-index executed outside repo gives correct error message' '
+	(
+		GIT_CEILING_DIRECTORIES=$TRASH_DIRECTORY/non &&
+		export GIT_CEILING_DIRECTORIES &&
+		cd non/git &&
+		test_must_fail git diff --no-index a 2>actual.err &&
+		echo "usage: git diff --no-index <path> <path>" >expect.err &&
+		test_cmp expect.err actual.err
+	)
+'
+
 test_done
-- 
1.8.5.4.g8639e57
Next: Thomas Gummerer
Message 1 of 2 in “diff: add test for --no-index executed outside repo”
  1. 1/2 diff: add test for --no-index executed outside repoThomas Gummerer, Dec 16, 2013
  2. 2/2 diff: avoid some nestingThomas Gummerer, Dec 16, 2013

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.