@matheusbsbs / matheus-bagliano / commits / 47579efc00
Fork 0

Add a demonstration/test of customized merge.

This demonstrates how the new low-level per-path merge backends, union and ours, work, and shows how they are controlled by the gitattribute mechanism. Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Apr 17, 2007 at 00:05 UTC 47579efc009c6f7afaf31be107eb92395a4f10db
1 file changed +72
t/t6026-merge-attr.sh new
+72
@@ -0,0 +1,72 @@
1 +#!/bin/sh
2 +#
3 +# Copyright (c) 2007 Junio C Hamano
4 +#
5 +
6 +test_description='per path merge controlled by merge attribute'
7 +
8 +. ./test-lib.sh
9 +
10 +test_expect_success setup '
11 +
12 + for f in text binary union
13 + do
14 + echo Initial >$f && git add $f || break
15 + done &&
16 + test_tick &&
17 + git commit -m Initial &&
18 +
19 + git branch side &&
20 + for f in text binary union
21 + do
22 + echo Master >>$f && git add $f || break
23 + done &&
24 + test_tick &&
25 + git commit -m Master &&
26 +
27 + git checkout side &&
28 + for f in text binary union
29 + do
30 + echo Side >>$f && git add $f || break
31 + done &&
32 + test_tick &&
33 + git commit -m Side
34 +
35 +'
36 +
37 +test_expect_success merge '
38 +
39 + {
40 + echo "binary -merge"
41 + echo "union merge=union"
42 + } >.gitattributes &&
43 +
44 + if git merge master
45 + then
46 + echo Gaah, should have conflicted
47 + false
48 + else
49 + echo Ok, conflicted.
50 + fi
51 +'
52 +
53 +test_expect_success 'check merge result in index' '
54 +
55 + git ls-files -u | grep binary &&
56 + git ls-files -u | grep text &&
57 + ! (git ls-files -u | grep union)
58 +
59 +'
60 +
61 +test_expect_success 'check merge result in working tree' '
62 +
63 + git cat-file -p HEAD:binary >binary-orig &&
64 + grep "<<<<<<<" text &&
65 + cmp binary-orig binary &&
66 + ! grep "<<<<<<<" union &&
67 + grep Master union &&
68 + grep Side union
69 +
70 +'
71 +
72 +test_done