[PATCH 3/4] add a test case for git-merge-one-file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Eventually, merge-one-file should go away. But in the meantime
let's make sure we don't have any regressions.

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@xxxxxx>
---
 t/t6025-merge-one-file.sh |   96 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 96 insertions(+), 0 deletions(-)
 create mode 100644 t/t6025-merge-one-file.sh

diff --git a/t/t6025-merge-one-file.sh b/t/t6025-merge-one-file.sh
new file mode 100644
index 0000000..2eadcb3
--- /dev/null
+++ b/t/t6025-merge-one-file.sh
@@ -0,0 +1,96 @@
+#!/bin/sh
+
+test_description='Test merge-one-file'
+. ./test-lib.sh
+
+for w in one two three; do
+	echo $w > $w
+	git-hash-object -t blob -w $w
+	eval hash_$w=$(git-hash-object -t blob -w $w)
+done
+
+git-update-index --index-info << EOF
+10644 $hash_one 1	one
+10644 $hash_two 2	one
+10644 $hash_three 3	one
+EOF
+
+test_expect_failure "1 -> 2 -> 3" \
+	"git-merge-one-file $hash_one $hash_two $hash_three two 0644 0644 0644"
+
+git-update-index --index-info << EOF
+10644 $hash_one 1	two
+10644 $hash_three 3	two
+EOF
+
+test_expect_failure "deleted in our; modified in their" \
+	"git-merge-one-file $hash_one '' $hash_three two 0644 '' 0644"
+
+git-update-index --index-info << EOF
+10644 $hash_one 1	two
+10644 $hash_one 3	two
+EOF
+
+test_expect_success "deleted in our" \
+	"git-merge-one-file $hash_one '' $hash_one two 0644 '' 0644"
+
+test_expect_success "-> file untouched in work tree" "test -f two"
+
+git-update-index --index-info << EOF
+10644 $hash_one 1	two
+10644 $hash_one 2	two
+EOF
+
+test_expect_success "deleted in their" \
+	"git-merge-one-file $hash_one $hash_one '' two 0644 0644 ''"
+
+test_expect_success "-> now deleted in work tree" "test ! -f two"
+
+git-update-index --index-info << EOF
+10644 $hash_one 2	two
+10644 $hash_one 3	two
+EOF
+
+test_expect_failure "created identically, but mode differs" \
+	"git-merge-one-file '' $hash_one $hash_one two '' 0644 0755"
+
+test_expect_success "created identically" \
+	"git-merge-one-file '' $hash_one $hash_one two '' 0644 0644"
+
+test_expect_success "-> correct file" "test z$(cat two) = zone"
+
+cat one three > thirteen
+hash_13=$(git-hash-object -t blob -w thirteen)
+
+git-update-index --index-info << EOF
+10644 $hash_one 2	two
+10644 $hash_13 3	two
+EOF
+
+test_expect_failure "created non-identically, but mergeable" \
+	"git-merge-one-file '' $hash_one $hash_13 two '' 0644 0644"
+
+test_expect_success "-> correct file" "diff -u thirteen two"
+
+git-update-index --index-info << EOF
+10644 $hash_one 1	two
+10644 $hash_two 2	two
+10644 $hash_three 3	two
+EOF
+
+test_expect_failure "modified non-identically" \
+	"git-merge-one-file $hash_one $hash_two $hash_three two 0644 0644 0644"
+
+cat > expect << EOF
+<<<<<<<
+two
+=======
+three
+>>>>>>>
+EOF
+
+sed -e "s/<<<<<<< .*/<<<<<<</" -e "s/>>>>>>> .*/>>>>>>>/" < two > out
+
+test_expect_success "-> correct file" "diff -u expect out"
+
+test_done
-- 
1.5.0.rc2.gc5868-dirty

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]