{"thread":{"id":"17677","subject":"[RFC] New command: 'git snapshot'.","startedAt":"2009-02-09T18:54:58Z","lastAt":"2009-02-11T20:40:15Z","messageCount":16,"participants":["Fabio Augusto Dal Castel","Giuseppe Bilotta","Brandon Casey","Sitaram Chamarty","Jon Loeliger","Junio C Hamano","Jeff King","Geoffrey Lee","Matthieu Moy"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"103871","messageId":"38cfbb550902091054u78f2e706u67752b4dc9de6c3b@mail.gmail.com","threadId":"17677","inReplyTo":null,"subject":"[RFC] New command: 'git snapshot'.","fromName":"Fabio Augusto Dal Castel","fromEmail":"fdcastel@gmail.com","sentAt":"2009-02-09T18:54:58Z","receivedAt":"2009-02-09T18:54:58Z","isPatch":false,"sender":{"key":"fdcastel@gmail.com","avatar":null},"body":"Abstract: Requesting suggestions for a new command to save the current\nworking dir state without collateral effects.\n\n\nQ. \"Why another command? We already have stash!\"\n\nA. Stash was always subject of many controversies. Trying to stay\napart from near-religious debates like\n\n* whether the syntax should be \"dangerous\" [sic] or \"newbie friendly\";\n* whether untracked files should be stashed or not;\n* whether stashes should expire or not\n\nthe fact is that different users have different needs and those\ndiscussions arise when trying to apply different behaviors to same\ncommand. Stash was always oriented to a 'pull into a dirty tree'\nsolution, and serves this purpose very well.\n\nSo, I propose a new 'git snapshot' command to use when 'git stash'\nbehaviour is not exactly what user needs.\n\n\nQ. Why on earth would someone want this instead of our lovely stash?\n\nA. Sometimes what we want is just a (you bet) \"snapshot\" of working\ndir. Something like \"Just remember. Do not touch.\"\n\nIn the excellent paper \"Git From the Bottom Up\" John Wiegley suggests\na \"git-snapshot\" script to be used in a cron job -- nothing more than:\n\ngit stash && git stash apply\n\nHowever, this is not an optimal solution for a 'real' snapshot:\n\n* It makes TWO unnecessary changes to working dir (to HEAD and back\nagain). Besides the heavier disk usage, this could, for example,\ncause an editor using inotify to think that the current file was\nexternally changed by another program and annoy the user asking if he\nwants to load the new content.\n\n* It will not save untracked files. An user counting with periodic\nsnapshots and working furiously for three days may be disappointed (to\nsay the least) when discover that a significant part of his work were\nNOT saved in history because contents actually were in new (untracked)\nfiles.\n\n* Stashes expire (already discussed in\nhttp://thread.gmane.org/gmane.comp.version-control.git/84665 )\n\nIn resume, all that 'git snapshot' would NOT do.\n\n\nQ. What are the differences between 'git stash' and 'git snapshot'?\n\nA.\n\ngit stash                         git snapshot\n\ntemporary/short-term              permanent/long-term\nreflog-based                      branch-based\napplies a \"git reset --hard\"      leaves working dir / index untouched\ndoes not stash untracked files    snapshots ALL files (except ignored)\n\n\nQ. How it works?\n\nA.[What follows is a textual description of my current implementation.\nOf course, there is nothing carved in stone: suggestions and comments\nare MORE than welcome.]\n\nAll snapshots are stored in a special branch (\"<branch>_snapshots\").\nSo, if you are on 'master' branch, a 'git snapshot' will create/use a\n'master_snapshots' branch.\n\nIf anything differs from last snapshot (a change into index, into a\nfile, or a new untracked file) the command will:\n\n1. Save the current index state;\n2. Add untracked/updated files to index;\n3. Create a new commit for the current state in snapshots branch;\n4. Update the HEAD of snapshots branch to this new commit;\n5. Restore the original index state (of step 1).\n\nHowever, if the current state of working dir is equal to the last\nsnapshot taken, there is no need to make another identical copy and\nthe command will just exit.\n\nThe command would not work if the current branch is a detached head.\nIt is by design, but just because I had a no better idea of what to do\nin this case <g>.\n\nTypical usage:\n\n\t(hack hack hack)\n\tgit-snapshot\n\t(hack hack hack)\n\tgit-snapshot\n\t(...)\n\nOpen questions / To-do list:\n\n- How to 'rollback' to a specific snapshot?\n  - Make a 'git-rollback <snapshot>' ? It would:\n   - Apply diffs between <snapshot> and current head (possible loss!).\n   - Restore the original index (where to save it? 'Hidden' commit?)\n\n\nBest Regards,\n\nFabio.\n\n\n\n\n\ndiff --git a/git-snapshot.sh b/git-snapshot.sh\nnew file mode 100644\nindex 0000000..5f19a6f\n--- /dev/null\n+++ b/git-snapshot.sh\n@@ -0,0 +1,61 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2009 F.D.Castel.\n+#\n+\n+. git-sh-setup\n+require_work_tree\n+cd_to_toplevel\n+\n+# Get current branch.\n+current_branch=$(git symbolic-ref -q HEAD | sed -e 's|^refs/heads/||')\n+test -z \"$current_branch\" &&\n+\tdie 'fatal: Cannot take snapshot from a detached HEAD.'\n+\t\n+# Save the current index state.\n+original_index=$(git write-tree) ||\n+\tdie \"fatal: Error saving original index state.\"\n+\n+# Create commit message describing the changes.\n+temp_file=\"$TMP/.git-snapshot\"\n+(\n+\tdate -R\n+\tprintf '\\n* New files:\\n'\t\t# ToDo: How to get only untracked? (without added)\n+\tgit ls-files --full-name -o\n+\tprintf '\\n* Changed files:\\n'\n+\tgit ls-files --full-name -m\t\t# ToDo: How to get only modified?\n(without deleted)\n+\tprintf '\\n* Deleted files:\\n'\n+\tgit ls-files --full-name -d\n+) > \"${temp_file}.message\"\n+\n+# Add untracked/updated files to index.\n+git add --all . ||\n+\tdie \"fatal: Error adding current state to index.\"\n+\n+# Set clean up trap (restore original index and delete temp files on exit).\n+trap \"git read-tree $original_index && rm -f '$temp_file.*'\" 0\n+\n+# Create snapshots branch (if needed).\n+snapshots_branch=\"${current_branch}_snapshots\"\n+git show-ref --verify --quiet -- \"refs/heads/$snapshots_branch\" ||\n+\tgit branch $snapshots_branch\n+\n+# Compare changes with last snapshot.\n+git diff --exit-code --raw --cached $snapshots_branch &&\n+\tdie 'Nothing to do: no changes since the last snapshot.'\n+\n+# Create a new commit for the current state in snapshots branch.\n+new_index=$(git write-tree) &&\n+\tsnapshots_head=$(git rev-parse --verify $snapshots_branch) &&\n+\tnew_commit=$(cat ${temp_file}.message | git commit-tree $new_index\n-p $snapshots_head) ||\n+\t\tdie \"fatal: Error commiting current state into snapshots branch.\"\n+\n+# ToDo: Where to store the original index (for a future 'rollback')?\n+#original_index_commit=$(printf '(original index for child commit)' |\ngit commit-tree $original_index)\n+\n+# Update the HEAD of snapshots branch to this new commit.\n+git symbolic-ref HEAD refs/heads/$snapshots_branch &&\n+\tgit update-ref -m \"'Snapshotting $current_branch to $new_commit'\"\nHEAD $new_commit $snapshots_head &&\n+\tgit symbolic-ref HEAD refs/heads/$current_branch ||\n+\t\tdie \"fatal: Error updating HEAD of snapshots branch.\"\n+\t\t\n\\ No newline at end of file\n"},{"id":"103883","messageId":"gmq1hu$ccn$1@ger.gmane.org","threadId":"17677","inReplyTo":"38cfbb550902091054u78f2e706u67752b4dc9de6c3b@mail.gmail.com","subject":"Re: [RFC] New command: 'git snapshot'.","fromName":"Giuseppe Bilotta","fromEmail":"giuseppe.bilotta@gmail.com","sentAt":"2009-02-09T19:52:30Z","receivedAt":"2009-02-09T19:52:30Z","isPatch":false,"sender":{"key":"giuseppe.bilotta@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1464?v=4"},"body":"On Monday 09 February 2009 19:54, Fabio Augusto Dal Castel wrote:\n\n> Q. What are the differences between 'git stash' and 'git snapshot'?\n> \n> A.\n> \n> git stash                         git snapshot\n> \n> temporary/short-term              permanent/long-term\n> reflog-based                      branch-based\n> applies a \"git reset --hard\"      leaves working dir / index untouched\n> does not stash untracked files    snapshots ALL files (except ignored)\n\nI like this snapshot idea, and I clearly see the difference\nbetween this and stash.\n\nFor example, I use stash when I want to move away from the current\nhacking because a new, more urgent change must be done somewhere\nelse.\n\nInstead, I see a usecase for git snapshot for progressive\ntemporary snapshot while working towards a more complex feature\nwhile needing temporary intermediate checkpoints: an effect\nsimilar to what I currently achieve using git commit (a first\ntime) and git commit --amend as my work progresses.\n\nIn this respect, I wouldn't agree with the first difference you\nremarked, but that's just the usecase I have in mind.\n\n> Q. How it works?\n> \n> A.[What follows is a textual description of my current implementation.\n> Of course, there is nothing carved in stone: suggestions and comments\n> are MORE than welcome.]\n> \n> All snapshots are stored in a special branch (\"<branch>_snapshots\").\n> So, if you are on 'master' branch, a 'git snapshot' will create/use a\n> 'master_snapshots' branch.\n\nI'm not sure I like the idea of creating these branches with these\nbranchnames. What about using another refs/ subtree? So\nrefs/snapshots/somebranchname would contain the snapshot paired\nwith refs/heads/somebranchname.\n\n-- \nGiuseppe \"Oblomov\" Bilotta\n"},{"id":"103920","messageId":"etsYQzEDjdk-_NxhvO3i6EyShR6eZ202GBdQx7ZZpPHH5iNfWiuV6g@cipher.nrlssc.navy.mil","threadId":"17677","inReplyTo":"38cfbb550902091054u78f2e706u67752b4dc9de6c3b@mail.gmail.com","subject":"Re: [RFC] New command: 'git snapshot'.","fromName":"Brandon Casey","fromEmail":"casey@nrlssc.navy.mil","sentAt":"2009-02-09T22:36:31Z","receivedAt":"2009-02-09T22:36:31Z","isPatch":false,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"Fabio Augusto Dal Castel wrote:\n\n> * Stashes expire (already discussed in\n> http://thread.gmane.org/gmane.comp.version-control.git/84665 )\n\nCorrection: stash expiration is now configurable and does not expire by\n            default thanks to Junio.\n\nNot sure if I'd use this snapshot tool, but per-branch stash would\nprobably be useful.  If stashes were per-branch, then it would probably\nbe pretty easy to build this snapshot tool on top of it.\n\n-brandon\n"},{"id":"103947","messageId":"slrngp21uj.i22.sitaramc@sitaramc.homelinux.net","threadId":"17677","inReplyTo":"etsYQzEDjdk-_NxhvO3i6EyShR6eZ202GBdQx7ZZpPHH5iNfWiuV6g@cipher.nrlssc.navy.mil","subject":"Re: [RFC] New command: 'git snapshot'.","fromName":"Sitaram Chamarty","fromEmail":"sitaramc@gmail.com","sentAt":"2009-02-10T04:51:31Z","receivedAt":"2009-02-10T04:51:31Z","isPatch":false,"sender":{"key":"sitaramc@gmail.com","avatar":"https://avatars.githubusercontent.com/u/43316?v=4"},"body":"On 2009-02-09, Brandon Casey <casey@nrlssc.navy.mil> wrote:\n\n> Not sure if I'd use this snapshot tool, but per-branch stash would\n> probably be useful.  If stashes were per-branch, then it would probably\n> be pretty easy to build this snapshot tool on top of it.\n\nI use cross-branch stashes all the time.  Stash it here, go\nthere, and pop the stash.  I hope that does not change :-)\n"},{"id":"104065","messageId":"1234295272.10335.26.camel@ld0161-tx32","threadId":"17677","inReplyTo":"slrngp21uj.i22.sitaramc@sitaramc.homelinux.net","subject":"Re: [RFC] New command: 'git snapshot'.","fromName":"Jon Loeliger","fromEmail":"jdl@freescale.com","sentAt":"2009-02-10T19:47:52Z","receivedAt":"2009-02-10T19:47:52Z","isPatch":false,"sender":{"key":"jdl@jdl.com","avatar":"https://gravatar.com/avatar/75ce9a10b151acd2c28ec4ab2136dba7b2ff1634530bd04b155981a749d08a64?d=mp&s=160"},"body":"On Tue, 2009-02-10 at 04:51 +0000, Sitaram Chamarty wrote:\n\n> I use cross-branch stashes all the time.  Stash it here, go\n> there, and pop the stash.  I hope that does not change :-)\n\nPerhaps 'git checkout -m other_branch'?\n\njdl\n"},{"id":"104071","messageId":"7v7i3ym3tr.fsf@gitster.siamese.dyndns.org","threadId":"17677","inReplyTo":"1234295272.10335.26.camel@ld0161-tx32","subject":"Re: [RFC] New command: 'git snapshot'.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-02-10T20:31:28Z","receivedAt":"2009-02-10T20:31:28Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jon Loeliger <jdl@freescale.com> writes:\n\n> On Tue, 2009-02-10 at 04:51 +0000, Sitaram Chamarty wrote:\n>\n>> I use cross-branch stashes all the time.  Stash it here, go\n>> there, and pop the stash.  I hope that does not change :-)\n>\n> Perhaps 'git checkout -m other_branch'?\n\nSure, or even \"git checkout other_branch\" without -m.\n\n\"Stash it here, go there, and pop the stash\" is what you would use when\nyou have many changes that you _know_ \"checkout -m\" will run a 3-way merge\nto produce a heavy conflict, and you suspect you may need to be able to\nretry the unstashing after taking a break.\n\nIf you are lucky and manage to resolve the conflicts easily (or did not\neven get conflicts when applying), then pop will drop the stash and you\nhave everything you want in your index and the work tree.  Otherwise, your\nwork tree would be a mess, and you may have to \"reset --hard\" out to start\nfrom scratch, but then the stash will still be there.\n"},{"id":"104072","messageId":"38cfbb550902101240x1202c592ra7eb01d66e22da43@mail.gmail.com","threadId":"17677","inReplyTo":"etsYQzEDjdk-_NxhvO3i6EyShR6eZ202GBdQx7ZZpPHH5iNfWiuV6g@cipher.nrlssc.navy.mil","subject":"Re: [RFC] New command: 'git snapshot'.","fromName":"Fabio Augusto Dal Castel","fromEmail":"fdcastel@gmail.com","sentAt":"2009-02-10T20:40:34Z","receivedAt":"2009-02-10T20:40:34Z","isPatch":false,"sender":{"key":"fdcastel@gmail.com","avatar":null},"body":"Brandon,\n\n> If stashes were per-branch, then it would probably\n> be pretty easy to build this snapshot tool on top of it.\n\nOr the other way around <g>.\n\nRemember that 'stash' is actually TWO commands in one:\n* Save current state\n* Reset to HEAD\n\nMy primary reason to use snapshots is to AVOID the second step.\n"},{"id":"104074","messageId":"38cfbb550902101248v16f0f0f0v6a48cabf498317cf@mail.gmail.com","threadId":"17677","inReplyTo":"38cfbb550902101232l4c83b6dfjc70e1e2f79a8c3c1@mail.gmail.com","subject":"Re: [RFC] New command: 'git snapshot'.","fromName":"Fabio Augusto Dal Castel","fromEmail":"fdcastel@gmail.com","sentAt":"2009-02-10T20:48:33Z","receivedAt":"2009-02-10T20:48:33Z","isPatch":false,"sender":{"key":"fdcastel@gmail.com","avatar":null},"body":"Giuseppe\n\n> I use stash when I want to move away from the current\n> hacking because a new, more urgent change must be done\n> somewhere else\n\nYes. That is exactly what stash is for. Temporary fixes. Now...\n\n\n> Instead, I see a usecase for git snapshot for progressive\n> temporary snapshot while working towards a more complex feature\n> while needing temporary intermediate checkpoints\n\nThat's the idea. You could take a snapshot automatically every x\nminutes. For example: I'm testing it taking a snapshot on every\nbuild/compile of my project (and it is going fine, BTW).\n\n\n> similar to what I currently achieve using git commit (a first\n> time) and git commit --amend as my work progresses.\n\nExcept that, in this solution, you have only ONE saved state.\nAlso, it needs to be done manually. I wanted something automatic (like\nJohn Wiegley's sugestion)\n\n\n\n> In this respect, I wouldn't agree with the first difference you\n> remarked, but that's just the usecase I have in mind.\n\nMaking another analogy: I see stash like a stack (you push/stash, and\nafter you pop/apply). And I don't see stacks as a good long-term\nstorages <g> (ok, you CAN 'cheat' and see all items other than the\nfirst)\n\nSnapshots would be like a queue: You can keep it entirely, or you can\nkeep only the last 'n' interesting snapshots, removing the others.\n\n\n\n\n> I'm not sure I like the idea of creating these branches with these\n> branchnames. What about using another refs/ subtree?\n\nI'm also not sure <g>. The idea of refs/ is a good one, too (and could\nsolve the problem of 'where to store the original index?'). But my\nfirst idea of using branches was to avoid a load of another\n'maintenance' commands ('snapshot list', 'snapshot delete', etc) and\nto use a more known facility (branches).\n\n\n\nBest regards,\n\nFabio.\n"},{"id":"104102","messageId":"20090210230054.GD26954@coredump.intra.peff.net","threadId":"17677","inReplyTo":"38cfbb550902101240x1202c592ra7eb01d66e22da43@mail.gmail.com","subject":"Re: [RFC] New command: 'git snapshot'.","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-02-10T23:00:54Z","receivedAt":"2009-02-10T23:00:54Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Feb 10, 2009 at 06:40:34PM -0200, Fabio Augusto Dal Castel wrote:\n\n> > If stashes were per-branch, then it would probably\n> > be pretty easy to build this snapshot tool on top of it.\n> \n> Or the other way around <g>.\n> \n> Remember that 'stash' is actually TWO commands in one:\n> * Save current state\n> * Reset to HEAD\n> \n> My primary reason to use snapshots is to AVOID the second step.\n\nDoesn't that argue for \"git stash --no-reset\" or similar instead of a\nseparate command?\n\n-Peff\n"},{"id":"104104","messageId":"7vy6wdkhzk.fsf@gitster.siamese.dyndns.org","threadId":"17677","inReplyTo":"20090210230054.GD26954@coredump.intra.peff.net","subject":"Re: [RFC] New command: 'git snapshot'.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-02-10T23:08:31Z","receivedAt":"2009-02-10T23:08:31Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> On Tue, Feb 10, 2009 at 06:40:34PM -0200, Fabio Augusto Dal Castel wrote:\n>\n>> > If stashes were per-branch, then it would probably\n>> > be pretty easy to build this snapshot tool on top of it.\n>> \n>> Or the other way around <g>.\n>> \n>> Remember that 'stash' is actually TWO commands in one:\n>> * Save current state\n>> * Reset to HEAD\n>> \n>> My primary reason to use snapshots is to AVOID the second step.\n>\n> Doesn't that argue for \"git stash --no-reset\" or similar instead of a\n> separate command?\n\nHow is it different from \"git stash create\"?\n"},{"id":"104113","messageId":"20090210233801.GA9617@coredump.intra.peff.net","threadId":"17677","inReplyTo":"7vy6wdkhzk.fsf@gitster.siamese.dyndns.org","subject":"Re: [RFC] New command: 'git snapshot'.","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-02-10T23:38:02Z","receivedAt":"2009-02-10T23:38:02Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Feb 10, 2009 at 03:08:31PM -0800, Junio C Hamano wrote:\n\n> >> Remember that 'stash' is actually TWO commands in one:\n> >> * Save current state\n> >> * Reset to HEAD\n> >> \n> >> My primary reason to use snapshots is to AVOID the second step.\n> >\n> > Doesn't that argue for \"git stash --no-reset\" or similar instead of a\n> > separate command?\n> \n> How is it different from \"git stash create\"?\n\nAccording to the man page, \"git stash create\" doesn't even store it in a\nref. I think the point would be to store it in a ref somewhere (as \"git\nstash save\" does), but not do the reset.\n\nBut I have never once used \"git stash create\", so maybe I am\nmisunderstanding it.\n\n-Peff\n"},{"id":"104114","messageId":"83d7aaa40902101539m3c40deeeo2d452f6dbb7c379c@mail.gmail.com","threadId":"17677","inReplyTo":"7vy6wdkhzk.fsf@gitster.siamese.dyndns.org","subject":"Re: [RFC] New command: 'git snapshot'.","fromName":"Geoffrey Lee","fromEmail":"geoffreyj.lee@gmail.com","sentAt":"2009-02-10T23:39:19Z","receivedAt":"2009-02-10T23:39:19Z","isPatch":false,"sender":{"key":"geoffreyj.lee@gmail.com","avatar":"https://gravatar.com/avatar/eda7290effb2fe936a54951db47d049adf71d6bd41b70c56dd9dedc8f3327c39?d=mp&s=160"},"body":"On Tue, Feb 10, 2009 at 3:08 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Jeff King <peff@peff.net> writes:\n> How is it different from \"git stash create\"?\n\nGit stash doesn't touch untracked files, whereas git snapshot would.\nTake another closer look at the table in the original post titled\n\"What are the differences between 'git stash' and 'git snapshot'?\"\n\n-Geoffrey Lee\n"},{"id":"104132","messageId":"slrngp4a3b.ual.sitaramc@sitaramc.homelinux.net","threadId":"17677","inReplyTo":"1234295272.10335.26.camel@ld0161-tx32","subject":"Re: [RFC] New command: 'git snapshot'.","fromName":"Sitaram Chamarty","fromEmail":"sitaramc@gmail.com","sentAt":"2009-02-11T01:22:51Z","receivedAt":"2009-02-11T01:22:51Z","isPatch":false,"sender":{"key":"sitaramc@gmail.com","avatar":"https://avatars.githubusercontent.com/u/43316?v=4"},"body":"On 2009-02-10, Jon Loeliger <jdl@freescale.com> wrote:\n> On Tue, 2009-02-10 at 04:51 +0000, Sitaram Chamarty wrote:\n>\n>> I use cross-branch stashes all the time.  Stash it here, go\n>> there, and pop the stash.  I hope that does not change :-)\n>\n> Perhaps 'git checkout -m other_branch'?\n\nAaah -- thanks!  I should have known there'd be an easier\nway... :-)\n"},{"id":"104154","messageId":"vpq3aelcpjk.fsf@bauges.imag.fr","threadId":"17677","inReplyTo":"20090210230054.GD26954@coredump.intra.peff.net","subject":"Re: [RFC] New command: 'git snapshot'.","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2009-02-11T09:04:47Z","receivedAt":"2009-02-11T09:04:47Z","isPatch":false,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> On Tue, Feb 10, 2009 at 06:40:34PM -0200, Fabio Augusto Dal Castel wrote:\n>\n>> Remember that 'stash' is actually TWO commands in one:\n>> * Save current state\n>> * Reset to HEAD\n>> \n>> My primary reason to use snapshots is to AVOID the second step.\n>\n> Doesn't that argue for \"git stash --no-reset\" or similar instead of a\n> separate command?\n\nI also think adding options to \"git stash\" would be better than\ncreating a new command. The \"git has too many commands\" is already one\nof the blocking factors for newcommers.\n\nAnd indeed, I don't think the choice in the comparison table between\nstash and snapshot should be all-or-nothing. There could be individual\noptions like --save-untracked, --per-branch, ... (--no-reset would\nprobably be redundant with stash create, but maybe stash create needs\na --keep-object-somewhere-in-a-reference like option). Then, having\n\"git snapshot\" would just be a matter of creating the accurate alias.\n\n-- \nMatthieu\n"},{"id":"104182","messageId":"20090211134322.GB19223@coredump.intra.peff.net","threadId":"17677","inReplyTo":"83d7aaa40902101539m3c40deeeo2d452f6dbb7c379c@mail.gmail.com","subject":"Re: [RFC] New command: 'git snapshot'.","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-02-11T13:43:22Z","receivedAt":"2009-02-11T13:43:22Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Feb 10, 2009 at 03:39:19PM -0800, Geoffrey Lee wrote:\n\n> Git stash doesn't touch untracked files, whereas git snapshot would.\n> Take another closer look at the table in the original post titled\n> \"What are the differences between 'git stash' and 'git snapshot'?\"\n\nSure, I was just responding to that particular statement about reset.\nBut I think it generalizes. Why not \"--untracked\" as an option?\n\nIn other words, there are several behaviors that people might not like\nabout stash, and I think they can be combined in multiple ways. So one\nsolution is to make another command which chooses a different set of\nbehaviors. But what about the person who wants \"--untracked\" but not\n\"--no-reset\"? Do they make a third command?\n\nSo it is much more flexible to make orthogonal switches that can be\nturned on and off independently. And of course if you have a workflow\nwhich always uses a particular set of switches, it is convenient to hide\nit behind an alias.  And if there are just a few workflows that are\ncommon to a lot of people, those can graduate to become git commands.\n\nBut this proposal seems to be starting in the opposite direction, with a\nnew command that is closely related to stash but changes a few\nbehaviors. I haven't seen a convincing argument that between stash and\nsnapshot, git will now serve all or most people's workflows (and we\ndon't need another command that does something in between).\n\n-Peff\n"},{"id":"104291","messageId":"38cfbb550902111240v6e593bfw5c8347d92fe8f767@mail.gmail.com","threadId":"17677","inReplyTo":"vpq3aelcpjk.fsf@bauges.imag.fr","subject":"Re: [RFC] New command: 'git snapshot'.","fromName":"Fabio Augusto Dal Castel","fromEmail":"fdcastel@gmail.com","sentAt":"2009-02-11T20:40:15Z","receivedAt":"2009-02-11T20:40:15Z","isPatch":false,"sender":{"key":"fdcastel@gmail.com","avatar":null},"body":"> Doesn't that argue for \"git stash --no-reset\" or similar instead of a\n> separate command?\n\nYes. And also for an \"--untracked\" (as already suggested).\n\nSince stashes does not expire anymore (as correctly pointed by\nBrandon), a snapshot could be reduced to an alias for:\n\ngit stash --no-reset --untracked\n\n(except for the branch storage)\n\n\nHowever, the rationale behind a new command was also to avoid the\n'loss of identity' of stash (as currently implemented). I always saw\nstash as a way to allow a temporary hack or a pull. If we start adding\na lot of switches into stash that ultimately would change its main\npurpose, should it yet be called 'stash'? (something like a 'git\ncommit --no-commit' ?)\n\n(Please, don't get me wrong: I'm just raising food for thoughts, here)\n\nMaybe the 'stash' command and multiples switches would be more\nappropriate if 'reset' was NOT the default behavior. Something like:\n\ngit stash [--untracked] [--reset]\n\nwhere the current 'git stash' would be 'git stash --reset'.Of course,\nthis would be a significant breaking change.\n\nI know... I know...  \"Heresy!\" You'd say... <g>\n\nBut... what about it? Why, after all, stash MUST do a reset?\n\n\"Do one thing. Do it well\"?\n\nRegards!\nFabio.\n"}]}