1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
#!/bin/sh
#
# Copyright (C) 2013-2014 Felipe Contreras
# Copyright (C) 2013 John Keeping
#
# This file may be used under the terms of the GNU GPL version 2.
#
test_description='Test the "fixup" instruction'
. ./test-lib.sh
commit_file() {
local filename="$1"
echo "$2" > $filename &&
git add -f $filename &&
git commit -q -m "commit $filename"
}
write_script() {
cat > "$1" &&
chmod +x "$1"
}
test_expect_success 'setup branches' '
git init -q &&
commit_file base base &&
git checkout -b branch1 &&
commit_file branch1 branch1 &&
git checkout -b branch2 master &&
commit_file branch2 branch2
'
write_script .git/EDITOR <<\EOF
#!/bin/sh
cat >> "$1" <<EOM
merge branch1
This merges branch 1.
merge branch2
This merges branch 2.
EOM
EOF
test_expect_success 'create integration branch' '
GIT_EDITOR=.git/EDITOR git reintegrate --create --edit --rebuild pu &&
git checkout HEAD^0 &&
commit_file fixup fixup &&
git update-ref refs/merge-fix/branch2 HEAD
'
write_script .git/EDITOR <<\EOF
#!/bin/sh
cat >> "$1" <<EOM
fixup refs/merge-fix/branch2
EOM
EOF
test_expect_success 'rebuild with fixup added' '
GIT_EDITOR=.git/EDITOR git reintegrate --edit --rebuild pu &&
git symbolic-ref HEAD > actual &&
echo refs/heads/pu > expect &&
test_cmp expect actual &&
git merge-base --is-ancestor branch1 HEAD &&
git merge-base --is-ancestor branch2 HEAD
'
test_expect_success 'check fixup applied' '
echo fixup > expect &&
test_cmp expect fixup
'
test_expect_success 'check fixup squashed' '
git log --oneline -- fixup > actual &&
grep "branch .branch2. into pu" actual &&
test $(wc -l <actual) = 1 || (
echo >&2 "Expected only a single commit touching fixup"
exit 1
)
'
test_done
|