2007-04-17 09:05:00 +02:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Copyright (c) 2007 Junio C Hamano
|
|
|
|
#
|
|
|
|
|
|
|
|
test_description='per path merge controlled by merge attribute'
|
|
|
|
|
|
|
|
. ./test-lib.sh
|
|
|
|
|
|
|
|
test_expect_success setup '
|
|
|
|
|
|
|
|
for f in text binary union
|
|
|
|
do
|
|
|
|
echo Initial >$f && git add $f || break
|
|
|
|
done &&
|
|
|
|
test_tick &&
|
|
|
|
git commit -m Initial &&
|
|
|
|
|
|
|
|
git branch side &&
|
|
|
|
for f in text binary union
|
|
|
|
do
|
|
|
|
echo Master >>$f && git add $f || break
|
|
|
|
done &&
|
|
|
|
test_tick &&
|
|
|
|
git commit -m Master &&
|
|
|
|
|
|
|
|
git checkout side &&
|
|
|
|
for f in text binary union
|
|
|
|
do
|
|
|
|
echo Side >>$f && git add $f || break
|
|
|
|
done &&
|
|
|
|
test_tick &&
|
Custom low-level merge driver support.
This allows users to specify custom low-level merge driver per
path, using the attributes mechanism. Just like you can specify
one of built-in "text", "binary", "union" low-level merge
drivers by saying:
* merge=text
.gitignore merge=union
*.jpg merge=binary
pick a name of your favorite merge driver, and assign it as the
value of the 'merge' attribute.
A custom low-level merge driver is defined via the config
mechanism. This patch introduces 'merge.driver', a multi-valued
configuration. Its value is the name (i.e. the one you use as
the value of 'merge' attribute) followed by a command line
specification. The command line can contain %O, %A, and %B to
be interpolated with the names of temporary files that hold the
common ancestor version, the version from your branch, and the
version from the other branch, and the resulting command is
spawned.
The low-level merge driver is expected to update the temporary
file for your branch (i.e. %A) with the result and exit with
status 0 for a clean merge, and non-zero status for a conflicted
merge.
A new test in t6026 demonstrates a sample usage.
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-04-18 07:51:45 +02:00
|
|
|
git commit -m Side &&
|
2007-04-17 09:05:00 +02:00
|
|
|
|
Custom low-level merge driver support.
This allows users to specify custom low-level merge driver per
path, using the attributes mechanism. Just like you can specify
one of built-in "text", "binary", "union" low-level merge
drivers by saying:
* merge=text
.gitignore merge=union
*.jpg merge=binary
pick a name of your favorite merge driver, and assign it as the
value of the 'merge' attribute.
A custom low-level merge driver is defined via the config
mechanism. This patch introduces 'merge.driver', a multi-valued
configuration. Its value is the name (i.e. the one you use as
the value of 'merge' attribute) followed by a command line
specification. The command line can contain %O, %A, and %B to
be interpolated with the names of temporary files that hold the
common ancestor version, the version from your branch, and the
version from the other branch, and the resulting command is
spawned.
The low-level merge driver is expected to update the temporary
file for your branch (i.e. %A) with the result and exit with
status 0 for a clean merge, and non-zero status for a conflicted
merge.
A new test in t6026 demonstrates a sample usage.
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-04-18 07:51:45 +02:00
|
|
|
git tag anchor
|
2007-04-17 09:05:00 +02:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success merge '
|
|
|
|
|
|
|
|
{
|
|
|
|
echo "binary -merge"
|
|
|
|
echo "union merge=union"
|
|
|
|
} >.gitattributes &&
|
|
|
|
|
|
|
|
if git merge master
|
|
|
|
then
|
|
|
|
echo Gaah, should have conflicted
|
|
|
|
false
|
|
|
|
else
|
|
|
|
echo Ok, conflicted.
|
|
|
|
fi
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'check merge result in index' '
|
|
|
|
|
|
|
|
git ls-files -u | grep binary &&
|
|
|
|
git ls-files -u | grep text &&
|
|
|
|
! (git ls-files -u | grep union)
|
|
|
|
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'check merge result in working tree' '
|
|
|
|
|
|
|
|
git cat-file -p HEAD:binary >binary-orig &&
|
|
|
|
grep "<<<<<<<" text &&
|
|
|
|
cmp binary-orig binary &&
|
|
|
|
! grep "<<<<<<<" union &&
|
|
|
|
grep Master union &&
|
|
|
|
grep Side union
|
|
|
|
|
|
|
|
'
|
|
|
|
|
2010-01-21 08:49:27 +01:00
|
|
|
test_expect_success 'retry the merge with longer context' '
|
|
|
|
echo text conflict-marker-size=32 >>.gitattributes &&
|
|
|
|
git checkout -m text &&
|
|
|
|
sed -ne "/^\([<=>]\)\1\1\1*/{
|
|
|
|
s/ .*$//
|
|
|
|
p
|
|
|
|
}" >actual text &&
|
|
|
|
grep ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" actual &&
|
|
|
|
grep "================================" actual &&
|
|
|
|
grep "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" actual
|
|
|
|
'
|
|
|
|
|
Custom low-level merge driver support.
This allows users to specify custom low-level merge driver per
path, using the attributes mechanism. Just like you can specify
one of built-in "text", "binary", "union" low-level merge
drivers by saying:
* merge=text
.gitignore merge=union
*.jpg merge=binary
pick a name of your favorite merge driver, and assign it as the
value of the 'merge' attribute.
A custom low-level merge driver is defined via the config
mechanism. This patch introduces 'merge.driver', a multi-valued
configuration. Its value is the name (i.e. the one you use as
the value of 'merge' attribute) followed by a command line
specification. The command line can contain %O, %A, and %B to
be interpolated with the names of temporary files that hold the
common ancestor version, the version from your branch, and the
version from the other branch, and the resulting command is
spawned.
The low-level merge driver is expected to update the temporary
file for your branch (i.e. %A) with the result and exit with
status 0 for a clean merge, and non-zero status for a conflicted
merge.
A new test in t6026 demonstrates a sample usage.
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-04-18 07:51:45 +02:00
|
|
|
cat >./custom-merge <<\EOF
|
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
orig="$1" ours="$2" theirs="$3" exit="$4"
|
|
|
|
(
|
|
|
|
echo "orig is $orig"
|
|
|
|
echo "ours is $ours"
|
|
|
|
echo "theirs is $theirs"
|
|
|
|
echo "=== orig ==="
|
|
|
|
cat "$orig"
|
|
|
|
echo "=== ours ==="
|
|
|
|
cat "$ours"
|
|
|
|
echo "=== theirs ==="
|
|
|
|
cat "$theirs"
|
|
|
|
) >"$ours+"
|
|
|
|
cat "$ours+" >"$ours"
|
|
|
|
rm -f "$ours+"
|
|
|
|
exit "$exit"
|
|
|
|
EOF
|
|
|
|
chmod +x ./custom-merge
|
|
|
|
|
|
|
|
test_expect_success 'custom merge backend' '
|
|
|
|
|
|
|
|
echo "* merge=union" >.gitattributes &&
|
|
|
|
echo "text merge=custom" >>.gitattributes &&
|
|
|
|
|
|
|
|
git reset --hard anchor &&
|
|
|
|
git config --replace-all \
|
2007-04-18 20:27:32 +02:00
|
|
|
merge.custom.driver "./custom-merge %O %A %B 0" &&
|
|
|
|
git config --replace-all \
|
|
|
|
merge.custom.name "custom merge driver for testing" &&
|
Custom low-level merge driver support.
This allows users to specify custom low-level merge driver per
path, using the attributes mechanism. Just like you can specify
one of built-in "text", "binary", "union" low-level merge
drivers by saying:
* merge=text
.gitignore merge=union
*.jpg merge=binary
pick a name of your favorite merge driver, and assign it as the
value of the 'merge' attribute.
A custom low-level merge driver is defined via the config
mechanism. This patch introduces 'merge.driver', a multi-valued
configuration. Its value is the name (i.e. the one you use as
the value of 'merge' attribute) followed by a command line
specification. The command line can contain %O, %A, and %B to
be interpolated with the names of temporary files that hold the
common ancestor version, the version from your branch, and the
version from the other branch, and the resulting command is
spawned.
The low-level merge driver is expected to update the temporary
file for your branch (i.e. %A) with the result and exit with
status 0 for a clean merge, and non-zero status for a conflicted
merge.
A new test in t6026 demonstrates a sample usage.
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-04-18 07:51:45 +02:00
|
|
|
|
|
|
|
git merge master &&
|
|
|
|
|
|
|
|
cmp binary union &&
|
|
|
|
sed -e 1,3d text >check-1 &&
|
2008-09-03 10:59:29 +02:00
|
|
|
o=$(git unpack-file master^:text) &&
|
|
|
|
a=$(git unpack-file side^:text) &&
|
|
|
|
b=$(git unpack-file master:text) &&
|
Custom low-level merge driver support.
This allows users to specify custom low-level merge driver per
path, using the attributes mechanism. Just like you can specify
one of built-in "text", "binary", "union" low-level merge
drivers by saying:
* merge=text
.gitignore merge=union
*.jpg merge=binary
pick a name of your favorite merge driver, and assign it as the
value of the 'merge' attribute.
A custom low-level merge driver is defined via the config
mechanism. This patch introduces 'merge.driver', a multi-valued
configuration. Its value is the name (i.e. the one you use as
the value of 'merge' attribute) followed by a command line
specification. The command line can contain %O, %A, and %B to
be interpolated with the names of temporary files that hold the
common ancestor version, the version from your branch, and the
version from the other branch, and the resulting command is
spawned.
The low-level merge driver is expected to update the temporary
file for your branch (i.e. %A) with the result and exit with
status 0 for a clean merge, and non-zero status for a conflicted
merge.
A new test in t6026 demonstrates a sample usage.
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-04-18 07:51:45 +02:00
|
|
|
sh -c "./custom-merge $o $a $b 0" &&
|
|
|
|
sed -e 1,3d $a >check-2 &&
|
|
|
|
cmp check-1 check-2 &&
|
|
|
|
rm -f $o $a $b
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'custom merge backend' '
|
|
|
|
|
|
|
|
git reset --hard anchor &&
|
|
|
|
git config --replace-all \
|
2007-04-18 20:27:32 +02:00
|
|
|
merge.custom.driver "./custom-merge %O %A %B 1" &&
|
|
|
|
git config --replace-all \
|
|
|
|
merge.custom.name "custom merge driver for testing" &&
|
Custom low-level merge driver support.
This allows users to specify custom low-level merge driver per
path, using the attributes mechanism. Just like you can specify
one of built-in "text", "binary", "union" low-level merge
drivers by saying:
* merge=text
.gitignore merge=union
*.jpg merge=binary
pick a name of your favorite merge driver, and assign it as the
value of the 'merge' attribute.
A custom low-level merge driver is defined via the config
mechanism. This patch introduces 'merge.driver', a multi-valued
configuration. Its value is the name (i.e. the one you use as
the value of 'merge' attribute) followed by a command line
specification. The command line can contain %O, %A, and %B to
be interpolated with the names of temporary files that hold the
common ancestor version, the version from your branch, and the
version from the other branch, and the resulting command is
spawned.
The low-level merge driver is expected to update the temporary
file for your branch (i.e. %A) with the result and exit with
status 0 for a clean merge, and non-zero status for a conflicted
merge.
A new test in t6026 demonstrates a sample usage.
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-04-18 07:51:45 +02:00
|
|
|
|
|
|
|
if git merge master
|
|
|
|
then
|
|
|
|
echo "Eh? should have conflicted"
|
|
|
|
false
|
|
|
|
else
|
|
|
|
echo "Ok, conflicted"
|
|
|
|
fi &&
|
|
|
|
|
|
|
|
cmp binary union &&
|
|
|
|
sed -e 1,3d text >check-1 &&
|
2008-09-03 10:59:29 +02:00
|
|
|
o=$(git unpack-file master^:text) &&
|
|
|
|
a=$(git unpack-file anchor:text) &&
|
|
|
|
b=$(git unpack-file master:text) &&
|
Custom low-level merge driver support.
This allows users to specify custom low-level merge driver per
path, using the attributes mechanism. Just like you can specify
one of built-in "text", "binary", "union" low-level merge
drivers by saying:
* merge=text
.gitignore merge=union
*.jpg merge=binary
pick a name of your favorite merge driver, and assign it as the
value of the 'merge' attribute.
A custom low-level merge driver is defined via the config
mechanism. This patch introduces 'merge.driver', a multi-valued
configuration. Its value is the name (i.e. the one you use as
the value of 'merge' attribute) followed by a command line
specification. The command line can contain %O, %A, and %B to
be interpolated with the names of temporary files that hold the
common ancestor version, the version from your branch, and the
version from the other branch, and the resulting command is
spawned.
The low-level merge driver is expected to update the temporary
file for your branch (i.e. %A) with the result and exit with
status 0 for a clean merge, and non-zero status for a conflicted
merge.
A new test in t6026 demonstrates a sample usage.
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-04-18 07:51:45 +02:00
|
|
|
sh -c "./custom-merge $o $a $b 0" &&
|
|
|
|
sed -e 1,3d $a >check-2 &&
|
|
|
|
cmp check-1 check-2 &&
|
|
|
|
rm -f $o $a $b
|
|
|
|
'
|
|
|
|
|
2008-09-06 18:29:49 +02:00
|
|
|
test_expect_success 'up-to-date merge without common ancestor' '
|
|
|
|
test_create_repo repo1 &&
|
|
|
|
test_create_repo repo2 &&
|
|
|
|
test_tick &&
|
|
|
|
(
|
|
|
|
cd repo1 &&
|
|
|
|
>a &&
|
|
|
|
git add a &&
|
|
|
|
git commit -m initial
|
|
|
|
) &&
|
|
|
|
test_tick &&
|
|
|
|
(
|
|
|
|
cd repo2 &&
|
|
|
|
git commit --allow-empty -m initial
|
|
|
|
) &&
|
|
|
|
test_tick &&
|
|
|
|
(
|
|
|
|
cd repo1 &&
|
|
|
|
git pull ../repo2 master
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
2007-04-17 09:05:00 +02:00
|
|
|
test_done
|