trinity-devel@lists.pearsoncomputing.net

Message: previous - next
Month: February 2012

Re: [trinity-devel] confused by git: scripts/switch_all_submodules_to_head_and_clean - calls self recursively? Why?

From: "Timothy Pearson" <kb9vqf@...>
Date: Fri, 17 Feb 2012 18:30:15 -0600
> Guys,
>
>   Trying to sort out my git issues, I have been picking through
> switch_all_submodules_to_head_and_clean. I cannot understand what the
> purpose of
> the line:
>
> git submodule foreach "$THISSCRIPT $gituser"
>
>   That line causes git to step through each of its submodules and call:
>
> "switch_all_submodules_to_head_and_clean <gitUser>"
>
>   Why? The script has already done everything at least once before?
> Dissecting
> the script it does:
>
> git reset --hard HEAD
> git clean -dxf
> git pull
> git reset --hard HEAD
> git clean -dxf
> sed -i "s/system@/$gituser@/g" .gitmodules  # or 's/system@//g'
> git submodule init
> git submodule update
> git submodule foreach "git checkout master"
> git submodule foreach "git pull"
>
> then it does:
>
> git submodule foreach "$THISSCRIPT $gituser"
>
>   Which causes this script to be run all over again on each submodule... I
> have
> changed this version of my script as follows and it seems to run on each
> submodule anyway:
>
> git reset --hard HEAD
> git clean -dxf
> git pull
> git reset --hard HEAD
> git clean -dxf
> sed -i "s/system@/$gituser@/g" .gitmodules  # or 's/system@//g'
> git submodule init
> git submodule update --recursive
> git submodule foreach --recursive "git checkout master"
> git submodule foreach --recursive "git pull"
>
>
> git pull gets everything:
>
> 16:32 archangel:/dat_f/tde/git> git pull
> remote: Counting objects: 14, done
> remote: Finding sources: 100% (12/12)
> remote: Total 12 (delta 8), reused 12 (delta 8)
> Unpacking objects: 100% (12/12), done.
> From http://scm.trinitydesktop.org/scm/git/tde
>    bf1ed1c..3f21128  master     -> origin/master
> Fetching submodule main/tdegraphics
> remote: Counting objects: 928, done
> remote: Finding sources: 100% (467/467)
> remote: Total 467 (delta 462), reused 467 (delta 462)
> Receiving objects: 100% (467/467), 35.02 KiB, done.
> Resolving deltas: 100% (462/462), completed with 455 local objects.
> <snip>
>
> git submodule init inits everything:
>
> 16:33 archangel:/dat_f/tde/git> git submodule init
> Submodule 'experimental' () registered for path 'experimental'
> Submodule 'main/applications/abakus' () registered for path
> 'main/applications/abakus'
> Submodule 'main/applications/adept' () registered for path
> 'main/applications/adept'
> <snip>
>
> git submodule update --recursive updates everything:
>
> 16:34 archangel:/dat_f/tde/git> git submodule update --recursive
> Submodule path 'main/applications/abakus': checked out
> 'af16f2796aed9a860d405ba77193bf4b9b90c21e'
> Submodule path 'main/applications/kio-locate': checked out
> '7415e07f61682107169f11e79cc0c8e50fb409a2'
> <snip>
>
> git submodule foreach --recursive "git checkout master" checks it all out:
>
> 16:35 archangel:/dat_f/tde/git> git submodule foreach --recursive "git
> checkout
> master"
> Entering 'experimental'
> Already on 'master'
> Entering 'main/applications/abakus'
> Already on 'master'
> <snip>
> Entering 'main/applications/kio-locate'
> Previous HEAD position was 7415e07... Remove spurious TQ_OBJECT instances
> Switched to branch 'master'
> Your branch is behind 'origin/master' by 1 commit, and can be
> fast-forwarded.
> Entering 'main/applications/kio-locate/cmake'
> Already on 'master'
> <snip>
>
> git submodule foreach --recursive "git pull" pulls everything:
>
> 16:35 archangel:/dat_f/tde/git> git submodule foreach --recursive "git
> pull"
> Entering 'experimental'
> Already up-to-date.
> Entering 'main/applications/abakus'
> remote: Counting objects: 17, done
> remote: Finding sources: 100% (9/9)
> remote: Total 9 (delta 8), reused 9 (delta 8)
> Unpacking objects: 100% (9/9), done.
> From http://scm.trinitydesktop.org/scm/git/abakus
>    af16f27..45794e3  master     -> origin/master
> Updating af16f27..45794e3
> Fast-forward
>  src/abakuslistview.h |    6 +++---
>  src/editor.h         |    4 ++--
>  src/function.h       |    2 +-
>  src/mainwindow.h     |    2 +-
>  src/resultlistview.h |    2 +-
>  src/valuemanager.h   |    2 +-
>  6 files changed, 9 insertions(+), 9 deletions(-)
> Entering 'main/applications/abakus/admin'
> Already up-to-date.
> Entering 'main/applications/abakus/cmake'
> Already up-to-date.
> <snip>
>
>   Why step through the modules doing it all over again? On my box, it just
> crashes with the error:
>
> "This script can only be run from a top level git directory.  Exiting..."
>
> What say the experts?

This behaviour was needed on my GIT versions to actually initialize the
submodules within other submodules (i.e. tdelibs/, which itself is a
submodule of tde/, contains a submodule admin/ that would not be
initialized normally by GIT).

I can't speak for the new versions of GIT yet. :-)

Tim