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

[PATCH 0/6] rebase: command "ref" and options --rewrite-{refs,heads,tags}

From
GPGreg Price <greg@quora.com>
Date
Jun 27, 2011, 00:16 UTC
Message-ID
<cover.1309133817.git.greg@quora.com>

This series adds a "ref" command to rebase -i, and options --rewrite-{refs,heads,tags} to generate "ref" commands in the original TODO file. This makes it easy to rebase a branch together with intermediate markers, or a series of branches.

For example, in this situation:
      part1 part2 topic
        |     |     |
        v     v     v
  A--*--*--*--*--*--*
   \
    B <--master

we may want to rebase 'topic' onto the new master, rewriting the intermediate branches 'part1', 'part2' to the corresponding new commits. This can be done with a sequence of "git rebase --onto" commands, but it's tricky to get right.

With this series, the command
  $ git rebase --rewrite-heads master topic
suffices to produce this result:
        part1 part2 topic
  A       |     |     |
   \      v     v     v
    B--*--*--*--*--*--*
    ^
    |
    master

I originally submitted a version of this series nearly a year and a half ago [1]. This version has been rebased to the new release 1.7.6 (Martin von Zweigbergk's cleanups gave me quite some conflicts to resolve, but are nevertheless much appreciated!) and the interface has been adjusted for the comments of Junio and others [2]. The general command is --rewrite-refs=PATTERN; --rewrite-heads and --rewrite-tags are provided as shortcuts, the former being equivalent to the --refs of my original proposal.

 [1]  http://www.amailbox.net/mailarchive/git/2009/12/22/18967
 [2]  http://www.amailbox.net/mailarchive/git/2009/12/22/18972

I have no excuse for the year and a half of delay in submitting the revised version, but I believe that late is better than never. =)

The series contains two preparatory patches that are independently useful:
  pretty: Add %D for script-friendly decoration
  for-each-ref: --stdin to match specified refs against pattern
Each one exposes a bit more knowledge of the repository in a
machine-readable form convenient for scripting.  I hope other people
may find them useful in writing other scripts.
Greg
---
Greg Price (6):
  rebase -i: Add the "ref" command
  pretty: Add %D for script-friendly decoration
  for-each-ref: --stdin to match specified refs against pattern
  rebase: --rewrite-{refs,heads,tags} to pull refs along with branch
  t/lib-rebase.sh: pass through ref commands
  rebase --rewrite-refs: tests
 Documentation/git-rebase.txt     |   15 ++++++++
 Documentation/pretty-formats.txt |    1 +
 builtin/for-each-ref.c           |   22 ++++++++++-
 git-rebase--interactive.sh       |   37 ++++++++++++++++++-
 git-rebase.sh                    |   28 ++++++++++++++
 pretty.c                         |   33 +++++++++++++----
 t/lib-rebase.sh                  |    2 +-
 t/t3420-rebase-ref.sh            |   75 ++++++++++++++++++++++++++++++++++++++
 8 files changed, 201 insertions(+), 12 deletions(-)
 create mode 100644 t/t3420-rebase-ref.sh
-- 
1.7.5.4
Next: Greg Price
Message 1 of 24 in “rebase: command "ref" and options --rewrite-{refs,heads,tags}”
  1. 0/6 rebase: command "ref" and options --rewrite-{refs,heads,tags}Greg Price, Jun 27, 2011
  2. 1/6 rebase -i: Add the "ref" commandGreg Price, Oct 10, 2009
  3. Junio C HamanoJun 27, 2011
  4. Greg PriceJun 28, 2011
  5. 2/6 pretty: Add %D for script-friendly decorationGreg Price, Nov 18, 2009
  6. Junio C HamanoJun 27, 2011
  7. 4/6 rebase: --rewrite-{refs,heads,tags} to pull refs along with branchGreg Price, Nov 18, 2009
  8. Phil HordJun 27, 2011
  9. Greg PriceJun 28, 2011
  10. 3/6 for-each-ref: --stdin to match specified refs against patternGreg Price, Jan 7, 2010
  11. 5/6 t/lib-rebase.sh: pass through ref commandsGreg Price, Jan 25, 2010
  12. 6/6 rebase --rewrite-refs: testsGreg Price, Jan 25, 2010
  13. Phil HordJun 27, 2011
  14. Greg PriceJun 28, 2011
  15. Junio C HamanoJun 27, 2011
  16. Greg PriceJun 28, 2011
  17. Junio C HamanoJun 27, 2011
  18. Greg PriceJun 28, 2011
  19. Greg PriceJun 28, 2011
  20. Ramkumar RamachandraJun 30, 2011
  21. Sverre RabbelierAug 3, 2011
  22. Greg PriceAug 3, 2011
  23. Junio C HamanoJun 27, 2011
  24. Greg PriceJun 28, 2011

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.