# Re: [PATCH (2nd try)] Add git-stash script

1 messages from 2007-06-30 to 2007-06-30. Participants: Junio C Hamano.
Thread: https://gitlist.dev/t/8778

## Junio C Hamano, 2007-06-30 02:23

Subject: Re: [PATCH (2nd try)] Add git-stash script
Message-ID: <7vbqeydvtd.fsf@assigned-by-dhcp.pobox.com>
URL: https://gitlist.dev/e/7vbqeydvtd.fsf%40assigned-by-dhcp.pobox.com
In-Reply-To: <200706300126.l5U1QPda021795@mi1.bluebottle.com>

```
 しらいしななこ <nanako3@bluebottle.com> writes:

> Unfortunately I haven't managed to get the suggestion to use
> "export GITHEAD_xxxx=NicerName" from Johannes Schindelin working
> yet.

I'd drop hints below, but first...

>  git-stash.sh |  153 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 153 insertions(+), 0 deletions(-)
>  create mode 100755 git-stash.sh

... we would want an entry in .gitignore and Makefile as well ;-)

> diff --git a/git-stash.sh b/git-stash.sh
> new file mode 100755
> index 0000000..8bf83c1
> --- /dev/null
> +++ b/git-stash.sh
> ...
> +apply_stash () {
> +	git-diff-files --quiet ||
> +		die 'Cannot restore on top of a dirty state'
> +
> +	# current index state
> +	c_tree=$(git-write-tree) ||
> +		die 'Cannot apply a stash in the middle of a merge'
> +
> +	s=$(git-rev-parse --revs-only --no-flags --default $ref_stash "$@") &&
> +	w_tree=$(git-rev-parse --verify "$s:") &&
> +	b_tree=$(git-rev-parse --verify "$s^:") ||
> +		die "$*: no valid stashed state found"

At this point, you would say:

	eval "
		GITHEAD_$w_tree='Stashed changes' &&
                GITHEAD_$c_tree='Updated upstream' &&
                GITHEAD_$b_tree='Version stash was based on'
	" &&
	export GITHEAD_$w_tree GITHEAD_$c_tree GITHEAD_$b_tree

I suspect you did not use eval and got syntax errors from
variable assignment from the shell?

	VAR_$iable='Assign ment'

is a syntax error, while

	export VAR_$iable

is not.  Don't ask me why.

```
