Re: git filter-branch --subdirectory-filter, still a mistery

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

 



Hi Thomas,

On Thursday 07 August 2008 09:50:03 am Thomas Rast wrote:
> Jan Wielemaker wrote:
> [...]
>
> > 	% git filter-branch --subdirectory-filter packages/chr HEAD
> >
> > This indeed creates a nice directory holding only the contents of
> > packages/chr.  But, starting qgit I see that all commits, also those
> > that had absolutely nothing to do with this dir are still there.
>
> The trick is to rewrite all refs, not just HEAD.  I usually proceed as
> follows:
>
>   cp -a repo repo.old  # just to keep a backup
>   cd repo
>   git filter-branch --subdirectory-filter somedir -- --all
>
> The --all tells it to rewrite as many refs as possible.  Note that the
> -- is required.  Also note that refs/original/* will still point to
> the old commits, so they won't "just vanish".  You may want to clone
> the repository or delete them manually once you are sure the
> filter-branch did the right thing.

Thanks. That is moving in the right direction! There are some, possibly
related, problems left (using 1.5.6.GIT).  According to git fsck,
my repo is clean.  I got:

  Ref 'refs/tags/V5.6.50' was rewritten
  error: Ref refs/tags/V5.6.50 is at 8678b32f71178019c06aefa40e2d3fb9a2e8ef25 
but
	expected 2e8aef64e2fed088720a19ac2ffa2481e5bc7806
  fatal: Cannot lock the ref 'refs/tags/V5.6.50'.
  Could not rewrite refs/tags/V5.6.50

Now, if I look in .git/packed-refs, I see this (i.e. a second line with
a ^) for all refs that cause problems:

274ec8ac671542206ba3567ff5d72b3e54c5603c refs/tags/V5.6.59
^28920c3c0a184698d9cd15a65cd643367200bbf5
faf203f9d9e350d84b6b38b7746e710b6232fc97 refs/tags/V5.6.58
^1edb1adedcc47ec15c3242234cc6b7ede94bbfba
48488c871227beabcb3ba167b737d6e33ced65bc refs/tags/V5.6.57
^766587b09e3d2f09c87b03ad0d7faf3529c9dcff

After a bit of puzzling I discovered the the SHA1 after the ^ refers to
the actual commit and I changed all these to `lightweight' tags by
putting the SHA1 behind ^ before the tag itself.  I wrote a little
sh/awk script to automate this (attached).

Now it runs to the end.  Unfortunagtely the history is completely
screwed up :-(:

	* There are a lot of commits that are not related to the dir
	* Commits start long before the directory came into existence,
	Looks like it just shows the whole project at this place.

I think the problem is related to the fact that the directory I want to
filter didn't exists at the start of the project. Looking at
git-rev-list, I found --remove-empty, so I added that after the --all,
but that doesn't appear to help.  I must admit I don't really know what
I'm doing (though I still think the result I want it well defined and
its hard to imagine I'm the only person who wants this).

If someone wants to help: clone git://gollem.science.uva.nl/home/git/pl.git
and try to filter the dir packages/chr.  You can browse the git at
http://gollem.science.uva.nl/git/pl.git

	Thanks --- Jan

Attachment: git-lightweight-tags
Description: application/shellscript


[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