Code

Merge branch 'tr/maint-1.6.1-doc-format-patch--root' into maint
[git.git] / t / t7004-tag.sh
index f377fea4bb1d32c95096defb9fb08b291b67dbff..69501e2711f26a7c498d545520dcf47c00d9b1e1 100755 (executable)
@@ -1090,6 +1090,121 @@ test_expect_success 'filename for the message is relative to cwd' '
        git cat-file tag tag-from-subdir-2 | grep "in sub directory"
 '
 
+# create a few more commits to test --contains
+
+hash1=$(git rev-parse HEAD)
+
+test_expect_success 'creating second commit and tag' '
+       echo foo-2.0 >foo &&
+       git add foo &&
+       git commit -m second
+       git tag v2.0
+'
+
+hash2=$(git rev-parse HEAD)
+
+test_expect_success 'creating third commit without tag' '
+       echo foo-dev >foo &&
+       git add foo &&
+       git commit -m third
+'
+
+hash3=$(git rev-parse HEAD)
+
+# simple linear checks of --continue
+
+cat > expected <<EOF
+v0.2.1
+v1.0
+v1.0.1
+v1.1.3
+v2.0
+EOF
+
+test_expect_success 'checking that first commit is in all tags (hash)' "
+       git tag -l --contains $hash1 v* >actual
+       test_cmp expected actual
+"
+
+# other ways of specifying the commit
+test_expect_success 'checking that first commit is in all tags (tag)' "
+       git tag -l --contains v1.0 v* >actual
+       test_cmp expected actual
+"
+
+test_expect_success 'checking that first commit is in all tags (relative)' "
+       git tag -l --contains HEAD~2 v* >actual
+       test_cmp expected actual
+"
+
+cat > expected <<EOF
+v2.0
+EOF
+
+test_expect_success 'checking that second commit only has one tag' "
+       git tag -l --contains $hash2 v* >actual
+       test_cmp expected actual
+"
+
+
+cat > expected <<EOF
+EOF
+
+test_expect_success 'checking that third commit has no tags' "
+       git tag -l --contains $hash3 v* >actual
+       test_cmp expected actual
+"
+
+# how about a simple merge?
+
+test_expect_success 'creating simple branch' '
+       git branch stable v2.0 &&
+        git checkout stable &&
+       echo foo-3.0 > foo &&
+       git commit foo -m fourth
+       git tag v3.0
+'
+
+hash4=$(git rev-parse HEAD)
+
+cat > expected <<EOF
+v3.0
+EOF
+
+test_expect_success 'checking that branch head only has one tag' "
+       git tag -l --contains $hash4 v* >actual
+       test_cmp expected actual
+"
+
+test_expect_success 'merging original branch into this branch' '
+       git merge --strategy=ours master &&
+        git tag v4.0
+'
+
+cat > expected <<EOF
+v4.0
+EOF
+
+test_expect_success 'checking that original branch head has one tag now' "
+       git tag -l --contains $hash3 v* >actual
+       test_cmp expected actual
+"
+
+cat > expected <<EOF
+v0.2.1
+v1.0
+v1.0.1
+v1.1.3
+v2.0
+v3.0
+v4.0
+EOF
+
+test_expect_success 'checking that initial commit is in all tags' "
+       git tag -l --contains $hash1 v* >actual
+       test_cmp expected actual
+"
+
 # mixing modes and options:
 
 test_expect_success 'mixing incompatibles modes and options is forbidden' '