pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/GitoxideLabs/gitoxide/pull/2615

" /> fix: use main repo when listing worktrees by shvvkz · Pull Request #2615 · GitoxideLabs/gitoxide · GitHub
Skip to content

fix: use main repo when listing worktrees#2615

Open
Viggo Casciano (shvvkz) wants to merge 7 commits into
GitoxideLabs:mainfrom
shvvkz:fix/worktree-list-output
Open

fix: use main repo when listing worktrees#2615
Viggo Casciano (shvvkz) wants to merge 7 commits into
GitoxideLabs:mainfrom
shvvkz:fix/worktree-list-output

Conversation

@shvvkz
Copy link
Copy Markdown

@shvvkz Viggo Casciano (shvvkz) commented May 21, 2026

Reported issue

gix worktree list displayed different kinds of information in the final column depending on the row.

When run from a linked worktree, the command used the current worktree as the first row, and then listed linked worktrees from the repository metadata. This could cause the current linked worktree to appear twice while the main worktree was omitted.

This also made the output differ from git worktree list, where the main worktree is listed first and the final column consistently shows the checked-out branch, or detached HEAD state.

Closes #1649.

Summary

  • Use the main repository as the starting point when listing worktrees.
  • Open each linked worktree as its own repository before reading its HEAD information.
  • Show the checked-out branch for linked worktrees instead of the worktree ID.
  • Align the path column based on the longest worktree path, matching git worktree list more closely.

Git reference

git worktree list lists the main worktree first, followed by linked worktrees. Its final column describes the checked-out branch or detached HEAD state for each worktree, rather than the internal worktree ID.

Validation

  • cargo fmt
  • cargo check -p gitoxide-core
  • cargo check -p gitoxide
  • cargo test -p gitoxide -- worktree
  • Manually compared gix worktree list with git worktree list from:
    • the main worktree
    • a linked worktree
    • a detached linked worktree
    • linked worktrees with short and long paths

Copilot AI review requested due to automatic review settings May 21, 2026 18:00
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Updates the worktree listing implementation to consistently enumerate from the main repository, enrich each entry with HEAD/branch details, and align output formatting for human-readable display.

Changes:

  • Switch enumeration logic to use main_repo and gather worktree data into a structured representation.
  • Add WorktreeInfo and a formatter to print aligned base/head/branch columns.
  • Include short HEAD IDs and branch (or detached) status for each worktree.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread gitoxide-core/src/repository/worktree.rs
Comment thread gitoxide-core/src/repository/worktree.rs Outdated
Comment thread gitoxide-core/src/repository/worktree.rs Outdated
Copy link
Copy Markdown
Contributor

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4ab146012d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "Codex (@codex) review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".

Comment thread gitoxide-core/src/repository/worktree.rs Outdated
Comment thread gitoxide-core/src/repository/worktree.rs Outdated
@Byron Sebastian Thiel (Byron) marked this pull request as draft May 21, 2026 22:07
@Byron
Copy link
Copy Markdown
Member

Thanks, needs review comments to be addressed (and rejection is an option).
CI seems flaky these days, re-run.
Set to draft while it's being worked on.

Also note that the review checkbox would mean to me that you will still have to review something that looks generated, which also needs to be called out as per contribution guidelines.

@shvvkz
Copy link
Copy Markdown
Author

I removed the review`checkbox to avoid confusion. The code wasn’t generated by AI; I had added that checkbox because I saw similar ones in other PRs.

I replied to the review threads and committed the changes for the review comments I agreed with.

I re-ran CI, but ci/test still seems to be failing. From what I saw, it looks similar to failures on other PRs as well.

@shvvkz Viggo Casciano (shvvkz) marked this pull request as ready for review May 22, 2026 19:14
Copilot AI review requested due to automatic review settings May 22, 2026 19:14
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.

Comment on lines +60 to +63
let head = repo.head_id().map_or_else(
|_| ZERO_HEAD.to_string(),
|id| id.to_hex_with_len(HEAD_LENGTH).to_string(),
);
}
for proxy in repo.worktrees()? {

let path_width = worktrees.iter().map(|worktree| worktree.base.len()).max().unwrap_or(0);

let branch = repo.head_name()?.map_or_else(
|| "<detached>".to_string(),
|name| name.shorten().to_owned().to_string(),
Copy link
Copy Markdown
Contributor

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 08219d4dda

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "Codex (@codex) review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".

Comment on lines +60 to +62
let head = repo.head_id().map_or_else(
|_| ZERO_HEAD.to_string(),
|id| id.to_hex_with_len(HEAD_LENGTH).to_string(),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Don’t mask all HEAD lookup failures as null OIDs

create_worktree_info() currently turns any repo.head_id() error into 000000000, but head_id() fails for more than just unborn branches (for example when HEAD points to an object ID that exists in refs but the object is missing/corrupt). In that case git worktree list still reports the abbreviated ref target, whereas this change silently reports a null OID, which misrepresents the checked-out revision and hides repository corruption. Limit the null-OID fallback to the unborn-HEAD case instead of swallowing every error.

Useful? React with 👍 / 👎.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gix worktree list first row appears similar to others but differs in meaning

3 participants

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy