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

Re: git filter-branch --subdirectory-filter

From
Jeff King <peff@peff.net>
Date
May 9, 2008, 08:00 UTC
Message-ID
<20080509080039.GA15393@sigill.intra.peff.net>
In-Reply-To
<e5e204700805090038k373bbabcyfb10d8c93ec5b3a7@mail.gmail.com>
On Fri, May 09, 2008 at 05:38:12PM +1000, James Sadler wrote:
Show 15 quoted lines
> I originally tried --subdirectory-filter by itself to see if it would
> do the job, but it filtered more commits than I thought it should
> (some commits that touched the subdir were missing after filter-branch
> was run).
> 
> I then began to question my understanding of the semantics of
> subdirectory-filter.
> 
> Is it meant to:
> A) Only keep commits where ALL of the changes in the commit only touch
> content under $DIR?
> B) Only keep commits where SOME of the changes in the commit touch
> content under $DIR?
> 
> I suspected that it was behaving as A.
My understanding is that it should behave as B. E.g.:
  git init
  mkdir subdir1 subdir2
  echo content 1 >subdir1/file
  echo content 2 >subdir2/file
  git add .
  git commit -m initial
  echo changes 1 >>subdir1/file
  git commit -a -m 'only one'
  echo more changes 1 >>subdir1/file
  echo more changes 2 >>subdir2/file
  git commit -a -m 'both'
  git filter-branch --subdirectory-filter subdir1
  git log --name-status --pretty=oneline
should show something like:
  b119e21829b6039aa8fe938fb0304a9a7436b84d both
  M       file
  db2ad8e702f36a1df99dd529aa594e756010b191 only one
  M       file
  dacb4c2536e61c18079bcc73ea81fa0fb139c097 initial
  A       file
IOW, all commits touch subdir1/file, which becomes just 'file'.

It could be a bug in git-filter-branch. What version of git are you using?

-Peff
Previous: Johannes SixtNext: James Sadler
Message 5 of 10 in “git filter-branch --subdirectory-filter”
  1. James SadlerMay 9, 2008
  2. Jeff KingMay 9, 2008
  3. James SadlerMay 9, 2008
  4. Johannes SixtMay 9, 2008
  5. Jeff KingMay 9, 2008
  6. James SadlerMay 10, 2008
  7. Jeff KingMay 10, 2008
  8. James SadlerMay 10, 2008
  9. James SadlerMay 10, 2008
  10. Jeff KingMay 10, 2008

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.