Skip to content

Commit 85776c7

Browse files
author
Masud Rahman
committed
Always shows type of change in status line.
1 parent 6e9a25f commit 85776c7

1 file changed

Lines changed: 16 additions & 11 deletions

File tree

git-vimdiff.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def write_header(f):
123123
f.write(u'cd {}\n'.format(root()))
124124
f.write(u'set laststatus=2\n')
125125

126-
def write_hash(f, mode, hash, name, type=None, score=None):
126+
def write_hash(f, mode, hash, name, type, score=None):
127127
f.write(u'setlocal noswapfile\n')
128128
f.write(u'set buftype=nowrite\n')
129129

@@ -139,29 +139,32 @@ def write_hash(f, mode, hash, name, type=None, score=None):
139139
f.write(u'+1d\n')
140140

141141
if score != None:
142-
status = '{0}\\ [{1}%%\\ similar]\\ ({2})'.format(name, score, mode)
143-
elif type != None:
144-
status = '{0}\\ [{1}]\\ ({2})'.format(name, type, mode)
142+
status = '{0}\\ [{1}, {2}%%\\ similar]\\ ({3})'.format(name,
143+
score,
144+
type,
145+
mode)
145146
else:
146-
status = '{0}\\ ({1})'.format(name, mode)
147+
status = '{0}\\ [{1}]\\ ({2})'.format(name, type, mode)
147148

148149
f.write(u'setlocal statusline={}\n'.format(status))
149150

150151
f.write(u'0\n')
151152

152-
def write_file(f, name):
153+
def write_file(f, name, type):
153154
f.write(u'e {}\n'.format(name.replace(' ', '\\ ')))
155+
status = '{0}\\ [{1}]'.format(name, type)
156+
f.write(u'setlocal statusline={}\n'.format(status))
154157
f.write(u'0\n')
155158

156-
def write_hash_or_file(f, mode, hash, name, type=None, score=None):
159+
def write_hash_or_file(f, mode, hash, name, type, score=None):
157160
if hash == '0000000000000000000000000000000000000000':
158-
write_file(f, name)
161+
write_file(f, name, type)
159162
return
160163

161164
object_data = subprocess.Popen(['git', 'show', hash],
162165
stdout=subprocess.PIPE).communicate()[0]
163166
if object_data == open(name).read():
164-
write_file(f, name)
167+
write_file(f, name, type)
165168
else:
166169
write_hash(f, mode, hash, name, type, score)
167170

@@ -180,12 +183,14 @@ def write_change(f, change):
180183
write_hash_or_file(f,
181184
change['dst']['mode'],
182185
change['dst']['hash'],
183-
change['name'])
186+
change['name'],
187+
change['type'])
184188
write_split(f)
185189
write_hash_or_file(f,
186190
change['src']['mode'],
187191
change['src']['hash'],
188-
change['name'])
192+
change['name'],
193+
change['type'])
189194
write_diff(f)
190195
elif change['type'] == 'copied':
191196
write_hash_or_file(f,

0 commit comments

Comments
 (0)