Changed an internal variable of mergetool to support custom commands
The variable $path changes to $MERGED so that it is more consistent with $BASE, $LOCAL and $REMOTE for future custom command lines. Signed-off-by: Charles Bailey <charles@hashpling.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Charles Bailey committed
Feb 21, 2008 at 23:30 UTC
b3ea27e4de24c7006969f493ba6bfbbc5b572d80
1 file changed
+50
-50
git-mergetool.sh
+50
-50
@@ -34,7 +34,7 @@ base_present () {
34
35
cleanup_temp_files () {
36
if test "$1" = --save-backup ; then
37
- mv -- "$BACKUP" "$path.orig"
37
+ mv -- "$BACKUP" "$MERGED.orig"
38
rm -f -- "$LOCAL" "$REMOTE" "$BASE"
39
else
40
rm -f -- "$LOCAL" "$REMOTE" "$BASE" "$BACKUP"
@@ -67,14 +67,14 @@ resolve_symlink_merge () {
67
read ans
68
case "$ans" in
69
[lL]*)
70
- git checkout-index -f --stage=2 -- "$path"
71
- git add -- "$path"
70
+ git checkout-index -f --stage=2 -- "$MERGED"
71
+ git add -- "$MERGED"
72
cleanup_temp_files --save-backup
73
return
74
;;
75
[rR]*)
76
- git checkout-index -f --stage=3 -- "$path"
77
- git add -- "$path"
76
+ git checkout-index -f --stage=3 -- "$MERGED"
77
+ git add -- "$MERGED"
78
cleanup_temp_files --save-backup
79
return
80
;;
@@ -95,12 +95,12 @@ resolve_deleted_merge () {
95
read ans
96
case "$ans" in
97
[mMcC]*)
98
- git add -- "$path"
98
+ git add -- "$MERGED"
99
cleanup_temp_files --save-backup
100
return
101
;;
102
[dD]*)
103
- git rm -- "$path" > /dev/null
103
+ git rm -- "$MERGED" > /dev/null
104
cleanup_temp_files
105
return
106
;;
@@ -112,11 +112,11 @@ resolve_deleted_merge () {
112
}
113
114
check_unchanged () {
115
- if test "$path" -nt "$BACKUP" ; then
115
+ if test "$MERGED" -nt "$BACKUP" ; then
116
status=0;
117
else
118
while true; do
119
- echo "$path seems unchanged."
119
+ echo "$MERGED seems unchanged."
120
printf "Was the merge successful? [y/n] "
121
read answer < /dev/tty
122
case "$answer" in
@@ -128,37 +128,37 @@ check_unchanged () {
128
}
129
130
merge_file () {
131
- path="$1"
131
+ MERGED="$1"
132
133
- f=`git ls-files -u -- "$path"`
133
+ f=`git ls-files -u -- "$MERGED"`
134
if test -z "$f" ; then
135
- if test ! -f "$path" ; then
136
- echo "$path: file not found"
135
+ if test ! -f "$MERGED" ; then
136
+ echo "$MERGED: file not found"
137
else
138
- echo "$path: file does not need merging"
138
+ echo "$MERGED: file does not need merging"
139
fi
140
exit 1
141
fi
142
143
- ext="$$$(expr "$path" : '.*\(\.[^/]*\)$')"
144
- BACKUP="$path.BACKUP.$ext"
145
- LOCAL="$path.LOCAL.$ext"
146
- REMOTE="$path.REMOTE.$ext"
147
- BASE="$path.BASE.$ext"
143
+ ext="$$$(expr "$MERGED" : '.*\(\.[^/]*\)$')"
144
+ BACKUP="$MERGED.BACKUP.$ext"
145
+ LOCAL="$MERGED.LOCAL.$ext"
146
+ REMOTE="$MERGED.REMOTE.$ext"
147
+ BASE="$MERGED.BASE.$ext"
148
149
- mv -- "$path" "$BACKUP"
150
- cp -- "$BACKUP" "$path"
149
+ mv -- "$MERGED" "$BACKUP"
150
+ cp -- "$BACKUP" "$MERGED"
151
152
- base_mode=`git ls-files -u -- "$path" | awk '{if ($3==1) print $1;}'`
153
- local_mode=`git ls-files -u -- "$path" | awk '{if ($3==2) print $1;}'`
154
- remote_mode=`git ls-files -u -- "$path" | awk '{if ($3==3) print $1;}'`
152
+ base_mode=`git ls-files -u -- "$MERGED" | awk '{if ($3==1) print $1;}'`
153
+ local_mode=`git ls-files -u -- "$MERGED" | awk '{if ($3==2) print $1;}'`
154
+ remote_mode=`git ls-files -u -- "$MERGED" | awk '{if ($3==3) print $1;}'`
155
156
- base_present && git cat-file blob ":1:$prefix$path" >"$BASE" 2>/dev/null
157
- local_present && git cat-file blob ":2:$prefix$path" >"$LOCAL" 2>/dev/null
158
- remote_present && git cat-file blob ":3:$prefix$path" >"$REMOTE" 2>/dev/null
156
+ base_present && git cat-file blob ":1:$prefix$MERGED" >"$BASE" 2>/dev/null
157
+ local_present && git cat-file blob ":2:$prefix$MERGED" >"$LOCAL" 2>/dev/null
158
+ remote_present && git cat-file blob ":3:$prefix$MERGED" >"$REMOTE" 2>/dev/null
159
160
if test -z "$local_mode" -o -z "$remote_mode"; then
161
- echo "Deleted merge conflict for '$path':"
161
+ echo "Deleted merge conflict for '$MERGED':"
162
describe_file "$local_mode" "local" "$LOCAL"
163
describe_file "$remote_mode" "remote" "$REMOTE"
164
resolve_deleted_merge
@@ -166,14 +166,14 @@ merge_file () {
166
fi
167
168
if is_symlink "$local_mode" || is_symlink "$remote_mode"; then
169
- echo "Symbolic link merge conflict for '$path':"
169
+ echo "Symbolic link merge conflict for '$MERGED':"
170
describe_file "$local_mode" "local" "$LOCAL"
171
describe_file "$remote_mode" "remote" "$REMOTE"
172
resolve_symlink_merge
173
return
174
fi
175
176
- echo "Normal merge conflict for '$path':"
176
+ echo "Normal merge conflict for '$MERGED':"
177
describe_file "$local_mode" "local" "$LOCAL"
178
describe_file "$remote_mode" "remote" "$REMOTE"
179
printf "Hit return to start merge resolution tool (%s): " "$merge_tool"
@@ -182,30 +182,30 @@ merge_file () {
182
case "$merge_tool" in
183
kdiff3)
184
if base_present ; then
185
- ("$merge_tool_path" --auto --L1 "$path (Base)" --L2 "$path (Local)" --L3 "$path (Remote)" \
186
- -o "$path" -- "$BASE" "$LOCAL" "$REMOTE" > /dev/null 2>&1)
185
+ ("$merge_tool_path" --auto --L1 "$MERGED (Base)" --L2 "$MERGED (Local)" --L3 "$MERGED (Remote)" \
186
+ -o "$MERGED" -- "$BASE" "$LOCAL" "$REMOTE" > /dev/null 2>&1)
187
else
188
- ("$merge_tool_path" --auto --L1 "$path (Local)" --L2 "$path (Remote)" \
189
- -o "$path" -- "$LOCAL" "$REMOTE" > /dev/null 2>&1)
188
+ ("$merge_tool_path" --auto --L1 "$MERGED (Local)" --L2 "$MERGED (Remote)" \
189
+ -o "$MERGED" -- "$LOCAL" "$REMOTE" > /dev/null 2>&1)
190
fi
191
status=$?
192
;;
193
tkdiff)
194
if base_present ; then
195
- "$merge_tool_path" -a "$BASE" -o "$path" -- "$LOCAL" "$REMOTE"
195
+ "$merge_tool_path" -a "$BASE" -o "$MERGED" -- "$LOCAL" "$REMOTE"
196
else
197
- "$merge_tool_path" -o "$path" -- "$LOCAL" "$REMOTE"
197
+ "$merge_tool_path" -o "$MERGED" -- "$LOCAL" "$REMOTE"
198
fi
199
status=$?
200
;;
201
meld|vimdiff)
202
touch "$BACKUP"
203
- "$merge_tool_path" -- "$LOCAL" "$path" "$REMOTE"
203
+ "$merge_tool_path" -- "$LOCAL" "$MERGED" "$REMOTE"
204
check_unchanged
205
;;
206
gvimdiff)
207
touch "$BACKUP"
208
- "$merge_tool_path" -f -- "$LOCAL" "$path" "$REMOTE"
208
+ "$merge_tool_path" -f -- "$LOCAL" "$MERGED" "$REMOTE"
209
check_unchanged
210
;;
211
xxdiff)
@@ -215,56 +215,56 @@ merge_file () {
215
-R 'Accel.SaveAsMerged: "Ctrl-S"' \
216
-R 'Accel.Search: "Ctrl+F"' \
217
-R 'Accel.SearchForward: "Ctrl-G"' \
218
- --merged-file "$path" -- "$LOCAL" "$BASE" "$REMOTE"
218
+ --merged-file "$MERGED" -- "$LOCAL" "$BASE" "$REMOTE"
219
else
220
"$merge_tool_path" -X --show-merged-pane \
221
-R 'Accel.SaveAsMerged: "Ctrl-S"' \
222
-R 'Accel.Search: "Ctrl+F"' \
223
-R 'Accel.SearchForward: "Ctrl-G"' \
224
- --merged-file "$path" -- "$LOCAL" "$REMOTE"
224
+ --merged-file "$MERGED" -- "$LOCAL" "$REMOTE"
225
fi
226
check_unchanged
227
;;
228
opendiff)
229
touch "$BACKUP"
230
if base_present; then
231
- "$merge_tool_path" "$LOCAL" "$REMOTE" -ancestor "$BASE" -merge "$path" | cat
231
+ "$merge_tool_path" "$LOCAL" "$REMOTE" -ancestor "$BASE" -merge "$MERGED" | cat
232
else
233
- "$merge_tool_path" "$LOCAL" "$REMOTE" -merge "$path" | cat
233
+ "$merge_tool_path" "$LOCAL" "$REMOTE" -merge "$MERGED" | cat
234
fi
235
check_unchanged
236
;;
237
ecmerge)
238
touch "$BACKUP"
239
if base_present; then
240
- "$merge_tool_path" "$BASE" "$LOCAL" "$REMOTE" --mode=merge3 --to="$path"
240
+ "$merge_tool_path" "$BASE" "$LOCAL" "$REMOTE" --mode=merge3 --to="$MERGED"
241
else
242
- "$merge_tool_path" "$LOCAL" "$REMOTE" --mode=merge2 --to="$path"
242
+ "$merge_tool_path" "$LOCAL" "$REMOTE" --mode=merge2 --to="$MERGED"
243
fi
244
check_unchanged
245
;;
246
emerge)
247
if base_present ; then
248
- "$merge_tool_path" -f emerge-files-with-ancestor-command "$LOCAL" "$REMOTE" "$BASE" "$(basename "$path")"
248
+ "$merge_tool_path" -f emerge-files-with-ancestor-command "$LOCAL" "$REMOTE" "$BASE" "$(basename "$MERGED")"
249
else
250
- "$merge_tool_path" -f emerge-files-command "$LOCAL" "$REMOTE" "$(basename "$path")"
250
+ "$merge_tool_path" -f emerge-files-command "$LOCAL" "$REMOTE" "$(basename "$MERGED")"
251
fi
252
status=$?
253
;;
254
esac
255
if test "$status" -ne 0; then
256
- echo "merge of $path failed" 1>&2
257
- mv -- "$BACKUP" "$path"
256
+ echo "merge of $MERGED failed" 1>&2
257
+ mv -- "$BACKUP" "$MERGED"
258
exit 1
259
fi
260
261
if test "$merge_keep_backup" = "true"; then
262
- mv -- "$BACKUP" "$path.orig"
262
+ mv -- "$BACKUP" "$MERGED.orig"
263
else
264
rm -- "$BACKUP"
265
fi
266
267
- git add -- "$path"
267
+ git add -- "$MERGED"
268
cleanup_temp_files
269
}
270