Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
executable file
·
237 lines (199 loc) · 6.46 KB

File metadata and controls

executable file
·
237 lines (199 loc) · 6.46 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
#!/usr/bin/tclsh
# This tool does better job as default configuration of 'gvimdiff' used as a difftool.
# It does the same if both files exist and the file was just altered - plus prints 'DIFF' message on console.
# If the file has been added or deleted, it just prints the info on the screen and
# allows you to edit the new file (if added) or diff-edit the new file under the name
# of the deleted file, if you answer 'e' for the prompt.
# To use that, put the following lines in your .gitconfig file:
#
# [diff]
# tool = gvimdiffwrp
#
# [difftool]
# prompt = no
#
# [difftool.gvimdiffwrp]
# cmd = gvimdiff-git-wrapper "\"$LOCAL\"" "\"$REMOTE\"" \""$BASE\""
# ^^^ IMPORTANT!!! These "double quoting" things are necessary so that
# names with spaces are correctly handled!
proc getpath arg { return $arg }
proc istemp {arg} {
return [expr {[string range $arg 0 3] == "/tmp"}]
}
if { [catch {exec uname -o} osname] } {
set osname $tcl_platform(os)
}
if { [info exists env(GVIM)] } {
set vim $env(GVIM)
if { [llength $vim] == 1 } {
set vim "$vim -f"
}
} elseif { [info exists env(DISPLAY)] } {
set vim "gvim -f"
} elseif { $osname == "Cygwin" && [info exists env(VIMPATH)]} {
set vim $env(VIMPATH)
puts "vim: $vim"
# Happens that there are spaces in the name.
# We don't predict that this contains an option.
# Protect against interpreting it as a list
if { [llength $vim] > 1 } {
set vim "{$vim}"
} elseif { [string index $vim 0] == "\"" } {
# Change "the path\to\windows" to {the path\to\windows}
# because in "" Tcl will resolve backslashes!
set vim "{[string range $vim 1 end-1]}"
}
if { [string match gvim* [file tail $vim]] } {
lappend vim -f
}
rename getpath ""
proc getpath arg { return [exec cygpath -w $arg] }
} elseif { $osname == "Windows" } {
set vim gvim.bat
rename istemp ""
proc istemp {arg} {
if { [info exists ::env(TEMP)] } {
set tmpdir [string tolower $::env(TEMP)]
set thispath [string tolower [file nativename $arg]]
if { [string first $tmpdir $thispath] == 0 } {
return true
}
return false
}
# Fall back to checking if the path starts from X:\temp
# Path is always absolute, so the first two will be V: / NNN
return [expr {[string tolower [lindex [file split $arg] 2]] == "temp"}]
}
} else {
set vim vim
}
proc ask text {
puts -nonewline $text
flush stdout
}
set autoskip no
if { [info exists env(AUTOSKIP)] } {
set as $env(AUTOSKIP)
if { [string is bool $as] } {
set autoskip $as
}
}
set skipfiles ""
if { [info exists env(SKIPFILES)] } {
set skipfiles $env(SKIPFILES)
}
proc answer {} {
if { $::autoskip } {
puts " (AUTOSKIP)"
return ""
}
set a [gets stdin]
return [string tolower [string index $a 0]]
}
#puts stderr "WILL RUN VIM:"
#for {set i 0} {$i < [llength $vim]} {incr i} {
# puts stderr "{$i} [lindex $vim $i]"
#}
lassign $argv older newer base
if { $older == "/dev/null" } {
set fname $newer
if { [string index $fname 0] == "/" && [lindex [file split [string range $fname 1 end]] 0] == "tmp" } {
set fname $base
}
if { [catch {set ftype [file type $fname]}] } {
set ftype THING
}
if { $ftype == "file" } {
ask "ADDED: $ftype '$fname' (e)dit/(s)kip/(d)elete from repo (NOT FROM FILESYSTEM) \[e/S/d\] "
switch -- [answer] {
e {
exec >@stdout 2>@stderr {*}$vim [getpath $fname]
}
d {
exec >@stdout 2>@stderr git rm --cached [getpath $fname]
}
}
} else {
# For other types offer just deletion
ask "ADDED: $ftype '$fname' (s)kip/(d)elete from repo (NOT FROM FILESYSTEM) \[S/d\] "
if { [answer] == "d" } {
exec >@stdout git rm --cached [getpath $fname]
}
}
exit 0
}
if { $newer == "/dev/null" } {
# It's impossible that it gets diff on a directory - git doesn't version directories.
# If it happens, it means that it's a directory for a submodule.
# Skip this completely - it should be reinstated by a submodule command
# basing on settings in .gitmodules file
if { [file type $older] == "directory" } {
puts stderr "WARNING: Ths '$base' directory is present as diff - it's possibly a submodule"
exit 0
}
ask "DELETED: '$base' (e)dit as new/(s)kip/(r)estore in the repo \[e/S/r\] "
switch -- [answer] {
e {
exec >@stdout 2>@stderr {*}$vim -d [getpath $older] [getpath $base]
}
r {
set attr [file attributes $older] ;# Copy the attributes, too!
file mkdir [file dirname $base] ;# make sure the directory exists
exec >@stdout touch $base ;# make sure the file exists
exec >@stdout git add $base ;# add as empty so that it's noted
file copy -force $older $base ;# now copy the contents to see it modified locally
puts stderr "NOTE: Applying attributes from '$older': $attr"
if { [catch {file attributes $base {*}$attr} rror] } {
puts stderr "*** WARNING: Failed to set original attributes to '$base'!"
}
}
}
exit 0
}
if { $base == "/dev/null" } {
set base $older ;# Nothing else
}
foreach mask $skipfiles {
if { [string match $mask $older] } {
puts "SKIPPING (for $mask): '$base'"
exit 0
}
}
puts "DIFF: '$base'" ;# -- (PASSED: $argv)"
# This call to 'diff' ignores differences caused by Windows EOLs.
if { [catch {exec diff --strip-trailing-cr -q $older $newer}] } {
set oldpath [getpath $older]
set setro "{+exec 'windo setlocal ro' | setlocal noro}" ;# Double container so that {*} will expand to no argument or enclosed argument
if { ![istemp $oldpath] } {
set setro ""
}
set verb ""; #"{+set verbose=1}"
set cmd [list {*}$vim -d [getpath $older] [getpath $newer] {*}$setro {*}$verb]
#puts "EXEC: $cmd"
exec >@stdout 2>@stderr {*}$cmd
} else {
puts " --- Diff reported no differences in file contents;"
set maxlen [expr {max([string length $older],[string length $newer])}]
set oxspace [string repeat " " [expr {$maxlen - [string length $older]}]]
set nxspace [string repeat " " [expr {$maxlen - [string length $newer]}]]
set any no
# Try to extract extra info about the differences:
# 1. Maybe they have different rights?
set oattr [file attributes $older]
set nattr [file attributes $newer]
if { $oattr != $nattr } {
puts " --- Attributes differ:\n\t$oxspace$older: $oattr\n\t$nxspace$newer: $nattr"
set any yes
}
#2. Maybe they are text files and have different EOLS?
# Extract the 'file' report and present it (it will show the differences)
set ofile [exec file -b $older]
set nfile [exec file -b $newer]
if { $ofile != $nfile } {
puts " --- Magic recognition differ:\n\t$oxspace$older: $ofile\n\t$nxspace$newer: $nfile"
set any yes
}
if { !$any } {
puts " --- and no reason for difference found."
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.