@matheusbsbs / matheus-bagliano / commits / b539c5e8fb
Fork 0

git-merge-one: new merge world order.

This does two things: - Use new --stage=2 option to create the working tree file with leading paths and correct permission bits using checkout-index, as before. - Make sure we do not confuse "merge" program when the file being merged has an unfortunate name, '-L'. Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Dec 7, 2005 at 00:50 UTC b539c5e8fbd36e38eb8f589e11aa5b136ddce753
1 file changed +9 -16
git-merge-one-file.sh
+9 -16
@@ -16,14 +16,6 @@
16 # been handled already by git-read-tree, but that one doesn't
17 # do any merges that might change the tree layout.
18
19 -verify_path() {
20 - file="$1"
21 - dir=`dirname "$file"` &&
22 - mkdir -p "$dir" &&
23 - rm -f -- "$file" &&
24 - : >"$file"
25 -}
26 -
19 case "${1:-.}${2:-.}${3:-.}" in
20 #
21 # Deleted in both or deleted in one and unchanged in the other
@@ -95,15 +87,16 @@ case "${1:-.}${2:-.}${3:-.}" in
87 ;;
88 esac
89
98 - # Create the working tree file, with the correct permission bits.
99 - # we can not rely on the fact that our tree has the path, because
100 - # we allow the merge to be done in an unchecked-out working tree.
101 - verify_path "$4" &&
102 - git-cat-file blob "$2" >"$4" &&
103 - case "$6" in *7??) chmod +x -- "$4" ;; esac &&
104 - merge "$4" "$orig" "$src2"
90 + # Be careful for funny filename such as "-L" in "$4", which
91 + # would confuse "merge" greatly.
92 + src1=`git-unpack-file $2`
93 + merge "$src1" "$orig" "$src2"
94 ret=$?
106 - rm -f -- "$orig" "$src2"
95 +
96 + # Create the working tree file, using "our tree" version from the
97 + # index, and then store the result of the merge.
98 + git-checkout-index -f --stage=2 -- "$4" && cat "$src1" >"$4"
99 + rm -f -- "$orig" "$src1" "$src2"
100
101 if [ "$6" != "$7" ]; then
102 echo "ERROR: Permissions conflict: $5->$6,$7."