git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] checkout: be quiet if not on isatty()

From
SNSteffen Daode Nurpmeso <sdaoden@googlemail.com>
Date
Aug 27, 2011, 19:45 UTC
Message-ID
<cover.1314472512.git.sdaoden@gmail.com>
In-Reply-To
<7vwrg5u7oz.fsf@alter.siamese.dyndns.org>
(Original subject was:
Re: [PATCH] progress: use \r as EOL only if isatty(stderr) is true)
@ Junio C Hamano <gitster@pobox.com> wrote (2011-06-28 20:33+0200):
> [..]
> I thought that we try to disable the progress pretty much
> everywhere when we are not talking to a tty[..]
Today i got this by accident:
    ================================================================
    openbsd-src.git-null: performing reduce
    Checking out files:  17% (11410/65508)   ^MChecking out files:
    18% (11792/65508)   ^M [..]

This is the output of my dumb arena-manager, which i append after the first scissor for reference. (Maybe someone finds it useful. It's a dumb sh(1) thing, i don't do shell scripting that often.) I haven't actually tried it yet, but setting .quiet for unpack_trees may stop this output. (Compilation succeeds, though.) I still and *truly* have no idea of the git(1) internals, so i may oversee .. just *any* thinkable side-effect. Hope this helps a bit. (Actual patch as response. Have a nice weekend.)

--Steffen
Ciao, sdaoden(*)(gmail.com)
ASCII ribbon campaign           ( ) More nuclear fission plants
  against HTML e-mail            X    can serve more coloured
    and proprietary attachments / \     and sounding animations
-- >8 --
#!/bin/bash
# NOTE: this acts according to extensions, e.g.:
#   docutils.svn-git-null: git svn
#   groff.cvs-git-null   : git cvsimport
#   openbsd-src.git-null : git
#   vim.hg-null          : Mercurial
# If a '-null' is in the suffix one may use 'reduce' and 'expand'
# modes; for git(1) these modes require an empty NULL branch:
#   $ git co --orphan NULL && git rm -rf '*' &&
#     echo DEFAULT-BRANCH >NULL && git add NULL && git ci -m NULL
# Mercurial has builtin support for 'null'.  (Nice for backups.)

# Top dir where everything happens ARENA="$HOME/arena/code.extern.repos"

##

GIT=git HG=hg SVN=svn CVS='cvs -fz 9 update -ACRPd' ESTAT=0 LOGFILE=lastlog.txt CVSROOT=/nonexistent CURR=/nonexistent

log() {
    echo "$*"
    echo "$*" >> $LOGFILE
}
logerr() {
    echo >&2 "ERROR: $*"
    echo "ERROR: $*" >> $LOGFILE
    ESTAT=1
}
SEP='================================================================'
intro() {
    log ''
    log $SEP
    log $1
}
final() {
    local es=$?
    if test $es -eq 0; then
        log "... ok: $1"
    else
        logerr "$1"
        ESTAT=$es
    fi
    log $SEP
    log ''
}
if test "$BASH" = x""; then
    echo >&2 "This script needs the GNU bash shell interpreter"
    exit 1
fi
cd $ARENA || {
    echo >&2 "Failed to chdir to $ARENA"
    exit 1
}
rm -rf $LOGFILE || {
    echo >&2 "Failed to remove stale $LOGFILE"
    exit 1
}

MODE="$1" shift PARAMS="$@" set -u test $# -ne 0 || PARAMS=$(echo *.*)

# Perform basename cleanup and move over to $params[]
log "$0: script startup, mode $MODE"
declare -a params
for rd in $PARAMS; do
    rd=$(echo "$rd" | sed -Ee 's/(.+)\/+$/\1/' -e 's/.*\/([^/]+)$/\1/')
    params[${#params[*]}]="$rd"
done
GITDID=
case "$MODE" in
reduce|expand)
    if test "$MODE" == 'reduce'; then
        git_branch='NULL'
        hg_branch='null'
    else
        git_branch=
        hg_branch=''
    fi
    for rd in ${params[@]}; do
        if test "$rd" == "${rd/null/}"; then
            log "[$rd: $MODE does not apply]"
            continue
        fi
        intro "$rd: performing $MODE"
        set -o pipefail
        (   cd "$rd" || exit 1
            if test "$rd" != "${rd/git-null}"; then
                # On branch NULL file NULL contains master branch's name
                if test -z "$git_branch"; then
                    if test -f NULL; then
                        git_branch=$(<NULL)
                    else
                        echo >&2 "No file NULL in $rd"
                        git_branch=master
                    fi
                fi
                $GIT checkout $git_branch
            else
                $HG up $hg_branch
            fi
            exit $?
        ) 2>&1 | tee -a "$LOGFILE"
        final "$rd"
        set +o pipefail
    done
    ;;
update)
    for rd in ${params[@]}; do
        intro "$rd: performing $MODE"
        set -o pipefail
        (   cd "$rd" || exit 1
            if test "$rd" != "${rd/.git}"; then
                #$GIT pull -v --ff-only --stat --prune
                $GIT fetch --verbose --prune
                GITDID=1
            elif test "$rd" != "${rd/.svn-git}"; then
                $GIT svn rebase
                GITDID=1
            elif test "$rd" != "${rd/.cvs-git}"; then
                ldir='.git/.cvsps'
                tar xjf "$ldir.tbz" || {
                    echo >&2 "$rd: bail: tar xjf $ldir.tbz"
                    exit 1
                }
                hdir="$HOME/.cvsps"
                test -d "$hdir" || mkdir "$hdir" || {
                    echo >&2 "$rd: failed to create $hdir directory"
                    exit 2
                }
                root="$ldir/CVSROOT"
                repo="$ldir/MODULE"
                cache=$(<$ldir/CVSPS_FILE)
                mv -f "$ldir/cvs-revisions" .git/
                mv -f "$ldir/$cache" "$hdir/$cache"
                $GIT cvsimport -aR -r origin -p '-u,--cvs-direct' \
                     -d $(<$root) $(<$repo)
                es=$?
                GITDID=1
                mv -f .git/cvs-revisions "$ldir/"
                mv -f "$hdir/$cache" "$ldir/$cache"
                tar cjf "$ldir.tbz" "$ldir" || {
                    echo >&2 "$rd: bail: tar cjf $ldir.tbz $ldir"
                    exit 3
                }
                rm -rf $ldir
                exit $es
            elif test "$rd" != "${rd/.hg}"; then
                $HG -v pull #-u
            elif test "$rd" != "${rd/.svn}"; then
                $SVN update
            elif test "$rd" != "${rd/.cvs}"; then
                $CVS
            else
                echo "Unknown revision-control-system: $rd"
                exit 1
            fi
        ) 2>&1 | tee -a "$LOGFILE"
        final "$rd"
        set +o pipefail
    done
    ;;
fullgc|gc)
    gct=
    test "$MODE" == fullgc && gct=--aggressive
    for rd in ${params[@]}; do
        intro "$rd: performing $MODE"
        set -o pipefail
        (   cd "$rd" || exit 1
            test "$rd" != "${rd/.git}" && git gc $gct
        ) 2>&1 | tee -a "$LOGFILE"
        final "$rd"
        set +o pipefail
    done
    ;;
*)
    echo 'USAGE: manager reduce|expand|update|gc|fullgc LIST-OF-DIRECTORIES'
    exit 1
    ;;
esac
test x"$GITDID" != x && log 'git(1) fetched data - do arena-manager [full]gc ..'

test $ESTAT -ne 0 && log 'Errors occurred!' exit $ESTAT # vim:set fenc=utf-8 filetype=sh syntax=sh ts=4 sts=4 sw=4 et tw=79:

Previous: Nicolas PitreNext: Steffen Daode Nurpmeso
Message 12 of 21 in “progress: use \r as EOL only if isatty(stderr) is true”
  1. progress: use \r as EOL only if isatty(stderr) is trueSteffen Daode Nurpmeso, Jun 28, 2011
  2. Junio C HamanoJun 28, 2011
  3. Steffen Daode NurpmesoJun 28, 2011
  4. Steffen Daode NurpmesoJun 28, 2011
  5. Jeff KingJun 28, 2011
  6. Junio C HamanoJun 29, 2011
  7. Miles BaderJun 30, 2011
  8. sideband: remove line padding (was: Re: [PATCH] progress: use \r as EOL only if isatty(stderr) is true)Steffen Daode Nurpmeso, Jun 29, 2011
  9. Nicolas PitreJun 29, 2011
  10. Steffen Daode NurpmesoJun 30, 2011
  11. Nicolas PitreJul 1, 2011
  12. checkout: be quiet if not on isatty()Steffen Daode Nurpmeso, Aug 27, 2011
  13. checkout: be quiet if not on isatty()Steffen Daode Nurpmeso, Aug 27, 2011
  14. Junio C HamanoAug 28, 2011
  15. martin f krafftAug 28, 2011
  16. checkout: add --verbose, and restrict progress reporting (was: Re: [PATCH] checkout: be quiet if not on isatty())Steffen Daode Nurpmeso, Aug 28, 2011
  17. 0/2 Add update_progress(), divert checkout messagessdaoden@googlemail.com, Aug 29, 2011
  18. 1/2 progress: add update_progress()sdaoden@googlemail.com, Aug 29, 2011
  19. 2/2 unpack-trees: divert check_updates() output via update_progress()sdaoden@googlemail.com, Aug 29, 2011
  20. Steffen Daode NurpmesoJun 28, 2011
  21. Steffen Daode NurpmesoJun 28, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.