Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat: add interactive git worktree operations #402
base: main
Are you sure you want to change the base?
Feat: add interactive git worktree operations #402
Changes from 2 commits
2218cbd
525441f
7e50ba6
a339901
2603418
e2764ec
36fd505
bcdd3a1
a0dc127
99d05c5
6a2257c
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the default preview looks a bit dull. This should have the same options as in
$_forgit_log_preview_options
by default. It might even be possible to simply call_forgit_branch_preview
from here. This would of course make it impossible to specify different options for_forgit_branch_preview
and_forgit_worktree_preview
, but that would be fine from my side as they show the same thing (a log). I think it would be best to implementFORGIT_WORKTREE_PREVIEW_GIT_OPTS
with #396 instead. Would be interested to hear what other maintainers think. @cjappl @carlfriedrich @wfxrThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be cleaner to
cd
into the directory here instead of doing so in forgit.plugin.zsh and forgit.plugin.fish.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cd
directly in the function only changes the current directory in the script child process, not in the terminal process where the script is calledcd
andpushd
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is tricky, because the actual change of the directory is currently implemented in the shell plugin. Some users (e.g. me) do not use forgit with the plugin but in the form of a subcommand of
git
. Callinggit forgit worktree_jump
won't work at the moment, though. IMO we should find a way to make this work correctly in both usecases, or otherwise rename the function (because right now it actually does not jump).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could rename the function to
worktree_select
-gws
(but also offer the
gwj
alias which combinescd
andworktree_select
)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that there is no way to manipulate the directory of the parent process, I think this is the best compromise we can achieve. @carlfriedrich WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems resonable to me. We should add an explaining line on this to the documentation, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What exactly is
grep -v "(bare)"
filtering out? I'm new to the whole worktree thing, could you please elaborate?There are also more things we need to filter out here:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When using worktrees with a bare clone, you automatically get the
git-dir
as an entry in thegit worktree list
output (even though its not really a worktree).So for certain operations we want to filter it out (like locking, unlocking, removing, ...).
Good catch on filtering already locked (totally slipped my mind).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to allow passing in additional arguments as we do with other functions by propagating the function arguments, so that
gwl --reason <STRING>
works as expected.This also applies to the other functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a fan of the header line here. I would prefer to have no header line and simply not display the root worktree with this command. This also applies to the other functions using
--header-lines=1
. Would be interested to know what other maintainers think @cjappl @carlfriedrich @wfxr.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the way we do it with all other forgit functions as well, so I would approve it like this. @sandr01d are you questioning this principle in general for all forgit functions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird, I've never noticed. In this case I'm fine with keeping it in this PR as well.