From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: skimo@liacs.nl
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH 4/4] Add git-rewrite-commits
Date: Mon, 9 Jul 2007 15:11:45 +0100 (BST) [thread overview]
Message-ID: <Pine.LNX.4.64.0707091450440.5546@racer.site> (raw)
In-Reply-To: <20070709134918.GT1528MdfPADPa@greensroom.kotnet.org>
Hi,
On Mon, 9 Jul 2007, Sven Verdoolaege wrote:
> On Mon, Jul 09, 2007 at 01:57:10PM +0100, Johannes Schindelin wrote:
>
> > On Mon, 9 Jul 2007, Sven Verdoolaege wrote:
> >
> > > What if the commit message is larger than the pipe buffer?
> >
> > You start_command(). Then you write() until it is all written, or the
> > pipe is broken. Then you get the output via index_pipe(). Which is a
> > single sha1. I do not understand your question.
>
> Ah, but that is not how my commit "filter" works right now. It should
> produce the whole commit on stdout (as mentioned in the documentation).
> So the default filter is "cat" (and not "git-hash-object -t commit
> --stdin", as you seem to assume).
Sorry. Somehow I misread that index_pipe() for a read_pipe().
> How about I change that to a filter that accepts a single SHA1 and
> produces zero or more SHA1's as output?
> A filter for the current rewrite-commits would then be replaced
> by "xargs | git-cat-file commit | original-filter | git-hash-object -t commit --stdin"
You still have not addressed the fundamental problem! If the commit
filter takes the things as a whole commit buffer or as a single sha1, or
if it writes one, two or -1 commits is not really a fundamental problem.
The real problem is that this filter can only act on _one_ commit. Yes,
it wants to change only one commit at a time, but it might need
information from _other_ commits, too!
> > To enhance on the above example: you're rewriting the commit messages
> > so that commit names are rewritten to match the rewritten commits.
> > That is possible by a message filter in cg-admin-rewritehist.
> >
> > But now somebody comes along, and says "I have a history I need to
> > rewrite. All bug fixes. The commit names were all abbreviated in the
> > commit messages, but they always had 'commit ' in front of them. I
> > want to rewrite them, too."
>
> The current git-rewrite-commits will rewrite all SHA1's it can find,
> irrespective of any 'commit ' that may precede it.
Even abbreviated ones?
> > > What's wrong with --author='!Darl McBribe' ?
> >
> > It is a very special use case. Not always will you be able to get all
> > the information from the commit object you need for conditional
> > operations. My example only showed that you can do the same with that
> > syntax. But imagine what you could do if we just added a small
> > syntactical sugar:
> >
> > -e '?has-path:README?substitute/v2/v3/'
>
> So you want to introduce a whole language?
> Isn't that a bit over-engineering?
We already have a tool which is powerful enough to do that. Yes, it is a
little complicated to operate, and yes, it is slower than your version.
But darn it, it _does_ more than your version.
It is a pity that you did not address the fundamental problem, so I have
to spend time (that I should really spend differently) thinking about it.
Alas, I think I have a solution. You need a flag:
--write-sha1-mappings=<directory>
Yes, it makes your code slower again, but only if you need those mappings.
Yes, it is way less convenient than the "map" function, but then you could
automatically write a script into that directory, providing the
convenience functions, and exporting the path so that you can say
--commit-filter '. "$G"; ... map "$sha1"'
and also add convenience functions "save <varname>" and "restore
<varname>" so that finally a bit of convenience is restored to the filter
writers.
But those are no longer fundamental problems. I'd be glad if you could
put these suggestions to use in rewrite-commits.
While at it, you should also change the semantics for the commit filter,
probably even less so than you suggested: since you rewrite the parents,
and the tree, you should continue to pipe this information into the commit
filter. That would be another place for a convenience function "commit",
which does the same as "git hash-object -w --stdin".
Okay now. To be precise, here is my wish list:
* rename the darned things to "filter" again.
* --write-sha1-mappings=<directory> (or --write-commit-mappings), possibly
defaulting to .git/mappings/. Be careful not to overwrite an existing
such directory.
* change the semantics of the commit filter: the output is a list
(possibly empty) of replacement sha1's for this commit.
* if any filters are called, provide a script with convenience functions,
and an environment variable pointing to it. These functions should
include:
* map
* commit
* save
* restore
Ciao,
Dscho
next prev parent reply other threads:[~2007-07-09 14:19 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-08 16:23 [PATCH 0/4] Add git-rewrite-commits skimo
2007-07-08 16:23 ` [PATCH 1/4] export get_short_sha1 skimo
2007-07-08 16:23 ` [PATCH 2/4] export add_ref_decoration skimo
2007-07-08 16:23 ` [PATCH 3/4] revision: mark commits that didn't match a pattern for later use skimo
2007-07-08 16:23 ` [PATCH 4/4] Add git-rewrite-commits skimo
2007-07-08 16:37 ` Johannes Schindelin
2007-07-08 17:30 ` Sven Verdoolaege
2007-07-08 18:17 ` Johannes Schindelin
2007-07-08 19:11 ` Sven Verdoolaege
2007-07-08 18:04 ` Steven Grimm
2007-07-08 18:15 ` Sven Verdoolaege
2007-07-08 18:41 ` Johannes Schindelin
2007-07-08 21:10 ` Sven Verdoolaege
2007-07-09 9:01 ` Johannes Sixt
2007-07-09 9:48 ` Sven Verdoolaege
2007-07-09 11:57 ` Johannes Schindelin
2007-07-08 23:56 ` Johannes Schindelin
2007-07-09 9:47 ` Sven Verdoolaege
2007-07-09 12:57 ` Johannes Schindelin
2007-07-09 13:49 ` Sven Verdoolaege
2007-07-09 14:11 ` Johannes Schindelin [this message]
2007-07-09 14:42 ` Sven Verdoolaege
2007-07-09 14:59 ` Johannes Schindelin
2007-07-09 12:36 ` Jeff King
2007-07-09 13:16 ` Johannes Schindelin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.4.64.0707091450440.5546@racer.site \
--to=johannes.schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=skimo@liacs.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).