29 lines
1.5 KiB
Bash
Executable File
29 lines
1.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Row 125 r3 step 2 (no tests): per path, compare the +/- lines of r3 (wt3 against BASE3) with r2 (build.patch.r2 against 19fe85c3e).
|
|
# Prints each path whose +/- lines differ, with the difference. Context lines are not compared.
|
|
set -uo pipefail
|
|
R=$HOME/dewey-scratch/r125; C=/mnt/storage/src/mosaic-stack
|
|
BASE3=${1:?r3 base sha}; O=$R/cmp3; rm -rf "$O"; mkdir -p "$O/r2" "$O/r3" || exit 2
|
|
# r2: re-split the r2 patch per file; r3: diff of the worktree files against BASE3.
|
|
python3 -I - "$R/build.patch.r2" "$O/r2" <<'EOF'
|
|
import sys, re, os
|
|
src, out = sys.argv[1], sys.argv[2]
|
|
cur = None; buf = {}
|
|
for line in open(src, encoding='utf-8', errors='surrogateescape'):
|
|
m = re.match(r'^diff --git a/(\S+) b/(\S+)', line)
|
|
if m: cur = m.group(2); buf[cur] = []; continue
|
|
if cur is None or line.startswith(('+++ ', '--- ')): continue
|
|
if line.startswith(('+', '-')): buf[cur].append(line)
|
|
for p, ls in buf.items():
|
|
with open(os.path.join(out, p.replace('/', '%')), 'w', encoding='utf-8', errors='surrogateescape') as f: f.writelines(ls)
|
|
EOF
|
|
cd "${WT:-$R/wt3}" || exit 2
|
|
while read -r p; do
|
|
git diff --no-color "$BASE3" -- "$p" | grep -E '^[+-]' | grep -vE '^(\+\+\+ |--- )' > "$O/r3/$(echo "$p" | tr '/' '%')"
|
|
done < "$R/candidate-paths.r2.txt"
|
|
n=0
|
|
for f in "$O"/r2/*; do b=$(basename "$f")
|
|
if ! cmp -s "$f" "$O/r3/$b"; then n=$((n+1)); echo "=== $(echo "$b" | tr '%' '/')"; diff "$f" "$O/r3/$b"; fi
|
|
done
|
|
echo "paths with +/- differences: $n of $(ls "$O/r2" | wc -l)"
|