{"thread":{"id":"8778","subject":"Re: [PATCH (2nd try)] Add git-stash script","startedAt":"2007-06-30T02:23:42Z","lastAt":"2007-06-30T02:23:42Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"46060","messageId":"7vbqeydvtd.fsf@assigned-by-dhcp.pobox.com","threadId":"8778","inReplyTo":"200706300126.l5U1QPda021795@mi1.bluebottle.com","subject":"Re: [PATCH (2nd try)] Add git-stash script","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-06-30T02:23:42Z","receivedAt":"2007-06-30T02:23:42Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":" しらいしななこ <nanako3@bluebottle.com> writes:\n\n> Unfortunately I haven't managed to get the suggestion to use\n> \"export GITHEAD_xxxx=NicerName\" from Johannes Schindelin working\n> yet.\n\nI'd drop hints below, but first...\n\n>  git-stash.sh |  153 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n>  1 files changed, 153 insertions(+), 0 deletions(-)\n>  create mode 100755 git-stash.sh\n\n... we would want an entry in .gitignore and Makefile as well ;-)\n\n> diff --git a/git-stash.sh b/git-stash.sh\n> new file mode 100755\n> index 0000000..8bf83c1\n> --- /dev/null\n> +++ b/git-stash.sh\n> ...\n> +apply_stash () {\n> +\tgit-diff-files --quiet ||\n> +\t\tdie 'Cannot restore on top of a dirty state'\n> +\n> +\t# current index state\n> +\tc_tree=$(git-write-tree) ||\n> +\t\tdie 'Cannot apply a stash in the middle of a merge'\n> +\n> +\ts=$(git-rev-parse --revs-only --no-flags --default $ref_stash \"$@\") &&\n> +\tw_tree=$(git-rev-parse --verify \"$s:\") &&\n> +\tb_tree=$(git-rev-parse --verify \"$s^:\") ||\n> +\t\tdie \"$*: no valid stashed state found\"\n\nAt this point, you would say:\n\n\teval \"\n\t\tGITHEAD_$w_tree='Stashed changes' &&\n                GITHEAD_$c_tree='Updated upstream' &&\n                GITHEAD_$b_tree='Version stash was based on'\n\t\" &&\n\texport GITHEAD_$w_tree GITHEAD_$c_tree GITHEAD_$b_tree\n\nI suspect you did not use eval and got syntax errors from\nvariable assignment from the shell?\n\n\tVAR_$iable='Assign ment'\n\nis a syntax error, while\n\n\texport VAR_$iable\n\nis not.  Don't ask me why.\n"}]}