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

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

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 7, 2010, 20:19 UTC
Message-ID
<7vtyux3bx1.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20100107200509.6117@nanako3.lavabit.com>
Nanako Shiraishi <nanako3@lavabit.com> writes:
Show 43 quoted lines
> 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@lavabit.com>
> ---
>  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?
Previous: Nanako ShiraishiNext: Johannes Sixt
Message 24 of 32 in “What's cooking in git.git (Jan 2010, #01; Mon, 04)”
  1. Junio C HamanoJan 4, 2010
  2. Matthieu MoyJan 4, 2010
  3. Junio C HamanoJan 4, 2010
  4. Johannes SixtJan 4, 2010
  5. Junio C HamanoJan 5, 2010
  6. Jeff KingJan 5, 2010
  7. Junio C HamanoJan 5, 2010
  8. Johannes SixtJan 5, 2010
  9. Junio C HamanoJan 6, 2010
  10. Johannes SixtJan 6, 2010
  11. Junio C HamanoJan 6, 2010
  12. Junio C HamanoJan 5, 2010
  13. Jeff KingJan 5, 2010
  14. Tay Ray ChuanJan 5, 2010
  15. Teach --[no-]rerere-autoupdate option to merge, revert and friendsJunio C Hamano, Jan 5, 2010
  16. Johan HerlandJan 5, 2010
  17. Ilari LiusvaaraJan 5, 2010
  18. Junio C HamanoJan 6, 2010
  19. Nanako ShiraishiJan 6, 2010
  20. Johannes SchindelinJan 6, 2010
  21. Junio C HamanoJan 6, 2010
  22. 1/2 rebase: fix --onto A...B parsing and add testsNanako Shiraishi, Jan 7, 2010
  23. 2/2 rebase -i: teach --onto A...B syntaxNanako Shiraishi, Jan 7, 2010
  24. Junio C HamanoJan 7, 2010
  25. Johannes SixtJan 7, 2010
  26. Avery PennarunJan 8, 2010
  27. Sverre RabbelierJan 8, 2010
  28. Avery PennarunJan 8, 2010
  29. Sverre RabbelierJan 8, 2010
  30. A Large Angry SCMJan 8, 2010
  31. Johannes SchindelinJan 9, 2010
  32. Avery PennarunJan 9, 2010

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.