60
|
60
|
|
|
61
|
61
|
|
<br /><br /><br /><br />
|
62
|
62
|
|
|
63
|
|
- |
<details class="diffstat" {{ 'open' if defaults.DIFF_SHOW_DIFFSTAT }}>
|
|
63
|
+ |
<details class="diffstat" {{ 'open' if defaults.DIFF_EXPAND_DIFFSTAT }}>
|
64
|
64
|
|
{# pygit2 appears to recompute all the stats every time we use diff.stats,
|
65
|
65
|
|
# therefore we set this variable in order to compute it only once.
|
66
|
66
|
|
#}
|
91
|
91
|
|
|
92
|
92
|
|
<br />
|
93
|
93
|
|
|
94
|
|
- |
<details class="diff_options">
|
|
94
|
+ |
<details class="diff_options" {{ 'open' if defaults.DIFF_EXPAND_DIFFOPTIONS }}>
|
95
|
95
|
|
<summary>Diff options</summary>
|
96
|
96
|
|
<form action="" method="get">
|
97
|
97
|
|
<table>
|
147
|
147
|
|
|
148
|
148
|
|
{% for patch in diff %}
|
149
|
149
|
|
|
150
|
|
- |
<table class="diff">
|
151
|
|
- |
|
|
150
|
+ |
<details class="diff_view" {{ 'open' if defaults.DIFF_EXPAND }}>
|
|
151
|
+ |
|
152
|
152
|
|
{# The following status values are defined in the git_delta_t enum
|
153
|
153
|
|
# in libgit2. See https://github.com/libgit2/libgit2/blob/main/include/git2/diff.h
|
154
|
154
|
|
# 0 = UNCHANGED
|
159
|
159
|
|
# 5 = COPIED
|
160
|
160
|
|
# ... (there are other codes that we don't use)
|
161
|
161
|
|
#}
|
162
|
|
- |
<thead>
|
163
|
|
- |
<tr>
|
164
|
|
- |
<td colspan="4">
|
165
|
|
- |
{% if patch.line_stats[1] + patch.line_stats[2] > 0 %}
|
166
|
|
- |
{% set color_border = patch.line_stats[1] / ( patch.line_stats[1] + patch.line_stats[2] ) * 100 %}
|
167
|
|
- |
{% else %}
|
168
|
|
- |
{% set color_border = 0 %}
|
169
|
|
- |
{% endif %}
|
170
|
|
- |
|
171
|
|
- |
<span class="histogram" style="border-image: linear-gradient(to right, lightgreen {{ color_border }}%, red {{ color_border }}%) 1;">
|
172
|
|
- |
+{{ patch.line_stats[1] }}/-{{ patch.line_stats[2] }}
|
173
|
|
- |
</span>
|
174
|
|
- |
|
175
|
|
- |
{% if patch.delta.status == 1 %}
|
176
|
|
- |
<b title="Added">A</b> {{ patch.delta.new_file.path }}
|
177
|
|
- |
{% endif %}
|
178
|
|
- |
|
179
|
|
- |
{% if patch.delta.status == 2 %}
|
180
|
|
- |
<b title="Deleted">D</b> {{ patch.delta.old_file.path }}
|
181
|
|
- |
{% endif %}
|
182
|
|
- |
|
183
|
|
- |
{% if patch.delta.status == 3 %}
|
184
|
|
- |
<b title="Modified">M</b> {{ patch.delta.new_file.path }}
|
185
|
|
- |
{% endif %}
|
186
|
|
- |
|
187
|
|
- |
{% if patch.delta.status == 4 %}
|
188
|
|
- |
<b title="Renamed">R</b> {{ patch.delta.old_file.path }} -> {{ patch.delta.new_file.path }}
|
189
|
|
- |
{% endif %}
|
190
|
|
- |
|
191
|
|
- |
{% if patch.delta.status == 5 %}
|
192
|
|
- |
<b title="Copied">C</b> {{ patch.delta.old_file.path }} {{ patch.delta.new_file.path }}
|
193
|
|
- |
{% endif %}
|
194
|
|
- |
</td>
|
195
|
|
- |
</tr>
|
|
162
|
+ |
<summary>
|
|
163
|
+ |
{% if patch.line_stats[1] + patch.line_stats[2] > 0 %}
|
|
164
|
+ |
{% set color_border = patch.line_stats[1] / ( patch.line_stats[1] + patch.line_stats[2] ) * 100 %}
|
|
165
|
+ |
{% else %}
|
|
166
|
+ |
{% set color_border = 0 %}
|
|
167
|
+ |
{% endif %}
|
|
168
|
+ |
|
|
169
|
+ |
<span class="histogram" style="border-image: linear-gradient(to right, lightgreen {{ color_border }}%, red {{ color_border }}%) 1;">
|
|
170
|
+ |
+{{ patch.line_stats[1] }}/-{{ patch.line_stats[2] }}
|
|
171
|
+ |
</span>
|
|
172
|
+ |
|
|
173
|
+ |
{% if patch.delta.status == 1 %}
|
|
174
|
+ |
<b title="Added">A</b> {{ patch.delta.new_file.path }}
|
|
175
|
+ |
{% endif %}
|
|
176
|
+ |
|
|
177
|
+ |
{% if patch.delta.status == 2 %}
|
|
178
|
+ |
<b title="Deleted">D</b> {{ patch.delta.old_file.path }}
|
|
179
|
+ |
{% endif %}
|
|
180
|
+ |
|
|
181
|
+ |
{% if patch.delta.status == 3 %}
|
|
182
|
+ |
<b title="Modified">M</b> {{ patch.delta.new_file.path }}
|
|
183
|
+ |
{% endif %}
|
|
184
|
+ |
|
|
185
|
+ |
{% if patch.delta.status == 4 %}
|
|
186
|
+ |
<b title="Renamed">R</b> {{ patch.delta.old_file.path }} -> {{ patch.delta.new_file.path }}
|
|
187
|
+ |
{% endif %}
|
|
188
|
+ |
|
|
189
|
+ |
{% if patch.delta.status == 5 %}
|
|
190
|
+ |
<b title="Copied">C</b> {{ patch.delta.old_file.path }} {{ patch.delta.new_file.path }}
|
|
191
|
+ |
{% endif %}
|
|
192
|
+ |
|
|
193
|
+ |
<table>
|
196
|
194
|
|
<tr>
|
197
|
195
|
|
<td colspan="4">
|
198
|
196
|
|
old size: {{ patch.delta.old_file.size|human_size(B=true) }}
|
213
|
211
|
|
{% endif %}
|
214
|
212
|
|
</td>
|
215
|
213
|
|
</tr>
|
216
|
|
- |
</thead>
|
217
|
|
- |
<tbody>
|
|
214
|
+ |
</table>
|
|
215
|
+ |
</summary>
|
|
216
|
+ |
|
|
217
|
+ |
<table class="diff">
|
218
|
218
|
|
{% if patch.delta.is_binary %}
|
219
|
219
|
|
<tr>
|
220
|
220
|
|
<td colspan="4">
|
226
|
226
|
|
{% for hunk in patch.hunks if not patch.delta.is_binary %}
|
227
|
227
|
|
|
228
|
228
|
|
{#### UDIFF mode ####}
|
|
229
|
+ |
{# In this mode the lines are printed one after the other. #}
|
229
|
230
|
|
|
230
|
231
|
|
{% if mode == 'udiff' %}
|
231
|
232
|
|
<tr class="header">
|
254
|
255
|
|
{% endif %}
|
255
|
256
|
|
|
256
|
257
|
|
{#### SSDIFF mode ####}
|
|
258
|
+ |
{# In this mode, changed lines are buffered until we find an
|
|
259
|
+ |
# unchanged line. When an unchanged line has been found, the
|
|
260
|
+ |
# buffer is emptied.
|
|
261
|
+ |
#}
|
257
|
262
|
|
|
258
|
263
|
|
{% if mode == 'ssdiff' %}
|
|
264
|
+ |
{% set buffer_deletions = [] %}
|
|
265
|
+ |
{% set buffer_insertions = [] %}
|
|
266
|
+ |
|
259
|
267
|
|
{% macro print_buffer(buffer_deletions, buffer_insertions) %}
|
260
|
268
|
|
{% for buffer_del, buffer_ins in zip_longest(buffer_deletions, buffer_insertions) %}
|
261
|
269
|
|
<tr class="ssdiff">
|
283
|
291
|
|
</tr>
|
284
|
292
|
|
{% endfor %}
|
285
|
293
|
|
|
286
|
|
- |
{# .clear() empties the buffer. However since it requires
|
287
|
|
- |
# {{}} brackets instead of {%%}, this line will print the
|
288
|
|
- |
# value of "buffer_deletions" which is "None".
|
|
294
|
+ |
{# .clear() empties the buffer. Since this requires {{}}
|
|
295
|
+ |
# brackets instead of {%%}, this line will print the value
|
|
296
|
+ |
# of "buffer_deletions" which is "None".
|
289
|
297
|
|
# "or ''" is a hack for printing an empty line instead of "None".
|
290
|
298
|
|
#}
|
291
|
299
|
|
{{ buffer_deletions.clear() or '' }}
|
296
|
304
|
|
<td colspan=4>{{ hunk.header }}</td>
|
297
|
305
|
|
</tr>
|
298
|
306
|
|
|
299
|
|
- |
{% set buffer_deletions = [] %}
|
300
|
|
- |
{% set buffer_insertions = [] %}
|
301
|
|
- |
|
302
|
307
|
|
{% for line in hunk.lines %}
|
303
|
308
|
|
{% if line.old_lineno < 0 %}
|
304
|
309
|
|
{{ buffer_insertions.append(line) or '' }}
|
313
|
318
|
|
{# Unload buffer #}
|
314
|
319
|
|
{{ print_buffer(buffer_deletions, buffer_insertions) }}
|
315
|
320
|
|
|
|
321
|
+ |
{# Insert the unchanged line. #}
|
316
|
322
|
|
<tr class="ssdiff">
|
317
|
323
|
|
<td class="lineno">
|
318
|
324
|
|
{{ line.old_lineno }}
|
327
|
333
|
|
{% endif %}
|
328
|
334
|
|
{% endfor %}
|
329
|
335
|
|
|
330
|
|
- |
{# Empty remaining buffer #}
|
|
336
|
+ |
{# Empty remaining buffer. There is a non-empty buffer if we did
|
|
337
|
+ |
# not find an unchanged line, for example when context_lines=0.
|
|
338
|
+ |
#}
|
331
|
339
|
|
{{ print_buffer(buffer_deletions, buffer_insertions) }}
|
332
|
340
|
|
{% endif %}
|
333
|
341
|
|
|
334
|
342
|
|
{% endfor %}
|
335
|
|
- |
</tbody>
|
336
|
|
- |
|
337
|
|
- |
</table>
|
|
343
|
+ |
|
|
344
|
+ |
</table>
|
|
345
|
+ |
</details>
|
338
|
346
|
|
|
339
|
347
|
|
{% endfor %}
|
340
|
348
|
|
</div>
|