From d24f5db8d6e9d626dd504c01db7d77fb0cf7c20e Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Tue, 9 Sep 2025 08:20:45 +1000 Subject: [PATCH] add_repo: improve it add all the bits --- add_repo | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/add_repo b/add_repo index f97551e..906c405 100755 --- a/add_repo +++ b/add_repo @@ -1,14 +1,19 @@ #!/bin/sh -if [ $# -lt 2 ] || [ $# -gt 3 ]; then - printf 'usage: %s []\n' "$0" 1>&2 +if [ $# -lt 3 ] || [ $# -gt 4 ]; then + printf 'usage: %s []\n' "$0" 1>&2 exit 1 fi -name="$1" -url="$2" -branch="$3" +contacts="$1" +name="$2" +url="$3" +branch="$4" +if [ -z "$contacts" ]; then + printf 'Need contacts\n' 1>&2 + exit 1 +fi if [ -z "$name" ]; then printf 'Need a remote name\n' 1>&2 exit 1 @@ -21,8 +26,26 @@ if [ -z "$branch" ]; then branch='master' fi -if git remote add --no-tags -t "$branch" "$name" "$url"; then - cp .git/config ../etc/git-config +url=$(printf '%s\n' "$url" | sed -Ee ' + s,^(git|https)://git.kernel.org/pub/scm/linux/kernel/git/,korg:, + s,^(git|https)://git.kernel.org/pub/scm/fs/,korgfs:, + s,^git://git.infradead.org/,id:, + s,^https://github.com/,gh:, + s,^https://gitlab.freedesktop.org/,gfo:, + s,/$,,') + +if ! git remote add --no-tags -t "$branch" "$name" "$url"; then + exit 1 fi +cp .git/config ../etc/git-config + +cd ../etc/ + +printf '%s\tgit\t%s\t-\t%s\tno\n' "$contacts" "$name" "$branch" >>../etc/control + +git diff + +printf '\nYou should probably adjust where this tree is listed in the control file\n' + exit 0 -- 2.47.3