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

[PATCHv6 2/4] t7512-status-help.sh: better advices for git status

From
KLKong Lucien <lucien.kong@ensimag.imag.fr>
Date
Jun 3, 2012, 18:30 UTC
Message-ID
<1338748217-16440-2-git-send-email-Lucien.Kong@ensimag.imag.fr>
In-Reply-To
<1338748217-16440-1-git-send-email-Lucien.Kong@ensimag.imag.fr>

The following tests include several cases in which the user needs to run 'git status' to know his current situation, whether there're conflicts or he's in rebase/bisect/am/ cherry-pick progress.

One of the test is about the set of the advice.statushints config key to 'false' in .git/config.

Signed-off-by: Kong Lucien <Lucien.Kong@ensimag.imag.fr>
Signed-off-by: Duperray Valentin <Valentin.Duperray@ensimag.imag.fr>
Signed-off-by: Jonas Franck <Franck.Jonas@ensimag.imag.fr>
Signed-off-by: Nguy Thomas <Thomas.Nguy@ensimag.imag.fr>
Signed-off-by: Nguyen Huynh Khoi Nguyen <Huynh-Khoi-Nguyen.Nguyen@ensimag.imag.fr>
Signed-off-by: Moy Matthieu <Matthieu.Moy@grenoble-inp.fr>
---
 t/t7512-status-help.sh |  303 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 303 insertions(+), 0 deletions(-)
 create mode 100755 t/t7512-status-help.sh
diff --git a/t/t7512-status-help.sh b/t/t7512-status-help.sh
new file mode 100755
index 0000000..5f62262
--- /dev/null
+++ b/t/t7512-status-help.sh
@@ -0,0 +1,303 @@
+#!/bin/sh
+#
+# Copyright (c) 2012 Valentin Duperray, Lucien Kong, Franck Jonas,
+#		     Thomas Nguy, Khoi Nguyen
+#		     Grenoble INP Ensimag
+#
+
+test_description='git status advices'
+
+. ./test-lib.sh
+
+. "$TEST_DIRECTORY"/lib-rebase.sh
+
+set_fake_editor
+
+test_expect_success 'status when conflicts unresolved' '
+	git init git &&
+	cd git &&
+	test_commit init main.txt init &&
+	git branch second_branch &&
+	test_commit on_master main.txt on_master &&
+	git checkout second_branch &&
+	test_commit on_second_branch main.txt on_second_branch &&
+	test_must_fail git merge master &&
+	cat >expected <<-\EOF &&
+	# On branch second_branch
+	# You have unmerged paths.
+	#   (fix conflicts and run "git commit")
+	#
+	# Unmerged paths:
+	#   (use "git add/rm <file>..." as appropriate to mark resolution)
+	#
+	#	both modified:      main.txt
+	#
+	no changes added to commit (use "git add" and/or "git commit -a")
+	EOF
+	git status --untracked-files=no >actual &&
+	test_cmp expected actual
+'
+
+
+test_expect_success 'status when conflicts resolved before commit' '
+	echo one >main.txt &&
+	git add main.txt &&
+	cat >expected <<-\EOF &&
+	# On branch second_branch
+	# All conflicts fixed but you are still merging.
+	#   (use "git commit" to conclude merge)
+	#
+	# Changes to be committed:
+	#
+	#	modified:   main.txt
+	#
+	# Untracked files not listed (use -u option to show untracked files)
+	EOF
+	git status --untracked-files=no >actual &&
+	test_cmp expected actual
+'
+
+
+test_expect_success 'status when rebase in progress before resolving conflicts' '
+	git commit -m "one" &&
+	test_commit two main.txt two &&
+	test_commit three main.txt three &&
+	test_must_fail git rebase HEAD^ --onto HEAD^^ &&
+	cat >expected <<-\EOF &&
+	# Not currently on any branch.
+	# You are currently rebasing.
+	#   (fix conflicts and then run "git rebase --continue")
+	#   (use "git rebase --skip" to skip this patch)
+	#   (use "git rebase --abort" to check out the original branch)
+	#
+	# Unmerged paths:
+	#   (use "git reset HEAD <file>..." to unstage)
+	#   (use "git add/rm <file>..." as appropriate to mark resolution)
+	#
+	#	both modified:      main.txt
+	#
+	no changes added to commit (use "git add" and/or "git commit -a")
+	EOF
+	git status --untracked-files=no >actual &&
+	test_cmp expected actual
+'
+
+
+test_expect_success 'status when rebase in progress before rebase --continue' '
+	test_when_finished "cd ../ && rm -rf git" &&
+	echo three >main.txt &&
+	git add main.txt &&
+	cat >expected <<-\EOF &&
+	# Not currently on any branch.
+	# You are currently rebasing.
+	#   (all conflicts fixed: run "git rebase --continue")
+	#
+	# Changes to be committed:
+	#   (use "git reset HEAD <file>..." to unstage)
+	#
+	#	modified:   main.txt
+	#
+	# Untracked files not listed (use -u option to show untracked files)
+	EOF
+	git status --untracked-files=no >actual &&
+	test_cmp expected actual
+'
+
+
+test_expect_success 'status when rebasing -i in edit mode' '
+	git init git &&
+	test_when_finished "rm -rf git fake-editor.sh" &&
+	(
+		cd git &&
+		test_commit one main.txt one &&
+		test_commit two main.txt two &&
+		test_commit three main.txt three &&
+		FAKE_LINES="1 edit 2" &&
+		export FAKE_LINES &&
+		git rebase -i HEAD~2 &&
+		cat >expected <<-\EOF &&
+		# Not currently on any branch.
+		# You are currently editing a commit during a rebase.
+		#   (use "git commit --amend" to amend the current commit)
+		#   (use "git rebase --continue" once you are satisfied with your changes)
+		#
+		nothing to commit (use -u to show untracked files)
+		EOF
+		git status --untracked-files=no >actual &&
+		test_cmp expected actual &&
+		git rebase --abort
+	)
+'
+
+
+test_expect_success 'status in an am session: file already exists' '
+	git init git &&
+	test_when_finished "rm -rf git" &&
+	(
+		cd git &&
+		test_commit one main.txt "one  " &&
+		git format-patch -1 -oMaildir &&
+		test_must_fail git am Maildir/*.patch &&
+		cat >expected <<-\EOF &&
+		# On branch master
+		# You are in the middle of an am session.
+		#   (when you have fixed this problem run "git am --resolved")
+		#   (use "git am --skip" to skip this patch)
+		#   (use "git am --abort" to restore the original branch)
+		#
+		nothing to commit (use -u to show untracked files)
+		EOF
+		git status --untracked-files=no >actual &&
+		test_cmp expected actual
+	)
+'
+
+
+test_expect_success 'status in an am session: file does not exist' '
+	git init git &&
+	test_when_finished "rm -rf git" &&
+	(
+		cd git &&
+		test_commit one main.txt "one" &&
+		git rm main.txt &&
+		git commit -m "delete main.txt" &&
+		git format-patch -1 -oMaildir &&
+		test_must_fail git am Maildir/*.patch &&
+		cat >expected <<-\EOF &&
+		# On branch master
+		# You are in the middle of an am session.
+		#   (when you have fixed this problem run "git am --resolved")
+		#   (use "git am --skip" to skip this patch)
+		#   (use "git am --abort" to restore the original branch)
+		#
+		nothing to commit (use -u to show untracked files)
+		EOF
+		git status --untracked-files=no >actual &&
+		test_cmp expected actual
+	)
+'
+
+
+test_expect_success 'status in an am session: empty patch' '
+	git init git &&
+	test_when_finished "rm -rf git" &&
+	(
+		cd git &&
+		test_commit one one.txt "one" &&
+		test_commit two two.txt "two" &&
+		test_commit three three.txt "three" &&
+		git format-patch -3 -oMaildir &&
+		git rm one.txt two.txt three.txt &&
+		git commit -m "delete all" &&
+		echo error >Maildir/0002-two.patch &&
+		test_must_fail git am Maildir/*.patch &&
+		cat >expected <<-\EOF &&
+		# On branch master
+		# You are in the middle of an am session.
+		# The current patch is empty; run "git am --skip" to skip it.
+		#   (use "git am --abort" to restore the original branch)
+		#
+		nothing to commit (use -u to show untracked files)
+		EOF
+		git status --untracked-files=no >actual &&
+		test_cmp expected actual
+	)
+'
+
+
+test_expect_success 'status when bisecting' '
+	git init git &&
+	test_when_finished "rm -rf git" &&
+	(
+		cd git &&
+		test_commit one main.txt one &&
+		test_commit two main.txt two &&
+		test_commit three main.txt three &&
+		git bisect start &&
+		git bisect bad &&
+		git bisect good one &&
+		cat >expected <<-\EOF &&
+		# Not currently on any branch.
+		# You are currently bisecting.
+		#   (use "git bisect reset" to get back to the original branch)
+		#
+		nothing to commit (use -u to show untracked files)
+		EOF
+		git status --untracked-files=no >actual &&
+		test_cmp expected actual
+	)
+'
+
+
+test_expect_success 'status when rebase conflicts with statushints disabled' '
+	git init git &&
+	test_when_finished "rm -rf git" &&
+	(
+		cd git &&
+		git config --local advice.statushints false &&
+		test_commit one main.txt one &&
+		test_commit two main.txt two &&
+		test_commit three main.txt three &&
+		test_must_fail git rebase HEAD^ --onto HEAD^^ &&
+		cat >expected <<-\EOF &&
+		# Not currently on any branch.
+		# You are currently rebasing.
+		#
+		# Unmerged paths:
+		#	both modified:      main.txt
+		#
+		no changes added to commit
+		EOF
+		git status --untracked-files=no >actual &&
+		test_cmp expected actual
+	)
+'
+
+
+test_expect_success 'status when cherry-picking before resolving conflicts' '
+	git init git &&
+	cd git &&
+	test_commit init main.txt init &&
+	git checkout -b second_branch &&
+	test_commit one main.txt one &&
+	test_commit two main.txt two &&
+	test_commit three main.txt three &&
+	git checkout master &&
+	test_must_fail git cherry-pick two &&
+	cat >expected <<-\EOF &&
+	# On branch master
+	# You are currently cherry-picking.
+	#   (fix conflicts and run "git commit")
+	#
+	# Unmerged paths:
+	#   (use "git add/rm <file>..." as appropriate to mark resolution)
+	#
+	#	both modified:      main.txt
+	#
+	no changes added to commit (use "git add" and/or "git commit -a")
+	EOF
+	git status --untracked-files=no >actual &&
+	test_cmp expected actual
+'
+
+test_expect_success 'status when cherry-picking after resolving conflicts' '
+	test_when_finished "cd ../ && rm -rf git"
+	echo end >main.txt &&
+	git add main.txt &&
+	cat >expected <<-\EOF &&
+	# On branch master
+	# You are currently cherry-picking.
+	#   (all conflicts fixed: run "git commit")
+	#
+	# Changes to be committed:
+	#
+	#	modified:   main.txt
+	#
+	# Untracked files not listed (use -u option to show untracked files)
+	EOF
+	git status --untracked-files=no >actual &&
+	test_cmp expected actual
+'
+
+
+test_done
-- 
1.7.8
Previous: Kong LucienNext: Junio C Hamano
Message 55 of 97 in “t7512-status-warnings.sh : better advices for git status”
  1. t7512-status-warnings.sh : better advices for git statusKong Lucien, May 24, 2012
  2. Matthieu MoyMay 24, 2012
  3. 1/2 wt-status: better advices for git statusKong Lucien, May 26, 2012
  4. 2/2 t7512-status-warnings.sh: better advices for git statusKong Lucien, May 26, 2012
  5. Matthieu MoyMay 27, 2012
  6. Matthieu MoyMay 28, 2012
  7. Nguyen Thai Ngoc DuyMay 26, 2012
  8. NGUY ThomasMay 26, 2012
  9. Matthieu MoyMay 27, 2012
  10. Matthieu MoyMay 27, 2012
  11. Junio C HamanoMay 28, 2012
  12. Matthieu MoyMay 28, 2012
  13. Junio C HamanoMay 30, 2012
  14. konglu@minatec.inpg.frMay 28, 2012
  15. 1/2 wt-status.*: better advices for git status addedKong Lucien, May 28, 2012
  16. 2/2 t7512-status-warnings.sh: better advices for git statusKong Lucien, May 28, 2012
  17. Matthieu MoyMay 28, 2012
  18. Matthieu MoyMay 28, 2012
  19. Junio C HamanoMay 29, 2012
  20. konglu@minatec.inpg.frMay 30, 2012
  21. Junio C HamanoMay 30, 2012
  22. Matthieu MoyMay 31, 2012
  23. 1/3 wt-status.*: better advices for git status addedKong Lucien, May 30, 2012
  24. 2/3 t7512-status-warnings.sh: better advices for git statusKong Lucien, May 30, 2012
  25. 3/3 Advices about 'git rm' during conflicts (unmerged paths) more relevantKong Lucien, May 30, 2012
  26. Junio C HamanoMay 30, 2012
  27. konglu@minatec.inpg.frMay 30, 2012
  28. Matthieu MoyMay 31, 2012
  29. konglu@minatec.inpg.frMay 31, 2012
  30. Junio C HamanoMay 30, 2012
  31. Junio C HamanoMay 30, 2012
  32. Matthieu MoyMay 31, 2012
  33. Matthieu MoyMay 31, 2012
  34. Matthieu MoyMay 31, 2012
  35. Andrew ArdillMay 31, 2012
  36. 1/3 wt-status.*: better advices for git status addedKong Lucien, May 31, 2012
  37. 2/3 t7512-status-help.sh: better advices for git statusKong Lucien, May 31, 2012
  38. 3/3 status: don't suggest "git rm" or "git add" if not appropriateKong Lucien, May 31, 2012
  39. Matthieu MoyJun 1, 2012
  40. Phil HordJun 1, 2012
  41. konglu@minatec.inpg.frJun 1, 2012
  42. Junio C HamanoJun 1, 2012
  43. Junio C HamanoMay 31, 2012
  44. konglu@minatec.inpg.frJun 1, 2012
  45. Matthieu MoyJun 1, 2012
  46. Junio C HamanoJun 1, 2012
  47. Junio C HamanoJun 1, 2012
  48. konglu@minatec.inpg.frJun 1, 2012
  49. Matthieu MoyJun 1, 2012
  50. konglu@minatec.inpg.frJun 1, 2012
  51. Phil HordJun 1, 2012
  52. Junio C HamanoJun 1, 2012
  53. Phil HordJun 4, 2012
  54. 1/4 wt-status.*: better advices for git status addedKong Lucien, Jun 3, 2012
  55. 2/4 t7512-status-help.sh: better advices for git statusKong Lucien, Jun 3, 2012
  56. Junio C HamanoJun 3, 2012
  57. konglu@minatec.inpg.frJun 4, 2012
  58. Junio C HamanoJun 4, 2012
  59. Junio C HamanoJun 4, 2012
  60. 3/4 status: don't suggest "git rm" or "git add" if not appropriateKong Lucien, Jun 3, 2012
  61. Matthieu MoyJun 3, 2012
  62. 4/4 status: better advices when splitting a commit (during rebase -i)Kong Lucien, Jun 3, 2012
  63. Junio C HamanoJun 3, 2012
  64. Phil HordJun 4, 2012
  65. konglu@minatec.inpg.frJun 5, 2012
  66. Junio C HamanoJun 3, 2012
  67. konglu@minatec.inpg.frJun 4, 2012
  68. Junio C HamanoJun 4, 2012
  69. 1/4 wt-status.*: better advices for git status addedKong Lucien, Jun 4, 2012
  70. 2/4 t7512-status-help.sh: better advices for git statusKong Lucien, Jun 4, 2012
  71. Matthieu MoyJun 4, 2012
  72. Junio C HamanoJun 4, 2012
  73. 3/4 status: don't suggest "git rm" or "git add" if not appropriateKong Lucien, Jun 4, 2012
  74. 4/4 status: better advices when splitting a commit (during rebase -i)Kong Lucien, Jun 4, 2012
  75. Junio C HamanoJun 4, 2012
  76. konglu@minatec.inpg.frJun 5, 2012
  77. Matthieu MoyJun 5, 2012
  78. 1/4 wt-status.*: better advices for git status addedLucien Kong, Jun 5, 2012
  79. 2/4 t7512-status-help.sh: better advices for git statusLucien Kong, Jun 5, 2012
  80. 3/4 status: don't suggest "git rm" or "git add" if not appropriateLucien Kong, Jun 5, 2012
  81. 4/4 status: better advices when splitting a commit (during rebase -i)Lucien Kong, Jun 5, 2012
  82. Junio C HamanoJun 5, 2012
  83. konglu@minatec.inpg.frJun 8, 2012
  84. Junio C HamanoJun 8, 2012
  85. 1/4 wt-status.*: better advices for git status addedLucien Kong, Jun 7, 2012
  86. 2/4 t7512-status-help.sh: better advices for git statusLucien Kong, Jun 7, 2012
  87. 3/4 status: don't suggest "git rm" or "git add" if not appropriateLucien Kong, Jun 7, 2012
  88. 4/4 status: better advices when splitting a commit (during rebase -i)Lucien Kong, Jun 7, 2012
  89. Junio C HamanoJun 7, 2012
  90. Junio C HamanoJun 7, 2012
  91. konglu@minatec.inpg.frJun 7, 2012
  92. 1/4 wt-status.*: better advices for git status addedLucien Kong, Jun 10, 2012
  93. 2/4 t7512-status-help.sh: better advices for git statusLucien Kong, Jun 10, 2012
  94. 3/4 status: don't suggest "git rm" or "git add" if not appropriateLucien Kong, Jun 10, 2012
  95. 4/4 status: better advices when splitting a commit (during rebase -i)Lucien Kong, Jun 10, 2012
  96. Junio C HamanoJun 11, 2012
  97. konglu@minatec.inpg.frJun 12, 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.