-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkdiff3-git-wrapper
More file actions
executable file
·46 lines (36 loc) · 1.05 KB
/
kdiff3-git-wrapper
File metadata and controls
executable file
·46 lines (36 loc) · 1.05 KB
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
#!/usr/bin/tclsh
# To use that, put the following lines in your .gitconfig file:
#
#[merge]
# tool = manual
#
#[mergetool]
# keepBackup = false
#
#[mergetool.manual]
# cmd = kdiff3-git-wrapper "\"$MERGED\"" "\"$BASE\"" "\"$LOCAL\"" "\"$REMOTE\""
# ^^^ IMPORTANT!!! These "double quoting" things are necessary so that
# names with spaces are correctly handled!
# Keep argument names same as they are
lassign $argv MERGED BASE LOCAL REMOTE
if { [catch {exec git branch --show-current} curbr] } {
set curbr ""
} else {
set curbr ": $curbr"
}
set merge_head ""
if {[catch {exec git rev-parse MERGE_HEAD} merge_head]} {
set merge_head ""
} else {
if { ![catch {exec git branch -a --contains $merge_head} cc] } {
set merge_head ": [string trim [lindex [split $cc \n] 0]]"
}
}
set lab_base "$MERGED (Base)"
set lab_local "$MERGED (Local$curbr)"
set lab_remote "$MERGED (Foreign$merge_head)"
if { [catch {exec >@stdout 2>@stderr kdiff3 --L1 $lab_base --L2 $lab_local --L3 $lab_remote -o $MERGED $BASE $LOCAL $REMOTE} errors] } {
puts stderr $errors
exit 1
}
exit 0