diff --git a/make/projects-dir.mk b/make/projects-dir.mk index 6cafc19e..19d8ff76 100644 --- a/make/projects-dir.mk +++ b/make/projects-dir.mk @@ -305,7 +305,7 @@ pull-all: purge git-get git-pull-all touch pull.done diff-all diff: $(SSH_WRAPPER_SH) - $(PGIT_SH) diff + $(PGIT_SH) --porcelain diff get-official: git-get-official get-maintainer: git-get-maintainer @@ -321,10 +321,10 @@ git-push-all: $(SSH_WRAPPER_SH) $(PGIT_SH) push $(PGIT_SH_OPTS_NETWORK) --all --recurse-submodules=on-demand git-diff: $(SSH_WRAPPER_SH) - $(PGIT_SH) diff + $(PGIT_SH) --porcelain diff git-short-diff: $(SSH_WRAPPER_SH) - $(PGIT_SH) diff --shortstat + $(PGIT_SH) --porcelain diff --shortstat git-status: $(PGIT_SH) status -uno @@ -349,7 +349,7 @@ git-get-%: $(SSH_WRAPPER_SH) $(PGIT_SH_GET) $(PGIT_SH_OPTS_NETWORK) --refspec "$*:master:current-branch" git-show-non-master-branches: - $(Q)$(PGIT_SH) branch 2>&1 | \ + $(Q)$(PGIT_SH) --porcelain branch 2>&1 | \ sed '/^#\|^*/!d; s/.*git -C //; s/ *branch *//; s/ *\* *//' | \ while read p; do \ read b ;\ diff --git a/scripts/pgit.sh b/scripts/pgit.sh index d26e544f..9a178940 100644 --- a/scripts/pgit.sh +++ b/scripts/pgit.sh @@ -4,7 +4,13 @@ log() { - echo "$myname $*" + local prefix="| " + [ "$porcelain" = 0 ] || prefix="" + if [ "$1" ]; then + echo "$prefix$*" >&2 + else + sed "s/^/$prefix/" >&2 + fi } err() @@ -38,6 +44,26 @@ fat_marker() log "# ====================================================$(counter) $@" } +log_start_stop() +{ + [ "$porcelain" = 1 ] || return + local b e + if [ "$1" = start ]; then + b="," + e=">" + else + b="\`" + e="<" + fi + shift + echo "$b----------------------------------------------- Running $cmdline --$e--" >&2 +} + +goodbye() +{ + log_start_stop stop +} + # # Guess and set the following global variables: # @@ -72,7 +98,11 @@ set_global_variables() run_git() { marker git "$@" - git "$@" + if [ "$porcelain" = 1 ]; then + git "$@" + else + git "$@" 2>&1 | log + fi } # ----------------- Commands @@ -194,7 +224,7 @@ cmd_get() if [ -z "$projects" ]; then projects=`$jw_projects projects list-repos --from-owner $from_user $remote_base` - [ "$?" != 0 ] && exit 1 + [ "$?" != 0 ] && fatal "Failed to enumerate repositories" fi if [ "$remote_user" ]; then @@ -224,7 +254,7 @@ cmd_get() [ "$refspec_arg" -a "$refspec_arg" != "$from_user:$from_ref:$to_ref" ] && log_refspec="$log_refspec ($refspec_arg)" fat_marker "Getting project $project_name from $log_refspec" if [ -d $project_dir ]; then - run_git -C $project_dir remote | grep -q "^$remote_name$" || { + git -C $project_dir remote | grep -q "^$remote_name$" || { run_git -C $project_dir remote add $remote_name $pull_url [ "$from_user" = "$remote_user" ] || run_git -C $project_dir remote set-url --push $remote_name no_push } @@ -265,7 +295,9 @@ cmd_diff() ) myname=${0##*/} -log "Running $0 $@" +cmdline="$myname $*" +porcelain=0 +log_start_stop start log "GIT_SSH=$GIT_SSH" log "JW_PKG_SSH_EXTRA_OPTS=$JW_PKG_SSH_EXTRA_OPTS" @@ -280,6 +312,9 @@ while [ "${1:0:1}" = - ]; do global_remote_base="$2" shift ;; + '--porcelain') + porcelain=1 + ;; esac shift done @@ -299,12 +334,13 @@ while [ "${1:0:1}" = - ]; do case $1 in '--login') remote_user="$2" - shift 2 + shift ;; *) break ;; esac + shift done case $cmd in