threads / discuss / 17243

parent-filter loses my merged branch -- what am I doing wrong?

Subject: parent-filter loses my merged branch -- what am I doing wrong?

## tl;dr

3 messages between Jan 19, 2009 and Jan 20, 2009.

replies: 2people: 2as markdown or json

Ask Bjørn Hansen· Jan 19, 2009, 03:45 UTC · lore
Hi everyone,

I'm converting another svn repository to git (yay). It's only about 1000 commits, but over more than 7 years and a cvs->svn conversion.

On Sam Villain's recommendation I'm spending a bit of time cleaning up the branches and merges with git filter-branch, but I don't think I'm quite understanding how it's supposed to work.

I put the repository up here (about 1MB):
	git clone git://git.develooper.com/qpsmtpd.git

I started out making a temporary tag for each svn commit, to have easier to use reference points:

for c in `git rev-list --all --date-order --timestamp | sort -n | awk  
'{print $2}'`; do
   svnid=`git show -s $c | tail -1 | sed 's/.*svn.perl.org\/qpsmtpd 
\///' | sed 's/\ .*//' | sed 's/^branches\///'`
   git tag -f $svnid $c
done

Then I tried getting the first merge adjusted to show both parents. The commit tagged v010@56 should be the second parent for trunk@57 (the original/other parent for trunk@57 is trunk@20).

I tried using:
git filter-branch --tag-name-filter cat --parent-filter '
                  if test $GIT_COMMIT = $(git rev-parse trunk@57)
                  then
                     echo "-p $(git rev-parse trunk@20) -p $(git rev- 
parse v010@56)"
                  else
                     cat
                  fi
         ' \
master

... but that seems to just basically throw away the "v010" branch! What did I do wrong? (Some of the other problems with this repository is that we moved the branches around with "svn mv", so some of the branches don't even have the branch point as a parent; but I'll get back to that when I get this simple case working).

(The script also loses all the temporary tags I added; I thought "-- tag-name-filter cat" would preserve them?)

  - ask
-- 
http://develooper.com/ - http://askask.com/
Johannes Sixt· Jan 19, 2009, 08:41 UTC · re: Ask Bjørn Hansen · lore

Re: parent-filter loses my merged branch -- what am I doing wrong?

Ask Bjørn Hansen schrieb:
> On Sam Villain's recommendation I'm spending a bit of time cleaning up
> the branches and merges with git filter-branch, but I don't think I'm
> quite understanding how it's supposed to work.

Don't use --parent-filter for this; use grafts. You can see the history in gitk right away. Later run filter-branch without a filter (except perhaps the tag-name-filter).

-- Hannes
Ask Bjørn Hansen· Jan 20, 2009, 20:05 UTC · re: Johannes Sixt · lore

Re: parent-filter loses my merged branch -- what am I doing wrong?

On Jan 19, 2009, at 0:41, Johannes Sixt wrote:
Show 11 quoted lines
> Ask Bjørn Hansen schrieb:
>> On Sam Villain's recommendation I'm spending a bit of time cleaning  
>> up
>> the branches and merges with git filter-branch, but I don't think I'm
>> quite understanding how it's supposed to work.
>
> Don't use --parent-filter for this; use grafts. You can see the  
> history in
> gitk right away. Later run filter-branch without a filter (except  
> perhaps
> the tag-name-filter).

Aha - excellent. I didn't understand clearly from the documentation that they'd be "written in stone" by filter-branch. Building the grafts with .git/info/grafts was much much easier.

   - ask
-- 
http://develooper.com/ - http://askask.com/

← back to recent threads