{"thread":{"id":"38785","subject":"[PATCH] git-completion: add stashes for gitk","startedAt":"2015-03-12T00:42:41Z","lastAt":"2015-03-14T05:18:31Z","messageCount":5,"participants":["Sveinung Kvilhaugsvik","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"257579","messageId":"1426120961-2273-1-git-send-email-sveinung84@users.sourceforge.net","threadId":"38785","inReplyTo":null,"subject":"[PATCH] git-completion: add stashes for gitk","fromName":"Sveinung Kvilhaugsvik","fromEmail":"sveinung84@users.sourceforge.net","sentAt":"2015-03-12T00:42:41Z","receivedAt":"2015-03-12T00:42:41Z","isPatch":true,"sender":{"key":"sveinung84@users.sourceforge.net","avatar":"https://avatars.githubusercontent.com/u/6710184?v=4"},"body":"Auto complete stashed modifications for gitk. This makes them easier to\ndiscover and faster to view.\n\nSigned-off-by: Sveinung Kvilhaugsvik <sveinung84@users.sourceforge.net>\n---\n contrib/completion/git-completion.bash | 2 ++\n 1 file changed, 2 insertions(+)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex c21190d..3a23abb 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2644,6 +2644,8 @@ __gitk_main ()\n \t\t;;\n \tesac\n \t__git_complete_revlist\n+\t__gitcomp_nl_append \"$(git --git-dir=\"$(__gitdir)\" stash list \\\n+\t\t\t| sed -n -e 's/:.*//p')\"\n }\n \n if [[ -n ${ZSH_VERSION-} ]]; then\n-- \n2.1.4\n"},{"id":"257593","messageId":"xmqq1tku3x3c.fsf@gitster.dls.corp.google.com","threadId":"38785","inReplyTo":"1426120961-2273-1-git-send-email-sveinung84@users.sourceforge.net","subject":"Re: [PATCH] git-completion: add stashes for gitk","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-03-12T18:11:03Z","receivedAt":"2015-03-12T18:11:03Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Sveinung Kvilhaugsvik <sveinung84@users.sourceforge.net> writes:\n\n> Auto complete stashed modifications for gitk. This makes them easier to\n> discover and faster to view.\n>\n> Signed-off-by: Sveinung Kvilhaugsvik <sveinung84@users.sourceforge.net>\n> ---\n>  contrib/completion/git-completion.bash | 2 ++\n>  1 file changed, 2 insertions(+)\n>\n> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n> index c21190d..3a23abb 100644\n> --- a/contrib/completion/git-completion.bash\n> +++ b/contrib/completion/git-completion.bash\n> @@ -2644,6 +2644,8 @@ __gitk_main ()\n>  \t\t;;\n>  \tesac\n>  \t__git_complete_revlist\n> +\t__gitcomp_nl_append \"$(git --git-dir=\"$(__gitdir)\" stash list \\\n> +\t\t\t| sed -n -e 's/:.*//p')\"\n\nI do not find it particularly useful to expand \"gitk st<TAB>\" to\n\"gitk st\" and offer \"sting stash@{0} stash@{1} stash@{2} stash@{3}\"\n('sting' happens to be just one of the names of my branches) as\npossible choices.\n\nBecause I happen to have only four stash entries right now, it may\nstill be manageable, but the stash entries can be dozens for some\npeople.\n\nOnce you have dozens of branches and tags, you learn to avoid \"gitk\n<TAB>\" (or \"git log <TAB>\") to prevent the completion code from\ndumping all these refnames at you.  Instead, you would give a few\ncharacters before hitting the <TAB> to limit the completion.  But\nthis change makes it harder if what you want happens to start with\nes-tee something, as you would get many stash@{...} entries along\nwith it.  Also, when you have no ref that is named es-tee something,\n\"gitk st<TAB>\" completes to \"gitk stash@{\", as if the problem the\nchange tries to cure is \"it is unnecessarily hard to type at-mark\nopen-brace\".\n\nI do not have to be the target audience, though.  Maybe this is\nuseful for some people.\n\nA bigger question is why this change is made to gitk completion.  If\nthis completion were useful for \"gitk\", wouoldn't it be equally\nuseful for \"git log\"?\n\nThanks.\n"},{"id":"257596","messageId":"xmqqioe62h5g.fsf@gitster.dls.corp.google.com","threadId":"38785","inReplyTo":"xmqq1tku3x3c.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH] git-completion: add stashes for gitk","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-03-12T18:40:43Z","receivedAt":"2015-03-12T18:40:43Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> ...  Also, when you have no ref that is named es-tee something,\n> \"gitk st<TAB>\" completes to \"gitk stash@{\", as if the problem the\n> change tries to cure is \"it is unnecessarily hard to type at-mark\n> open-brace\".\n>\n> I do not have to be the target audience, though.  Maybe this is\n> useful for some people.\n\nThere is another thing your patch made me notice, which is not a\nproblem that is introduced by your desire to include stash entries\nto the completion.\n\nThe way in which the users can name a stash entry is not very\ndescriptive.  I often cannot offhand remember what stash@{2}\ncontains, for example, in my tree.  So it is not very useful to be\noffered a choice among stash@{0} stash@{1} stash@{2} and stash@{3}\nby a TAB completion.\n\nIf there were a way for users to say \"The one I made to stash away\nthat change\" from the command line (I do not mean \"git stash list |\ngrep 'that change'\"), it would be good.  A new syntax to name a\nstash entry by pattern matching with the message given to \"stash\nsave\" could be something like (just thinking aloud, not suggesting\nthat this has to be our final design of that syntax):\n\n    $ git log stash@{/$pattern}\n\nand then it mould make a lot of sense for a completion request\n\n    $ git log stash@{<TAB>\n\nto result in something like this:\n\n    \"stash@{/avoid unnecessary negation}\"\n    \"stash@{/style fix t4122}\"\n    ...\n"},{"id":"257644","messageId":"CANAO8VEUu9erxMLU523vQhg1hyfwVASH-Ng6YGKTN0RiB+H9FQ@mail.gmail.com","threadId":"38785","inReplyTo":"xmqqioe62h5g.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH] git-completion: add stashes for gitk","fromName":"Sveinung Kvilhaugsvik","fromEmail":"sveinung84@users.sourceforge.net","sentAt":"2015-03-13T17:25:48Z","receivedAt":"2015-03-13T17:25:48Z","isPatch":true,"sender":{"key":"sveinung84@users.sourceforge.net","avatar":"https://avatars.githubusercontent.com/u/6710184?v=4"},"body":"Thank you for the review.\n\nI now understand that the commit message should have provided way more\ncontext about my use case.\n\nI used Bazaar almost exclusively until about a year ago. Git's ability\nto put stuff in the index without committing and the power of \"git\nrebase\" covers many of the use cases I would have used shelves\n(\"stashes\") for in Bazaar. But a stash is still, as far as I know Git,\nthe best solution in some cases.\n\nA Bazaar shelve (\"stash\") has a stable number. (Applying a shelve from\nthe middle of the list won't cause a renumbering) A git stash will\nchange its number when a new stash is added. (On the positive side\nthis allows stash@{2.hours.ago}) The renumbering makes it more\ndifficult to keep track of what is there. I therefore have more need\nof a quick way to get an overview of the stashes in git than in\nbazaar. You idea of using a stash's message to refer to it would solve\nthis.\n\nIn Bazaar I can quickly get an overview of the shelves (\"stashes\") by\ntyping \"bzr qshelve\" and clicking on the \"View shelved changes\" tab.\nIts has a list of my shelves including their number and message at the\ntop. Under it the diff of the currently selected shelve is displayed.\nThis makes it fast to get an overview of the shelves.\n\nThe objective the patch tries to achieve is to speed up getting an\noverview of stashed changes in gitk. A big stash in \"git stash list\n-p\" can force a user to read it slowly or risk skipping the next\nstash. By typing \"gitk stash@{<TAB>\" all stashes are listed. The user\ncan then know if there are more stashes that haven't been viewed yet\nand stop reading a stash when he knows what the current stash is. (If\nI understand things right \"gitk stash@{.}\" would have the problem of\nburying old stashed under the commits above it)\n\n> A bigger question is why this change is made to gitk completion.  If\n> this completion were useful for \"gitk\", wouoldn't it be equally\n> useful for \"git log\"?\nI must admit that I didn't know that \"git log\" could display the\ncontent of a stashed change. After trying \"git log -p -m stash@{0}\" I\nwould say that adding stashes for \"git log\" would be slightly less\nuseful. \"gitk stash@{0}\" allows me to look at the stashed change and\nfind out what it contains. \"git log -p\" (note: no \"-m\" since the user\ndon't know that a stash is a merge commit) won't let me do that.\nAnother reason is that \"git stash show -p stash@{0}\" already is\nautocompleted for those that wish to view their stash diff on the\ncommand line)\n\n> If there were a way for users to say \"The one I made to stash away\n> that change\" from the command line (I do not mean \"git stash list |\n> grep 'that change'\"), it would be good.\nGreat idea.\n\n-- \nHelsing\nSveinung\n\n\"The Lord requires of his saints confession of sins during their whole\nlives, and that without ceasing, and promises pardon. How presumptuous,\nthen, to exempt them from sin, or when they have stumbled, to exclude them\naltogether from grace?\" (sitat John Calvin)\n"},{"id":"257663","messageId":"xmqqtwxoxil4.fsf@gitster.dls.corp.google.com","threadId":"38785","inReplyTo":"CANAO8VEUu9erxMLU523vQhg1hyfwVASH-Ng6YGKTN0RiB+H9FQ@mail.gmail.com","subject":"Re: [PATCH] git-completion: add stashes for gitk","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-03-14T05:18:31Z","receivedAt":"2015-03-14T05:18:31Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Sveinung Kvilhaugsvik <sveinung84@users.sourceforge.net> writes:\n\n>> A bigger question is why this change is made to gitk completion.  If\n>> this completion were useful for \"gitk\", wouoldn't it be equally\n>> useful for \"git log\"?\n> I must admit that I didn't know that \"git log\" could display the\n> content of a stashed change. After trying \"git log -p -m stash@{0}\" I\n> would say that adding stashes for \"git log\" would be slightly less\n> useful.\n\nYeah, it would not be so useful to dig with \"log\" beyond the commit\nthat each stash entry is based on.  But imagine \"git show stash@{....}\"\nor \"git log -g stash@{0}\"?\n"}]}