{"thread":{"id":"11892","subject":"[PATCH] git-stash: alias 'list' to 'ls' and 'clear' to 'rm'","startedAt":"2008-02-05T10:38:19Z","lastAt":"2008-02-06T23:53:37Z","messageCount":9,"participants":["Tim Stoakes","Wincent Colaiuta","Johannes Schindelin","Brandon Casey","Paolo Bonzini","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"67500","messageId":"1202207899-28578-1-git-send-email-tim@stoakes.net","threadId":"11892","inReplyTo":null,"subject":"[PATCH] git-stash: alias 'list' to 'ls' and 'clear' to 'rm'","fromName":"Tim Stoakes","fromEmail":"tim@stoakes.net","sentAt":"2008-02-05T10:38:19Z","receivedAt":"2008-02-05T10:38:19Z","isPatch":true,"sender":{"key":"tim@stoakes.net","avatar":null},"body":"Signed-off-by: Tim Stoakes <tim@stoakes.net>\n---\n Documentation/git-stash.txt |    2 ++\n git-stash.sh                |    4 ++--\n 2 files changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-stash.txt b/Documentation/git-stash.txt\nindex cd0dc1b..fc5866f 100644\n--- a/Documentation/git-stash.txt\n+++ b/Documentation/git-stash.txt\n@@ -44,6 +44,7 @@ save [<message>]::\n \tthe description along with the stashed state.\n \n list::\n+ls::\n \n \tList the stashes that you currently have.  Each 'stash' is listed\n \twith its name (e.g. `stash@\\{0}` is the latest stash, `stash@\\{1}` is\n@@ -79,6 +80,7 @@ have conflicts (which are stored in the index, where you therefore can no\n longer apply the changes as they were originally).\n \n clear::\n+rm::\n \tRemove all the stashed states. Note that those states will then\n \tbe subject to pruning, and may be difficult or impossible to recover.\n \ndiff --git a/git-stash.sh b/git-stash.sh\nindex b00f888..8884950 100755\n--- a/git-stash.sh\n+++ b/git-stash.sh\n@@ -198,7 +198,7 @@ apply_stash () {\n \n # Main command set\n case \"$1\" in\n-list)\n+list | ls)\n \tshift\n \tif test $# = 0\n \tthen\n@@ -219,7 +219,7 @@ apply)\n \tshift\n \tapply_stash \"$@\"\n \t;;\n-clear)\n+clear | rm)\n \tshift\n \tclear_stash \"$@\"\n \t;;\n-- \n1.5.4\n"},{"id":"67505","messageId":"D512F3C0-3354-40BB-BD8D-8B3A85196825@wincent.com","threadId":"11892","inReplyTo":"1202207899-28578-1-git-send-email-tim@stoakes.net","subject":"Re: [PATCH] git-stash: alias 'list' to 'ls' and 'clear' to 'rm'","fromName":"Wincent Colaiuta","fromEmail":"win@wincent.com","sentAt":"2008-02-05T11:06:00Z","receivedAt":"2008-02-05T11:06:00Z","isPatch":true,"sender":{"key":"greg@hurrell.net","avatar":"https://avatars.githubusercontent.com/u/7074?v=4"},"body":"El 5/2/2008, a las 11:38, Tim Stoakes escribió:\n\n> clear::\n> +rm::\n> \tRemove all the stashed states. Note that those states will then\n> \tbe subject to pruning, and may be difficult or impossible to recover.\n\nIsn't \"rm\" a bit misleading here? Seeing as the clear subcommand  \nreally does an \"rm -rf\".\n\nAlso, is there any other precedent in the command suite for  \nabbreviating subcommand names in that way (ie. not just by shortening  \nthem, but by using alternative names based on filesystem commands)? It  \nstrikes me as a bit inconsistent.\n\nCheers,\nWincent\n"},{"id":"67506","messageId":"20080205112000.GD29545@mail.stoakes.net","threadId":"11892","inReplyTo":"D512F3C0-3354-40BB-BD8D-8B3A85196825@wincent.com","subject":"Re: [PATCH] git-stash: alias 'list' to 'ls' and 'clear' to 'rm'","fromName":"Tim Stoakes","fromEmail":"tim@stoakes.net","sentAt":"2008-02-05T11:20:01Z","receivedAt":"2008-02-05T11:20:01Z","isPatch":true,"sender":{"key":"tim@stoakes.net","avatar":null},"body":"Wincent Colaiuta(win@wincent.com)@050208-12:06:\n> El 5/2/2008, a las 11:38, Tim Stoakes escribi?:\n>\n>> clear::\n>> +rm::\n>> \tRemove all the stashed states. Note that those states will then\n>> \tbe subject to pruning, and may be difficult or impossible to recover.\n>\n> Isn't \"rm\" a bit misleading here? Seeing as the clear subcommand really \n> does an \"rm -rf\".\n\n$ git stash clear foo\ngit stash clear with parameters is unimplemented\n\nIt appears that 'clear' is intended to behave like 'rm', however, it\nisn't implemented yet.\n\n> Also, is there any other precedent in the command suite for abbreviating \n> subcommand names in that way (ie. not just by shortening them, but by using \n> alternative names based on filesystem commands)? It strikes me as a bit \n> inconsistent.\n\nFor example 'git remote' uses 'rm', and there exists 'git rm', 'git\nls-files', 'git ls-remotes' etc. Granted, these are not abbreviations of\nother (also available) longer term. The fact that some commands use\nshell command names, and others use words, appears to be the\ninconsistency to me. However, renaming 'git stash list' to 'git stash\nls' would break compatibility, so seemed too heavy to me.\n\nTim\n\n-- \nTim Stoakes\n"},{"id":"67507","messageId":"773F09A7-0871-4950-BDE4-D54E822C8203@wincent.com","threadId":"11892","inReplyTo":"20080205112000.GD29545@mail.stoakes.net","subject":"Re: [PATCH] git-stash: alias 'list' to 'ls' and 'clear' to 'rm'","fromName":"Wincent Colaiuta","fromEmail":"win@wincent.com","sentAt":"2008-02-05T12:12:06Z","receivedAt":"2008-02-05T12:12:06Z","isPatch":true,"sender":{"key":"greg@hurrell.net","avatar":"https://avatars.githubusercontent.com/u/7074?v=4"},"body":"El 5/2/2008, a las 12:20, Tim Stoakes escribió:\n\n> Wincent Colaiuta(win@wincent.com)@050208-12:06:\n>> El 5/2/2008, a las 11:38, Tim Stoakes escribi?:\n>>\n>>> clear::\n>>> +rm::\n>>> \tRemove all the stashed states. Note that those states will then\n>>> \tbe subject to pruning, and may be difficult or impossible to  \n>>> recover.\n>>\n>> Isn't \"rm\" a bit misleading here? Seeing as the clear subcommand  \n>> really\n>> does an \"rm -rf\".\n>\n> $ git stash clear foo\n> git stash clear with parameters is unimplemented\n>\n> It appears that 'clear' is intended to behave like 'rm', however, it\n> isn't implemented yet.\n\nNo, I don't think it was ever _intended_ to behave like rm. It does  \npretty much what the man page says, clears all stashed states and that  \nwas always its intention.\n\nBut lots of people have said that they'd like to be able to pop only  \nto topmost stash off the stack, or delete a specific stash, and some  \nhave reported being caught by surprise and clearing all stashes when  \nthey only wanted to delete one of them. There were patch(es) to the  \nmailing list a while back teaching \"git reflog\" to delete specific  \nentries, and seeing as \"git stash\" is built on top of reflogs the idea  \nwas that if someone wants to implement a subcommand for deleting  \nspecific stashes (or a push/pop kind of thing) then the reflog stuff  \nwould enable that. I think the refog patch(es) was/were from Dscho. I  \ncan't remember who/if has followed up with push/pop/delete patches for  \n\"git stash\".\n\nCheers,\nWincent\n"},{"id":"67513","messageId":"alpine.LSU.1.00.0802051401000.8543@racer.site","threadId":"11892","inReplyTo":"773F09A7-0871-4950-BDE4-D54E822C8203@wincent.com","subject":"Re: [PATCH] git-stash: alias 'list' to 'ls' and 'clear' to 'rm'","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-02-05T14:03:08Z","receivedAt":"2008-02-05T14:03:08Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 5 Feb 2008, Wincent Colaiuta wrote:\n\n> El 5/2/2008, a las 12:20, Tim Stoakes escribió:\n> \n> > Wincent Colaiuta(win@wincent.com)@050208-12:06:\n> > > El 5/2/2008, a las 11:38, Tim Stoakes escribi?:\n> > > \n> > > > clear::\n> > > > +rm::\n> > > > \tRemove all the stashed states. Note that those states will \n> > > >         then be subject to pruning, and may be difficult or \n> > > >         impossible to recover.\n> > > \n> > > Isn't \"rm\" a bit misleading here? Seeing as the clear subcommand \n> > > really does an \"rm -rf\".\n> > \n> > $ git stash clear foo\n> > git stash clear with parameters is unimplemented\n> > \n> > It appears that 'clear' is intended to behave like 'rm', however, it \n> > isn't implemented yet.\n> \n> No, I don't think it was ever _intended_ to behave like rm. It does \n> pretty much what the man page says, clears all stashed states and that \n> was always its intention.\n> \n> But lots of people have said that they'd like to be able to pop only to \n> topmost stash off the stack, or delete a specific stash, and some have \n> reported being caught by surprise and clearing all stashes when they \n> only wanted to delete one of them. There were patch(es) to the mailing \n> list a while back teaching \"git reflog\" to delete specific entries, and \n> seeing as \"git stash\" is built on top of reflogs the idea was that if \n> someone wants to implement a subcommand for deleting specific stashes \n> (or a push/pop kind of thing) then the reflog stuff would enable that. I \n> think the refog patch(es) was/were from Dscho. I can't remember who/if \n> has followed up with push/pop/delete patches for \"git stash\".\n\nThe followup was by Brandon (Cc'ed) to add \"stash drop\":\n\nhttp://article.gmane.org/gmane.comp.version-control.git/69627/match=stash+drop\n\nHowever, I did not like that \"drop\" should be introduced before \"pop\" \n(=apply&&drop).\n\nCiao,\nDscho\n"},{"id":"67666","messageId":"47A9DE06.9050307@nrlssc.navy.mil","threadId":"11892","inReplyTo":"alpine.LSU.1.00.0802051401000.8543@racer.site","subject":"[PATCH WIP] git-stash: add new 'drop' subcommand","fromName":"Brandon Casey","fromEmail":"casey@nrlssc.navy.mil","sentAt":"2008-02-06T16:19:18Z","receivedAt":"2008-02-06T16:19:18Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"This allows a single stash entry to be deleted. It takes an\noptional argument which is a stash reflog entry. If no\narguments are supplied, it drops the most recent stash entry.\n\nSigned-off-by: Brandon Casey <casey@nrlssc.navy.mil>\n---\n\n\nJohannes Schindelin wrote:\n> On Tue, 5 Feb 2008, Wincent Colaiuta wrote:\n>> I can't remember who/if \n>> has followed up with push/pop/delete patches for \"git stash\".\n>\n> The followup was by Brandon (Cc'ed) to add \"stash drop\":\n\nHere is the same patch rebased on top of next.\n\nThis doesn't work perfectly yet. One or both of refs/stash and\nlogs/refs/stash are not being updated correctly.\n\nWhen the top-most stash is dropped, refs/stash is not updated to\ncontain the commit id of the new stash@{0}. A subsequent drop then\nproduces a warning like:\n\nwarning: Log .git/logs/refs/stash unexpectedly ended on Wed, 6 Feb 2008 10:00:20 -0600.\n\nSo this is still a work in progress.\n\nAlso missing is the ability to drop multiple stash entries at\none time. I think reflog delete will have to be modified to\naccommodate this. What happens is that the deletions are performed\nin a loop, and each deletion shifts the reflog entries so that they\ndon't necessarily point to the same thing.\n\n    $ git stash list\n    stash@{0} My fourth stash\n    stash@{1} My third stash\n    stash@{2} My second stash\n    stash@{3} My first stash\n    $ git reflog delete stash@{1} stash@{2}\n    $ git stash list\n    stash@{0} My fourth stash\n    stash@{1} My second stash\n\n\"My third stash\" and \"My second stash\" should have been deleted, but\n\"My first stash\" was deleted instead.\n\n-brandon\n\n\n Documentation/git-stash.txt |    7 ++++++-\n git-stash.sh                |   25 ++++++++++++++++++++++++-\n 2 files changed, 30 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-stash.txt b/Documentation/git-stash.txt\nindex cd0dc1b..f339a57 100644\n--- a/Documentation/git-stash.txt\n+++ b/Documentation/git-stash.txt\n@@ -8,7 +8,7 @@ git-stash - Stash the changes in a dirty working directory away\n SYNOPSIS\n --------\n [verse]\n-'git-stash' (list | show [<stash>] | apply [<stash>] | clear)\n+'git-stash' (list | show [<stash>] | apply [<stash>] | clear | drop [<stash>])\n 'git-stash' [save [<message>]]\n \n DESCRIPTION\n@@ -82,6 +82,11 @@ clear::\n \tRemove all the stashed states. Note that those states will then\n \tbe subject to pruning, and may be difficult or impossible to recover.\n \n+drop [<stash>]::\n+\n+\tRemove a single stashed state from the stash list. When no `<stash>`\n+\tis given, it removes the latest one. i.e. `stash@\\{0}`\n+\n \n DISCUSSION\n ----------\ndiff --git a/git-stash.sh b/git-stash.sh\nindex b00f888..d6d77fa 100755\n--- a/git-stash.sh\n+++ b/git-stash.sh\n@@ -1,7 +1,7 @@\n #!/bin/sh\n # Copyright (c) 2007, Nanako Shiraishi\n \n-USAGE='[  | save | list | show | apply | clear | create ]'\n+USAGE='[  | save | list | show | apply | clear | drop | create ]'\n \n SUBDIRECTORY_OK=Yes\n OPTIONS_SPEC=\n@@ -196,6 +196,25 @@ apply_stash () {\n \tfi\n }\n \n+drop_stash () {\n+\thave_stash || die 'No stash entries to drop'\n+\n+\ttest $# = 0 && set -- \"$ref_stash@{0}\"\n+\n+\t# Verify supplied argument looks like a stash entry\n+\ts=$(git rev-parse --revs-only --no-flags \"$@\") &&\n+\tgit rev-parse --verify \"$s:\"   > /dev/null 2>&1 &&\n+\tgit rev-parse --verify \"$s^1:\" > /dev/null 2>&1 &&\n+\tgit rev-parse --verify \"$s^2:\" > /dev/null 2>&1 ||\n+\t\tdie \"$*: not a valid stashed state\"\n+\n+\tgit reflog delete \"$@\" && echo \"Dropped $* ($s)\" ||\n+\t\tdie \"$*: Could not drop stash entry\"\n+\n+\t# clear_stash if we just dropped the last stash entry\n+\tgit rev-parse --verify \"$ref_stash@{0}\" > /dev/null 2>&1 || clear_stash\n+}\n+\n # Main command set\n case \"$1\" in\n list)\n@@ -230,6 +249,10 @@ create)\n \tfi\n \tcreate_stash \"$*\" && echo \"$w_commit\"\n \t;;\n+drop)\n+\tshift\n+\tdrop_stash \"$@\"\n+\t;;\n *)\n \tif test $# -eq 0\n \tthen\n-- \n1.5.4.1135.g75520\n"},{"id":"67676","messageId":"47A9EA4A.60101@gnu.org","threadId":"11892","inReplyTo":"47A9DE06.9050307@nrlssc.navy.mil","subject":"Re: [PATCH WIP] git-stash: add new 'drop' subcommand","fromName":"Paolo Bonzini","fromEmail":"bonzini@gnu.org","sentAt":"2008-02-06T17:11:38Z","receivedAt":"2008-02-06T17:11:38Z","isPatch":true,"sender":{"key":"bonzini@gnu.org","avatar":"https://avatars.githubusercontent.com/u/42082?v=4"},"body":"\n> Also missing is the ability to drop multiple stash entries at\n> one time. I think reflog delete will have to be modified to\n> accommodate this. What happens is that the deletions are performed\n> in a loop, and each deletion shifts the reflog entries so that they\n> don't necessarily point to the same thing.\n\nYou just have to sort them backwards, either here or in git reflog.\n\n> +drop)\n> +\tshift\n> +\tdrop_stash \"$@\"\n\ndrop_stash $(echo \"$@\" | tr ' ' '\\n' | sort -runt\\{ -k2)\n\nPaolo\n"},{"id":"67691","messageId":"7vfxw5yimp.fsf@gitster.siamese.dyndns.org","threadId":"11892","inReplyTo":"47A9EA4A.60101@gnu.org","subject":"Re: [PATCH WIP] git-stash: add new 'drop' subcommand","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-02-06T19:44:46Z","receivedAt":"2008-02-06T19:44:46Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Paolo Bonzini <bonzini@gnu.org> writes:\n\n>> Also missing is the ability to drop multiple stash entries at\n>> one time. I think reflog delete will have to be modified to\n>> accommodate this. What happens is that the deletions are performed\n>> in a loop, and each deletion shifts the reflog entries so that they\n>> don't necessarily point to the same thing.\n>\n> You just have to sort them backwards, either here or in git reflog.\n>\n>> +drop)\n>> +\tshift\n>> +\tdrop_stash \"$@\"\n>\n> drop_stash $(echo \"$@\" | tr ' ' '\\n' | sort -runt\\{ -k2)\n\nYes, but this makes me suspect that the parameter should be\nsimply \"n m\" instead of \"stash@{n} stash@{m}\".\n"},{"id":"67735","messageId":"alpine.LSU.1.00.0802062333080.8543@racer.site","threadId":"11892","inReplyTo":"47A9DE06.9050307@nrlssc.navy.mil","subject":"Re: [PATCH WIP] git-stash: add new 'drop' subcommand","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-02-06T23:53:37Z","receivedAt":"2008-02-06T23:53:37Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 6 Feb 2008, Brandon Casey wrote:\n\n> This allows a single stash entry to be deleted. It takes an optional \n> argument which is a stash reflog entry. If no arguments are supplied, it \n> drops the most recent stash entry.\n\nJust to repeat my opinion: \"drop\" is not useful.  I think 'git stash pop \n\"$1\"' = 'git stash apply \"$1\" && git stash drop \"$1\"' would be a sane \ninterface.\n\nAnd this means that a multiple drop would become uninteresting.\n\nAs for your reflog delete with multiple arguments... Right.  This needs a \nchange in the callback data cmd_reflog_expire_cb, recno needs to become a \npointer to an int, instead of an int.  Then, cmd_delete() has to allocate \nargc + 1 int values, setting the last to -1.  It has to shift the recno \npointer in the loop to the respective next element of this allocated \narray.  The values need to be sorted after the loop in ascending order.  \nThen, in a loop from the last to the second entry, the _difference_ \narray[i] - array[i-1] has to be stored in array[i].  Also, recno has to be \nreset to the first element in the array.  Then, expire_reflog_ent() has to \nbe changed to check \"recno && *recno >= 0\", and if \"--*(cb->cmd->recno) == \n0\", it not only has to prune, but before that increment cb->cmd->recno, so \nit points to the next element of the array.\n\nAlso, I think that \"reflog delete\" should probably just realise when it \ndeleted the last element, and update the ref with the new last element (or \ndelete it if none is left).\n\nCiao,\nDscho\n"}]}