Skip to content

update: fails with a raw git error when the branch lives in a different worktree #247

Description

@alexrinass

git flow <type> update <name> (and the top-level git flow update) checks
the named branch out directly on whatever repo the command was invoked from,
with no worktree awareness at all — unlike finish/delete, which gained a
redirect mechanism for exactly this in #175/#245. Naming a branch that has
its own separate linked worktree, from anywhere else, fails with a raw git
error instead of either redirecting or refusing cleanly.

Steps to Reproduce

  1. git flow feature start my-feature --worktree (creates a separate
    worktree for the branch, leaving the main worktree elsewhere)
  2. From the main worktree (not the feature's own): git flow feature update my-feature

Expected Behavior

Either the update runs correctly against the branch's own worktree (a
redirect, mirroring finish), or it refuses cleanly with an actionable
message naming the worktree.

Actual Behavior

Error: failed to checkout branch 'feature/my-feature': failed to checkout branch: exit status 128

Exit code 3 (generic Git error), not one of the validation exit codes the
rest of the worktree-aware commands use.

Notes

Found during the from-scratch audit that also produced #245's later fixes,
as the one bounded follow-up check explicitly scoped alongside that PR
rather than folded into it. internal/update.UpdateBranchFromParentWithMessage
is shared by both the standalone update command and finish's own
child-branch auto-update step — finish never hits this gap because it
redirects to a safe worktree (and, since #245's holistic-audit fixes,
refuses up front if an auto-update child has a conflicting worktree of its
own) before calling into it. The standalone command has no equivalent
guard.

The common case — running update from inside the branch's own worktree,
or with no worktree involved at all — is unaffected; this only surfaces
when naming a branch checked out somewhere else.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions