summaryrefslogtreecommitdiff
path: root/include/git.sh
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2024-06-07 16:15:26 +0100
committerLeah Rowe <leah@libreboot.org>2024-06-07 16:19:43 +0100
commitacd3608bb124eb9fe29b015591c4b0c83655be3c (patch)
tree3a2e5c945e95615179076fb3fc6c93195d1b4599 /include/git.sh
parent668bcbf69cbc250a49134056c1bf870af62e36e1 (diff)
git.sh: unified handling of git clone/reset/am
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'include/git.sh')
-rwxr-xr-xinclude/git.sh34
1 files changed, 15 insertions, 19 deletions
diff --git a/include/git.sh b/include/git.sh
index c723fec0..3e326255 100755
--- a/include/git.sh
+++ b/include/git.sh
@@ -43,9 +43,8 @@ prepare_new_tree()
{
printf "Creating %s tree %s (%s)\n" "$project" "$tree" "$_target"
- cp -R "src/$project/$project" "$tmpgit" || \
- $err "prepare_new_tree $project/$tree: can't make tmpclone"
- git_prep "$PWD/$cfgsdir/$tree/patches" "src/$project/$tree" "update"
+ git_prep "src/$project/$project" "src/$project/$project" \
+ "$PWD/$cfgsdir/$tree/patches" "src/$project/$tree" "update"
nuke "$project/$tree" "$project/$tree"
}
@@ -78,22 +77,18 @@ clone_project()
e "$loc" d && return 0
remkdir "${tmpgit%/*}"
-
- git clone $url "$tmpgit" || git clone $bkup_url "$tmpgit" \
- || $err "clone_project: could not download $project"
- git_prep "$PWD/config/$project/patches" "$loc"
+ git_prep "$url" "$bkup_url" "$PWD/config/$project/patches" "$loc"
}
git_prep()
{
- _patchdir="$1"
- _loc="$2"
+ _patchdir="$3" # $1 and $2 are gitrepo and gitrepo_backup
+ _loc="$4"
[ -z "${rev+x}" ] && $err "git_prep $_loc: rev not set"
- git -C "$tmpgit" reset --hard $rev || $err "git -C $_loc: !reset $rev"
- git_am_patches "$tmpgit" "$_patchdir" || $err "!am $_loc $_patchdir"
- if singletree "$project" || [ $# -gt 2 ]; then
+ tmpclone "$1" "$2" "$tmpgit" "$rev" "$_patchdir"
+ if singletree "$project" || [ $# -gt 4 ]; then
prep_submodules "$_loc"
fi
@@ -124,23 +119,24 @@ fetch_submodule()
{
mcfgdir="$mdir/${1##*/}"
eval "$(setvars "" subrev subrepo subrepo_bkup)"
-
[ ! -f "$mcfgdir/module.cfg" ] || . "$mcfgdir/module.cfg" || \
$err "! . $mcfgdir/module.cfg"
[ -z "$subrepo" ] && [ -z "$subrepo_bkup" ] && return 0
-
for mvar in subrepo subrepo_bkup subrev; do
eval "[ -n \"\$$mvar\" ] || $err \"$1, $mdir: $mvar unset\""
done
rm -Rf "$tmpgit/$1" || $err "!rm '$mdir' '$1'"
- git clone $subrepo "$tmpgit/$1" || git clone $subrepo_bkup \
- "$tmpgit/$1" || $err "clone_project: could not download $project"
- git -C "$tmpgit/$1" reset --hard "$subrev" || \
- $err "$mdir $1: cannot reset git revision"
+ tmpclone "$subrepo" "$subrepo_bkup" "$tmpdir/$1" "$subrev" \
+ "$mdir/${1##*/}/patches"
+}
- git_am_patches "$tmpgit/$1" "$mdir/${1##*/}/patches"
+tmpclone()
+{
+ git clone $1 "$3" || git clone $2 "$3" || $err "!clone $1 $2 $3 $4 $5"
+ git -C "$3" reset --hard "$4" || $err "!reset $1 $2 $3 $4 $5"
+ git_am_patches "$3" "$5"
}
git_am_patches()