From 5b673ec0deccc385f639c4041bd2d08e873b4f8c Mon Sep 17 00:00:00 2001 From: Erik Arvidsson Date: Mon, 28 Sep 2026 16:52:32 +0200 Subject: [PATCH] fix(scripts): keep the original author when a Co-authored-by already exists sign-branch.sh added the original author as a Co-authored-by trailer with `git interpret-trailers --if-exists doNothing`. --if-exists matches on the trailer key alone, so any existing Co-authored-by (an agent's, for example) made it skip the new one and the original author was dropped from the rebuilt commit. addIfDifferent still skips an exact duplicate. --- scripts/sign-branch.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/sign-branch.sh b/scripts/sign-branch.sh index 11549ab..ce96e31 100755 --- a/scripts/sign-branch.sh +++ b/scripts/sign-branch.sh @@ -185,9 +185,11 @@ while read -r sha; do trailer=(--trailer "Co-authored-by: $(git log -1 --format='%an' "$sha") <$orig_email>") fi # ${arr[@]+...} so an empty array is not an unbound-variable error under bash 3.2, - # which is still what macOS ships as /bin/bash. + # which is still what macOS ships as /bin/bash. addIfDifferent, not doNothing: + # --if-exists matches on the key alone, so doNothing dropped the original author + # whenever the message already had any Co-authored-by (an agent's, say). msg=$(git log -1 --format='%B' "$sha" \ - | git interpret-trailers --if-exists doNothing ${trailer[@]+"${trailer[@]}"}) + | git interpret-trailers --if-exists addIfDifferent ${trailer[@]+"${trailer[@]}"}) new=$( export GIT_AUTHOR_NAME=$me_name GIT_AUTHOR_EMAIL=$me_email export GIT_AUTHOR_DATE=$(git log -1 --format='%aI' "$sha")