Code

Merge branch 'master' into cc/trace
[git.git] / t / t1400-update-ref.sh
index f6b076bafd54ee069129560aba6c8e60a55c26c3..ddc80bbeae7703b8c4a2ddcf12d8b1ec9c6bbe46 100755 (executable)
@@ -14,6 +14,8 @@ D=4444444444444444444444444444444444444444
 E=5555555555555555555555555555555555555555
 F=6666666666666666666666666666666666666666
 m=refs/heads/master
+n_dir=refs/heads/gu
+n=$n_dir/fixes
 
 test_expect_success \
        "create $m" \
@@ -25,6 +27,16 @@ test_expect_success \
         test $B = $(cat .git/$m)'
 rm -f .git/$m
 
+test_expect_success \
+       "fail to create $n" \
+       'touch .git/$n_dir
+        git-update-ref $n $A >out 2>err
+        test $? = 1 &&
+        test "" = "$(cat out)" &&
+        grep "error: unable to resolve reference" err &&
+        grep $n err'
+rm -f .git/$n_dir out err
+
 test_expect_success \
        "create $m (by HEAD)" \
        'git-update-ref HEAD $A &&
@@ -178,22 +190,48 @@ rm -f .git/$m .git/logs/$m expect
 
 test_expect_success \
     'creating initial files' \
-    'cp ../../COPYING COPYING &&
-     git-add COPYING &&
+    'echo TEST >F &&
+     git-add F &&
+        GIT_AUTHOR_DATE="2005-05-26 23:30" \
         GIT_COMMITTER_DATE="2005-05-26 23:30" git-commit -m add -a &&
-        cp ../../Makefile COPYING &&
-        GIT_COMMITTER_DATE="2005-05-26 23:41" git-commit -m change -a'
+        h_TEST=$(git-rev-parse --verify HEAD)
+        echo The other day this did not work. >M &&
+        echo And then Bob told me how to fix it. >>M &&
+        echo OTHER >F &&
+        GIT_AUTHOR_DATE="2005-05-26 23:41" \
+        GIT_COMMITTER_DATE="2005-05-26 23:41" git-commit -F M -a &&
+        h_OTHER=$(git-rev-parse --verify HEAD) &&
+        echo FIXED >F &&
+        GIT_AUTHOR_DATE="2005-05-26 23:44" \
+        GIT_COMMITTER_DATE="2005-05-26 23:44" git-commit --amend &&
+        h_FIXED=$(git-rev-parse --verify HEAD) &&
+        echo TEST+FIXED >F &&
+        echo Merged initial commit and a later commit. >M &&
+        echo $h_TEST >.git/MERGE_HEAD &&
+        GIT_AUTHOR_DATE="2005-05-26 23:45" \
+        GIT_COMMITTER_DATE="2005-05-26 23:45" git-commit -F M &&
+        h_MERGED=$(git-rev-parse --verify HEAD)
+        rm -f M'
+
+cat >expect <<EOF
+$Z $h_TEST $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 commit (initial): add
+$h_TEST $h_OTHER $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150860 +0000   commit: The other day this did not work.
+$h_OTHER $h_FIXED $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117151040 +0000  commit (amend): The other day this did not work.
+$h_FIXED $h_MERGED $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117151100 +0000 commit (merge): Merged initial commit and a later commit.
+EOF
+test_expect_success \
+       'git-commit logged updates' \
+       'diff expect .git/logs/$m'
+unset h_TEST h_OTHER h_FIXED h_MERGED
 
 test_expect_success \
-       'git-cat-file blob master:COPYING (expect Makefile)' \
-       'git-cat-file blob master:COPYING | diff - ../../Makefile'
+       'git-cat-file blob master:F (expect OTHER)' \
+       'test OTHER = $(git-cat-file blob master:F)'
 test_expect_success \
-       'git-cat-file blob master@{2005-05-26 23:30}:COPYING (expect COPYING)' \
-       'git-cat-file blob "master@{2005-05-26 23:30}:COPYING" \
-         | diff - ../../COPYING'
+       'git-cat-file blob master@{2005-05-26 23:30}:F (expect TEST)' \
+       'test TEST = $(git-cat-file blob "master@{2005-05-26 23:30}:F")'
 test_expect_success \
-       'git-cat-file blob master@{2005-05-26 23:42}:COPYING (expect Makefile)' \
-       'git-cat-file blob "master@{2005-05-26 23:42}:COPYING" \
-         | diff - ../../Makefile'
+       'git-cat-file blob master@{2005-05-26 23:42}:F (expect OTHER)' \
+       'test OTHER = $(git-cat-file blob "master@{2005-05-26 23:42}:F")'
 
 test_done