summaryrefslogtreecommitdiffstats
path: root/pkgs
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/claude-inbox.nix17
1 files changed, 13 insertions, 4 deletions
diff --git a/pkgs/claude-inbox.nix b/pkgs/claude-inbox.nix
index bd134b3..2b8cf37 100644
--- a/pkgs/claude-inbox.nix
+++ b/pkgs/claude-inbox.nix
@@ -43,6 +43,8 @@ let
and git cherry-pick --continue, then push, or --abort), and push it.
push: master to claude; --force for a rewritten master, but only
while claude's is still the one last fetched (--force-with-lease).
+ Both push master to claude's master, and give master that upstream, if
+ it has none.
DIR: $CLAUDE_INBOX_SRC, or ~/sync/src; HOST: $CLAUDE_INBOX_VM, or claude.
Options of a command (-f, --pick, --diff) can go anywhere after it.
-- takes the next word for REPO, even list or help.
@@ -94,6 +96,13 @@ let
seen() {
git -C "$r" update-ref "refs/claude-seen/$1" "refs/remotes/claude/$1"
}
+ # master to claude's master, always; and if master has no upstream
+ # (a new one, of take --force, say), claude's, so @{u} works
+ push_master() {
+ git -C "$r" push "$@" claude master
+ git -C "$r" rev-parse -q --verify 'master@{upstream}' >/dev/null 2>&1 ||
+ git -C "$r" branch -q --set-upstream-to=claude/master master
+ }
# the command's own options (-f, --pick, --diff) anywhere among its
# arguments
force=
@@ -242,7 +251,7 @@ let
git -C "$r" branch -q --set-upstream-to="$up" master
fi
echo "claude-inbox: $name: master is $b now; the old one is $old"
- git -C "$r" push --force-with-lease claude master
+ push_master --force-with-lease
elif test -n "$pick"; then
# what git cherry calls new (+), oldest first: rebased commits
# that master has already are left out, as a rebase would
@@ -251,11 +260,11 @@ let
# shellcheck disable=SC2086
git -C "$r" cherry-pick $picks ||
die "$name: stopped picking $b (resolve, git cherry-pick --continue, then claude-inbox $name push; or git cherry-pick --abort)"
- git -C "$r" push claude master
+ push_master
else
git -C "$r" -c advice.diverging=false merge --ff-only "claude/$b" ||
die "$name: $b isn't master and more (take --pick, or --force)"
- git -C "$r" push claude master
+ push_master
fi
seen "$b"
;;
@@ -269,7 +278,7 @@ let
test -e "$(git -C "$r" rev-parse --path-format=absolute --git-path sequencer)"; then
die "$name: a cherry-pick is in progress (git cherry-pick --continue, or --abort)"
fi
- git -C "$r" push ''${force:+--force-with-lease} claude master
+ push_master ''${force:+--force-with-lease}
;;
*)
usage >&2