From 650470e45111aa37808895346d1f64d51256dcf9 Mon Sep 17 00:00:00 2001 From: Marko Petzold Date: Fri, 20 Nov 2026 14:46:06 +0100 Subject: [PATCH 1/2] fix: handle SIGPIPE in git log to ensure proper title retrieval for merges --- scripts/pr.sh | 4 +++- scripts/test_pr.sh | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/scripts/pr.sh b/scripts/pr.sh index 5db6a31..96eaac4 100755 --- a/scripts/pr.sh +++ b/scripts/pr.sh @@ -263,7 +263,9 @@ cmd_merge() { die "merge: $branch changes $vf ($there -> $here): that is a release (just release-patch)" done fi - [ -n "$title" ] || title=$(git log --reverse --format=%s origin/main..HEAD | head -n1) + # sed reads to the end: head would stop early, and git log's SIGPIPE (141) + # would end the script under pipefail. + [ -n "$title" ] || title=$(git log --reverse --format=%s origin/main..HEAD | sed -n 1p) [ -n "$title" ] || die "merge: no commits on $branch beyond main" if release_title "$title"; then die "merge: '$title' starts with 'release ' (the title of release pull requests); pass another title" diff --git a/scripts/test_pr.sh b/scripts/test_pr.sh index c8ff90f..e7cc4de 100755 --- a/scripts/test_pr.sh +++ b/scripts/test_pr.sh @@ -164,6 +164,14 @@ expect "merge: squash auto-merge" logged "gh pr merge feat --squash --auto --del check "merge: an existing pull request is reused" 0 merge VERSION "docs: another title" expect "merge: no second pull request" not_logged "gh pr create" +# More log output than a pipe holds: a reader that stops after the first line +# must not end the merge (git log gets SIGPIPE, 141 under pipefail). +setup VERSION 1.2.3 +echo c >>"$repo/work.txt" +git -C "$repo" commit -q -am "$(head -c 200000 /dev/zero | tr '\0' x)" +check "merge: a long branch log still gives the first commit's subject" 0 merge VERSION +expect "merge: title = the first commit's subject, not the long one" logged "gh pr create --base main --head feat --title fix the widget" + setup VERSION 1.2.3 git -C "$repo" rm -q VERSION git -C "$repo" commit -q -m "a repository without a version" From e27e5b67d6f49f8d46c34d4074b6a5dce2b2b18e Mon Sep 17 00:00:00 2001 From: Marko Petzold Date: Fri, 20 Nov 2026 15:02:05 +0100 Subject: [PATCH 2/2] fix: adjust git commit command to handle large input through stdin --- scripts/test_pr.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/test_pr.sh b/scripts/test_pr.sh index e7cc4de..e263fa5 100755 --- a/scripts/test_pr.sh +++ b/scripts/test_pr.sh @@ -168,7 +168,8 @@ expect "merge: no second pull request" not_logged "gh pr create" # must not end the merge (git log gets SIGPIPE, 141 under pipefail). setup VERSION 1.2.3 echo c >>"$repo/work.txt" -git -C "$repo" commit -q -am "$(head -c 200000 /dev/zero | tr '\0' x)" +# Through stdin: Linux refuses a single argument over 128 KiB. +head -c 200000 /dev/zero | tr '\0' x | git -C "$repo" commit -q -a -F - check "merge: a long branch log still gives the first commit's subject" 0 merge VERSION expect "merge: title = the first commit's subject, not the long one" logged "gh pr create --base main --head feat --title fix the widget"