-
Notifications
You must be signed in to change notification settings - Fork 155
Feature: Added git stash push selector #251
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
Conversation
Thanks. Great work with #241 btw., this makes working with the code base so much easier! |
|
Cool, good idea. Going to try it out locally. Also THANK YOU for the video describing the functionality, really helps in evaluating if it's working as intended 🎉 I would be in favor of adding the message in the future, as I constantly do
When you do it, you don't have to do the -m flag, I would just do |
|
A couple more thoughts after playing with this for a bit:
|
[[ $# -ne 0 ]] && git stash push -u "$@" && returnas there would be no way to determine whether the provided arguments are intended as message or files. I personally would prefer having the message, because you could still use an alias for the other behavior. What do you think?
|
This is actually something I have implemented in my environment as a keybinding within |
I would definitely be interested in that. |
I would personally prefer the message over the files. What do you think @carlfriedrich ?
Very interesting! I would definitely be keen on seeing that. |
|
Alright, I've pushed support for adding an optional message like |
|
No idea why @wfxr got removed from the reviewers. I can't add him again... |
|
Checking it out as my main branch, so far so good.
…On Wed, Nov 30, 2022 at 4:00 PM, sandr01d ***@***.***> wrote:
No idea why ***@***.***(https://github.com/wfxr) got removed from the reviewers. I can't add him again...
—
Reply to this email directly, [view it on GitHub](#251 (comment)), or [unsubscribe](https://github.com/notifications/unsubscribe-auth/ADMDXY2VVTGSC6JEZK5QA4DWK7TANANCNFSM6AAAAAASMFIFPQ).
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
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.
Sorry for coming back to this so late.
After thinking about this a bit more, I am not sure how I like the message as a positional argument, given that we don't do anything similar elsewhere in forgit.
On other commands we allow bypassing the interactive fzf selector, so that we can use forgit commands just like git commands, e.g. git forgit checkout_branch mybranch calls git checkout mybranch directly, without opening the fzf dialog.
Similarly, I would expect git forgit stash myfile to call git stash push myfile directly.
The current implementation in this PR would still open the fzf dialog and then stash the files with the message myfile. While I definitely see that it's the most easy solution to provide a message, it doesn't feel coherent within forgit, though.
I have two suggestions to this:
-
Use
-m mymessageinstead, just like we already discussed above. We would still have to handle this independently of other positional arguments in order to get the "standard" forgit behavior for arguments as well. -
Query the message interactively after selecting the files to stash, e.g. using
read -p "Optional stash message: " stash_msg. Then append-m $stash_msgto thegit stashcommand.
This would be something new to forgit, but I would consider this most user-friendly. However, I know that @wfxr likes to keep things simple, and this suggestion might be out of scope for forgit, so maybe option 1 might be the most cohesive one.
Let me know what you all think.
|
I would be ok dropping support for the message here. I’ve been going back and forth on it.
#2 is interesting though, I could be down with that. That seems like the best solution so far.
After playing with it for a bit the ergonomics of putting the message in before you stash or look at the files is strange.
…On Mon, Dec 12, 2022 at 10:15 AM, Tim ***@***.***> wrote:
@carlfriedrich requested changes on this pull request.
***@***.***(https://github.com/sandr01d) ***@***.***(https://github.com/cjappl)
Sorry for coming back to this so late.
After thinking about this a bit more, I am not sure how I like the message as a positional argument, given that we don't do anything similar elsewhere in forgit.
On other commands we allow bypassing the interactive fzf selector, so that we can use forgit commands just like git commands, e.g. git forgit checkout_branch mybranch calls git checkout mybranch directly, without opening the fzf dialog.
Similarly, I would expect git forgit stash myfile to call git stash myfile directly.
The current implementation in this PR would still open the fzf dialog and then stash the files with the message myfile. While I definitely see that it's the most easy solution to provide a message, it doesn't feel coherent within forgit, though.
I have two suggestions to this:
-
Use -m mymessage instead, just like we already discussed above. We would still have to handle this independently of other positional arguments in order to get the "standard" forgit behavior for arguments as well.
-
Query the message interactively after selecting the files to stash, e.g. using read -p "Optional stash message: " stash_msg. Then append -m $stash_msg to the git stash command.
This would be something new to forgit, but I would consider this most user-friendly. However, I know that ***@***.***(https://github.com/wfxr) likes to keep things simple, and this suggestion might be out of scope for forgit, so maybe option 1 might be the most cohesive one.
Let me know what you all think.
—
Reply to this email directly, [view it on GitHub](#251 (review)), or [unsubscribe](https://github.com/notifications/unsubscribe-auth/ADMDXYYH764RU5OM4APMJGTWM5MSXANCNFSM6AAAAAASMFIFPQ).
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Yes, I actually agree with that. |
|
GitHub keeps removing the requested reviews for me, sorry! Could somebody re-assign @wfxr ?
I see your point there. I've tested this feature throughout the week and I also don't like that this behaves differently than everything else in forgit. Do I understand this correctly, that with 2. we would always prompt the user for a message? If so, I would favor 1. I often stash my changes for a very short period of time and don't want to add a message for that. In this kind of situations this could be annoying. |
Same here, totally agree. So let's move on with option 1 then. You can still name your stash afterwards if you like to keep it, e.g. using this alias which I got from StackOverflow: git config alias.stash-rename '!_() { rev=$(git rev-parse $1) && git stash drop $1 || exit 1 ; git stash store -m "$2" $rev; }; _' |
|
Works for me! Sorry for the churn. I appreciate you trying my suggestion out @sandr01d! :)
…On Tue, Dec 13, 2022 at 1:01 AM, Tim ***@***.***> wrote:
***@***.***(https://github.com/sandr01d)
> I see your point there. I've tested this feature throughout the week and I also don't like that this behaves differently than everything else in forgit. Do I understand this correctly, that with 2. we would always prompt the user for a message? If so, I would favor 1. I often stash my changes for a very short period of time and don't want to add a message for that. In this kind of situations this could be annoying.
Same here, totally agree. So let's move on with option 1 then.
You can still name your stash afterwards if you like to keep it, e.g. using this alias which I got [from StackOverflow](https://stackoverflow.com/questions/25931026/how-can-i-rename-a-git-stash):
git config alias.stash-rename
'
!_() { rev=$(git rev-parse $1) && git stash drop $1 || exit 1 ; git stash store -m "$2" $rev; }; _
'
—
Reply to this email directly, [view it on GitHub](#251 (comment)), or [unsubscribe](https://github.com/notifications/unsubscribe-auth/ADMDXY7NXWOFSLPCQUGNRELWNAUNLANCNFSM6AAAAAASMFIFPQ).
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
…rectly The behavior of gsp changes in the following ways: 1. The message is no longer a positional argument, instead a named argument (-m or --message) has to be used 2. -u/--include-untracked is skipped when evaluating whether or not to pass arguments to git stash push directly because when not passing arguments to git directly, -u is always used 3. All other arguments (e.g. file paths) will cause git stash push to be run directly without invoking fzf
|
I've implemented option 1 now. I find using this way more intuitive now. Let me know what you think :) |
cjappl
left a comment
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.
WFM: Will leave to @wfxr or @carlfriedrich to give final approval
Check list
Description
Added an interactive git stash push selector, that works similar to
forgit::add. The alias for it isgsp. I thought about passing arguments to the command to be able to use e.g.-m "name"to be able to name the stash entry, but had no luck implementing this so far. If anyone has an idea, let me know and I'll update my PR. From my perspective we could merge this PR without this additional feature.This closes #243
gsp.mp4
Type of change
Test environment