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

mergetool: fix running mergetool in sub-directories

The previous fix to mergetool to use checkout-index instead of cat-file broke running mergetool anywhere except the root of the repository. This fixes it by using the correct relative paths for temporary files and index paths. Signed-off-by: Charles Bailey <charles@hashpling.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Charles Bailey committed Jan 30, 2009 at 23:20 UTC ff4a18552aa48f3227e2465072951dacc34aee9b
2 files changed +5 -6
git-mergetool.sh
+4 -5
@@ -13,7 +13,6 @@ SUBDIRECTORY_OK=Yes
13 OPTIONS_SPEC=
14 . git-sh-setup
15 require_work_tree
16 -prefix=$(git rev-parse --show-prefix)
16
17 # Returns true if the mode reflects a symlink
18 is_symlink () {
@@ -131,7 +130,7 @@ checkout_staged_file () {
130 tmpfile=$(expr "$(git checkout-index --temp --stage="$1" "$2")" : '\([^ ]*\) ')
131
132 if test $? -eq 0 -a -n "$tmpfile" ; then
134 - mv -- "$tmpfile" "$3"
133 + mv -- "$(git rev-parse --show-cdup)$tmpfile" "$3"
134 fi
135 }
136
@@ -161,9 +160,9 @@ merge_file () {
160 local_mode=`git ls-files -u -- "$MERGED" | awk '{if ($3==2) print $1;}'`
161 remote_mode=`git ls-files -u -- "$MERGED" | awk '{if ($3==3) print $1;}'`
162
164 - base_present && checkout_staged_file 1 "$prefix$MERGED" "$BASE"
165 - local_present && checkout_staged_file 2 "$prefix$MERGED" "$LOCAL"
166 - remote_present && checkout_staged_file 3 "$prefix$MERGED" "$REMOTE"
163 + base_present && checkout_staged_file 1 "$MERGED" "$BASE"
164 + local_present && checkout_staged_file 2 "$MERGED" "$LOCAL"
165 + remote_present && checkout_staged_file 3 "$MERGED" "$REMOTE"
166
167 if test -z "$local_mode" -o -z "$remote_mode"; then
168 echo "Deleted merge conflict for '$MERGED':"
t/t7610-mergetool.sh
+1 -1
@@ -66,7 +66,7 @@ test_expect_success 'mergetool crlf' '
66 git reset --hard
67 '
68
69 -test_expect_failure 'mergetool in subdir' '
69 +test_expect_success 'mergetool in subdir' '
70 git checkout -b test3 branch1
71 cd subdir && (
72 test_must_fail git merge master >/dev/null 2>&1 &&