proj/gagit:main commit in: /

Michał Górny <[email protected]> Mon, 03 Aug 2026 19:22:41 +0000 (UTC)
Newsgroups gmane.linux.gentoo.cvs
Message-ID <1785784285.499ccebe43fbcefed96126dda7d024a20f46d63c.mgorny@gentoo>
commit:     499ccebe43fbcefed96126dda7d024a20f46d63c
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Mon Aug  3 19:11:25 2026 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Aug  3 19:11:25 2026 +0000
URL:        https://gitweb.gentoo.org/proj/gagit.git/commit/?id=499ccebe

Support overriding the target branch

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 gagit | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/gagit b/gagit
index 662a1f4..84acbbc 100755
--- a/gagit
+++ b/gagit
@@ -31,6 +31,9 @@ print_help() {
 	echo "  -r REMOTE, --remote REMOTE"
 	echo "                   Specify the Codeberg remote name"
 	echo "                   (default: search for codeberg.org SSH URL)"
+	echo "  -T TARGET, --target TARGET"
+	echo "                   Specify the target branch"
+	echo "                   (default: first of dev, main, master on remote)"
 	echo "  -t TOPIC, --topic TOPIC"
 	echo "                   Specify the topic to use (default: branch name)"
 	echo "  -h, --help       Print this help message"
@@ -82,6 +85,7 @@ fj_b64() {
 main() {
 	local editor=
 	local remote=
+	local target=
 	local topic=
 
 	while [[ ${#} -gt 0 ]]; do
@@ -116,6 +120,17 @@ main() {
 			--remote=*)
 				remote=${1#*=}
 				;;
+			-T|--target)
+				[[ ${#} -gt 1 ]] || die "${0}: missing argument to ${1}"
+				target=${2}
+				shift
+				;;
+			-T*)
+				target=${1#-T}
+				;;
+			--target=*)
+				target=${1#*=}
+				;;
 			-t|--topic)
 				[[ ${#} -gt 1 ]] || die "${0}: missing argument to ${1}"
 				topic=${2}
@@ -159,8 +174,10 @@ main() {
 
 	: "${topic:=${branch}}"
 
-	local target=$(find_target_branch "${remote}")
-	[[ -z ${remote} ]] && die "Unable to find a target branch"
+	if [[ -z ${target} ]]; then
+		local target=$(find_target_branch "${remote}")
+		[[ -z ${target} ]] && die "Unable to find a target branch"
+	fi
 	echo "Target branch: ${target}" >&2
 
 	local template=$(get_template)