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

3 messages from 2007-01-24 to 2007-01-25. Participants: Johannes Schindelin, Junio C Hamano.
Thread: https://gitlist.dev/t/6493

## Johannes Schindelin, 2007-01-24 01:14

Subject: [PATCH 3/4] add a test case for git-merge-one-file
Message-ID: <Pine.LNX.4.63.0701240214000.22628@wbgn013.biozentrum.uni-wuerzburg.de>
URL: https://gitlist.dev/e/Pine.LNX.4.63.0701240214000.22628%40wbgn013.biozentrum.uni-wuerzburg.de

```

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

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, 2007-01-25 00:10

Subject: Re: [PATCH 3/4] add a test case for git-merge-one-file
Message-ID: <7vy7nsc6f0.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vy7nsc6f0.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <Pine.LNX.4.63.0701240214000.22628@wbgn013.biozentrum.uni-wuerzburg.de>

```
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?

```

## Johannes Schindelin, 2007-01-25 08:34

Subject: Re: [PATCH 3/4] add a test case for git-merge-one-file
Message-ID: <Pine.LNX.4.63.0701250932360.22628@wbgn013.biozentrum.uni-wuerzburg.de>
URL: https://gitlist.dev/e/Pine.LNX.4.63.0701250932360.22628%40wbgn013.biozentrum.uni-wuerzburg.de
In-Reply-To: <7vy7nsc6f0.fsf@assigned-by-dhcp.cox.net>

```
Hi,

On Wed, 24 Jan 2007, Junio C Hamano wrote:

> 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

```
