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

Re: [PATCH] diff: exit(1) if 'diff --quiet <repo file> <external file>' finds changes

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 18, 2012, 18:00 UTC
Message-ID
<7v1ulc4i0w.fsf@alter.siamese.dyndns.org>
In-Reply-To
<CAFouetjkSQuY6pyFdiVsM5tUnEiFK6uWTqDO38uhwUjaDVre1w@mail.gmail.com>
Tim Henigan <tim.henigan@gmail.com> writes:
Show 16 quoted lines
> To obtain full coverage, it seems we need to test:
>     1) git diff --quiet <file in repo> <file outside repo>
>     2) git diff --quiet <file outside repo> <file outside repo>
>
> for each of the following options:
>     a) no additional options
>     b) --ignore-space-at-eol
>     c) --ignore-all-space
>
> These seem like the only diff options that should be tested...am I
> missing anything?
>
> Because some of the tests require one directory that is a repo and one
> directory that is not, it seems best to create a new test file with
> $TEST_NO_CREATE_REPO set.  Then the setup function can create both the
> repo and the plain directory.

It is probably overkill to add a new test that only to add 3 (the "two paths outside repo" among the 6 = 2 * 3 combinations above). Inside t4035, you could dig new directory two levels deep, chdir to it and set GIT_CEILING_DIRECTORY to its first level and run test, no? Something along these lines (the diff invoked would obviously be not between foo and bar)...

 t/t4035-diff-quiet.sh | 12 ++++++++++++
 1 file changed, 12 insertions(+)
diff --git a/t/t4035-diff-quiet.sh b/t/t4035-diff-quiet.sh
index cdb9202..e7065cc 100755
--- a/t/t4035-diff-quiet.sh
+++ b/t/t4035-diff-quiet.sh
@@ -77,4 +77,16 @@ test_expect_success 'git diff-index --cached HEAD' '
 	}
 '
 
+test_expect_success 'git diff-no-index outside repository' '
+	mkdir -p not/here &&
+	(
+		cd not/here &&
+		GIT_CEILING_DIRECTORIES=$TRASH_DIRECTORY/not &&
+		export GIT_CEILING_DIRECTORIES &&
+		echo foo >foo &&
+		echo bar >bar &&
+		git diff foo bar
+	)
+'
+
 test_done
Previous: Tim Henigan
Message 12 of 12 in “diff: exit(1) if 'diff --quiet <repo file> <external file>' finds changes”
  1. diff: exit(1) if 'diff --quiet <repo file> <external file>' finds changesTim Henigan, Jun 15, 2012
  2. Jeff KingJun 15, 2012
  3. Jeff KingJun 15, 2012
  4. Junio C HamanoJun 15, 2012
  5. Jeff KingJun 15, 2012
  6. Tim HeniganJun 15, 2012
  7. Junio C HamanoJun 15, 2012
  8. Jeff KingJun 15, 2012
  9. Junio C HamanoJun 15, 2012
  10. Junio C HamanoJun 15, 2012
  11. Tim HeniganJun 18, 2012
  12. Junio C HamanoJun 18, 2012

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.