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

[PATCH 5/5 v2] t7609: test merge and checkout error messages

From
DGDiane Gasselin <diane.gasselin@ensimag.imag.fr>
Date
Jun 15, 2010, 12:22 UTC
Message-ID
<1276604576-28092-6-git-send-email-diane.gasselin@ensimag.imag.fr>
In-Reply-To
<1276604576-28092-5-git-send-email-diane.gasselin@ensimag.imag.fr>

Test porcelain and plumbing error messages for different types of errors of merge and checkout.

Signed-off-by: Diane Gasselin <diane.gasselin@ensimag.imag.fr>
Signed-off-by: Clément Poulain <clement.poulain@ensimag.imag.fr>
Signed-off-by: Axel Bonnet <axel.bonnet@ensimag.imag.fr>
---
 t/t7609-merge-co-error-msgs.sh |  125 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 125 insertions(+), 0 deletions(-)
 create mode 100755 t/t7609-merge-co-error-msgs.sh
diff --git a/t/t7609-merge-co-error-msgs.sh b/t/t7609-merge-co-error-msgs.sh
new file mode 100755
index 0000000..b636b75
--- /dev/null
+++ b/t/t7609-merge-co-error-msgs.sh
@@ -0,0 +1,125 @@
+#!/bin/sh
+
+test_description='unpack-trees error messages'
+
+. ./test-lib.sh
+
+
+test_expect_success 'setup' '
+	echo one >one &&
+	git add one &&
+	git commit -a -m First &&
+
+	git checkout -b branch &&
+	echo two>two &&
+	echo three>three &&
+	echo four>four &&
+	echo five>five &&
+	git add two three four five &&
+	git commit -m Second &&
+
+	git checkout master &&
+	echo other>two &&
+	echo other>three &&
+	echo other>four &&
+	echo other>five
+'
+
+cat> expect <<\EOF
+error: The following untracked working tree files would be overwritten by merge:
+	two
+	three
+	four
+	five
+Please move or remove them before you can merge.
+EOF
+
+test_expect_success 'untracked files overwritten by merge' '
+	! git merge branch 2> out &&
+	test_cmp out expect
+'
+
+cat> expect <<\EOF
+error: Your local changes to the following files would be overwritten by merge:
+	two
+	three
+	four
+Please, commit your changes or stash them before you can merge.
+error: The following untracked working tree files would be overwritten by merge:
+	five
+Please move or remove them before you can merge.
+EOF
+
+test_expect_success 'untracked files or local changes ovewritten by merge' '
+	git add two &&
+	git add three &&
+	git add four &&
+	! git merge branch 2> out &&
+	test_cmp out expect
+'
+
+cat> expect <<\EOF
+error: You have local changes to the following files:
+	rep/two
+	rep/one
+Cannot switch branches.
+EOF
+
+test_expect_success 'cannot switch branches because of local changes' '
+	git add five &&
+	mkdir rep &&
+	echo one>rep/one &&
+	echo two>rep/two &&
+	git add rep/one rep/two &&
+	git commit -m Fourth &&
+	git checkout master &&
+	echo uno>rep/one &&
+	echo dos>rep/two &&
+	! git checkout branch 2> out &&
+	test_cmp out expect
+'
+
+cat> expect <<\EOF
+error: Your local changes to the following files would be overwritten by checkout:
+	rep/two
+	rep/one
+Please, commit your changes or stash them before you can swicth branches.
+EOF
+
+test_expect_success 'not uptodate file porcelain checkout error' '
+	git add rep/one rep/two &&
+	! git checkout branch 2> out &&
+	test_cmp out expect
+'
+
+cat> expect <<\EOF
+error: Updating the following directories would lose untracked files in it:
+	rep2
+	rep
+
+EOF
+
+test_expect_success 'not_uptodate_dir porcelain checkout error' '
+	git init uptodate &&
+	cd uptodate &&
+	mkdir rep &&
+	mkdir rep2 &&
+	touch rep/foo &&
+	touch rep2/foo &&
+	git add rep/foo rep2/foo &&
+	git commit -m init &&
+	git checkout -b branch &&
+	git rm rep -r &&
+	git rm rep2 -r &&
+	> rep &&
+	> rep2 &&
+	git add rep rep2&&
+	git commit -m "added test as a file" &&
+	git checkout master &&
+	> rep/untracked-file &&
+	> rep2/untracked-file &&
+	! git checkout branch 2> out &&
+	test_cmp out ../expect
+'
+
+test_done
-- 
1.6.6.7.ga5fe3
Previous: Diane GasselinNext: Matthieu Moy
Message 6 of 13 in “unpack_trees: nicer error messages”
  1. 0/5 unpack_trees: nicer error messagesDiane Gasselin, Jun 15, 2010
  2. 1/5 merge-recursive: porcelain messages for checkoutDiane Gasselin, Jun 15, 2010
  3. 2/5 unpack_trees: group errors by typeDiane Gasselin, Jun 15, 2010
  4. 3/5 unpack_trees_options: update porcelain messagesDiane Gasselin, Jun 15, 2010
  5. 4/5 tests: update porcelain expected messageDiane Gasselin, Jun 15, 2010
  6. 5/5 t7609: test merge and checkout error messagesDiane Gasselin, Jun 15, 2010
  7. Matthieu MoyJun 15, 2010
  8. Matthieu MoyJun 15, 2010
  9. Matthieu MoyJun 15, 2010
  10. Diane GasselinJun 15, 2010
  11. Matthieu MoyJun 15, 2010
  12. Diane GasselinJun 15, 2010
  13. Matthieu MoyJun 15, 2010

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.