* [PATCH] git-completion: add stashes for gitk
@ 2015-03-12 0:42 Sveinung Kvilhaugsvik
2015-03-12 18:11 ` Junio C Hamano
0 siblings, 1 reply; 5+ messages in thread
From: Sveinung Kvilhaugsvik @ 2015-03-12 0:42 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Sveinung Kvilhaugsvik
Auto complete stashed modifications for gitk. This makes them easier to
discover and faster to view.
Signed-off-by: Sveinung Kvilhaugsvik <sveinung84@users.sourceforge.net>
---
contrib/completion/git-completion.bash | 2 ++
1 file changed, 2 insertions(+)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index c21190d..3a23abb 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2644,6 +2644,8 @@ __gitk_main ()
;;
esac
__git_complete_revlist
+ __gitcomp_nl_append "$(git --git-dir="$(__gitdir)" stash list \
+ | sed -n -e 's/:.*//p')"
}
if [[ -n ${ZSH_VERSION-} ]]; then
--
2.1.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] git-completion: add stashes for gitk
2015-03-12 0:42 [PATCH] git-completion: add stashes for gitk Sveinung Kvilhaugsvik
@ 2015-03-12 18:11 ` Junio C Hamano
2015-03-12 18:40 ` Junio C Hamano
0 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2015-03-12 18:11 UTC (permalink / raw)
To: Sveinung Kvilhaugsvik; +Cc: git
Sveinung Kvilhaugsvik <sveinung84@users.sourceforge.net> writes:
> Auto complete stashed modifications for gitk. This makes them easier to
> discover and faster to view.
>
> Signed-off-by: Sveinung Kvilhaugsvik <sveinung84@users.sourceforge.net>
> ---
> contrib/completion/git-completion.bash | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> index c21190d..3a23abb 100644
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -2644,6 +2644,8 @@ __gitk_main ()
> ;;
> esac
> __git_complete_revlist
> + __gitcomp_nl_append "$(git --git-dir="$(__gitdir)" stash list \
> + | sed -n -e 's/:.*//p')"
I do not find it particularly useful to expand "gitk st<TAB>" to
"gitk st" and offer "sting stash@{0} stash@{1} stash@{2} stash@{3}"
('sting' happens to be just one of the names of my branches) as
possible choices.
Because I happen to have only four stash entries right now, it may
still be manageable, but the stash entries can be dozens for some
people.
Once you have dozens of branches and tags, you learn to avoid "gitk
<TAB>" (or "git log <TAB>") to prevent the completion code from
dumping all these refnames at you. Instead, you would give a few
characters before hitting the <TAB> to limit the completion. But
this change makes it harder if what you want happens to start with
es-tee something, as you would get many stash@{...} entries along
with it. Also, when you have no ref that is named es-tee something,
"gitk st<TAB>" completes to "gitk stash@{", as if the problem the
change tries to cure is "it is unnecessarily hard to type at-mark
open-brace".
I do not have to be the target audience, though. Maybe this is
useful for some people.
A bigger question is why this change is made to gitk completion. If
this completion were useful for "gitk", wouoldn't it be equally
useful for "git log"?
Thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] git-completion: add stashes for gitk
2015-03-12 18:11 ` Junio C Hamano
@ 2015-03-12 18:40 ` Junio C Hamano
2015-03-13 17:25 ` Sveinung Kvilhaugsvik
0 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2015-03-12 18:40 UTC (permalink / raw)
To: git; +Cc: Sveinung Kvilhaugsvik
Junio C Hamano <gitster@pobox.com> writes:
> ... Also, when you have no ref that is named es-tee something,
> "gitk st<TAB>" completes to "gitk stash@{", as if the problem the
> change tries to cure is "it is unnecessarily hard to type at-mark
> open-brace".
>
> I do not have to be the target audience, though. Maybe this is
> useful for some people.
There is another thing your patch made me notice, which is not a
problem that is introduced by your desire to include stash entries
to the completion.
The way in which the users can name a stash entry is not very
descriptive. I often cannot offhand remember what stash@{2}
contains, for example, in my tree. So it is not very useful to be
offered a choice among stash@{0} stash@{1} stash@{2} and stash@{3}
by a TAB completion.
If there were a way for users to say "The one I made to stash away
that change" from the command line (I do not mean "git stash list |
grep 'that change'"), it would be good. A new syntax to name a
stash entry by pattern matching with the message given to "stash
save" could be something like (just thinking aloud, not suggesting
that this has to be our final design of that syntax):
$ git log stash@{/$pattern}
and then it mould make a lot of sense for a completion request
$ git log stash@{<TAB>
to result in something like this:
"stash@{/avoid unnecessary negation}"
"stash@{/style fix t4122}"
...
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] git-completion: add stashes for gitk
2015-03-12 18:40 ` Junio C Hamano
@ 2015-03-13 17:25 ` Sveinung Kvilhaugsvik
2015-03-14 5:18 ` Junio C Hamano
0 siblings, 1 reply; 5+ messages in thread
From: Sveinung Kvilhaugsvik @ 2015-03-13 17:25 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
Thank you for the review.
I now understand that the commit message should have provided way more
context about my use case.
I used Bazaar almost exclusively until about a year ago. Git's ability
to put stuff in the index without committing and the power of "git
rebase" covers many of the use cases I would have used shelves
("stashes") for in Bazaar. But a stash is still, as far as I know Git,
the best solution in some cases.
A Bazaar shelve ("stash") has a stable number. (Applying a shelve from
the middle of the list won't cause a renumbering) A git stash will
change its number when a new stash is added. (On the positive side
this allows stash@{2.hours.ago}) The renumbering makes it more
difficult to keep track of what is there. I therefore have more need
of a quick way to get an overview of the stashes in git than in
bazaar. You idea of using a stash's message to refer to it would solve
this.
In Bazaar I can quickly get an overview of the shelves ("stashes") by
typing "bzr qshelve" and clicking on the "View shelved changes" tab.
Its has a list of my shelves including their number and message at the
top. Under it the diff of the currently selected shelve is displayed.
This makes it fast to get an overview of the shelves.
The objective the patch tries to achieve is to speed up getting an
overview of stashed changes in gitk. A big stash in "git stash list
-p" can force a user to read it slowly or risk skipping the next
stash. By typing "gitk stash@{<TAB>" all stashes are listed. The user
can then know if there are more stashes that haven't been viewed yet
and stop reading a stash when he knows what the current stash is. (If
I understand things right "gitk stash@{.}" would have the problem of
burying old stashed under the commits above it)
> A bigger question is why this change is made to gitk completion. If
> this completion were useful for "gitk", wouoldn't it be equally
> useful for "git log"?
I must admit that I didn't know that "git log" could display the
content of a stashed change. After trying "git log -p -m stash@{0}" I
would say that adding stashes for "git log" would be slightly less
useful. "gitk stash@{0}" allows me to look at the stashed change and
find out what it contains. "git log -p" (note: no "-m" since the user
don't know that a stash is a merge commit) won't let me do that.
Another reason is that "git stash show -p stash@{0}" already is
autocompleted for those that wish to view their stash diff on the
command line)
> If there were a way for users to say "The one I made to stash away
> that change" from the command line (I do not mean "git stash list |
> grep 'that change'"), it would be good.
Great idea.
--
Helsing
Sveinung
"The Lord requires of his saints confession of sins during their whole
lives, and that without ceasing, and promises pardon. How presumptuous,
then, to exempt them from sin, or when they have stumbled, to exclude them
altogether from grace?" (sitat John Calvin)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] git-completion: add stashes for gitk
2015-03-13 17:25 ` Sveinung Kvilhaugsvik
@ 2015-03-14 5:18 ` Junio C Hamano
0 siblings, 0 replies; 5+ messages in thread
From: Junio C Hamano @ 2015-03-14 5:18 UTC (permalink / raw)
To: Sveinung Kvilhaugsvik; +Cc: git
Sveinung Kvilhaugsvik <sveinung84@users.sourceforge.net> writes:
>> A bigger question is why this change is made to gitk completion. If
>> this completion were useful for "gitk", wouoldn't it be equally
>> useful for "git log"?
> I must admit that I didn't know that "git log" could display the
> content of a stashed change. After trying "git log -p -m stash@{0}" I
> would say that adding stashes for "git log" would be slightly less
> useful.
Yeah, it would not be so useful to dig with "log" beyond the commit
that each stash entry is based on. But imagine "git show stash@{....}"
or "git log -g stash@{0}"?
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-03-14 5:22 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-12 0:42 [PATCH] git-completion: add stashes for gitk Sveinung Kvilhaugsvik
2015-03-12 18:11 ` Junio C Hamano
2015-03-12 18:40 ` Junio C Hamano
2015-03-13 17:25 ` Sveinung Kvilhaugsvik
2015-03-14 5:18 ` Junio C Hamano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).