git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Jan 24, 2007, 01:14 UTC
Message-ID
<Pine.LNX.4.63.0701240214000.22628@wbgn013.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
Next: Junio C Hamano
Message 1 of 3 in “add a test case for git-merge-one-file”
  1. 3/4 add a test case for git-merge-one-fileJohannes Schindelin, Jan 24, 2007
  2. Junio C HamanoJan 25, 2007
  3. Johannes SchindelinJan 25, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.