threads / patch / 8778

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

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

## tl;dr

One message between Jun 30, 2007 and Jun 30, 2007. Diffs are folded; open one to read it.

replies: 0people: 1as markdown or json

Junio C Hamano· Jun 30, 2007, 02:23 UTC · lore
 しらいしななこ <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 ;-)
Show 18 quoted lines
> 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.

← back to recent threads