From: Thomas Rast <trast@student.ethz.ch>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: git@vger.kernel.org, Jan Wielemaker <J.Wielemaker@uva.nl>
Subject: Re: [RFH] filter-branch: ancestor detection weirdness
Date: Fri, 8 Aug 2008 16:14:41 +0200 [thread overview]
Message-ID: <200808081614.44422.trast@student.ethz.ch> (raw)
In-Reply-To: <alpine.DEB.1.00.0808081341170.9611@pacific.mpi-cbg.de.mpi-cbg.de>
[-- Attachment #1: Type: text/plain, Size: 3376 bytes --]
Johannes Schindelin wrote:
>
> On Fri, 8 Aug 2008, Thomas Rast wrote:
>
> > diff --git a/git-filter-branch.sh b/git-filter-branch.sh
> > index 182822a..52b2bdf 100755
> > --- a/git-filter-branch.sh
> > +++ b/git-filter-branch.sh
> > @@ -325,15 +325,9 @@ while read ref
> > do
> > sha1=$(git rev-parse "$ref"^0)
> > test -f "$workdir"/../map/$sha1 && continue
> > - # Assign the boundarie(s) in the set of rewritten commits
> > - # as the replacement commit(s).
> > - # (This would look a bit nicer if --not --stdin worked.)
> > - for p in $( (cd "$workdir"/../map; ls | sed "s/^/^/") |
> > - git rev-list $ref --boundary --stdin |
> > - sed -n "s/^-//p")
> > - do
> > - map $p >> "$workdir"/../map/$sha1
> > - done
> > + # Assign the first commit not pruned as the replacement.
> > + candidate=$(git rev-list $ref -1 -- "$filter_subdir")
I think I see the actual problem. I made a small testing repository
with history that looks like this:
* a6f2213... (refs/heads/master) Merge branch 'side'
|\
| * 311f888... (refs/heads/side) outside
| * 472893d... inside dir
* | 9bd52bc... (refs/heads/stale) outside
* | d1b451a... inside dir
|/
* 1c48eea... initial
It is available at
git://persephone.dnsalias.net/git/filtertest.git
if you want to try. All commits labelled 'inside dir' do something in
dir/; the others don't. (You can disregard the 'other' branch for
now; I wanted to test the behaviour on completely disconnected history
too, since that's the case with Jan's repo.)
Let's depict this as the following for now, where capitals stand for
"interesting" commits under the subdirectory filter:
i -- A -- b(stale) -- M(master)
\ /
\- C -- d(side) --/
When saying
$ git filter-branch --subdirectory-filter dir -- --all'
I would expect the history to look like:
A(stale) -- M(master)
/
C(side) --/
I think treating it this way makes a lot of sense; you get the last
state that your subdirectory had on the corresponding branch or tag.
(Similarly, a leaf branch that does not affect 'dir' should be backed
up until it hits an ancestor that survives the filter.)
Now the problem with the above ancestor detection is the following.
Consider that at this point, the 'map' directory contains the
(unfiltered) SHA1 for every commit that was rewritten during the
filtering process, i.e.
$ g rev-list --all -- dir | git name-rev --stdin
093c591b3d751ce778b4a6e5c2a0906b097b5868 (other~1)
a6f22134f8ab8bcc762949df53f674e3410f7fc3 (master)
d1b451a4b0657ea894fd772fc609f7863b7dfd15 (stale~1)
472893d579383f56f006ff42c563dcbb730bc5b8 (side~1)
So 'map' has the values for M, A, and C. Now if you expand the call
(cd "$workdir"/../map; ls | sed "s/^/^/") |
git rev-list $ref --boundary --stdin
you'll find that during ref=refs/heads/side, it is equivalent to
$ git rev-list side --boundary ^master ^side~1 ^stale~1 ^other~1
[no output!]
Oops, it seems that wasn't what we wanted. The '^master', which
reaches 'side' already, precludes all output.
So now that I've finally understood what is going on, I think a more
careful use of rev-list -1 is actually a correct and easy way to
figure out an ancestor. Patch follows.
- Thomas
--
Thomas Rast
trast@student.ethz.ch
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
next prev parent reply other threads:[~2008-08-08 14:15 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-06 13:39 git filter-branch --subdirectory-filter, still a mistery Jan Wielemaker
2008-08-07 7:13 ` Jan Wielemaker
2008-08-07 7:50 ` Thomas Rast
2008-08-07 10:14 ` Jan Wielemaker
2008-08-07 23:48 ` Thomas Rast
2008-08-07 23:50 ` [PATCH] filter-branch: be more helpful when an annotated tag changes Thomas Rast
2008-08-08 20:10 ` [TOY PATCH] filter-branch: add option --delete-unchanged Thomas Rast
2008-08-09 0:35 ` Johannes Schindelin
2008-08-11 10:43 ` Jan Wielemaker
2008-09-14 16:29 ` Felipe Contreras
2008-08-07 23:54 ` [RFH] filter-branch: ancestor detection weirdness Thomas Rast
2008-08-08 11:42 ` Johannes Schindelin
2008-08-08 14:14 ` Thomas Rast [this message]
2008-08-08 14:16 ` [PATCH] filter-branch: fix ancestor discovery for --subdirectory-filter Thomas Rast
2008-08-08 14:39 ` [RFH] filter-branch: ancestor detection weirdness Johannes Schindelin
2008-08-08 18:37 ` Thomas Rast
2008-08-08 18:39 ` [PATCH v2] filter-branch: fix ref rewriting with --subdirectory-filter Thomas Rast
2008-08-09 0:16 ` [RFH] filter-branch: ancestor detection weirdness Johannes Schindelin
2008-08-09 1:25 ` Junio C Hamano
2008-08-09 9:25 ` Thomas Rast
2008-08-09 9:35 ` Thomas Rast
2008-08-10 14:02 ` [PATCH] filter-branch: use --simplify-merges Thomas Rast
2008-08-12 1:54 ` Junio C Hamano
2008-08-12 2:13 ` Junio C Hamano
2008-08-12 5:47 ` Thomas Rast
2008-08-12 6:59 ` Junio C Hamano
2008-08-12 8:45 ` [PATCH 0/3] filter-branch --subdirectory-filter improvements Thomas Rast
2008-08-12 12:11 ` Jan Wielemaker
2008-08-12 8:45 ` [PATCH 1/3] filter-branch: Extend test to show rewriting bug Thomas Rast
2008-08-12 8:45 ` [PATCH 2/3] filter-branch: fix ref rewriting with --subdirectory-filter Thomas Rast
2008-08-12 8:45 ` [PATCH 3/3] filter-branch: use --simplify-merges Thomas Rast
2008-08-12 8:18 ` [RFH] filter-branch: ancestor detection weirdness Petr Baudis
2008-08-12 18:33 ` Junio C Hamano
2008-08-09 10:00 ` Thomas Rast
2008-08-12 21:33 ` Junio C Hamano
2008-08-12 22:15 ` Thomas Rast
2008-08-08 7:44 ` git filter-branch --subdirectory-filter, still a mistery Jan Wielemaker
2008-08-08 11:25 ` Jan Wielemaker
2008-08-07 14:04 ` [PATCH] Documentation: filter-branch: document how to filter all refs Thomas Rast
2008-08-07 14:16 ` [PATCH v2] " Thomas Rast
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200808081614.44422.trast@student.ethz.ch \
--to=trast@student.ethz.ch \
--cc=J.Wielemaker@uva.nl \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).