Subject: Re: Subtree in Git

From: Herman van Rink <[email-masked]>
Date: Wed, 13 Jun 2012 15:20:03 +0200

On 12-06-12 03:30, [email-masked] wrote:
> <[email-masked]> writes:
>
>> <[email-masked]> writes:
>>
>>>> Its now available as https://github.com/helmo/git/tree/subtree-updates
>>>> The subtree merge version is still available as
>>>> https://github.com/helmo/git/tree/subtree-updates-merged
>>> Cool.  I'll take a look, probably Wednesday at the earliest.
>> Ack.  Sorry, I got sidetracked by home repair issues.  This is still on
>> my radar.  Just wanted to let you know I haven't forgotten.
> Ok, I FINALLY got a look at this (yay!).  Some comments:
>
> Can you put each of these changes in its own commit?
>
>     Collected subtree updates
>     
>     These include:
>      * a .gittrees file with meta data
>      * new sub commands (push-all, pull-all, from-submodule, prune, diff, list)
>      * Documentation updates
>
> It's hard to tell what's what with one big diff.  Each command should
> get its own commit plus more if infrastructure work has to be done.  I
> realize it's a bit of a pain to reformulate this but git rebase -i makes
> it easy and the history will be much better long-term.
>
> Each command should be described briefly in the commit log.

That would indeed be nice, but as some parts interdependent it would be
rather complicated.
And what is the use if their not fully independently testable.

If you want to fake a nice history tree then go ahead, I just don't have
the energy to go through these commits again just for that.

> Some questions/comments:
>
> - Is .gittrees the right solution?  I like the feature it provides but
>   an external file feels a bit hacky.  I wonder if there is a better way
>   to track this metadata.  Notes maybe?  Other git experts will have to
>   chime in with suggestions.

It's similar to what git submodule does. And when you add this file to
the index you can use it on other checkouts as well.

>
>
> +               # this is ugly, but I don't know of a better way to do it. My git-fu is weak.
> +               # git diff-tree expects a treeish, but I have only a repository and branch name.
> +               # I don't know how to turn that into a treeish without creating a remote.
> +               # Please change this if you know a better way!
>
> - Anyone know a better way?  :)
>
>
> +               if [ $# -eq 1 ]; then
> +                       repository=$(git config -f .gittrees subtree.$prefix.url)
> +                       refspec=$1
> +               elif [ $# -eq 2 ]; then
> +                       repository=$1
> +                       refspec=$2
> +               else
> +                       repository=$(git config -f .gittrees subtree.$prefix.url)
> +                       refspec=$(git config -f .gittrees subtree.$prefix.branch)
> +               fi
>
> - This code seems to be repeated a lot.  Maybe it should be a utility
>   function.

Yes that's there three times...
 
>
>
> <more>
> +check_not()
> +{
> +       echo
> +       echo "check: NOT " "$@"
> +       if "$@"; then
> +               echo FAILED
> +               exit 1
> +       else
> +               echo ok
> +               return 0
> +       fi
> +}
> +
> +check_equal()
> +{
> +       echo
> +       echo "check a:" "{$1}"
> +       echo "      b:" "{$2}"
> +       if [ "$1" = "$2" ]; then
> +               return 0
> +       else
> +               echo FAILED
> +               exit 1
> +       fi
> +}
> <more>
>
> - I removed all this stuff in favor of the test library.  Please don't
>   reintroduce it.  These new tests will have to be rewritten in terms of
>   the existing test infrastructure.  It's not too hard.

I've left it in to be able to verify your new tests. Once all the new
tests are passing we can get rid of the old one, not before.
And as all the old tests are contained in test.sh it should not interfere...

>
> I like the features introduced here.  The code and tests need a bit of
> cleanup and they really should be split into multiple commits.
>
> Thanks for working on this!
>
>                                    -Dave
>

-- 
Met vriendelijke groet / Regards,

Herman van Rink 
Initfour websolutions