Re: import files w/ history

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2009-03-03, Jeff King <peff@xxxxxxxx> wrote:
> On Tue, Mar 03, 2009 at 12:54:54PM +0000, Csaba Henk wrote:
>
>> How could I import some files from an unrelated git repo with history?
>
> Just "git pull" from the other repo, which will include all of its
> history. If you want to pretend that the other history contains just a
> subset of the true history, use "git filter-branch" to rewrite it first.

Thanks Jeff, but it didn't work well for a large repo. At least not what
I could carve out myself.

The repo in question is the DragonFlyBSD repository, and I wanted to
cut out the history of sys/dev/disk/vn/vn.c. After reading
git-filter-branch(1) I come up with the following: first I wanted to
select those commits where the file in question was modified. I tried
to use the following filtration:

$ git filter-branch --commit-filter '
   if [ $# -lt 3 ] || git diff --stat $3 $1 | grep -q 'sys/dev/disk/vn/vn\.c'
   then
     git commit-tree "$@"
   else
     skip_commit "$@"
   fi' HEAD

It should select those commits where vn.c differs from the vn.c in the _first_
parent, so probably it's not exactly what I want, but anyway, I went on
to give it a try.

I have even tested this filter script on a small repo and it worked
well. Then I ran it against the Dfly repo, and after 23 hours of
processing I ended up with:

...
23575b3e0b087120b0475ae93c505c72a9779fdb
35ac2f0aa5ac0ca78109781817c524fa354e8691
23575b3e0b087120b0475ae93c505c72a9779fdb
35ac2f0aa5ac0ca78109781817c524fa354e8691
23575b3e0b087120b0475ae93c505c72a9779fdb
35ac2f0aa5ac0ca78109781817c524fa354e8691
23575b3e0b087120b0475ae93c505c72a9779fdb
35ac2f0aa5ac0ca78109781817c524fa354e8691
23575b3e0b087120b0475ae93c505c72a9779fdb
35ac2f0aa5ac0ca78109781817c524fa354e8691
WARNING: Ref 'refs/heads/__rewrite' points to the first one now.

And the result is completely f*cked up.
Neither those two commits which occur repeatedly at the end of the
output, nor the commit at the actual position of the __rewrite brach
has a parent, and the upstream commits from which these were derived
didn't affect vn.c.

  *  *  *

OK, I then tried to do more RTFM and be more clever and efficient, and
find a way to specify directly those commits which affect vn.c. As "git
rev-list" can be invoked like "git rev-list <commit> <path>", and the
synopsis of "git filter-branch" is like

 git filter-branch [options] [--] [<rev-list options>...]

I then gave a try to:

$ git filter-branch --  master sys/dev/disk/vn/vn.c

but no dice -- I got:

  fatal: ambiguous argument 'sys/dev/disk/vn/vn.c': unknown revision or
  path not in the working tree.
  Use '--' to separate paths from revisions
  Could not get the commits

Any idea?

Thanks,
Csaba

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux