Skip to content

Instantly share code, notes, and snippets.

@rainbow23
Created September 30, 2025 07:04
Show Gist options
  • Select an option

  • Save rainbow23/3963094cdce51fbfbcfe89657ffa09dd to your computer and use it in GitHub Desktop.

Select an option

Save rainbow23/3963094cdce51fbfbcfe89657ffa09dd to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
set -euo pipefail
if [ $# -lt 1 ] || [ $# -gt 2 ]; then
echo "Usage: $0 <block-log> [output-prefix]" >&2
exit 1
fi
BLOCKLOG="$1"
PREFIX="${2:-pana}" # デフォルトは "pana"
if [ ! -f "$BLOCKLOG" ]; then
echo "Error: file not found: $BLOCKLOG" >&2
exit 1
fi
i=1
awk '
/^PANA/ { if (match($0, /[0-9a-f]{7,40}/, m)) first=m[0] }
/^NO_PANA/ { if (match($0, /[0-9a-f]{7,40}/, m)) { last=m[0]; print first, last } }
' "$BLOCKLOG" \
| while read -r first last; do
outfile="${PREFIX}${i}.patch"
echo "Generating patch for $first...$last -> $outfile"
git format-patch "${first}...${last}" -1 --stdout > "$outfile"
i=$((i+1))
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment