Fourth batch
[gitweb.git] / t / t6050-replace.sh
index aa3e24963967ba4be2394ceeab26f8317fb31b4b..e7e64e085ddcfe7d7cf4df844472a6bf456ab079 100755 (executable)
@@ -40,7 +40,8 @@ commit_peeling_shows_parents ()
        test "$_found" = "$_parent" || return 1
        _parent_number=$(( $_parent_number + 1 ))
     done &&
-    test_must_fail git rev-parse --verify $_commit^$_parent_number
+    test_must_fail git rev-parse --verify $_commit^$_parent_number 2>err &&
+    test_i18ngrep "Needed a single revision" err
 }
 
 commit_has_parents ()
@@ -113,6 +114,12 @@ test_expect_success 'test GIT_NO_REPLACE_OBJECTS env variable' '
      GIT_NO_REPLACE_OBJECTS=1 git show $HASH2 | grep "A U Thor"
 '
 
+test_expect_success 'test core.usereplacerefs config option' '
+       test_config core.usereplacerefs false &&
+       git cat-file commit $HASH2 | grep "author A U Thor" &&
+       git show $HASH2 | grep "A U Thor"
+'
+
 cat >tag.sig <<EOF
 object $HASH2
 type commit
@@ -127,8 +134,8 @@ test_expect_success 'tag replaced commit' '
 
 test_expect_success '"git fsck" works' '
      git fsck master >fsck_master.out &&
-     grep "dangling commit $R" fsck_master.out &&
-     grep "dangling tag $(cat .git/refs/tags/mytag)" fsck_master.out &&
+     test_i18ngrep "dangling commit $R" fsck_master.out &&
+     test_i18ngrep "dangling tag $(cat .git/refs/tags/mytag)" fsck_master.out &&
      test -z "$(git fsck)"
 '
 
@@ -387,9 +394,11 @@ test_expect_success 'replace ref cleanup' '
 '
 
 test_expect_success '--graft with and without already replaced object' '
-       test $(git log --oneline | wc -l) = 7 &&
+       git log --oneline >log &&
+       test_line_count = 7 log &&
        git replace --graft $HASH5 &&
-       test $(git log --oneline | wc -l) = 3 &&
+       git log --oneline >log &&
+       test_line_count = 3 log &&
        commit_has_parents $HASH5 &&
        test_must_fail git replace --graft $HASH5 $HASH4 $HASH3 &&
        git replace --force -g $HASH5 $HASH4 $HASH3 &&
@@ -397,6 +406,28 @@ test_expect_success '--graft with and without already replaced object' '
        git replace -d $HASH5
 '
 
+test_expect_success '--graft using a tag as the new parent' '
+       git tag new_parent $HASH5 &&
+       git replace --graft $HASH7 new_parent &&
+       commit_has_parents $HASH7 $HASH5 &&
+       git replace -d $HASH7 &&
+       git tag -a -m "annotated new parent tag" annotated_new_parent $HASH5 &&
+       git replace --graft $HASH7 annotated_new_parent &&
+       commit_has_parents $HASH7 $HASH5 &&
+       git replace -d $HASH7
+'
+
+test_expect_success '--graft using a tag as the replaced object' '
+       git tag replaced_object $HASH7 &&
+       git replace --graft replaced_object $HASH5 &&
+       commit_has_parents $HASH7 $HASH5 &&
+       git replace -d $HASH7 &&
+       git tag -a -m "annotated replaced object tag" annotated_replaced_object $HASH7 &&
+       git replace --graft annotated_replaced_object $HASH5 &&
+       commit_has_parents $HASH7 $HASH5 &&
+       git replace -d $HASH7
+'
+
 test_expect_success GPG 'set up a signed commit' '
        echo "line 17" >>hello &&
        echo "line 18" >>hello &&
@@ -455,7 +486,10 @@ test_expect_success '--convert-graft-file' '
        printf "%s\n%s %s\n\n# comment\n%s\n" \
                $(git rev-parse HEAD^^ HEAD^ HEAD^^ HEAD^2) \
                >.git/info/grafts &&
-       git replace --convert-graft-file &&
+       git status 2>stderr &&
+       test_i18ngrep "hint:.*grafts is deprecated" stderr &&
+       git replace --convert-graft-file 2>stderr &&
+       test_i18ngrep ! "hint:.*grafts is deprecated" stderr &&
        test_path_is_missing .git/info/grafts &&
 
        : verify that the history is now "grafted" &&