threads / patch / 6493

patch, 4 partsadd a test case for git-merge-one-file

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

## tl;dr

3 messages between Jan 24, 2007 and Jan 25, 2007. Diffs are folded; open one to read it.

replies: 2people: 2as markdown or json

Johannes Schindelin· Jan 24, 2007, 01:14 UTC · lore

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@gmx.de>
---
 t/t6025-merge-one-file.sh |   96 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 96 insertions(+), 0 deletions(-)
 create mode 100644 t/t6025-merge-one-file.sh
Show changes to t/t6025-merge-one-file.sh +96 −0
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
Junio C Hamano· Jan 25, 2007, 00:10 UTC · re: Johannes Schindelin · lore

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

Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 5 quoted lines
> +git-update-index --index-info << EOF
> +10644 $hash_one 1	one
> +10644 $hash_two 2	one
> +10644 $hash_three 3	one
> +EOF

How can this work with 10644 instead of 100644? Did you spot a bug in update-index --index-info?

Johannes Schindelin· Jan 25, 2007, 08:34 UTC · re: Junio C Hamano · lore

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

Hi,
On Wed, 24 Jan 2007, Junio C Hamano wrote:
Show 10 quoted lines
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> 
> > +git-update-index --index-info << EOF
> > +10644 $hash_one 1	one
> > +10644 $hash_two 2	one
> > +10644 $hash_three 3	one
> > +EOF
> 
> How can this work with 10644 instead of 100644?  Did you spot a
> bug in update-index --index-info?

Actually, since !S_ISLNK(010644), it uses ce_permissions(010644), which basically only checks if (010644 & 0100) is set (i.e. if it is executable by the user), and depending on this returns 0755 or 0644.

That's why it works.

Ciao, Dscho

← back to recent threads