summaryrefslogtreecommitdiff
path: root/contrib/subtree/git-subtree.sh
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@datawire.io>2021-04-27 21:17:42 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-04-28 07:47:18 (GMT)
commit534ff90dbd74a81beee357220cfa026efc18fea6 (patch)
treea34fb1e4d3e7ee501ac0d1b3e2ee5cac895d2181 /contrib/subtree/git-subtree.sh
parent5cdae0f6fd76bd1c12304240a17a5a12632fbb12 (diff)
downloadgit-534ff90dbd74a81beee357220cfa026efc18fea6.zip
git-534ff90dbd74a81beee357220cfa026efc18fea6.tar.gz
git-534ff90dbd74a81beee357220cfa026efc18fea6.tar.bz2
subtree: don't let debug and progress output clash
Currently, debug output (triggered by passing '-d') and progress output stomp on each other. The debug output is just streamed as lines to stderr, and the progress output is sent to stderr as '%s\r'. When writing to a file, it is awkward to read and difficult to distinguish between the debug output and a progress line. When writing to a terminal the debug lines hide progress lines. So, when '-d' has been passed, spit out progress as 'progress: %s\n', instead of as '%s\r', so that it can be detected, and so that the debug lines don't overwrite the progress when written to a terminal. Signed-off-by: Luke Shumaker <lukeshu@datawire.io> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'contrib/subtree/git-subtree.sh')
-rwxr-xr-xcontrib/subtree/git-subtree.sh22
1 files changed, 21 insertions, 1 deletions
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 441571c..53a1a02 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -67,7 +67,27 @@ debug () {
progress () {
if test -z "$GIT_QUIET"
then
- printf "%s\r" "$*" >&2
+ if test -z "$arg_debug"
+ then
+ # Debug mode is off.
+ #
+ # Print one progress line that we keep updating (use
+ # "\r" to return to the beginning of the line, rather
+ # than "\n" to start a new line). This only really
+ # works when stderr is a terminal.
+ printf "%s\r" "$*" >&2
+ else
+ # Debug mode is on. The `debug` function is regularly
+ # printing to stderr.
+ #
+ # Don't do the one-line-with-"\r" thing, because on a
+ # terminal the debug output would overwrite and hide the
+ # progress output. Add a "progress:" prefix to make the
+ # progress output and the debug output easy to
+ # distinguish. This ensures maximum readability whether
+ # stderr is a terminal or a file.
+ printf "progress: %s\n" "$*" >&2
+ fi
fi
}