reopen_tempfile(): truncate opened file
[gitweb.git] / t / t2203-add-intent.sh
index 06e69e8fd25bfde856636b5e551d98c53e8c1bf3..04d840a5448567bf438688c4aebd7e94d63da4ec 100755 (executable)
@@ -27,12 +27,12 @@ test_expect_success 'git status' '
 
 test_expect_success 'git status with porcelain v2' '
        git status --porcelain=v2 | grep -v "^?" >actual &&
-       nam1=d00491fd7e5bb6fa28c517a0bb32b8b506539d4d &&
-       nam2=ce013625030ba8dba906f756967f9e9ca394464a &&
+       nam1=$(echo 1 | git hash-object --stdin) &&
+       nam2=$(git hash-object elif) &&
        cat >expect <<-EOF &&
-       1 DA N... 100644 000000 100644 $nam1 $_z40 1.t
-       1 A. N... 000000 100644 100644 $_z40 $nam2 elif
-       1 .A N... 000000 000000 100644 $_z40 $_z40 file
+       1 DA N... 100644 000000 100644 $nam1 $ZERO_OID 1.t
+       1 A. N... 000000 100644 100644 $ZERO_OID $nam2 elif
+       1 .A N... 000000 000000 100644 $ZERO_OID $ZERO_OID file
        EOF
        test_cmp expect actual
 '
@@ -141,10 +141,10 @@ test_expect_success 'cache-tree does skip dir that becomes empty' '
        )
 '
 
-test_expect_success 'commit: ita entries ignored in empty intial commit check' '
-       git init empty-intial-commit &&
+test_expect_success 'commit: ita entries ignored in empty initial commit check' '
+       git init empty-initial-commit &&
        (
-               cd empty-intial-commit &&
+               cd empty-initial-commit &&
                : >one &&
                git add -N one &&
                test_must_fail git commit -m nothing-new-here
@@ -162,5 +162,65 @@ test_expect_success 'commit: ita entries ignored in empty commit check' '
        )
 '
 
+test_expect_success 'rename detection finds the right names' '
+       git init rename-detection &&
+       (
+               cd rename-detection &&
+               echo contents >first &&
+               git add first &&
+               git commit -m first &&
+               mv first third &&
+               git add -N third &&
+
+               git status | grep -v "^?" >actual.1 &&
+               test_i18ngrep "renamed: *first -> third" actual.1 &&
+
+               git status --porcelain | grep -v "^?" >actual.2 &&
+               cat >expected.2 <<-\EOF &&
+                R first -> third
+               EOF
+               test_cmp expected.2 actual.2 &&
+
+               hash=$(git hash-object third) &&
+               git status --porcelain=v2 | grep -v "^?" >actual.3 &&
+               cat >expected.3 <<-EOF &&
+               2 .R N... 100644 100644 100644 $hash $hash R100 third   first
+               EOF
+               test_cmp expected.3 actual.3
+       )
+'
+
+test_expect_success 'double rename detection in status' '
+       git init rename-detection-2 &&
+       (
+               cd rename-detection-2 &&
+               echo contents >first &&
+               git add first &&
+               git commit -m first &&
+               git mv first second &&
+               mv second third &&
+               git add -N third &&
+
+               git status | grep -v "^?" >actual.1 &&
+               test_i18ngrep "renamed: *first -> second" actual.1 &&
+               test_i18ngrep "renamed: *second -> third" actual.1 &&
+
+               git status --porcelain | grep -v "^?" >actual.2 &&
+               cat >expected.2 <<-\EOF &&
+               R  first -> second
+                R second -> third
+               EOF
+               test_cmp expected.2 actual.2 &&
+
+               hash=$(git hash-object third) &&
+               git status --porcelain=v2 | grep -v "^?" >actual.3 &&
+               cat >expected.3 <<-EOF &&
+               2 R. N... 100644 100644 100644 $hash $hash R100 second  first
+               2 .R N... 100644 100644 100644 $hash $hash R100 third   second
+               EOF
+               test_cmp expected.3 actual.3
+       )
+'
+
 test_done