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

[PATCH 1/4] t5510: start tracking-ref tests from a known state

From
Jeff King <peff@peff.net>
Date
May 11, 2013, 16:14 UTC
Message-ID
<20130511161400.GA3270@sigill.intra.peff.net>
In-Reply-To
<20130511161320.GA14990@sigill.intra.peff.net>

We have three sequential tests for for whether tracking refs are updated by various fetches and pulls; the first two should not update the ref, and the third should. Each test depends on the state left by the test before.

This is fragile (a failing early test will confuse later tests), and means we cannot add more "should update" tests after the third one.

Let's instead save the initial state before these tests, and then reset to a known state before running each test.

Signed-off-by: Jeff King <peff@peff.net>
---
 t/t5510-fetch.sh | 10 ++++++++++
 1 file changed, 10 insertions(+)
diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh
index d7a19a1..789c228 100755
--- a/t/t5510-fetch.sh
+++ b/t/t5510-fetch.sh
@@ -370,12 +370,20 @@ test_expect_success 'explicit fetch should not update tracking' '
 
 '
 
+test_expect_success 'mark initial state of origin/master' '
+	(
+		cd three &&
+		git tag base-origin-master refs/remotes/origin/master
+	)
+'
+
 test_expect_success 'explicit fetch should not update tracking' '
 
 	cd "$D" &&
 	git branch -f side &&
 	(
 		cd three &&
+		git update-ref refs/remotes/origin/master base-origin-master &&
 		o=$(git rev-parse --verify refs/remotes/origin/master) &&
 		git fetch origin master &&
 		n=$(git rev-parse --verify refs/remotes/origin/master) &&
@@ -390,6 +398,7 @@ test_expect_success 'explicit pull should not update tracking' '
 	git branch -f side &&
 	(
 		cd three &&
+		git update-ref refs/remotes/origin/master base-origin-master &&
 		o=$(git rev-parse --verify refs/remotes/origin/master) &&
 		git pull origin master &&
 		n=$(git rev-parse --verify refs/remotes/origin/master) &&
@@ -404,6 +413,7 @@ test_expect_success 'configured fetch updates tracking' '
 	git branch -f side &&
 	(
 		cd three &&
+		git update-ref refs/remotes/origin/master base-origin-master &&
 		o=$(git rev-parse --verify refs/remotes/origin/master) &&
 		git fetch origin &&
 		n=$(git rev-parse --verify refs/remotes/origin/master) &&
-- 
1.8.3.rc1.2.g12db477
Previous: Jeff KingNext: Eric Sunshine
Message 2 of 12 in “update tracking refs on explicit fetch”
  1. 0/4 update tracking refs on explicit fetchJeff King, May 11, 2013
  2. 1/4 t5510: start tracking-ref tests from a known stateJeff King, May 11, 2013
  3. Eric SunshineMay 14, 2013
  4. 2/4 fetch/pull doc: untangle meaning of bare <ref>Jeff King, May 11, 2013
  5. 3/4 refactor "ref->merge" flagJeff King, May 11, 2013
  6. 4/4 fetch: opportunistically update tracking refsJeff King, May 11, 2013
  7. Thomas RastMay 12, 2013
  8. Thomas RastMay 12, 2013
  9. Jeff KingMay 16, 2013
  10. Junio C HamanoAug 6, 2013
  11. Jeff KingAug 6, 2013
  12. Junio C HamanoAug 6, 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.