-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathgit-iter-diff.sh
More file actions
37 lines (26 loc) · 815 Bytes
/
git-iter-diff.sh
File metadata and controls
37 lines (26 loc) · 815 Bytes
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
#!/bin/sh
# Usage: ./git-iter-diffs.sh <start-tag> <end-tag> [output-dir]
START="$1"
END="$2"
OUTDIR="${3:-diffs}"
if [ -z "$START" ] || [ -z "$END" ]; then
echo "Usage: $0 <start-tag> <end-tag> [output-dir]"
exit 1
fi
mkdir -p "$OUTDIR" || exit 1
# Get commit list (oldest → newest), excluding START itself
COMMITS=$(git rev-list --reverse "$START..$END") || exit 1
i=1
for COMMIT in $COMMITS; do
PARENT=$(git rev-parse "$COMMIT^" 2>/dev/null)
# Skip root commits (no parent)
if [ -z "$PARENT" ]; then
continue
fi
SHORT=$(git rev-parse --short "$COMMIT")
FILE=$(printf "%s/%03d-%s.diff" "$OUTDIR" "$i" "$SHORT")
echo "Generating $FILE"
git diff "$PARENT" "$COMMIT" > "$FILE"
i=$((i + 1))
done
echo "Done. Generated $((i - 1)) diff files in $OUTDIR"