Repository navigation
Expand file tree
/
Copy path.git-diffrange
More file actions
632 lines (532 loc) · 21.3 KB
/
Copy path.git-diffrange
File metadata and controls
632 lines (532 loc) · 21.3 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
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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
#!/bin/bash
# Añadimos variables para patch diario
PATCH_FLAG=0
OUTPUT_NAME="report"
# Formato custom para daily summary (opcional)
DS_FORMAT=""
# ------------------------
# HELP
# ------------------------
show_help() {
cat << 'EOF'
git-diffrange - Git diff wrapper with date ranges and daily summaries
USAGE
git diffrange [options] [date] [date]
PREDEFINED RANGES
-cw, --current-week Changes from this Monday → now
-lw, --last-week Changes from last Monday → last Sunday
CUSTOM DATE RANGES
<date> From date to now
<date> [<date>] From first date to second date (if there's one)
Format: YYYY-MM-DD
Example: git diffrange 2024-01-01 2024-12-31
OPTIONS
-a, --author <name> Filter commits by author (case-insensitive)
Matches both name and email
DAILY SUMMARY MODE
-ds Enable daily summary (groups commits by day)
-ds=format{...} Daily summary with inline format
--daily-summary Same as -ds (long form)
--daily-summary=format{...}
Daily summary with inline format (long form)
--ds-format '<format>' Custom format for commit lines
Tokens: %h %H %s %an %ae %ad %n
Example: --ds-format ' • %s (%h) — %an'
PATCH OPTIONS
-p, --patch Generate patches
• Without -ds: normal diff output
• With -ds: per-day .patch files
-n, --name <label> Name prefix for daily patch files
Default: "report"
OUTPUT OPTIONS
--stat Show only statistics (files changed, +/-)
--name-only Show only names of changed files
INTERACTIVE MODE
-i Browse commits/files with fzf
Note: Incompatible with -ds
HELP
-h, --help Show this help
-fh, --formatter-help Show detailed formatter documentation
EXAMPLES
# Current week changes
git diffrange -cw
# Last week with daily summary
git diffrange -lw -ds
# Custom format for specific author
git diffrange -cw -a john --ds-format '%s (%h) — %an'
# Generate daily patches
git diffrange -lw -ds -p -n "sprint-23"
# Custom date range with stats
git diffrange 2024-01-01 2024-12-31 --stat
For detailed formatting help: git diffrange -fh
EOF
exit 0
}
show_formatter_help() {
cat << 'EOF'
═════════════════════════════════════════════════════════════════════��═════════
FORMATTER HELP - git diffrange
═══════════════════════════════════════════════════════════════════════════════
HOW TO PASS CUSTOM FORMATS
───────────────────────────────────────────────────────────────────────────────
You can provide a custom per-commit line format in three equivalent ways:
1. Inline with -ds (short):
-ds=format{...}
2. Inline with --daily-summary (long):
--daily-summary=format{...}
3. With a dedicated flag (best for spaces/special chars):
--ds-format '...'
IMPORTANT QUOTING NOTE (zsh/macOS)
───────────────────────────────────────────────────────────────────────────────
If your format contains spaces or special characters, quote it.
With brace expansion in zsh, prefer quotes when using -ds=format{...}.
Safe patterns:
-ds='format{%h %s}'
--daily-summary='format{[%ad] %an: %s}'
--ds-format ' • %s (%h)'
SUPPORTED TOKENS
───────────────────────────────────────────────────────────────────────────────
Within your format, you can use these tokens:
%h short commit hash (e.g., e7f6a512)
%H full commit hash (40 chars)
%s subject line (single-line commit title)
%an author name
%ae author email
%ad commit date (YYYY-MM-DD; daily summary groups by this)
%n newline (inserts a real line break)
Notes:
• Day headers (like 14/11/2025:) are printed separately above each day
• DS_FORMAT applies only to commit lines
• If DS_FORMAT is not set, the default is: " • %s (%h)"
• Any %X unknown token remains unchanged (e.g., %x stays as "%x")
• If you want indentation or a bullet, include it in your format
EXAMPLES
───────────────────────────────────────────────────────────────────────────────
Default-like but explicit:
--ds-format ' • %s (%h)'
Minimal hash per line:
-ds='format{%H %n}'
Subject with short hash and author:
--ds-format '%s (%h) — %an'
Multi-line pretty:
--ds-format '%s%n by %an <%ae>%n %H'
Date, subject, and email:
--ds-format '[%ad] %s — %ae'
Just subjects (no bullet/indent):
--ds-format '%s'
GOOD PATTERNS TO AVOID SHELL QUIRKS
───────────────────────────────────────────────────────────────────────────────
Prefer --ds-format when your format has spaces:
--ds-format '%s (%h)'
If you use -ds=format{...}, quote it if it contains spaces:
-ds='format{%s (%h)}'
BEHAVIOR DETAILS
───────────────────────────────────────────────────────────────────────────────
Grouping:
Commits are grouped by day and listed earliest → latest (ascending).
The header uses dd/mm/YYYY; the %ad token in your format is YYYY-MM-DD.
Author filtering:
-a/--author uses case-insensitive matching (name or email).
Patches:
If you also pass -p, per-day .patch files are generated.
DS_FORMAT affects only the printed summary, not the patch content.
Safety:
We parse git log using an internal ASCII separator to avoid breaking
on special characters in subjects/names.
EDGE CASES AND TIPS
───────────────────────────────────────────────────────────────────────────────
Literal percent signs:
Any % not followed by a known token is left as-is (e.g., %x).
If you need a literal string like "%h" and don't want it replaced,
change it slightly (e.g., "%{h}" or "% h").
Newlines:
%n inserts a newline; if your format ends with %n, you'll get a blank
line after that commit's block—useful for multi-line layouts.
QUICK TRY-IT COMMANDS
───────────────────────────────────────────────────────────────────────────────
Current week, minimal hashes only:
git diffrange -cw --ds-format '%H'
Current week, tidy bullets:
git diffrange -cw --ds-format ' • %s (%h)'
Last week, author-focused:
git diffrange -lw -a cando --ds-format '[%ad] %s — %an'
═══════════════════════════════════════════════════════════════════════════════
EOF
exit 0
}
# ------------------------
# ARGUMENT PARSING
# ------------------------
AUTHOR=""
DIFF_OPTS=()
INTERACTIVE=0
RANGE=""
RANGE2=""
POSITIONALS=()
DAILY_SUMMARY=0
# Helper para extraer formato de -ds=...
_extract_ds_format() {
local val="$1"
# soporta: format{...} o {...}
if [[ "$val" == format\{*\} ]]; then
DS_FORMAT="${val#format\{}"; DS_FORMAT="${DS_FORMAT%\}}"
elif [[ "$val" == \{*\} ]]; then
DS_FORMAT="${val#\{}"; DS_FORMAT="${DS_FORMAT%\}}"
else
DS_FORMAT="$val"
fi
}
while [[ $# -gt 0 ]]; do
case "$1" in
-h|--help)
show_help ;;
-fh|--formatter-help)
show_formatter_help ;;
-a|--author)
AUTHOR="$2"; shift ;;
-ds|--daily-summary)
DAILY_SUMMARY=1 ;;
-ds=*)
DAILY_SUMMARY=1
_extract_ds_format "${1#*=}" ;;
--daily-summary=*)
DAILY_SUMMARY=1
_extract_ds_format "${1#*=}" ;;
--ds-format)
DS_FORMAT="$2"; shift ;;
-n|--name)
OUTPUT_NAME="$2"; shift ;;
--stat|--name-only)
DIFF_OPTS+=("$1") ;;
--patch|-p)
DIFF_OPTS+=("-p"); PATCH_FLAG=1 ;;
-i)
INTERACTIVE=1 ;;
-cw|--current-week)
RANGE="cw" ;;
-lw|--last-week)
RANGE="lw" ;;
*)
POSITIONALS+=("$1") ;;
esac
shift
done
set -- "${POSITIONALS[@]}"
# If RANGE not set by flag, use positional arguments as custom date ranges
if [[ -z "$RANGE" ]]; then
if [[ $# -eq 0 ]]; then
echo "Error: debes especificar un rango. Usa -h para ver la ayuda." >&2
exit 1
fi
RANGE="$1"
RANGE2="$2"
fi
# ------------------------
# VALIDACIÓN: incompatibilidades
# ------------------------
if [[ $INTERACTIVE -eq 1 && ${#DIFF_OPTS[@]} -gt 0 ]]; then
echo "Error: las opciones ${DIFF_OPTS[*]} no soportan modo interactivo (-i)" >&2
exit 1
fi
if [[ $INTERACTIVE -eq 1 && $DAILY_SUMMARY -eq 1 ]]; then
echo "Error: el modo resumen diario (-ds) no soporta modo interactivo (-i)" >&2
exit 1
fi
# ------------------------
# VALIDACIÓN: fzf instalado?
# ------------------------
if [[ $INTERACTIVE -eq 1 ]]; then
if ! command -v fzf >/dev/null 2>&1; then
echo "Error: fzf no está instalado. Para usar modo interactivo:"; echo " brew install fzf"; exit 1
fi
fi
# ------------------------
# Helpers fzf (solo modo interactivo)
# ------------------------
fzf_commit() {
git log --pretty=format:"%h %s" | fzf --preview "git show {1}" | awk '{print $1}'
}
fzf_file() {
git diff "$FROM" "$TO" --name-only | fzf
}
# ------------------------
# FIND COMMIT HELPERS
# ------------------------
# Busca el último commit ANTES de la fecha dada (cualquier autor)
find_commit_any() {
local date_val="$1"
local commit
commit=$(git log --before="$date_val" -n1 --format="%H" 2>/dev/null)
if [[ -z "$commit" ]]; then
git hash-object -t tree /dev/null # Empty tree
else
echo "$commit"
fi
}
# Busca el último commit ANTES de la fecha dada filtrando por autor (case-insensitive)
find_commit_author() {
local date_val="$1"
local commit
if [[ -z "$AUTHOR" ]]; then
commit=$(git log --before="$date_val" -n1 --format="%H" 2>/dev/null)
else
commit=$(git log --before="$date_val" --regexp-ignore-case --author="$AUTHOR" -n1 --format="%H" 2>/dev/null)
fi
if [[ -z "$commit" ]]; then
git hash-object -t tree /dev/null # Empty tree
else
echo "$commit"
fi
}
# Backward-compat shim (deprecated): mantener nombre original si se usa en algún lugar no actualizado
find_commit() {
local date_val="$1"
local commit
if [[ -n "$AUTHOR" ]]; then
commit=$(git log --before="$date_val" --regexp-ignore-case --author="$AUTHOR" -n1 --format="%H" 2>/dev/null)
else
commit=$(git log --before="$date_val" -n1 --format="%H" 2>/dev/null)
fi
if [[ -z "$commit" ]]; then
git hash-object -t tree /dev/null # Empty tree
else
echo "$commit"
fi
}
# ------------------------
# RANGES
# ------------------------
case "$RANGE" in
cw|current-week)
# Para semana actual: desde el lunes de esta semana (inclusive) hasta ahora
# Buscar el último commit antes del lunes (que será el punto de partida)
MONDAY_DATE=$(date -v -monday +%Y-%m-%d)
FROM=$(find_commit_any "$MONDAY_DATE")
TO="" ;;
lw|last-week)
# Para semana pasada: desde el lunes pasado hasta el domingo pasado
LAST_MONDAY=$(date -v -monday -v-1w +%Y-%m-%d)
LAST_SUNDAY=$(date -v -sunday -v-1w +%Y-%m-%d)
FROM=$(find_commit_any "$LAST_MONDAY")
TO=$(find_commit_any "$LAST_SUNDAY") ;;
*)
FROM=$(find_commit_any "$RANGE")
if [[ -n "$RANGE2" ]]; then
TO=$(find_commit_any "$RANGE2")
else
TO=""
fi ;;
esac
# ------------------------
# VALIDACIÓN DE COMMITS
# ------------------------
if [[ -z "$FROM" || "$FROM" == "" ]]; then
if [[ -n "$AUTHOR" ]]; then
echo "Error: no se encontró ningún commit del autor \"$AUTHOR\" para el rango \"$RANGE\"" >&2
else
echo "Error: no se encontró ningún commit para el rango \"$RANGE\"" >&2
fi
exit 1
fi
if [[ "$RANGE" == "lw" || "$RANGE" == "last-week" || -n "$RANGE2" ]]; then
if [[ -z "$TO" || "$TO" == "" ]]; then
if [[ -n "$AUTHOR" ]]; then
echo "Error: no se encontró commit final para el autor \"$AUTHOR\" en el rango \"$RANGE\" → \"$RANGE2\"" >&2
else
echo "Error: no se encontró commit final para el rango \"$RANGE\" → \"$RANGE2\"" >&2
fi
exit 1
fi
fi
# ------------------------
# DAILY SUMMARY MODE
# ------------------------
if [[ $DAILY_SUMMARY -eq 1 ]]; then
# Determinar fechas de cabecera
if [[ "$RANGE" == "cw" ]]; then
START_DATE_RAW=$(date -v -monday +%Y-%m-%d)
END_DATE_RAW=$(date +%Y-%m-%d)
elif [[ "$RANGE" == "lw" ]]; then
START_DATE_RAW=$(date -v -monday -v -1w +%Y-%m-%d)
END_DATE_RAW=$(date -v -sunday -v -1w +%Y-%m-%d)
else
START_DATE_RAW="$RANGE"
if [[ -n "$RANGE2" ]]; then
END_DATE_RAW="$RANGE2"
else
END_DATE_RAW=$(date +%Y-%m-%d)
fi
fi
format_date() { local d="$1"; echo "${d:8:2}/${d:5:2}/${d:0:4}"; }
format_date_filename() { local d="$1"; echo "${d:8:2}-${d:5:2}-${d:0:4}"; }
START_FMT=$(format_date "$START_DATE_RAW")
END_FMT=$(format_date "$END_DATE_RAW")
# Obtener commits del rango; usar separador ASCII US (0x1f) para campos
SEP=$'\x1f'
RANGE_END_REF=${TO:-HEAD}
# Incluir también committer para filtros flexibles
LOG_PRETTY="%ad${SEP}%h${SEP}%H${SEP}%an${SEP}%ae${SEP}%cn${SEP}%ce${SEP}%s"
# Usar fechas (since/until) y luego filtrar por autor/committer de forma flexible
LOG_ARGS=("--since=$START_DATE_RAW 00:00:00" "--until=$END_DATE_RAW 23:59:59" "--date=short" "--pretty=format:${LOG_PRETTY}" "--reverse")
COMMITS_RAW=$(git log "${LOG_ARGS[@]}")
# Filtrar commits por fecha y ordenar por día
FILTERED_COMMITS=""
while IFS=$'\x1f' read -r day shortH longH authorN authorE committerN committerE subject || [[ -n "$day" ]]; do
[[ -z "$day" ]] && continue
# Filtrar por rango de fechas estrictamente
if [[ "$day" < "$START_DATE_RAW" || "$day" > "$END_DATE_RAW" ]]; then continue; fi
# Si hay filtro de autor, aplicar coincidencia flexible:
# - Subcadena (case-insensitive) en autor/committer (nombre o email)
# - Incluir commits con trailers Co-authored-by que contengan el patrón
if [[ -n "$AUTHOR" ]]; then
_pat=$(printf "%s" "$AUTHOR" | tr '[:upper:]' '[:lower:]')
_an=$(printf "%s" "$authorN" | tr '[:upper:]' '[:lower:]')
_ae=$(printf "%s" "$authorE" | tr '[:upper:]' '[:lower:]')
_cn=$(printf "%s" "$committerN" | tr '[:upper:]' '[:lower:]')
_ce=$(printf "%s" "$committerE" | tr '[:upper:]' '[:lower:]')
_include=0
if [[ "$_an" == *"$_pat"* || "$_ae" == *"$_pat"* || "$_cn" == *"$_pat"* || "$_ce" == *"$_pat"* ]]; then
_include=1
else
if git show -s --format=%b "$longH" | grep -i -F "co-authored-by" | grep -i -F -q "$AUTHOR"; then
_include=1
fi
fi
[[ $_include -eq 0 ]] && continue
fi
FILTERED_COMMITS+="$day$SEP$shortH$SEP$longH$SEP$authorN$SEP$authorE$SEP$subject\n"
done <<< "$COMMITS_RAW"
COMMITS=$(printf "%b" "$FILTERED_COMMITS" | LC_ALL=C sort -t"$SEP" -k1,1)
if [[ -z "$COMMITS" ]]; then
echo "(Sin commits en el rango)"; exit 0
fi
echo "Weekly Report (${START_FMT} - ${END_FMT})"; echo ""
# Helper para renderizar línea custom
render_commit_line() {
local fmt="$1"; local day="$2" shortH="$3" longH="$4" an="$5" ae="$6" subject="$7"
local out="$fmt"
out="${out//%ad/$day}"; out="${out//%h/$shortH}"; out="${out//%H/$longH}"
out="${out//%an/$an}"; out="${out//%ae/$ae}"; out="${out//%s/$subject}"
# Reemplazar %n por salto de línea real
out=${out//%n/$'\n'}
printf "%s" "$out"
}
# Iterar y agrupar por día
DAYS_ORDERED=()
prev_day=""
while IFS=$'\x1f' read -r day shortH longH authorN authorE subject || [[ -n "$day" ]]; do
[[ -z "$day" ]] && continue
if [[ "$day" != "$prev_day" ]]; then
if [[ -n "$prev_day" ]]; then echo ""; fi
echo "$(format_date "$day"):"
DAYS_ORDERED+=("$day")
prev_day="$day"
fi
if [[ -n "$DS_FORMAT" ]]; then
render_commit_line "$DS_FORMAT" "$day" "$shortH" "$longH" "$authorN" "$authorE" "$subject"
echo ""
else
echo " • $subject ($shortH)"
fi
done <<< "$COMMITS"
echo ""
if [[ $PATCH_FLAG -eq 1 ]]; then
OUTPUT_DIR="diff_reports"; mkdir -p "$OUTPUT_DIR"
echo "Generando parches diarios en $OUTPUT_DIR/ usando nombre '$OUTPUT_NAME'..." >&2
for day in "${DAYS_ORDERED[@]}"; do
next_day=$(date -j -f "%Y-%m-%d" "$day" -v+1d +%Y-%m-%d 2>/dev/null || date -v+1d -j -f "%Y-%m-%d" "$day" +%Y-%m-%d 2>/dev/null)
fname_date=$(format_date_filename "$day")
patch_file="$OUTPUT_DIR/${fname_date}_${OUTPUT_NAME}.patch"
if [[ -n "$AUTHOR" ]]; then
# Con filtro de autor: concatenar parches solo de commits del autor en ese día
# Extraer SHAs largos de los commits de ese día desde COMMITS (campo 3)
_day_shas=()
while IFS= read -r _line; do
[[ -z "$_line" ]] && continue
IFS=$'\x1f' read -r _d _short _long _an _ae _sub <<< "$_line"
if [[ "$_d" == "$day" ]]; then
_day_shas+=("$_long")
fi
done <<< "$(printf "%b" "$COMMITS")"
if [[ ${#_day_shas[@]} -eq 0 ]]; then
continue
fi
: > "$patch_file"
for sha in "${_day_shas[@]}"; do
# Adjuntar diff solo de ese commit
git show -p "$sha" >> "$patch_file"
printf "\n" >> "$patch_file"
done
if [[ ! -s "$patch_file" ]]; then rm -f "$patch_file"; continue; fi
echo " - $patch_file" >&2
continue
fi
# Sin filtro de autor: usar diff neto del día (baseline → end)
# baseline_commit: último commit ANTES de ese día (inicio del día) - sin filtrar por autor
baseline_commit=$(find_commit_any "$day")
# Si el día es igual o mayor que END_DATE_RAW (es el último día del rango), usar HEAD
if [[ "$day" == "$END_DATE_RAW" || "$day" > "$END_DATE_RAW" ]]; then
end_commit=$RANGE_END_REF
# Resolver HEAD a su hash real para comparación
end_commit_hash=$(git rev-parse "$end_commit" 2>/dev/null)
# Si baseline es igual a HEAD, obtener el parent del primer commit del día
if [[ "$baseline_commit" == "$end_commit_hash" ]]; then
# obtener primer commit del día usando el separador SEP
first_commit_of_day=$(printf "%b" "$COMMITS" | awk -v RS='\n' -v FS='\x1f' -v d="$day" '$1==d{print $2; exit}')
if [[ -n "$first_commit_of_day" ]]; then
parent_commit=$(git rev-parse "${first_commit_of_day}^" 2>/dev/null)
if [[ -n "$parent_commit" ]]; then
baseline_commit="$parent_commit"
else
baseline_commit="__ROOT__:${first_commit_of_day}"
fi
fi
fi
else
# Para días intermedios, buscar el último commit antes del siguiente día
end_commit=$(find_commit_any "$next_day")
if [[ -z "$end_commit" || "$end_commit" == "$baseline_commit" ]]; then
end_commit=$RANGE_END_REF
fi
fi
if [[ -z "$baseline_commit" || -z "$end_commit" || "$baseline_commit" == "$end_commit" ]]; then
continue
fi
if [[ "$baseline_commit" == __ROOT__:* ]]; then
root_commit="${baseline_commit#__ROOT__:}"
git show "$root_commit" > "$patch_file"
if [[ "$root_commit" != "$end_commit" ]]; then
git diff "$root_commit" "$end_commit" -p >> "$patch_file"
fi
else
git diff "$baseline_commit" "$end_commit" -p > "$patch_file"
fi
if [[ ! -s "$patch_file" ]]; then rm -f "$patch_file"; continue; fi
echo " - $patch_file" >&2
done
echo "Parches generados." >&2
fi
exit 0
fi
# ------------------------
# INTERACTIVE MODE
# ------------------------
if [[ $INTERACTIVE -eq 1 ]]; then
echo "Selecciona commit inicial (FROM):"; FROM=$(fzf_commit)
echo "Selecciona commit final (TO):"; TO=$(fzf_commit)
echo "Selecciona archivo específico (o ‘Esc’ para todo el diff):"; FILE=$(fzf_file)
if [[ -n "$FILE" ]]; then
git diff "$FROM" "$TO" "$FILE"
else
git diff "$FROM" "$TO"
fi
exit 0
fi
# ------------------------
# NORMAL DIFF
# ------------------------
if [[ -n "$TO" ]]; then
git diff "$FROM" "$TO" "${DIFF_OPTS[@]}"
else
git diff "$FROM" "${DIFF_OPTS[@]}"
fi