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

Re: [PATCH 4/4] Add git-rewrite-commits

From
Jeff King <peff@peff.net>
Date
Jul 9, 2007, 12:36 UTC
Message-ID
<20070709123626.GC23494@sigill.intra.peff.net>
In-Reply-To
<Pine.LNX.4.64.0707090011070.4248@racer.site>
On Mon, Jul 09, 2007 at 12:56:04AM +0100, Johannes Schindelin wrote:
Show 8 quoted lines
> But hey, maybe it _is_ time to rethink the whole filter business, and 
> introduce some kind of regular expression based action language. Something 
> like
> 
> 	git rewrite-commits -e '/^author Darl McBribe/skip-commit' \
> 		-e 'substitute/^author Joahnnes/author Johannes/header' \
> 		-e 'substitute/poreclain/porcelain/body' \
> 		-e 'rewrite-commit-names'

This is starting to look an awful lot like sed. Which is good, but I wonder if we can get sed to do the heavy lifting. I have had success with similar systems by writing the data structure out into a canonical format, editing it as text, and then "applying" the result.

Something like:
  git rewrite-generate oldbranch |
    sed 's/^author Darl McBribe/skip-commit/'
    sed 's/^author Joahnnes/author Johannes/' |
    git-rewrite-commit-names |
    git rewrite-apply newbranch
where git-rewrite-generate would generate something like git-log output,
and git-rewrite-apply would, given a log-ish input, write a new history
branch. A nice advantage is that it makes things like this very natural:
  git rewrite-generate oldbranch >history
  vi history
  git rewrite-apply newbranch <history
which allows interactive editing.
Of course, this is:
  - possibly inefficient, since rewrite-apply doesn't know what you
    changed and what you didn't change; it would have to recalculate
    a lot of sha1 hashes.
  - doesn't really deal with actual tree rewriting, unless there is some
    canonical text format for that, and then we are talking about making
    things _really_ inefficient

Hmm. Which makes me think that maybe 'git-format-patch' is really git-rewrite-generate, and 'git-am' is really git-rewrite-apply (but with some extensions to preserve committer info).

So maybe a bad idea, but I thought I would throw it out there.
-Peff
Previous: Johannes SchindelinNext: Johannes Schindelin
Message 24 of 25 in “Add git-rewrite-commits”
  1. 0/4 Add git-rewrite-commitsskimo@liacs.nl, Jul 8, 2007
  2. 1/4 export get_short_sha1skimo@liacs.nl, Jul 8, 2007
  3. 2/4 export add_ref_decorationskimo@liacs.nl, Jul 8, 2007
  4. 3/4 revision: mark commits that didn't match a pattern for later useskimo@liacs.nl, Jul 8, 2007
  5. 4/4 Add git-rewrite-commitsskimo@liacs.nl, Jul 8, 2007
  6. Johannes SchindelinJul 8, 2007
  7. Sven VerdoolaegeJul 8, 2007
  8. Johannes SchindelinJul 8, 2007
  9. Sven VerdoolaegeJul 8, 2007
  10. Steven GrimmJul 8, 2007
  11. Sven VerdoolaegeJul 8, 2007
  12. Johannes SchindelinJul 8, 2007
  13. Sven VerdoolaegeJul 8, 2007
  14. Johannes SixtJul 9, 2007
  15. Sven VerdoolaegeJul 9, 2007
  16. Johannes SchindelinJul 9, 2007
  17. Johannes SchindelinJul 8, 2007
  18. Sven VerdoolaegeJul 9, 2007
  19. Johannes SchindelinJul 9, 2007
  20. Sven VerdoolaegeJul 9, 2007
  21. Johannes SchindelinJul 9, 2007
  22. Sven VerdoolaegeJul 9, 2007
  23. Johannes SchindelinJul 9, 2007
  24. Jeff KingJul 9, 2007
  25. Johannes SchindelinJul 9, 2007

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.