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

From: Greg Hendershott (greghendershott at gmail.com)
Date: Thu Apr 17 22:12:57 EDT 2014

Yes. FWIW I do:

function parse_git_dirty() {
  [[ $(git status 2> /dev/null | tail -n1) != *"working directory
clean"* ]] && echo "*"
}

function parse_git_branch() {
  git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/*
\(.*\)/\1$(parse_git_dirty)/"
}

Which goes into the the end of:

    greg at mbp in ~/src/plt/racket on master*
    $

And now that you mention it, I _did_ see the "*" in my prompt. I
should have paid attention to it, but
`git status` showed nothing. I should have done `git diff`.

Sorry for the noise here. (My total experience with git submodule
updates consists of the 2 or 3 times I've had to do this with Racket
-- and at intervals of enough months that I manage to forget in
between.)


On Thu, Apr 17, 2014 at 9:37 PM, Spencer Florence <spencer at florence.io> wrote:
> 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"

Posted on the dev mailing list.