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

[PATCH v2 13/14] stash: add t3906 for submodule updates

From
Jens Lehmann <jens.lehmann@web.de>
Date
Jun 19, 2014, 20:12 UTC
Message-ID
<53A34446.5080009@web.de>
In-Reply-To
<539DD219.40108@web.de>

Test that the stash apply command updates the work tree as expected for changes which don't result in conflicts. To make that work add a helper function that uses read-tree to apply the changes of the target commit to the work tree, then stashes these changes and at last applies that stash.

Implement the KNOWN_FAILURE_STASH_DOES_IGNORE_SUBMODULE_CHANGES switch and reuse two other already present switches to expect the known failure that stash does ignore submodule changes.

Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
---
Changes to v1:
*) use "expect" instead of "expected"
 t/lib-submodule-update.sh  | 23 ++++++++++++++++++-----
 t/t3906-stash-submodule.sh | 24 ++++++++++++++++++++++++
 2 files changed, 42 insertions(+), 5 deletions(-)
 create mode 100755 t/t3906-stash-submodule.sh
diff --git a/t/lib-submodule-update.sh b/t/lib-submodule-update.sh
index a38cf52..2a504b2 100755
--- a/t/lib-submodule-update.sh
+++ b/t/lib-submodule-update.sh
@@ -219,7 +219,14 @@ test_submodule_switch () {
 	command="$1"
 	######################### Appearing submodule #########################
 	# Switching to a commit letting a submodule appear creates empty dir ...
-	test_expect_success "$command: added submodule creates empty directory" '
+	if test "$KNOWN_FAILURE_STASH_DOES_IGNORE_SUBMODULE_CHANGES" = 1
+	then
+		# Restoring stash fails to restore submodule index entry
+		RESULT="failure"
+	else
+		RESULT="success"
+	fi
+	test_expect_$RESULT "$command: added submodule creates empty directory" '
 		prolog &&
 		reset_work_tree_to no_submodule &&
 		(
@@ -233,7 +240,7 @@ test_submodule_switch () {
 		)
 	'
 	# ... and doesn't care if it already exists ...
-	test_expect_success "$command: added submodule leaves existing empty directory alone" '
+	test_expect_$RESULT "$command: added submodule leaves existing empty directory alone" '
 		prolog &&
 		reset_work_tree_to no_submodule &&
 		(
@@ -262,7 +269,7 @@ test_submodule_switch () {
 	'
 	# Replacing a tracked file with a submodule produces an empty
 	# directory ...
-	test_expect_success "$command: replace tracked file with submodule creates empty directory" '
+	test_expect_$RESULT "$command: replace tracked file with submodule creates empty directory" '
 		prolog &&
 		reset_work_tree_to replace_sub1_with_file &&
 		(
@@ -302,7 +309,13 @@ test_submodule_switch () {

 	######################## Disappearing submodule #######################
 	# Removing a submodule doesn't remove its work tree ...
-	test_expect_success "$command: removed submodule leaves submodule directory and its contents in place" '
+	if test "$KNOWN_FAILURE_STASH_DOES_IGNORE_SUBMODULE_CHANGES" = 1
+	then
+		RESULT="failure"
+	else
+		RESULT="success"
+	fi
+	test_expect_$RESULT "$command: removed submodule leaves submodule directory and its contents in place" '
 		prolog &&
 		reset_work_tree_to add_sub1 &&
 		(
@@ -314,7 +327,7 @@ test_submodule_switch () {
 		)
 	'
 	# ... especially when it contains a .git directory.
-	test_expect_success "$command: removed submodule leaves submodule containing a .git directory alone" '
+	test_expect_$RESULT "$command: removed submodule leaves submodule containing a .git directory alone" '
 		prolog &&
 		reset_work_tree_to add_sub1 &&
 		(
diff --git a/t/t3906-stash-submodule.sh b/t/t3906-stash-submodule.sh
new file mode 100755
index 0000000..d7219d6
--- /dev/null
+++ b/t/t3906-stash-submodule.sh
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+test_description='stash apply can handle submodules'
+
+. ./test-lib.sh
+. "$TEST_DIRECTORY"/lib-submodule-update.sh
+
+git_stash () {
+	git status -su >expect &&
+	ls -1pR * >>expect &&
+	git read-tree -u -m "$1" &&
+	git stash &&
+	git status -su >actual &&
+	ls -1pR * >>actual &&
+	test_cmp expect actual &&
+	git stash apply
+}
+
+KNOWN_FAILURE_STASH_DOES_IGNORE_SUBMODULE_CHANGES=1
+KNOWN_FAILURE_CHERRY_PICK_SEES_EMPTY_COMMIT=1
+KNOWN_FAILURE_NOFF_MERGE_DOESNT_CREATE_EMPTY_SUBMODULE_DIR=1
+test_submodule_switch "git_stash"
+
+test_done
-- 
2.0.0.406.gf4dce28
Previous: Jens LehmannNext: Jens Lehmann
Message 30 of 65 in “Add submodule test harness”
  1. 00/14 Add submodule test harnessJens Lehmann, Jun 15, 2014
  2. 01/14 test-lib: add test_dir_is_empty()Jens Lehmann, Jun 15, 2014
  3. Junio C HamanoJun 16, 2014
  4. Jens LehmannJun 17, 2014
  5. 01/14 test-lib: add test_dir_is_empty()Jens Lehmann, Jun 19, 2014
  6. 02/14 submodules: Add the lib-submodule-update.sh test libraryJens Lehmann, Jun 15, 2014
  7. Junio C HamanoJun 16, 2014
  8. Jens LehmannJun 17, 2014
  9. Junio C HamanoJun 17, 2014
  10. Jens LehmannJun 17, 2014
  11. Junio C HamanoJun 17, 2014
  12. 02/14 submodules: Add the lib-submodule-update.sh test libraryJens Lehmann, Jun 19, 2014
  13. Junio C HamanoJun 20, 2014
  14. 02/14 submodules: Add the lib-submodule-update.sh test libraryJens Lehmann, Jul 1, 2014
  15. 03/14 checkout: call the new submodule update test frameworkJens Lehmann, Jun 15, 2014
  16. 04/14 apply: add t4137 for submodule updatesJens Lehmann, Jun 15, 2014
  17. 05/14 read-tree: add t1013 for submodule updatesJens Lehmann, Jun 15, 2014
  18. 06/14 reset: add t7112 for submodule updatesJens Lehmann, Jun 15, 2014
  19. 07/14 bisect: add t6041 for submodule updatesJens Lehmann, Jun 15, 2014
  20. 07/14 bisect: add t6041 for submodule updatesJens Lehmann, Jun 19, 2014
  21. 08/14 merge: add t7613 for submodule updatesJens Lehmann, Jun 15, 2014
  22. 09/14 rebase: add t3426 for submodule updatesJens Lehmann, Jun 15, 2014
  23. Eric SunshineJun 16, 2014
  24. Jens LehmannJun 17, 2014
  25. 09/14 rebase: add t3426 for submodule updatesJens Lehmann, Jun 19, 2014
  26. 10/14 pull: add t5572 for submodule updatesJens Lehmann, Jun 15, 2014
  27. 11/14 cherry-pick: add t3512 for submodule updatesJens Lehmann, Jun 15, 2014
  28. 12/14 am: add t4255 for submodule updatesJens Lehmann, Jun 15, 2014
  29. 13/14 stash: add t3906 for submodule updatesJens Lehmann, Jun 15, 2014
  30. 13/14 stash: add t3906 for submodule updatesJens Lehmann, Jun 19, 2014
  31. 14/14 revert: add t3513 for submodule updatesJens Lehmann, Jun 15, 2014
  32. 14/14 revert: add t3513 for submodule updatesJens Lehmann, Jun 19, 2014
  33. Torsten BögershausenJul 2, 2014
  34. Jens LehmannJul 2, 2014
  35. Torsten BögershausenJul 3, 2014
  36. Jens LehmannJul 3, 2014
  37. Junio C HamanoJul 7, 2014
  38. Torsten BögershausenJul 7, 2014
  39. Jens LehmannJul 8, 2014
  40. Ramsay JonesJul 8, 2014
  41. Ramsay JonesJul 8, 2014
  42. No fchmod() under msygit - Was: Re: [PATCH 00/14] Add submodule test harnessTorsten Bögershausen, Jul 9, 2014
  43. Eric WongJul 9, 2014
  44. Erik Faye-LundJul 14, 2014
  45. Nico WilliamsJul 14, 2014
  46. Nico WilliamsJul 14, 2014
  47. Karsten BleesJul 14, 2014
  48. Junio C HamanoJul 14, 2014
  49. Torsten BögershausenJul 9, 2014
  50. Junio C HamanoJul 9, 2014
  51. Jens LehmannJul 9, 2014
  52. Junio C HamanoJul 9, 2014
  53. Junio C HamanoJul 10, 2014
  54. Jens LehmannJul 12, 2014
  55. Junio C HamanoJul 14, 2014
  56. Jens LehmannJul 14, 2014
  57. Junio C HamanoJul 14, 2014
  58. Johannes SixtJul 9, 2014
  59. Junio C HamanoJul 9, 2014
  60. Eric WongJul 9, 2014
  61. Junio C HamanoJul 9, 2014
  62. No fchmd. was: Re: [PATCH 00/14] Add submodule test harnessTorsten Bögershausen, Jul 10, 2014
  63. Junio C HamanoJul 10, 2014
  64. Torsten BögershausenJul 10, 2014
  65. Junio C HamanoJul 10, 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.