Skip to content

[worktrees] Crashes trying to pull a branch that is checked out in a worktree #325

Description

@yarikoptic

I have a number of worktrees

❯ git wlm
master=no   audio-video-clean              v1.11.1-168-g681b8920c  -  /home/yoh/proj/bids/bids-specification-bep047
master=no   BEP028_spec                    v1.10.1-464-g7b4fec518  -  /home/yoh/proj/bids/bids-specification-bep028
master=no   bep032                         v1.10.1-367-gbbb8e1f33  -  /home/yoh/proj/bids/bids-specification-bep032
master=no   bep038-cohorts_tsv             v1.10.1-268-ge15c61013  -  /home/yoh/proj/bids/bids-specification-bep038
master=no   bep044-yahya-master            v1.11.1-195-g907d5877f  -  /home/yoh/proj/bids/bids-specification-bep044
master=no   bf-rendering-2421              v1.11.1-41-gf7d93e225   -  /home/yoh/proj/bids/bids-specification/.git-meta/worktrees/bf-rendering-2421
master=no   enh-catch-bad-json             v1.10.1-132-g41610f3ea  -  /home/yoh/proj/bids/bids-specification-bep020
master=no   enh-released-in                v1.11.1-43-g4d0bff9e2   -  /home/yoh/proj/bids/bids-specification/.git-meta/worktrees/enh-released-in
master=no   mediafiles                     v1.11.1-77-gc68c3bbbe   -  /home/yoh/proj/bids/bids-specification-bep044-mediafiles
master=no   pr-2485                        v1.11.1-90-g688bc1ae2   -  /home/yoh/proj/bids/bids-specification-master
master=yes  enh-ci-compare-render          v1.11.1-55-g4235ae7a2   -  /home/yoh/proj/bids/bids-specification/.git-meta/worktrees/enh-ci-compare-render
master=yes  enh-prs-review-skill           v1.11.1-55-g4235ae7a2   -  /home/yoh/proj/bids/bids-specification/.git-meta/worktrees/enh-prs-review-skill
master=yes  enh-reviewers-acknowledgement  v1.11.1-55-g4235ae7a2   -  /home/yoh/proj/bids/bids-specification/.git-meta/worktrees/enh-reviewers-acknowledgement
master=yes  enh-triage                     v1.11.1-4-g9d1db0327    -  /home/yoh/proj/bids/bids-specification-enh-triage
master=yes  master                         v1.11.1-97-g91f4bfd1c   -  /home/yoh/proj/bids/bids-specification
❯ git wlm --help
'wlm' is aliased to '!f() { if [ $# -eq 0 ]; then for c in master main maint dev release; do git rev-parse --verify --quiet "refs/heads/$c" >/dev/null && set -- "$@" "$c"; done; fi; git worktree list --porcelain | awk "/^worktree / {wt=\$2} /^branch / {print wt, \$2}" | while read -r wt ref; do br=${ref#refs/heads/}; base=$(git describe --tags --match="[0-9]*.*" --match="v[0-9]*.*" "$ref" 2>/dev/null || echo -); rel=$(git describe --contains --match="[0-9]*.*" --match="v[0-9]*.*" "$ref" 2>/dev/null || echo -); line="$br	$base	$rel	$wt"; for t in "$@"; do if git merge-base --is-ancestor "$ref" "$t" 2>/dev/null; then line="$t=yes	$line"; else line="$t=no$line"; fi; done; printf "%s\n" "$line"; done | sort | column -t; }; f'

and running git-dmb 7.6.1 results in

❯ git dmb
Do you want to run "git remote update --prune" for 1 remote(s):
  - gh-yarikoptic

Update? [y/N] y

Remote 'gh-yarikoptic' is not up to date with 1 local branch(es):
  - master

This will likely impair detection of merged branches for remote 'gh-yarikoptic'.
Please consider getting it back in sync by running
  $ git push gh-yarikoptic master

and then invoking git-delete-merged-branches, again.

Do you want to run "git pull --ff-only" for 4 branch(es):
  - bep032
  - bids-2.0
  - maint/1.11.1
  - master

Pull? [y/N] y
fatal: 'bep032' is already used by worktree at '/home/yoh/proj/bids/bids-specification-bep032'

Error: Command 'git checkout -q bep032' returned non-zero exit status 128.

so seems it needs first to cd to collect listing of worktrees and if branch has one -- do its pull in there not in CWD .

Also, unclear why checkout is needed at all! should be a fetch and update-ref invocation to update the ref unless branch is checked out

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

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions