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

Re: [RFC/PATCHv8 00/10] git notes

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 20, 2009, 11:02 UTC
Message-ID
<7veintzcff.fsf@alter.siamese.dyndns.org>
In-Reply-To
<7vk4xl1nkl.fsf@alter.siamese.dyndns.org>

By the way, we could probably use this to make the command sequence even shorter.

I have to warn that this has never been used in real life, unlike the "checkout A...B" one --- caveat emptor.

Also I didn't bother touching up "rebase -i"; it is left as an excercise to the readers ;-)

-- >8 --
Subject: [PATCH] "rebase --onto A...B" replays history on the merge base between A and B

This is in spirit similar to "checkout A...B". To re-queue a new set of patches for a series that the original author prepared to apply on 'next' on the same base as before, you would do something like this:

    $ git checkout next^0
    $ git am -s rerolled-series.mbox
    $ git rebase --onto next...jh/notes next

The first two commands recreates commits to be rebased as the original author intended (i.e. applies directly on top of 'next'), and the rebase command replays that history on top of the same commit the series being replaced was built on (which is typically much older than the tip of 'next').

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 git-rebase.sh |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)
diff --git a/git-rebase.sh b/git-rebase.sh
index 6830e16..570e2b6 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -34,6 +34,8 @@ set_reflog_action rebase
 require_work_tree
 cd_to_toplevel
 
+LF='
+'
 OK_TO_SKIP_PRE_REBASE=
 RESOLVEMSG="
 When you have resolved this problem run \"git rebase --continue\".
@@ -417,7 +419,22 @@ fi
 
 # Make sure the branch to rebase onto is valid.
 onto_name=${newbase-"$upstream_name"}
-onto=$(git rev-parse --verify "${onto_name}^0") || exit
+if	left=$(expr "$onto_name" : '\(.*\)\.\.\.') &&
+	right=$(expr "$onto_name" : '\.\.\.\(.*\)$') &&
+	: ${left:=HEAD} ${right:=HEAD} &&
+	onto=$(git merge-base "$left" "$right")
+then
+	case "$onto" in
+	?*"$LF"?*)
+		die "$onto_name: there are more than one merge bases"
+		;;
+	'')
+		die "$onto_name: there is no merge base"
+		;;
+	esac
+else
+	onto=$(git rev-parse --verify "${onto_name}^0") || exit
+fi
 
 # If a hook exists, give it a chance to interrupt
 run_pre_rebase_hook "$upstream_arg" "$@"
-- 
1.6.5.3.342.g14bb9
Previous: Junio C HamanoNext: Alex Riesen
Message 20 of 26 in “[RFC/PATCHv8 00/10] git notes”
  1. Johan HerlandNov 20, 2009
  2. 01/10 Notes API: get_commit_notes() -> format_note() + remove the commit restrictionJohan Herland, Nov 20, 2009
  3. 02/10 Notes API: init_notes(): Initialize the notes tree from the given notes refJohan Herland, Nov 20, 2009
  4. 03/10 Notes API: add_note(): Add note objects to the internal notes tree structureJohan Herland, Nov 20, 2009
  5. 04/10 Notes API: get_note(): Return the note annotating the given objectJohan Herland, Nov 20, 2009
  6. 05/10 Notes API: for_each_note(): Traverse the entire notes tree with a callbackJohan Herland, Nov 20, 2009
  7. 06/10 Notes API: Allow multiple concurrent notes trees with new struct notes_treeJohan Herland, Nov 20, 2009
  8. 07/10 Refactor notes concatenation into a flexible interface for combining notesJohan Herland, Nov 20, 2009
  9. 08/10 fast-import: Proper notes tree manipulation using the notes APIJohan Herland, Nov 20, 2009
  10. Shawn O. PearceNov 26, 2009
  11. Johan HerlandNov 26, 2009
  12. Shawn O. PearceNov 26, 2009
  13. 09/10 Rename t9301 to t9350, to make room for more fast-import testsJohan Herland, Nov 20, 2009
  14. 10/10 Add more testcases to test fast-import of notesJohan Herland, Nov 20, 2009
  15. Junio C HamanoNov 20, 2009
  16. Johan HerlandNov 20, 2009
  17. Nanako ShiraishiNov 20, 2009
  18. Johannes SchindelinNov 20, 2009
  19. Junio C HamanoNov 20, 2009
  20. Junio C HamanoNov 20, 2009
  21. Alex RiesenJan 19, 2010
  22. Junio C HamanoJan 19, 2010
  23. Junio C HamanoJan 20, 2010
  24. Johannes SixtJan 20, 2010
  25. Junio C HamanoJan 20, 2010
  26. Alex RiesenJan 20, 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.