diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2022-12-06 10:21:05 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2022-12-07 09:41:15 -0700 |
commit | e27b9fcc8e89e847a4c7f7f6a80cc15e991dd260 (patch) | |
tree | 63d70b744f188c4bcd8d4bbae53b595cd01f1b4d /lib-src | |
parent | ef847ef49ea911825ae279f892d3823ad6ca5039 (diff) | |
download | dotfiles-e27b9fcc8e89e847a4c7f7f6a80cc15e991dd260.tar.gz |
factor out some linked worktree configuration
Diffstat (limited to 'lib-src')
-rw-r--r-- | lib-src/mr/config | 47 |
1 files changed, 32 insertions, 15 deletions
diff --git a/lib-src/mr/config b/lib-src/mr/config index c3e4f841..9d8d8d0e 100644 --- a/lib-src/mr/config +++ b/lib-src/mr/config @@ -70,6 +70,29 @@ lib = mine() { workstation || on spwhitton@athena spwhitton@erebus } + # myrepos git_status assumes a separate registration for each worktree. + git_worktree_checkout () { + local repo=$1; shift + local i=0 + while [ $((i += 1)) -lt $# ]; do + set -- "$@" "$1"; shift + done + local committish=$1; shift + git -C "$repo" worktree add "$@" "$MR_REPO" "$committish" + } + git_worktree_skip () { + case "$MR_ACTION" in + checkout) + eval "set -- $(mr config "$MR_REPO" checkout)" + [ "$1" = git_worktree_checkout -a ! -d "$2" ] && return 0 + ;; + # Avoid fetching from remotes over and over again. + update) + return 0 + ;; + esac + return 1 + } #################################################################### @@ -353,26 +376,20 @@ pull = git checkout "$hostname" \ skip = lazy || ( [ "$MR_ACTION" = pull ] \ && [ -z "$(git for-each-ref '[r]efs/heads/'$hostname)" ] ) -# myrepos git_status assumes a separate registration for each worktree. -# Empty update action to prevent fetching from remotes over and over again. - [src/emacs-snapshot] -checkout = git -C "$HOME/src/emacs" worktree add -b athena/unstable \ - "$HOME/src/emacs-snapshot" demeter/athena/unstable -update = : -skip = ! workstation || ! [ -d "$HOME/src/emacs" ] +checkout = git_worktree_checkout "$HOME/src/emacs" \ + -b athena/unstable demeter/athena/unstable +skip = ! workstation || git_worktree_skip [src/emacs-dfsg] -checkout = git -C "$HOME/src/emacs" worktree add -b deb/emacs/d/sid/master \ - "$HOME/src/emacs-dfsg" debian/deb/emacs/d/sid/master -update = : -skip = ! workstation || ! [ -d "$HOME/src/emacs" ] +checkout = git_worktree_checkout "$HOME/src/emacs" \ + -b deb/emacs/d/sid/master debian/deb/emacs/d/sid/master +skip = ! workstation || git_worktree_skip [src/emacs-non-dfsg] -checkout = git -C "$HOME/src/emacs" worktree add -b deb/emacs-non-dfsg/d/sid/master \ - "$HOME/src/emacs-non-dfsg" debian/deb/emacs-non-dfsg/d/sid/master -update = : -skip = ! workstation || ! [ -d "$HOME/src/emacs" ] +checkout = git_worktree_checkout "$HOME/src/emacs" \ + -b deb/emacs-non-dfsg/d/sid/master debian/deb/emacs-non-dfsg/d/sid/master +skip = ! workstation || git_worktree_skip #################################################################### |