Subject: Re: [PATCH/RFC 02/10] Teach rebase interactive the reset command

From: Junio C Hamano <[email-masked]>
Date: Fri, 11 Apr 2008 16:56:00 -0700

Jörg Sommer <[email-masked]> writes:

> ---
>  git-rebase--interactive.sh    |   20 ++++++++++++++++++++
>  t/t3404-rebase-interactive.sh |   10 ++++++++++
>  2 files changed, 30 insertions(+), 0 deletions(-)
>
> diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
> index b001ddf..7dac51b 100755
> --- a/git-rebase--interactive.sh
> +++ b/git-rebase--interactive.sh
> @@ -258,6 +258,16 @@ parse_mark() {
>  	return 1
>  }
>  
> +mark_to_sha1() {
> +	local mark

Bashism.

> +	if mark=$(parse_mark $1)
> +	then
> +		cat "$MARKS"/$mark

This cat may become "rev-parse --verify" if we decide to move $MARKS
underneath refs/ namespace somewhere.

> +	reset|r)
> +		comment_for_reflog reset
> +
> +		mark_action_done
> +		tmp=$(mark_to_sha1 $sha1) || \
> +			tmp=$(git rev-parse --verify $sha1) ||

and you then would not need to do the verify twice.

> +			die "Invalid parent '$sha1' in $command $sha1 $rest"
> +		output git reset --hard $tmp

Could this step fail, and if it does what should happen?

> @@ -569,6 +588,7 @@ do
>  #  edit = use commit, but stop for amending
>  #  squash = use commit, but meld into previous commit
>  #  mark #NUM = mark the current HEAD for later reference
> +#  reset #NUM|commit = reset HEAD to a previous set mark or a commit

"to a previously set mark".  But I would say upfront "in the todo insn
whenever you need to refer to a commit, in addition to
the usual commit object name, you can use '#num' syntax to refer to a
commit previously marked with the 'mark' insn." and make this line just
read:

    #  reset commit = reset HEAD to the commit