git: a1a06bc68661 - main - ghpr: Make init a little more robust

From: Warner Losh <imp_at_FreeBSD.org>
Date: Tue, 22 Apr 2025 18:17:02 UTC
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=a1a06bc686615bc4ff32b553ad1193fb30406607

commit a1a06bc686615bc4ff32b553ad1193fb30406607
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2025-04-22 16:25:17 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2025-04-22 18:16:55 +0000

    ghpr: Make init a little more robust
    
    Use newer git config subcomands and set the values so we don't get repetition.
    
    Sponsored by:           Netflix
---
 tools/tools/git/ghpr/ghpr-init.sh | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/tools/tools/git/ghpr/ghpr-init.sh b/tools/tools/git/ghpr/ghpr-init.sh
index 3b1d65c56fe2..567148b14716 100644
--- a/tools/tools/git/ghpr/ghpr-init.sh
+++ b/tools/tools/git/ghpr/ghpr-init.sh
@@ -16,12 +16,14 @@ if [ "$(git config branch.${BRANCH}.opabinia)" = "true" ]; then
     # Bail if the branch already exists
 else
     if git rev-parse --verify ${BRANCH} > /dev/null 2>&1; then
-	echo "Branch ${BRANCH} already exists, skipping creation"
+	echo "Branch ${BRANCH} already exists, skipping creation, but rebasing to ${base}"
+	git rebase ${base} ${BRANCH}
     else
 	# Create the branch and tag it as the one we're using for opabinia merging.
+	echo "Creating ${BRANCH} from ${base} to land changes"
 	git checkout -b ${BRANCH} ${base} || die "Can't create ${BRANCH}"
     fi
 fi
 
-git config --add --type bool branch.${BRANCH}.opabinia true || die "Can't annotate"
-git config --add branch.${BRANCH}.opabinia.base ${base} || die "Can't annotate"
+git config set --type bool --all branch.${BRANCH}.opabinia true || die "Can't annotate"
+git config set --all branch.${BRANCH}.opabinia.base "${base}" || die "Can't annotate"