Only print the progress message if on a TTY
authorCatalin Marinas <catalin.marinas@gmail.com>
Tue, 5 Dec 2006 22:07:22 +0000 (22:07 +0000)
committerCatalin Marinas <catalin.marinas@gmail.com>
Tue, 5 Dec 2006 22:07:22 +0000 (22:07 +0000)
The "Checking for changes..." message should only be printed if stdout
is a TTY to avoid unnecessary information for people redirecting the
output to a file.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
stgit/git.py

index 0e83ffc..984b749 100644 (file)
@@ -185,10 +185,9 @@ def __tree_status(files = None, tree_id = 'HEAD', unknown = False,
                   noexclude = True, verbose = False):
     """Returns a list of pairs - [status, filename]
     """
-    if verbose:
-        print >> sys.stderr, \
-              'Checking for changes in the working directory...',
-        sys.stderr.flush()
+    if verbose and sys.stdout.isatty():
+        print 'Checking for changes in the working directory...',
+        sys.stdout.flush()
 
     refresh_index()
 
@@ -226,8 +225,8 @@ def __tree_status(files = None, tree_id = 'HEAD', unknown = False,
         if fs[1] not in conflicts:
             cache_files.append(fs)
 
-    if verbose:
-        print >> sys.stderr, 'done'
+    if verbose and sys.stdout.isatty():
+        print 'done'
 
     return cache_files