Re: [PATCH (v2) 2/2] rebase -i: teach --onto A...B syntax

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Nanako Shiraishi <nanako3@xxxxxxxxxxx> writes:

> When rewriting commits on a topic branch, sometimes it is easier to
> compare the version of commits before and after the rewrite if they are
> based on the same commit that forked from the upstream. An earlier commit
> by Junio (fixed up by the previous commit) gives "--onto A...B" syntax to
> rebase command, and rebases on top of the merge base between A and B;
> teach the same to the interactive version, too.
>
> Signed-off-by: しらいし ななこ <nanako3@xxxxxxxxxxx>
> ---
>  git-rebase--interactive.sh       |   21 ++++++++++++++++++++-
>  t/t3415-rebase-onto-threedots.sh |   30 ++++++++++++++++++++++++++++++
>  2 files changed, 50 insertions(+), 1 deletions(-)
>
> diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
> index 23ded48..f7ae02c 100755
> --- a/git-rebase--interactive.sh
> +++ b/git-rebase--interactive.sh
> @@ -482,6 +482,25 @@ get_saved_options () {
>  	test -f "$DOTEST"/rebase-root && REBASE_ROOT=t
>  }
>  
> +LF='
> +'
> +parse_onto () {
> +	case "$1" in
> +	*...*)
> +		if	left=${1%...*} right=${1#*...} &&
> +			onto=$(git merge-base --all ${left:-HEAD} ${right:-HEAD})
> +		then
> +			case "$onto" in
> +			?*"$LF"?* | '')
> +				exit 1 ;;
> +			esac
> +			echo "$onto"
> +			exit 0
> +		fi
> +	esac
> +	git rev-parse --verify "$1^0"
> +}
> +
>  while test $# != 0
>  do
>  	case "$1" in

I am a bit unhappy about the duplication.  The text of this function is
different from the one in "rebase" proper, but they implement essentially
the same logic.  I was tempted to suggest having a common helper function,
but as Dscho mentioned "rebase -i" implementation does not share much with
"rebase" (even though it shares the external command line interface from
the end user's point of view), and I don't see a readily available place
(other than in git-sh-setup) to do so.

Ideas?
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]