{"thread":{"id":"8944","subject":"[PATCH 1/2] stash: implement \"stash create\"","startedAt":"2007-07-09T07:57:53Z","lastAt":"2007-07-09T07:57:53Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"46841","messageId":"7v3azyvwji.fsf@assigned-by-dhcp.cox.net","threadId":"8944","inReplyTo":null,"subject":"[PATCH 1/2] stash: implement \"stash create\"","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-07-09T07:57:53Z","receivedAt":"2007-07-09T07:57:53Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"This subcommand creates a stash from the current state and writes out the\nresulting commit object ID to the standard output, without updating the\nstash ref nor resetting the tree.  It is intended to be used by scripts\nto temporarily rewind the working tree to a clean state.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n\n * This is currently only needed for the next one, which I do\n   not think is ready for 1.5.3, so both will stay in either\n   'pu' or perhaps in 'next'.\n\n git-stash.sh |   25 +++++++++++++++++++++----\n 1 files changed, 21 insertions(+), 4 deletions(-)\n\ndiff --git a/git-stash.sh b/git-stash.sh\nindex de13dd1..8c22cd4 100755\n--- a/git-stash.sh\n+++ b/git-stash.sh\n@@ -23,7 +23,7 @@ clear_stash () {\n \t: >\"$logfile\"\n }\n \n-save_stash () {\n+create_stash () {\n \tstash_msg=\"$1\"\n \n \tif no_changes\n@@ -31,9 +31,6 @@ save_stash () {\n \t\techo >&2 'No local changes to save'\n \t\texit 0\n \tfi\n-\ttest -f \"$GIT_DIR/logs/$ref_stash\" ||\n-\t\tclear_stash || die \"Cannot initialize stash\"\n-\n \t# state of the base commit\n \tif b_commit=$(git rev-parse --verify HEAD)\n \tthen\n@@ -79,7 +76,20 @@ save_stash () {\n \tw_commit=$(printf '%s\\n' \"$stash_msg\" |\n \t\tgit commit-tree $w_tree -p $b_commit -p $i_commit) ||\n \t\tdie \"Cannot record working tree state\"\n+}\n+\n+save_stash () {\n+\tstash_msg=\"$1\"\n+\n+\tif no_changes\n+\tthen\n+\t\techo >&2 'No local changes to save'\n+\t\texit 0\n+\tfi\n+\ttest -f \"$GIT_DIR/logs/$ref_stash\" ||\n+\t\tclear_stash || die \"Cannot initialize stash\"\n \n+\tcreate_stash \"$stash_msg\"\n \tgit update-ref -m \"$stash_msg\" $ref_stash $w_commit ||\n \t\tdie \"Cannot save the current status\"\n \tprintf >&2 'Saved \"%s\"\\n' \"$stash_msg\"\n@@ -185,6 +195,13 @@ apply)\n clear)\n \tclear_stash\n \t;;\n+create)\n+\tif test $# -gt 0 && test \"$1\" = create\n+\tthen\n+\t\tshift\n+\tfi\n+\tcreate_stash \"$*\" && echo \"$w_commit\"\n+\t;;\n help | usage)\n \tusage\n \t;;\n-- \n1.5.3.rc0.81.g1ed84\n"}]}