[racket-dev] Using `git submodule` vs. `git pull --ff-only upstream master`

From: Spencer Florence (spencer at florence.io)
Date: Thu Apr 17 21:37:23 EDT 2014

stale git submodules show up on a status. What I've found helpful is to add
a bit in my prompt that tells me if the current git repository has a non
"up to date" status (And the current branch). If you're running Zsh this is
a good place to start for that:

git_prompt_info() {
  ref=$(git symbolic-ref HEAD 2> /dev/null)
  if [[ -n $ref ]]; then
    echo -n "[%F{red}${ref#refs/heads/}%f"
    st=$(git status -s 2> /dev/null)
    if [[ -n $st ]]; then
      echo -n "%f*%f"
    fi
    echo -n "]"
  fi
}
export PS1='$(git_prompt_info)[%F{green}%m%F{white}:%F{blue}%2c%f] '


Or on Bash:


function git_prompt_info() {
  ref=$(git symbolic-ref HEAD 2> /dev/null | cut -d'/' -f3)
  if [[ -n $ref ]]; then
    # Zsh prompt this was based on
    # echo "[%{$fg_bold[green]%}${ref#refs/heads/}%{$reset_color%}]"
    echo "[$(tput setaf 2)$ref$(tput sgr0)]"
  fi
}
export PS1="\$(git_prompt_info)$PS1"


On Thu, Apr 17, 2014 at 9:25 PM, Greg Hendershott <greghendershott at gmail.com
> wrote:

> For whoever else might find this useful building on OS X.
>
> Building HEAD today I got this new error:
>
> raco setup: --- creating launchers ---
> raco setup: launcher: <console-bin>/raco
> raco setup: --- installing man pages ---
> raco setup: --- installing collections ---
> raco setup: --- post-installing collections ---
> raco setup: --- checking package dependencies ---
> make install-common-last
> make fix-paths
> if [ "" != "" ]; then \
>           racket/racketcgc -G /Users/greg/src/plt/racket/build/config -u \
>             "../../collects/setup/unixstyle-install.rkt" \
>             make-install-destdir-fix "../.." \
>             "/Users/greg/src/plt/racket/racket/bin"
> "/Users/greg/src/plt/racket/racket/collects"
> "/Users/greg/src/plt/racket/racket/doc"
> "/Users/greg/src/plt/racket/racket/lib"
> "/Users/greg/src/plt/racket/racket/include"
> "/Users/greg/src/plt/racket/racket/lib"
> "/Users/greg/src/plt/racket/racket/share"
> "/Users/greg/src/plt/racket/racket/etc"
> "/Users/greg/src/plt/racket/racket/share/applications"
> "/Users/greg/src/plt/racket/racket/man" "yes"; \
>         fi
> make preserve-raco-pkg-default-scope
> :
> cp "../COPYING-libscheme.txt" "../COPYING_LESSER.txt" "../COPYING.txt"
> "/Users/greg/src/plt/racket/racket/share"/
> if racket/bin/racket -G build/config -I racket/base -e '(case
> (system-type) [(macosx) (exit 0)] [else (exit 1)])' ; then make
> native-from-git ; fi
> if [ ! -d native-pkgs/racket-win32-i386 ]; then make complain-no-submodule
> ; fi
> make pkg-links PKGS="main-distribution plt-services" LINK_MODE="--save"
> racket/bin/racket -U -G build/config racket/src/link-all.rkt ++dir
> pkgs ++dir native-pkgs --save main-distribution plt-services
> racket-lib
> Linking packages:
>   plt-services
>   racket-lib
>   main-distribution
> Recording packages choice in racket/etc/link-pkgs.rktd
> link-all: requested package not available: "draw-x86_64-macosx-2"
>   context...:
>    /Users/greg/src/plt/racket/racket/src/link-all.rkt:150:6: for-loop
>    /Users/greg/src/plt/racket/racket/src/link-all.rkt:148:2: loop
>    /Users/greg/src/plt/racket/racket/src/link-all.rkt: [running body]
> make[2]: *** [pkg-links] Error 1
> make[1]: *** [plain-in-place] Error 2
> make: *** [in-place] Error 2
>
>
> Although this is unlike the previous symptoms of stale submodules,
> "draw-x86_64-macosx-2" sounds like something that might be related to
> native-pkgs. So on a hunch I tried this:
>
> $ git submodule update
> remote: Counting objects: 214, done.
> remote: Compressing objects: 100% (157/157), done.
> remote: Total 214 (delta 59), reused 183 (delta 44)
> Receiving objects: 100% (214/214), 19.84 MiB | 54 KiB/s, done.
> Resolving deltas: 100% (59/59), done.
> From https://github.com/plt/libs
>    b698e73..3d8856e  master     -> origin/master
> Submodule path 'native-pkgs': checked out
> '3d8856eb987af16ab27cc99d4d24d5f9e7efc33b'
>
>
> Although it was an unusually slow/big fetch, it succeeded.
>
> And now the build now. (Well as I type this, my laptop fans are
> blazing away, as it is still running the raco setup stage. But it
> proceeded OK past the point it was failing before.)
>
> Maybe this is obvious to everyone else, but I wanted to mention it in
> case it helped anyone else building on OS X.
>
> On Tue, Dec 17, 2013 at 4:48 PM, Greg Hendershott
> <greghendershott at gmail.com> wrote:
> > To answer my own question, back in July Matthew had posted here:
> >
> > On Sat, Jul 27, 2013 at 9:10 AM, Matthew Flatt <mflatt at cs.utah.edu>
> wrote:
> >> Nothing has been split out of the current git repository, but there is
> >> now a "native-pkgs" git submodule for the native-library packages.
> >>
> >> If you build on Mac OS X or Windows or if you run a snapshot build,
> >> then you'll need to use
> >>
> >>   git pull
> >>   git submodule init
> >>   git submodule update
> >>
> >> once on each repository checkout from now on, and
> >>
> >>   git pull
> >>   git submodule update
> >>
> >> for updates after the first checkout.
> >>
> >> If you just `git pull' without the submodule commands, then you'll have
> >> an empty "native-pkgs" directory. That's fine if you're building on,
> >> say, Linux. If you're on Mac OS X or Windows, then the makefile should
> >> give you a good error message and suggest using `git submodule init'
> >> and `git submodule update'.
> >>
> >> If you use `git submodule update' today and forget to use it in the
> >> future, probably things will be fine for a long time, because
> >> "native-pkgs" doesn't change often. If "native-pkgs" does change and
> >> you forget `git submodule update', then (as I understand things) `git
> >> status' will tell you that there's a mismatch. The mismatch report
> >> might take a form that's not entirely clear, but it should be enough to
> >> remind you to run `git submodule update'.
> >
> > It turned out that it wasn't enough to remind _me_. :)  Running `git
> > submodule update` resolved this for me.
> >
> >
> > On Fri, Sep 20, 2013 at 2:30 PM, Greg Hendershott
> > <greghendershott at gmail.com> wrote:
> >> I build Racket while keeping my forked repo's `master` branch an
> >> exact, fast-forwardable copy of PLT's remote upstream `master`. [1]
> >>
> >> This has worked fine building Racket on Linux, and continues to do so.
> >>
> >> But on OS X, I need to follow these instructions from INSTALL.TXT, wrt
> >> the pkg re-org:
> >>
> >>>>>
> >> On Mac OS X and Windows, you'll need native-library packages in the
> >> "native-pkgs" directory. In the git repostory, "native-pkgs" is a git
> >> submodule, so you'll need
> >>    git submodule init
> >>    git submodule update
> >> to get it set up.
> >> <<<
> >>
> >> After I do so, the resulting build works great.
> >>
> >> However it introduces a change:
> >>
> >>>>>
> >> greg at mbp in ~/src/plt/racket on master*
> >> $ git diff
> >> diff --git a/native-pkgs b/native-pkgs
> >> index f367c0c..f8c8984 160000
> >> --- a/native-pkgs
> >> +++ b/native-pkgs
> >> @@ -1 +1 @@
> >> -Subproject commit f367c0c4b05b91401d68b0180b416d616b31720d
> >> +Subproject commit f8c8984ebe8a442d474558dced0eb824cbb24772
> >> <<<
> >>
> >> If I commit this, my master wouldn't be a FF copy anymore (AFIK). So I
> don't.
> >>
> >> But as a result, if I switch to a topic branch without committing
> >> (normally a no-no), it's a bit weird:
> >>
> >>>>>
> >> greg at mbp in ~/src/plt/racket on master*
> >> $ git checkout imap-append-flags
> >> warning: unable to rmdir native-pkgs: Directory not empty
> >> Switched to branch 'imap-append-flags'
> >> <<<
> >>
> >> After switching back to master, everything seems OK:
> >>
> >>>>>
> >> greg at mbp in ~/src/plt/racket on imap-append-flags*
> >> $ git checkout master
> >> M native-pkgs
> >> Switched to branch 'master'
> >> Your branch is ahead of 'origin/master' by 771 commits.
> >> <<<
> >>
> >> Is this -- the warning about native-pkgs -- something I should just
> >> learn to ignore and treat as the new normal?
> >>
> >>
> >> [1]:
> http://www.greghendershott.com/2013/04/a-guide-for-infrequent-contributors-to-racket.html
> _________________________
>   Racket Developers list:
>   http://lists.racket-lang.org/dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/dev/archive/attachments/20140417/dc7be6b2/attachment-0001.html>

Posted on the dev mailing list.