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

Re: import files w/ history

From
CHCsaba Henk <csaba-ml@creo.hu>
Date
Mar 9, 2009, 05:15 UTC
Message-ID
<slrngr99ei.1t4t.csaba-ml@beastie.creo.hu>
In-Reply-To
<20090308001021.GA26167@coredump.intra.peff.net>
On 2009-03-08, Jeff King <peff@peff.net> wrote:
Show 14 quoted lines
> What you really want to do is say:
>
>   - for every commit, narrow the tree to _just_ the one file
>
>   - if there were no changes in the narrowed tree, just throw out the
>     commit
>
> You can use an --index-filter to do the former, and a --commit-filter to
> do the latter (or just use --prune-empty, which is a shorthand).
>
> Another poster had a similar problem, and you can see the right
> filter-branch recipe there:
>
>   http://article.gmane.org/gmane.comp.version-control.git/111991
Thanks, this did the job.
Show 12 quoted lines
>
> I think you need an extra '--' to separate the paths from the revisions
> in the rev-list arguments:
>
>   git filter-branch -- master -- sys/dev/disk/vn/vn.c
>
> but even that doesn't quite do what you want. It limits the commits that
> are shown, similar to your first attempt above, but it doesn't cut down
> the tree itself (OTOH, limiting by path rather than using --prune-empty
> is likely to run faster, since you won't even look at commits that are
> uninteresting. However, it may change the shape of your history with
> respect to branching and merging).

Finally I choose to add the path to the rev-list args -- 80 vs 15000 commits does make a difference. (I can still check if there was any histroy [I just coined this from "history" and "destroy" :)] and go back to the full-scan way if yes.)

But I still had a hard time with it... Finally I realized that if I do filtering this way, I have to start filtering from the topmost commit which affects the given file.

If I just start from origin/HEAD (assuming that it's on a commit which does not affect the file), then it won't be found as a key of the mapping created by git-filter-branch (as it's ignored because rev-listing was narrowed down to the file), and therefore filter-branch finally punts with "WARNING: Ref '<sha1>' is unchanged". I don't know if it's an intended behaviour, or something which could/should be improved, or at least documented... seems to be some sort of POLS violation to me (at least I was surprised :) ).

Regards, Csaba

Previous: Jeff KingNext: Jeff King
Message 6 of 8 in “import files w/ history”
  1. Csaba HenkMar 3, 2009
  2. Jeff KingMar 3, 2009
  3. Csaba HenkMar 6, 2009
  4. Miklos VajnaMar 6, 2009
  5. Jeff KingMar 8, 2009
  6. Csaba HenkMar 9, 2009
  7. Jeff KingMar 10, 2009
  8. Csaba HenkMar 11, 2009

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.