Changeset aedc00d in Klonkt for scripts


Ignore:
Timestamp:
06/29/2026 11:48:17 PM (2 months ago)
Author:
roboburr <roboburr@…>
Branches:
main
Children:
f882048
Parents:
1273101
Message:

fix(install): checkout -f -B <branch> FETCH_HEAD to avoid a divergent local branch

reset --hard FETCH_HEAD updates the content but leaves the CURRENT local branch (e.g. main,
when switching to the stable channel) pointing at the other branch's commit — git status
then reports "diverged from origin/main". checkout -f -B <branch> FETCH_HEAD makes the local
branch BE the target branch at the fetched tip: still robust (needs no origin/<branch> ref) and
forced (deploy), with no divergent-branch state and a clean channel switch.

  • scripts/install.sh — both the installer's update step and the generated klonkt-update now use git checkout -qf -B <branch> FETCH_HEAD

Co-Authored-By: Claude <noreply@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • scripts/install.sh

    r1273101 raedc00d  
    142142  git -C "$KLONKT_DIR" remote set-url origin "$KLONKT_REPO"
    143143  git -C "$KLONKT_DIR" fetch --depth 1 origin "$KLONKT_BRANCH"
    144   # Reset to FETCH_HEAD, not origin/$KLONKT_BRANCH: a single-branch/shallow clone (or one
    145   # originally on a different branch, e.g. main → stable) has no origin/<branch> tracking ref,
    146   # so `reset --hard origin/stable` fails with "ambiguous argument". FETCH_HEAD always points
    147   # at what we just fetched, regardless of refspec or which branch the clone started on.
    148   git -C "$KLONKT_DIR" reset --hard FETCH_HEAD
     144  # Check out FETCH_HEAD AS the target branch — not `reset --hard origin/$KLONKT_BRANCH`
     145  # (a single-branch/shallow clone, or one that started on a different branch like main,
     146  # has no origin/<branch> ref → "ambiguous argument 'origin/stable'"), and not a plain
     147  # `reset --hard FETCH_HEAD` (that would leave the OLD local branch, e.g. main, pointing at
     148  # a stable commit → `git status` reports it as diverged from origin/main). `checkout -f -B`
     149  # makes the local branch BE $KLONKT_BRANCH at the fetched tip: robust, forced, no divergence.
     150  git -C "$KLONKT_DIR" checkout -qf -B "$KLONKT_BRANCH" FETCH_HEAD
    149151else
    150152  [ -e "$KLONKT_DIR" ] && [ -n "$(ls -A "$KLONKT_DIR" 2>/dev/null)" ] && die "$KLONKT_DIR already exists and is not a git checkout. Pick --dir, or clean it up."
     
    240242B=\$(runuser -u ${KLONKT_USER} -- git -C "\$D" rev-parse HEAD 2>/dev/null || true)
    241243runuser -u ${KLONKT_USER} -- git -C "\$D" fetch --depth 1 origin ${KLONKT_BRANCH}
    242 runuser -u ${KLONKT_USER} -- git -C "\$D" reset --hard FETCH_HEAD
     244runuser -u ${KLONKT_USER} -- git -C "\$D" checkout -qf -B ${KLONKT_BRANCH} FETCH_HEAD
    243245A=\$(runuser -u ${KLONKT_USER} -- git -C "\$D" rev-parse HEAD)
    244246if [ "\$B" = "\$A" ]; then
Note: See TracChangeset for help on using the changeset viewer.