ref-filter: rename the 'strip' option to 'lstrip'
[gitweb.git] / t / lib-submodule-update.sh
index f2e58eb904574090ca4a16f4a8b52de5b9fa0f5a..79cdd34a540ddc7230b1aefb7fb4af5915c7085f 100755 (executable)
@@ -227,7 +227,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 &&
                (
@@ -241,7 +248,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 &&
                (
@@ -270,7 +277,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 &&
                (
@@ -285,7 +292,16 @@ test_submodule_switch () {
        '
        # ... as does removing a directory with tracked files with a
        # submodule.
-       test_expect_success "$command: replace directory with submodule" '
+       if test "$KNOWN_FAILURE_NOFF_MERGE_DOESNT_CREATE_EMPTY_SUBMODULE_DIR" = 1
+       then
+               # Non fast-forward merges fail with "Directory sub1 doesn't
+               # exist. sub1" because the empty submodule directory is not
+               # created
+               RESULT="failure"
+       else
+               RESULT="success"
+       fi
+       test_expect_$RESULT "$command: replace directory with submodule" '
                prolog &&
                reset_work_tree_to replace_sub1_with_directory &&
                (
@@ -301,7 +317,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 &&
                (
@@ -313,7 +335,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 &&
                (
@@ -328,7 +350,16 @@ test_submodule_switch () {
        '
        # Replacing a submodule with files in a directory must fail as the
        # submodule work tree isn't removed ...
-       test_expect_success "$command: replace submodule with a directory must fail" '
+       if test "$KNOWN_FAILURE_NOFF_MERGE_ATTEMPTS_TO_MERGE_REMOVED_SUBMODULE_FILES" = 1
+       then
+               # Non fast-forward merges attempt to merge the former
+               # submodule files with the newly checked out ones in the
+               # directory of the same name while it shouldn't.
+               RESULT="failure"
+       else
+               RESULT="success"
+       fi
+       test_expect_$RESULT "$command: replace submodule with a directory must fail" '
                prolog &&
                reset_work_tree_to add_sub1 &&
                (
@@ -340,7 +371,7 @@ test_submodule_switch () {
                )
        '
        # ... especially when it contains a .git directory.
-       test_expect_success "$command: replace submodule containing a .git directory with a directory must fail" '
+       test_expect_$RESULT "$command: replace submodule containing a .git directory with a directory must fail" '
                prolog &&
                reset_work_tree_to add_sub1 &&
                (
@@ -384,7 +415,16 @@ test_submodule_switch () {
 
        ########################## Modified submodule #########################
        # Updating a submodule sha1 doesn't update the submodule's work tree
-       test_expect_success "$command: modified submodule does not update submodule work tree" '
+       if test "$KNOWN_FAILURE_CHERRY_PICK_SEES_EMPTY_COMMIT" = 1
+       then
+               # When cherry picking a SHA-1 update for an ignored submodule
+               # the commit incorrectly fails with "The previous cherry-pick
+               # is now empty, possibly due to conflict resolution."
+               RESULT="failure"
+       else
+               RESULT="success"
+       fi
+       test_expect_$RESULT "$command: modified submodule does not update submodule work tree" '
                prolog &&
                reset_work_tree_to add_sub1 &&
                (
@@ -400,7 +440,7 @@ test_submodule_switch () {
 
        # Updating a submodule to an invalid sha1 doesn't update the
        # submodule's work tree, subsequent update will fail
-       test_expect_success "$command: modified submodule does not update submodule work tree to invalid commit" '
+       test_expect_$RESULT "$command: modified submodule does not update submodule work tree to invalid commit" '
                prolog &&
                reset_work_tree_to add_sub1 &&
                (
@@ -415,7 +455,7 @@ test_submodule_switch () {
        '
        # Updating a submodule from an invalid sha1 doesn't update the
        # submodule's work tree, subsequent update will succeed
-       test_expect_success "$command: modified submodule does not update submodule work tree from invalid commit" '
+       test_expect_$RESULT "$command: modified submodule does not update submodule work tree from invalid commit" '
                prolog &&
                reset_work_tree_to invalid_sub1 &&
                (