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

(Ab)using filter-branch from a post-receive hook

From
Wincent Colaiuta <win@wincent.com>
Date
Jul 15, 2012, 04:01 UTC
Message-ID
<8D1AF968-AF34-4590-AB8F-E644C534A928@wincent.com>
Hi,
At $day_job we want to start publishing a subtree of our codebase as open source. As we audit and prep more sections of the code base, we'll be broadening the subtree(s) that we export, until eventually we want as close as possible to the whole thing to be open source.
The resulting public repo would only contain commits from the master branch that touch the "open" parts of the tree, so while the result wouldn't be complete or coherent, it would produce a "read-only" open source artifact and allow us to start sharing code today rather than a year or two years from now when the entire code base is audited.
I'm thinking of (ab)using filter-branch from a post-receive hook as a means to do this. Does this sound sane, or are there better options?
Specifically, I was thinking of doing the following:
- on pushing into our authoritative repo, we replicate to a second "scratch" repo where all the dirty work gets done
- the scratch repo has a master branch, and an initial "open" branch created using `git filter-branch`
- a post-receive hook in the scratch repo, given a series of commits A..B on the master branch, cherry-picks them onto the "open" branch, producing commits A'..B'
- the hook runs `git filter-branch` on the "open" branch over commits A'..B', filtering the not-yet-open parts of the tree and dropping empty commits
- the hook pushes the resulting HEAD to a public repo
Thoughts? Closest to this idea that I've been able to find online so far is [1].

Cheers, Wincent

[1] http://stackoverflow.com/questions/2296047/repeatedly-using-git-filter-branch-to-rewrite-new-commits
Next: Junio C Hamano
Message 1 of 5 in “(Ab)using filter-branch from a post-receive hook”
  1. Wincent ColaiutaJul 15, 2012
  2. Junio C HamanoJul 15, 2012
  3. Wincent ColaiutaJul 15, 2012
  4. Junio C HamanoJul 15, 2012
  5. Wincent ColaiutaJul 15, 2012

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.