From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Subject: [PATCH 2/6] New merge tests
Date: Wed, 21 May 2008 18:16:45 -0700 [thread overview]
Message-ID: <1211419009-9741-3-git-send-email-gitster@pobox.com> (raw)
In-Reply-To: <1211419009-9741-2-git-send-email-gitster@pobox.com>
From: Sverre Hvammen Johansen <hvammen@gmail.com>
Introduce new merge tests for preparation of new features:
--ff=<fast forward option>
Head reduction
--ff=only
Set up the framework (based on t7600) and add some test cases
that should succeed independent of the new features.
Signed-off-by: Sverre Hvammen Johansen <hvammen@gmail.com>
---
t/t7601-merge-ff-options.sh | 477 +++++++++++++++++++++++++++++++++++++++++++
1 files changed, 477 insertions(+), 0 deletions(-)
create mode 100755 t/t7601-merge-ff-options.sh
diff --git a/t/t7601-merge-ff-options.sh b/t/t7601-merge-ff-options.sh
new file mode 100755
index 0000000..e499bf5
--- /dev/null
+++ b/t/t7601-merge-ff-options.sh
@@ -0,0 +1,477 @@
+#!/bin/sh
+#
+# Copyright (c) 2008 Sverre Hvammen Johansen, based on t7600 by Lars Hjemli
+#
+
+test_description='git-merge
+
+Testing basic merge operations/option parsing.'
+
+. ./test-lib.sh
+
+cat >file <<EOF
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+EOF
+
+cat >file.1 <<EOF
+1 X
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+EOF
+
+cat >file.5 <<EOF
+1
+2
+3
+4
+5 X
+6
+7
+8
+9
+10
+11
+12
+EOF
+
+cat >file.9 <<EOF
+1
+2
+3
+4
+5
+6
+7
+8
+9 X
+10
+11
+12
+EOF
+
+cat >result.0 <<EOF
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+EOF
+
+cat >result.1 <<EOF
+1 X
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+EOF
+
+cat >result.1-5 <<EOF
+1 X
+2
+3
+4
+5 X
+6
+7
+8
+9
+10
+11
+12
+EOF
+
+cat >result.9 <<EOF
+1
+2
+3
+4
+5
+6
+7
+8
+9 X
+10
+11
+12
+EOF
+
+cat >result.1-5-9 <<EOF
+1 X
+2
+3
+4
+5 X
+6
+7
+8
+9 X
+10
+11
+12
+EOF
+
+cat >result.1-5-9-13 <<EOF
+1 X
+2
+3
+4
+5 X
+6
+7
+8
+9 X
+10
+11
+12
+13 x
+EOF
+
+cat >result.1-5-13 <<EOF
+1 X
+2
+3
+4
+5 X
+6
+7
+8
+9
+10
+11
+12
+13 x
+EOF
+
+cat >result.5-13 <<EOF
+1
+2
+3
+4
+5 X
+6
+7
+8
+9
+10
+11
+12
+13 x
+EOF
+
+cat >result.1-13 <<EOF
+1 X
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13 x
+EOF
+
+cat >extend <<EOF
+13 x
+EOF
+
+
+create_merge_msgs() {
+ echo "Merge commit 'c2'" >msg.1-5 &&
+ echo "Merge commit 'c2'; commit 'c3'" >msg.1-5-9 &&
+ echo "Squashed commit of the following:" >squash.1 &&
+ echo >>squash.1 &&
+ git log --no-merges ^HEAD c1 >>squash.1 &&
+ echo "Squashed commit of the following:" >squash.1-5 &&
+ echo >>squash.1-5 &&
+ git log --no-merges ^HEAD c2 >>squash.1-5 &&
+ echo "Squashed commit of the following:" >squash.1-5-9 &&
+ echo >>squash.1-5-9 &&
+ git log --no-merges ^HEAD c2 c3 >>squash.1-5-9
+}
+
+verify_diff() {
+ if ! diff -u "$1" "$2"
+ then
+ echo "$3"
+ false
+ fi
+}
+
+verify_merge() {
+ verify_diff "$2" "$1" "[OOPS] bad merge result" &&
+ if test $(git ls-files -u | wc -l) -gt 0
+ then
+ echo "[OOPS] unmerged files"
+ false
+ fi &&
+ if ! git diff --exit-code
+ then
+ echo "[OOPS] working tree != index"
+ false
+ fi &&
+ if test -n "$3"
+ then
+ git show -s --pretty=format:%s HEAD >msg.act &&
+ verify_diff "$3" msg.act "[OOPS] bad merge message"
+ fi
+}
+
+verify_head() {
+ if test "$1" != "$(git rev-parse HEAD)"
+ then
+ echo "[OOPS] HEAD != $1"
+ false
+ fi
+}
+
+verify_parents() {
+ i=1
+ while test $# -gt 0
+ do
+ if test "$1" != "$(git rev-parse HEAD^$i)"
+ then
+ echo "[OOPS] HEAD^$i != $1"
+ return 1
+ fi
+ i=$(expr $i + 1)
+ shift
+ done
+}
+
+verify_mergeheads() {
+ i=1
+ if ! test -f .git/MERGE_HEAD
+ then
+ echo "[OOPS] MERGE_HEAD is missing"
+ false
+ fi &&
+ while test $# -gt 0
+ do
+ head=$(head -n $i .git/MERGE_HEAD | tail -n 1)
+ if test "$1" != "$head"
+ then
+ echo "[OOPS] MERGE_HEAD $i != $1"
+ return 1
+ fi
+ i=$(expr $i + 1)
+ shift
+ done
+}
+
+verify_no_mergehead() {
+ if test -f .git/MERGE_HEAD
+ then
+ echo "[OOPS] MERGE_HEAD exists"
+ false
+ fi
+}
+
+# Setup with the following commits:
+#
+# y3
+# / \
+# / \
+# y1 y2
+# | \ / |
+# | \ / |
+# x1 x0 x2
+# | / \ |
+# | / \ |
+# c1 c2
+# \ /
+# \ /
+# c0---c3
+#
+
+test_expect_success 'setup' '
+ git add file &&
+ test_tick &&
+ git commit -m "commit 0" &&
+ git tag c0 &&
+ c0=$(git rev-parse HEAD) &&
+
+ cp file.1 file &&
+ git add file &&
+ test_tick &&
+ git commit -m "commit 1" &&
+ git tag c1 &&
+ c1=$(git rev-parse HEAD) &&
+ test_tick &&
+
+ git reset --hard "$c0" &&
+ cp file.5 file &&
+ git add file &&
+ git commit -m "commit 2" &&
+ test_tick &&
+ git tag c2 &&
+ c2=$(git rev-parse HEAD) &&
+
+ git reset --hard "$c0" &&
+ cp file.9 file &&
+ git add file &&
+ test_tick &&
+ git commit -m "commit 3" &&
+ git tag c3 &&
+ c3=$(git rev-parse HEAD) &&
+ test_tick &&
+
+ git reset --hard "$c1" &&
+ cat extend >>file &&
+ git add file &&
+ git commit -m "commit 4" &&
+ git tag x1 &&
+ x1=$(git rev-parse HEAD) &&
+ test_tick &&
+
+ git reset --hard "$c1" &&
+ git merge "$c2" &&
+ git tag x0 &&
+ x0=$(git rev-parse HEAD) &&
+ test_tick &&
+
+ git reset --hard "$c2" &&
+ cat extend >>file &&
+ git add file &&
+ git commit -m "commit 5" &&
+ git tag x2 &&
+ x2=$(git rev-parse HEAD) &&
+ test_tick &&
+
+ git reset --hard "$x1" &&
+ git merge "$x0" &&
+ git tag y1 &&
+ y1=$(git rev-parse HEAD) &&
+ test_tick &&
+
+ git reset --hard "$x0" &&
+ git merge "$x2" &&
+ git tag y2 &&
+ y2=$(git rev-parse HEAD) &&
+ test_tick &&
+
+ git reset --hard "$y1" &&
+ git merge "$y2" &&
+ git tag y3 &&
+ y3=$(git rev-parse HEAD) &&
+ test_tick &&
+ git reset --hard "$c0" &&
+ create_merge_msgs &&
+
+ git reset --hard x1 &&
+ git clone .git clone &&
+ git config remote.clone.url clone &&
+ git config remote.clone.fetch "+refs/heads/*:refs/remotes/clone/*" &&
+
+ (mkdir new && cd new && git init && cp ../file.9 file2 && git add file2 && test_tick && git commit -m "commit new") &&
+ git config remote.new.url new &&
+ git config remote.new.fetch "+refs/heads/*:refs/remotes/new/*"
+'
+
+test_debug 'gitk --all'
+
+test_expect_success 'merge c1 with c0 and c0' '
+ git reset --hard c1 &&
+ git config branch.master.mergeoptions "" &&
+ test_tick &&
+ git merge c0 c0 &&
+ verify_merge file result.1 &&
+ verify_head $c1
+'
+
+test_debug 'gitk --all'
+
+test_expect_success 'merge c0 with c1 and c2' '
+ git reset --hard c0 &&
+ git config branch.master.mergeoptions "" &&
+ test_tick &&
+ git merge c1 c2 &&
+ verify_merge file result.1-5 &&
+ verify_parents $c1 $c2
+'
+
+test_debug 'gitk --all'
+
+test_expect_success 'merge c1 with c0, c2, c0, and c1' '
+ git reset --hard c1 &&
+ git config branch.master.mergeoptions "" &&
+ test_tick &&
+ git merge c0 c2 c0 c1 &&
+ verify_merge file result.1-5 &&
+ verify_parents $c1 $c2
+'
+
+test_debug 'gitk --all'
+
+test_expect_success 'merge y2 with x0, c3, and c0' '
+ git reset --hard y2 &&
+ git config branch.master.mergeoptions "" &&
+ test_tick &&
+ git merge x0 c3 c0 &&
+ verify_merge file result.1-5-9-13 &&
+ verify_parents $y2 $c3
+'
+
+test_debug 'gitk --all'
+
+test_expect_success 'merge x0 with y2, c3, and c0' '
+ git reset --hard x0 &&
+ git config branch.master.mergeoptions "" &&
+ test_tick &&
+ git merge y2 c3 c0 &&
+ verify_merge file result.1-5-9-13 &&
+ verify_parents $y2 $c3
+'
+
+test_debug 'gitk --all'
+
+
+test_expect_success 'merge c1 with c2 and x1' '
+ git reset --hard c1 &&
+ git config branch.master.mergeoptions "" &&
+ test_tick &&
+ git merge c2 x1 &&
+ verify_merge file result.1-5-13 &&
+ verify_parents $c2 $x1
+'
+
+test_debug 'gitk --all'
+
+test_done
--
1.5.5.1.499.g878b8
next prev parent reply other threads:[~2008-05-22 1:17 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-22 1:16 [PATCH 0/6] Forwarding Sverre's "merge --ff=<allow,only,never>" series Junio C Hamano
2008-05-22 1:16 ` [PATCH 1/6] Documentation for joining more than two histories Junio C Hamano
2008-05-22 1:16 ` Junio C Hamano [this message]
2008-05-22 1:16 ` [PATCH 3/6] Introduce -ff=<fast forward option> Junio C Hamano
2008-05-22 1:16 ` [PATCH 4/6] Restructure git-merge.sh Junio C Hamano
2008-05-22 1:16 ` [PATCH 5/6] Head reduction before selecting merge strategy Junio C Hamano
2008-05-22 1:16 ` [PATCH 6/6] Introduce fast forward option only Junio C Hamano
2008-05-22 10:48 ` [PATCH 4/6] Restructure git-merge.sh Johannes Schindelin
2008-05-22 12:50 ` Johannes Schindelin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1211419009-9741-3-git-send-email-gitster@pobox.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).