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

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

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Jul 8, 2007, 23:56 UTC
Message-ID
<Pine.LNX.4.64.0707090011070.4248@racer.site>
In-Reply-To
<1183911808787-git-send-email-skimo@liacs.nl>
Hi,

I am way too tired to comment in detail, but here are some preliminary findings:

- your command line interface is very nice and elegant.
- you use a lot of what was in cg-admin-rewritehist (including 
  adjustments I made in the documentation for filter-branch), but you also 
  make it more confusing for people used to that tool:
	- instead of leaving the original branches as they are, you 
	  overwrite them. That's okay. But then you put the originals into 
	  refs/rewritten. Without cg-admin-rewritehist using that name 
	  for the _result_, you could explain your way out of confusion. 
	  As it is, you cannot.
	- in spite of doing the same as cg-admin-rewritehist with filters, 
	  you call them maps. But they are no maps. They are manipulators, 
	  you can call them mutators or filters, too. Given what people 
	  know of cg-admin-rewritehist, you really should keep the name 
	  "filter".
	- the name "map" itself is used in cg-admin-rewritehist, to map 
	  commit names from old to new. By using that name differently, 
	  again you contribute to confusion, for no good reason.
- neat idea to abuse the decorator for rewriting purposes.
- get_one_line() is a misnomer. It wants to be named get_linelen().
- instead of spawning read-tree, you could use unpack_trees() to boost 
  performance even more. But I guess it is probably left for later, to 
  make it easier to review the patch.
- your memspn() and memcspn() functions are very inefficient. Better walk 
  the memory, introduce a GIT_HEXCHAR into ctype.c, ishexchar() into 
  git-compat-util.h, and use that.
- The example you give with "git update-index --remove" can fail, right? 
  Tell the user about that.
- The commit filter again deviates from the usage in cg-admin-rewritehist. 
  I can see that you wanted to make it more versatile. However, it makes 
  the tool potentially also a bit more cumbersome to use. Besides, you use 
  a temporary file where there is no need to.
- "map" is missing. This is a function that you can use in all filters in 
  cg-admin-rewritehist, except (unfortunately) in the commit filter (for 
  technical reasons). Alas, these technical reasons also prevent such a 
  function to be usable by any of the filters ("maps", as you call them).
- the more fundamental problem with the missing "map", I do not see a 
  reasonable way to get the same functionality from any of the code 
  snippets passed to rewrite-commits. Indeed, even the workaround of 
  cg-admin-rewritehist, to read $TEMP/map/$sha1, does not work, since you 
  are keeping it all in memory. On IRC, gitster suggested to use a 
  bidirectional pipe (such as stdin/stdout) to get at the new commit 
  names, but because of buffering, I guess this is no joy.

As commented on IRC, the env/tree/parent/msg filters of cg-admin-rewritehist could be all emulated by commit filters. However, that would be really inconvenient. So at a later stage, these would have to be integrated into rewrite-commits (even if it would be possible to drive rewrite-commits by a shell porcelain, but I guess you are opposed to that idea, since you want to do everything else in C, too).

However, the biggest and very real problem is that your filters do not have a "map" function to get the rewritten sha1 for a given sha1. That is what makes the filters so versatile, though, since you can skip revisions by much more complex rules than just greps on the commit message or header.

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'
Hmm?

Ciao, Dscho

Previous: Johannes SchindelinNext: Sven Verdoolaege
Message 17 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.