summaryrefslogtreecommitdiff
path: root/t/t2200-add-update.sh
diff options
context:
space:
mode:
Diffstat (limited to 't/t2200-add-update.sh')
-rwxr-xr-xt/t2200-add-update.sh61
1 files changed, 52 insertions, 9 deletions
diff --git a/t/t2200-add-update.sh b/t/t2200-add-update.sh
index f57a6e0..4cdebda 100755
--- a/t/t2200-add-update.sh
+++ b/t/t2200-add-update.sh
@@ -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
@@ -25,8 +25,8 @@ test_expect_success setup '
echo initial >dir1/sub2 &&
echo initial >dir2/sub3 &&
git add check dir1 dir2 top foo &&
- test_tick
- git-commit -m initial &&
+ test_tick &&
+ git commit -m initial &&
echo changed >check &&
echo changed >top &&
@@ -40,20 +40,20 @@ test_expect_success update '
'
test_expect_success 'update noticed a removal' '
- test "$(git-ls-files dir1/sub1)" = ""
+ test "$(git ls-files dir1/sub1)" = ""
'
test_expect_success 'update touched correct path' '
- test "$(git-diff-files --name-status dir2/sub3)" = ""
+ test "$(git diff-files --name-status dir2/sub3)" = ""
'
test_expect_success 'update did not touch other tracked files' '
- test "$(git-diff-files --name-status check)" = "M check" &&
- test "$(git-diff-files --name-status top)" = "M top"
+ test "$(git diff-files --name-status check)" = "M check" &&
+ test "$(git diff-files --name-status top)" = "M top"
'
test_expect_success 'update did not touch untracked files' '
- test "$(git-ls-files dir2/other)" = ""
+ test "$(git ls-files dir2/other)" = ""
'
test_expect_success 'cache tree has not been corrupted' '
@@ -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 &&
@@ -124,8 +124,51 @@ test_expect_success 'add -n -u should not add but just report' '
after=$(git ls-files -s check top) &&
test "$before" = "$after" &&
+ test_i18ncmp expect actual
+
+'
+
+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 &&
+
+ # Explicit resolving by adding removed paths should fail
+ test_must_fail git add path4 &&
+ test_must_fail git add path6 &&
+
+ # "add -u" should notice removals no matter what stages
+ # the index entries are in.
+ git add -u &&
+ git ls-files -s path1 path2 path3 path4 path5 path6 >actual &&
+ {
+ echo "100644 $three 0 path1"
+ echo "100644 $two 0 path3"
+ echo "100644 $two 0 path5"
+ } >expect &&
test_cmp expect actual
+'
+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