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

Re: Rewriting references to existing commits in commit messages with filter-branch

From
VZVadim Zeitlin <vz-git@zeitlins.org>
Date
Mar 11, 2013, 15:58 UTC
Message-ID
<loom.20130311T164232-124@post.gmane.org>
In-Reply-To
<87y5dut72l.fsf@pctrast.inf.ethz.ch>
Thomas Rast <trast <at> student.ethz.ch> writes:
Show 20 quoted lines
> 
> Vadim Zeitlin <vz-git <at> zeitlins.org> writes:
> 
> > Lawrence Mitchell <wence <at> gmx.li> writes:
> >
> >> Vadim Zeitlin wrote:
> >> 
> >> [...]
> >> 
> >> > git filter-branch --msg-filter svnmsg2git --tag-name-filter cat -- --all
> >> 
> >> git rev-list lists by default in chronological order.  Do you
> >> want to pass --topo-order as one of the rev-list options?
> >
> >  Thanks, this looked like a good idea but reading git-filter-branch code it
> > seems to already do it, at
> > https://github.com/git/git/blob/master/git-filter-branch.sh#L269 you can see
> > that it does "git rev-list --reverse --topo-order ...".
> 
> Try overring that with --date-order (you may have to patch the source).
 Thanks for the hint, this was indeed the solution. And there is actually no
need to patch the source because, considering the way git-filter-branch.sh is
written, the user-specified parameters come after the hard-coded --topo-order
and it seems that --date-order overrides it if it comes after it. So I just had
to use

git filter-branch --msg-filter svnmsg2git --tag-name-filter cat -- --date-order --all

instead of my original command. The only remaining question I have is why isn't --date-order the default? At least when using message filter, it seems to me that we always want to rewrite commits in chronological order to deal with possible back references (even when not migrating from svn, commit messages can still refer to previous commits, like e.g. the ones created by "git revert" do and they need to be updated when rewriting history). So why not use it in git-filter-branch.sh?

 BTW, the explanation for the new errors I was getting with --date-order was
that I had some artificial commits generated by cvs2svn in the history of this
repository which had _exactly_ the same date as the previous commit and
--date-order sorted them in the wrong order for some reason. I got round this by
simply checking for the specific form of the message (which is "This commit was
generated by cvs2svn to compensate for changes in rNNNNN, which included commits
to RCS files with non-trunk default branches.") and replacing "rNNNNN" with "the
previous commit" in this particular case in order to avoid the problem.
 Thanks again for your help!
VZ
Previous: Thomas RastNext: Michael Haggerty
Message 5 of 7 in “Rewriting references to existing commits in commit messages with filter-branch”
  1. Vadim ZeitlinMar 11, 2013
  2. Lawrence MitchellMar 11, 2013
  3. Vadim ZeitlinMar 11, 2013
  4. Thomas RastMar 11, 2013
  5. Vadim ZeitlinMar 11, 2013
  6. Michael HaggertyMar 11, 2013
  7. Vadim ZeitlinMar 11, 2013

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.