git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 30, 2007, 02:23 UTC
Message-ID
<7vbqeydvtd.fsf@assigned-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 ;-)
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.
Message 1 of 1 in “Re: [PATCH (2nd try)] Add git-stash script”
  1. Junio C HamanoJun 30, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.