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

Re: git filter-branch --filter-notes/--post-rewrite?

From
Johan Herland <johan@herland.net>
Date
Mar 21, 2011, 02:39 UTC
Message-ID
<201103210339.09460.johan@herland.net>
In-Reply-To
<hbf.20110320kak3@bombur.uio.no>
On Sunday 20 March 2011, Hallvard B Furuseth wrote:
Show 10 quoted lines
> Thomas Rast writes:
> >Johan Herland wrote:
> >> Looking at git-rebase.sh (where it _is_ implemented), it seems to be a
> >> matter of feeding "old_sha1 new_sha1" pairs into a "rewritten" file,
> >> and then passing that file to the stdin of "git notes copy
> >> --for-rewrite=filter- branch" (followed by passing the same file to
> >> the "post-rewrite" hook).
> 
> That appends to the notes history instead of replacing it, which seems
> broken to me.  So I'm doing fast-export <notes> | edit; fast-import.

Yeah, Rewriting the notes history along with the "real" history requires a bit more work. In reality, though, if the notes history is not interesting in itself, you can first do the notes rewrite I describe above, next prune the notes tree ("git notes prune") to remove the old notes from the notes tree, then finally drop the entire notes history except the last commit (using grafts + filter-branch, or using commit-tree to simply wrapping the notes tree object in a new parent-less notes commit).

Show 15 quoted lines
> > I had a patch for this back when post-rewrite was invented,
> > 
> >   http://thread.gmane.org/gmane.comp.version-control.git/139919/focus=1
> >   39917
> > 
> > but Hannes replied that it should grow a real notes filter, and while
> > I dropped it there, I tend to agree with him.  Feel free to pick it up
> > again.
> 
> A notes filter would be nice, but I don't understand why there's no
> post-rewrite hook or option to let us get at the rewrite info before
> it is deleted.  For one thing a notes filter might not do just what is
> intended (as above), but one might want the mapping info for other
> things too.  E.g. just to save it in case there are mailings floating
> around which refer to old commit IDs.

We should probably apply Thomas' post-rewrite patch in any case. It gives the post-rewrite hook access to both the old and new commit IDs, so should have all the info you need to do whatever you want with the repo.

Note that after filter-branch is done, you should still be able to access the old objects (by using the old commit IDs directly), at least until the next "git gc".

> In any case, thanks for the answers.  I guess I can live with copying
> the git-filter-branch script when needed, it's not as if I run that
> every day.

Yeah, using filter-branch on an everyday basis would sound like a fundamental workflow problem. ;)

Have fun! :)
...Johan
-- 
Johan Herland, <johan@herland.net>
www.herland.net
Previous: Hallvard B Furuseth
Message 5 of 5 in “git filter-branch --filter-notes/--post-rewrite?”
  1. Hallvard B FurusethMar 17, 2011
  2. Johan HerlandMar 18, 2011
  3. Thomas RastMar 18, 2011
  4. Hallvard B FurusethMar 20, 2011
  5. Johan HerlandMar 21, 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.