]> asedeno.scripts.mit.edu Git - git.git/blobdiff - t/t2200-add-update.sh
Merge branch 'ja/send-email-ehlo'
[git.git] / t / t2200-add-update.sh
index cd9231cf614c4326518632e514ccc68a5dc59223..2ad2819a345af53ff6ab0b7c28fa313f1a0a5956 100755 (executable)
@@ -12,7 +12,7 @@ and issues a git add -u with path limiting on "dir" to add
 only the updates to dir/sub.
 
 Also tested are "git add -u" without limiting, and "git add -u"
-without contents changes.'
+without contents changes, and other conditions'
 
 . ./test-lib.sh
 
@@ -80,7 +80,7 @@ test_expect_success 'change gets noticed' '
 
 '
 
-test_expect_success 'replace a file with a symlink' '
+test_expect_success SYMLINKS 'replace a file with a symlink' '
 
        rm foo &&
        ln -s top foo &&
@@ -128,4 +128,57 @@ test_expect_success 'add -n -u should not add but just report' '
 
 '
 
+test_expect_success 'add -u resolves unmerged paths' '
+       git reset --hard &&
+       one=$(echo 1 | git hash-object -w --stdin) &&
+       two=$(echo 2 | git hash-object -w --stdin) &&
+       three=$(echo 3 | git hash-object -w --stdin) &&
+       {
+               for path in path1 path2
+               do
+                       echo "100644 $one 1     $path"
+                       echo "100644 $two 2     $path"
+                       echo "100644 $three 3   $path"
+               done
+               echo "100644 $one 1     path3"
+               echo "100644 $one 1     path4"
+               echo "100644 $one 3     path5"
+               echo "100644 $one 3     path6"
+       } |
+       git update-index --index-info &&
+       echo 3 >path1 &&
+       echo 2 >path3 &&
+       echo 2 >path5 &&
+       git add -u &&
+       git ls-files -s path1 path2 path3 path4 path5 path6 >actual &&
+       {
+               echo "100644 $three 0   path1"
+               echo "100644 $one 1     path3"
+               echo "100644 $one 1     path4"
+               echo "100644 $one 3     path5"
+               echo "100644 $one 3     path6"
+       } >expect &&
+       test_cmp expect actual &&
+
+       # Bonus tests.  Explicit resolving
+       git add path3 path5 &&
+       test_must_fail git add path4 &&
+       test_must_fail git add path6 &&
+       git rm path4 &&
+       git rm path6 &&
+
+       git ls-files -s "path?" >actual &&
+       {
+               echo "100644 $three 0   path1"
+               echo "100644 $two 0     path3"
+               echo "100644 $two 0     path5"
+       } >expect
+
+'
+
+test_expect_success '"add -u non-existent" should fail' '
+       test_must_fail git add -u non-existent &&
+       ! (git ls-files | grep "non-existent")
+'
+
 test_done