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

[PATCH 5/5] ff-refs: Add tests

From
Michael Rappazzo <rappazzo@gmail.com>
Date
Nov 11, 2015, 02:11 UTC
Message-ID
<1447207885-10911-6-git-send-email-rappazzo@gmail.com>
In-Reply-To
<1447207885-10911-1-git-send-email-rappazzo@gmail.com>
Signed-off-by: Michael Rappazzo <rappazzo@gmail.com>
---
 t/t7900-ff-refs.sh | 164 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 164 insertions(+)
 create mode 100755 t/t7900-ff-refs.sh
diff --git a/t/t7900-ff-refs.sh b/t/t7900-ff-refs.sh
new file mode 100755
index 0000000..3cfbcb8
--- /dev/null
+++ b/t/t7900-ff-refs.sh
@@ -0,0 +1,164 @@
+#!/bin/sh
+
+# SKIPPED
+
+test_description='test ff-refs'
+
+. ./test-lib.sh
+
+test_expect_success 'setup' '
+	test_commit init &&
+	for i in $(test_seq 1 9)
+	do
+		echo "data" >file_$i &&
+		git add file_$i &&
+		git commit -m"Commit $i" &&
+		git branch br_$i
+	done
+'
+
+test_expect_success 'UP-TO-DATE for equal branch' '
+	test_when_finished "rm -rf local" &&
+	git clone . local &&
+	(
+		cd local &&
+		git ff-refs >actual &&
+		grep "UP-TO-DATE" actual
+	)
+'
+
+test_expect_success 'UP-TO-DATE for ahead local branch' '
+	test_when_finished "rm -rf local" &&
+	git clone . local &&
+	(
+		cd local &&
+		git ff-refs >actual &&
+		echo "data" >file_new &&
+		git add file_new &&
+		git commit -m"Commit new" &&
+		grep "UP-TO-DATE" actual
+	)
+'
+
+test_expect_success 'REMOTE-MISSING by local config change' '
+	test_when_finished "rm -rf local" &&
+	git clone . local &&
+	(
+		cd local &&
+		git config --replace branch.master.merge refs/heads/nothing &&
+		git ff-refs >actual &&
+		grep "REMOTE-MISSING" actual
+	)
+'
+
+test_expect_success 'NON-FAST-FORWARD for diverged branch' '
+	test_when_finished "rm -rf local" &&
+	git clone . local &&
+	(
+		cd local &&
+		git reset --hard origin/br_3 &&
+		echo "data" >file_new &&
+		git add file_new &&
+		git commit -m"Commit new" &&
+		git ff-refs >actual &&
+		grep "NON-FAST-FORWARD" actual
+	)
+'
+
+test_expect_success 'UPDATED for fast-forwardable branch' '
+	test_when_finished "rm -rf local" &&
+	git clone . local &&
+	(
+		cd local &&
+		git reset --hard origin/br_3 &&
+		git ff-refs >actual &&
+		grep "UPDATED" actual
+	)
+'
+
+test_expect_success 'WOULD-UPDATE for dry-run on fast-forwardable branch' '
+	test_when_finished "rm -rf local" &&
+	git clone . local &&
+	(
+		cd local &&
+		git reset --hard origin/br_3 &&
+		git ff-refs --dry-run >actual &&
+		grep "WOULD-UPDATE" actual
+	)
+'
+
+test_expect_success 'SKIPPED for skip-worktrees on fast-forwardable branch' '
+	test_when_finished "rm -rf local" &&
+	git clone . local &&
+	(
+		cd local &&
+		git reset --hard origin/br_3 &&
+		git ff-refs --skip-worktrees >actual &&
+		grep "SKIPPED" actual
+	)
+'
+
+test_expect_success 'WOULD-SKIP for dry-run, skip-worktrees on fast-forwardable branch' '
+	test_when_finished "rm -rf local" &&
+	git clone . local &&
+	(
+		cd local &&
+		git reset --hard origin/br_3 &&
+		git ff-refs --dry-run --skip-worktrees >actual &&
+		grep "WOULD-SKIP" actual
+	)
+'
+
+test_expect_success 'UPDATE for fast-forwardable, not checked-out branch' '
+	test_when_finished "rm -rf local" &&
+	git clone . local &&
+	(
+		cd local &&
+		git reset --hard origin/br_3 &&
+		git checkout -b other origin/br_3 &&
+		git ff-refs >actual &&
+		grep "master" actual | grep "UPDATED"
+	)
+'
+
+test_expect_success 'UPDATE for fast-forwardable, not checked-out branch using --skip-worktrees' '
+	test_when_finished "rm -rf local" &&
+	git clone . local &&
+	(
+		cd local &&
+		git reset --hard origin/br_3 &&
+		git checkout -b other origin/br_3 &&
+		git ff-refs --skip-worktrees >actual &&
+		grep "master" actual | grep "UPDATED"
+	)
+'
+
+test_expect_success 'UPDATE multiple' '
+	test_when_finished "rm -rf local" &&
+	git clone . local &&
+	(
+		cd local &&
+		git reset --hard origin/br_3 &&
+		git checkout -b other origin/br_5 &&
+		git reset --hard origin/br_3 &&
+		git ff-refs >actual &&
+		grep "master" actual | grep "UPDATED" &&
+		grep "other" actual | grep "UPDATED"
+	)
+'
+
+test_expect_success 'UPDATE one, skip worktree on another' '
+	test_when_finished "rm -rf local" &&
+	git clone . local &&
+	(
+		cd local &&
+		git reset --hard origin/br_3 &&
+		git checkout -b other origin/br_5 &&
+		git reset --hard origin/br_3 &&
+		git ff-refs --skip-worktrees >actual &&
+		grep "master" actual | grep "UPDATED" &&
+		grep "other" actual | grep "SKIPPED"
+	)
+'
+
+test_done
-- 
2.6.2
Previous: Michael RappazzoNext: Michael J Gruber
Message 6 of 13 in “ff-refs: builtin command to fast-forward local refs”
  1. 0/5 ff-refs: builtin command to fast-forward local refsMichael Rappazzo, Nov 11, 2015
  2. 1/5 ff-refs: builtin cmd to check and fast forward local refs to their upstreamMichael Rappazzo, Nov 11, 2015
  3. 2/5 ff-refs: update each updatable refMichael Rappazzo, Nov 11, 2015
  4. 3/5 ff-refs: add --dry-run and --skip-worktree optionsMichael Rappazzo, Nov 11, 2015
  5. 4/5 ff-refs: Add documentationMichael Rappazzo, Nov 11, 2015
  6. 5/5 ff-refs: Add testsMichael Rappazzo, Nov 11, 2015
  7. Michael J GruberNov 11, 2015
  8. Mike RappazzoNov 11, 2015
  9. Michael J GruberNov 17, 2015
  10. Mike RappazzoNov 17, 2015
  11. Johannes SchindelinNov 18, 2015
  12. Jeff KingNov 24, 2015
  13. Junio C HamanoDec 1, 2015

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.