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

[PATCH 1/2] t7501: fix "empty commit" test with NO_PERL

From
Jeff King <peff@peff.net>
Date
Jan 23, 2014, 19:54 UTC
Message-ID
<20140123195456.GA31871@sigill.intra.peff.net>
In-Reply-To
<20140123195404.GA31314@sigill.intra.peff.net>

t7501.9 tries to check that "git commit" will fail when the index is unchanged. It relies on previous tests not to have modified the index. When it was originally written, this was always the case. However, commit c65dc35 (t7501: test the right kind of breakage, 2012-03-30) changed earlier tests (4 and 5) to leave a modification in the index.

We never noticed, however, because t7501.7, between the two, clears the index state as a side effect. However, that test depends on the PERL prerequisite, and so it does not always run. Therefore if NO_PERL is set, we do not run the intervening test, the index is left unclean, and t7501.9 fails.

We could fix this by moving t7501.9 up in the script. However, this patch instead leaves it in place and adds a "git reset" before the commit. This makes the test more explicit about its preconditions, and will future-proof it against any other changes in the test state.

Signed-off-by: Jeff King <peff@peff.net>
---
 t/t7501-commit.sh | 1 +
 1 file changed, 1 insertion(+)
diff --git a/t/t7501-commit.sh b/t/t7501-commit.sh
index f04798f..94eec83 100755
--- a/t/t7501-commit.sh
+++ b/t/t7501-commit.sh
@@ -57,6 +57,7 @@ test_expect_success 'using invalid commit with -C' '
 '
 
 test_expect_success 'nothing to commit' '
+	git reset --hard &&
 	test_must_fail git commit -m initial
 '
 
-- 
1.8.5.2.500.g8060133
Previous: Jeff KingNext: Jeff King
Message 2 of 9 in “solaris test fixups”
  1. 0/2 solaris test fixupsJeff King, Jan 23, 2014
  2. 1/2 t7501: fix "empty commit" test with NO_PERLJeff King, Jan 23, 2014
  3. 2/2 t7700: do not use "touch -r"Jeff King, Jan 23, 2014
  4. Junio C HamanoJan 23, 2014
  5. Jeff KingJan 23, 2014
  6. Junio C HamanoJan 23, 2014
  7. Jeff KingJan 23, 2014
  8. Junio C HamanoJan 23, 2014
  9. Jeff KingJan 23, 2014

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.