git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Genealogical branches
@ 2006-02-16  2:20 Ron Parker
  0 siblings, 0 replies; only message in thread
From: Ron Parker @ 2006-02-16  2:20 UTC (permalink / raw)
  To: git

[-- Attachment #1: Type: text/plain, Size: 3710 bytes --]

I am working on a stepped tutorial that walks the user through the
development of a number of related files. I have been trying to keep
this under various SCMs. Currently git seems like the best match. But
I have some questions.

The issue is that I want to have a directory which will ultimately
contain selected portions of the final products genealogy in addition
to other files. For example:

        README
        ...
        test1
        test2
        test3a
        test3b
        ...

And each step is developed from the preceding one. However, not being
perfect, there have been occasions where I have found mistakes in an
earlier step that need to be corrected and propagated to the later
steps.

I have found a work flow that seems to do what I want, but there may
be a better way to do this and I would like some advice. I initialize
the DB and work on test1, that is then branched to step2 where test1
is first renamed and then modified to become test2.

At this point I create a "final" branch and through some shenanigans I
don't completely understand, I pull from master and B2 to get both
step1 and step2 into final with their full history. Then as changes
are made to step1 I can pull those into later steps. Another tricky
part is that when I get to final, I have to pull from all of the
ancestral branches simultaneously.

Anyway, here is an annotated script that illustrates this, it is also
attached without the extra commentary:

--- BEGIN GENETEST.SH ---
mkdir genetest
cd genetest
git init-db
cat - >test1 <<EOF
aaaaaaaa
BBBBBBBB
cccccccc
EOF
echo README>README
git add .
git commit -a -m "Initial checkin"

# Create step2 branch
git checkout -b step2
git mv test1 test2
git commit -a -m "Created step2"
echo dddddddd>>test2
echo "README 2">README
git commit -a -m "Added step2 changes"

# Create conglomerate branch
git checkout master
git checkout -b final

# This is where the shenanigans come in. I'm not even completely sure
#  why it works. But arrived at the first two commands through
# experimentation. I thought one or the other would suffice, but
# neither alone did.  The two together, however, bring this basically
# up to step2 status with test1 being deleted and a step2->step2
# merge indicated in the log.
git fetch -a . step2
git pull -a . step2

# So then this finds the deleted file and brings it back in from master.
FILES=$(git-diff-index --name-only --diff-filter=D master)
git add $FILES

git commit -a -m "Created final"

# Now let's go modify master and see whether or not changes
# propagate forward to both files in final.
git checkout master
cat - >test1 <<EOF
aaaaaaaa
bbbbbbbb
cccccccc
EOF
git commit -a -m "Fixed the B... line"

# Pull the changes into step2 and resolve the conflict from the
# too-close-together line changes.
git checkout step2
git pull . master || true
mv -f test1 test2
echo dddddddd>>test2
MSG=$(cat .git/MERGE_MSG)
git commit -a -m "$MSG"

# Now check that all changes come through successfully,
# the interesting thing is that all the "ancestor" branches
# MUST be pulled at together or things don't work.
git checkout final
git pull . master step2

# Check that README matches the one from step2
# and that the B... line has been corrected in both
# versions of the ancestor file.
cat README
cat test1
cat test2

# If we've gotten this far, say so.
echo SUCCEEDED
--- END GENETEST.SH ---

So can anyone explain why the mystery portions "work" and why I have
to pull from all the ancestral branches simultaneously?

Also, if you have a better solution or work flow I'm open to it.

Thanks,

--
Ron Parker

[-- Attachment #2: genetest.sh --]
[-- Type: application/x-sh, Size: 1314 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-02-16  2:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-02-16  2:20 Genealogical branches Ron Parker

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).