# Re: [PATCH] Print progress message to stderr, not stdout

10 messages from 2006-11-11 to 2006-12-05. Participants: Johannes Schindelin, Catalin Marinas, Karl Hasselström, Marco Costalba.
Thread: https://gitlist.dev/t/43143

## Karl Hasselström, 2006-11-11 12:16

Subject: [PATCH] Print progress message to stderr, not stdout
Message-ID: <20061111121625.8988.45195.stgit@localhost>
URL: https://gitlist.dev/e/20061111121625.8988.45195.stgit%40localhost

```
Printing progress messages to stdout causes them to get mixed up with
the actual output of the program. Using stderr is much better, since
the user can then redirect the two components separately.

Signed-off-by: Karl Hasselström <kha@treskal.com>
---

I noticed this when creating a patch with "stg export -s" for the
import regression test.

 stgit/git.py |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/stgit/git.py b/stgit/git.py
index 2a6ae91..8d88769 100644
--- a/stgit/git.py
+++ b/stgit/git.py
@@ -186,8 +186,8 @@ def __tree_status(files = None, tree_id
     """Returns a list of pairs - [status, filename]
     """
     if verbose:
-        print 'Checking for changes in the working directory...',
-        sys.stdout.flush()
+        sys.stderr.write('Checking for changes in the working directory...')
+        sys.stderr.flush()
 
     refresh_index()
 
@@ -226,7 +226,7 @@ def __tree_status(files = None, tree_id
             cache_files.append(fs)
 
     if verbose:
-        print 'done'
+        print >> sys.stderr, 'done'
 
     return cache_files

```

## Marco Costalba, 2006-12-02 13:20

Subject: Re: [PATCH] Print progress message to stderr, not stdout
Message-ID: <e5bfff550612020520w3ad48a09xfdde63b9050a75cf@mail.gmail.com>
URL: https://gitlist.dev/e/e5bfff550612020520w3ad48a09xfdde63b9050a75cf%40mail.gmail.com
In-Reply-To: <20061111121625.8988.45195.stgit@localhost>

```
On 11/11/06, Karl Hasselström <kha@treskal.com> wrote:
> Printing progress messages to stdout causes them to get mixed up with
> the actual output of the program. Using stderr is much better, since
> the user can then redirect the two components separately.
>

This patch breaks qgit.

GUI interface to stgit pop and push commands is broken because a
command that prints to stderr is considered a failing one by qgit.

I would kindly ask you to:

1 - Revert the patch. That would be the best. You can use a prefix to
printed message instead, see git pull, something like 'stg: bla bla
bla' . In any case, IMHO, using stderr for normal activity logging
does not sound like a great idea in general.

2 - At least add a '-v' '--verbose' option that defaults to quiet so
to not break back compatibility.


Thanks
Marco

P.S: I cannot change the stderr == 'something has gone wrong'
behaviour because the interface to git commands works with this, and,
BTW, _all_ the git commands respect the behaviour stderr == empty ->

```

## Catalin Marinas, 2006-12-04 09:17

Subject: Re: [PATCH] Print progress message to stderr, not stdout
Message-ID: <b0943d9e0612040117y6554b891yaf6eb59d0d52ebf0@mail.gmail.com>
URL: https://gitlist.dev/e/b0943d9e0612040117y6554b891yaf6eb59d0d52ebf0%40mail.gmail.com
In-Reply-To: <e5bfff550612020520w3ad48a09xfdde63b9050a75cf@mail.gmail.com>

```
On 02/12/06, Marco Costalba <mcostalba@gmail.com> wrote:
> On 11/11/06, Karl Hasselström <kha@treskal.com> wrote:
> > Printing progress messages to stdout causes them to get mixed up with
> > the actual output of the program. Using stderr is much better, since
> > the user can then redirect the two components separately.
>
> This patch breaks qgit.
>
> GUI interface to stgit pop and push commands is broken because a
> command that prints to stderr is considered a failing one by qgit.
>
> I would kindly ask you to:
>
> 1 - Revert the patch. That would be the best. You can use a prefix to
> printed message instead, see git pull, something like 'stg: bla bla
> bla' . In any case, IMHO, using stderr for normal activity logging
> does not sound like a great idea in general.
>
> 2 - At least add a '-v' '--verbose' option that defaults to quiet so
> to not break back compatibility.

Since there are other tools relying on a clean stderr, I think I would
revert it and add a verbose flag and/or config option. Karl, any
thoughts on this (since you sent the patch)?

-- 

```

## Karl Hasselström, 2006-12-04 15:37

Subject: Re: [PATCH] Print progress message to stderr, not stdout
Message-ID: <20061204153705.GA8644@diana.vm.bytemark.co.uk>
URL: https://gitlist.dev/e/20061204153705.GA8644%40diana.vm.bytemark.co.uk
In-Reply-To: <b0943d9e0612040117y6554b891yaf6eb59d0d52ebf0@mail.gmail.com>

```
On 2006-12-04 09:17:16 +0000, Catalin Marinas wrote:

> On 02/12/06, Marco Costalba <mcostalba@gmail.com> wrote:
>
> > On 11/11/06, Karl Hasselström <kha@treskal.com> wrote:
> >
> > > Printing progress messages to stdout causes them to get mixed up
> > > with the actual output of the program. Using stderr is much
> > > better, since the user can then redirect the two components
> > > separately.
> >
> > This patch breaks qgit.
>
> Since there are other tools relying on a clean stderr, I think I
> would revert it and add a verbose flag and/or config option. Karl,
> any thoughts on this (since you sent the patch)?

I introduced this since I wanted to divert the output to a file, and
the progress message had no business being written to that file. But a
command line option to suppress progress messages would work just as
well if that's what git does.

-- 
Karl Hasselström, kha@treskal.com

```

## Marco Costalba, 2006-12-04 18:34

Subject: Re: [PATCH] Print progress message to stderr, not stdout
Message-ID: <e5bfff550612041034g727a1bebg464f7c523c0fac7f@mail.gmail.com>
URL: https://gitlist.dev/e/e5bfff550612041034g727a1bebg464f7c523c0fac7f%40mail.gmail.com
In-Reply-To: <20061204153705.GA8644@diana.vm.bytemark.co.uk>

```
On 12/4/06, Karl Hasselström <kha@treskal.com> wrote:
> On 2006-12-04 09:17:16 +0000, Catalin Marinas wrote:
>
> > On 02/12/06, Marco Costalba <mcostalba@gmail.com> wrote:
> >
> > > On 11/11/06, Karl Hasselström <kha@treskal.com> wrote:
> > >
> > > > Printing progress messages to stdout causes them to get mixed up
> > > > with the actual output of the program. Using stderr is much
> > > > better, since the user can then redirect the two components
> > > > separately.
> > >
> > > This patch breaks qgit.
> >
> > Since there are other tools relying on a clean stderr, I think I
> > would revert it and add a verbose flag and/or config option. Karl,
> > any thoughts on this (since you sent the patch)?
>
> I introduced this since I wanted to divert the output to a file, and
> the progress message had no business being written to that file. But a
> command line option to suppress progress messages would work just as
> well if that's what git does.
>

If you don't mind I would prefer a command line option to _enable_
progress messages, something like -v or --verbose so to keep back
compatibility with current versions of tools that do not expect stderr
messages.

Thanks

```

## Catalin Marinas, 2006-12-04 22:13

Subject: Re: [PATCH] Print progress message to stderr, not stdout
Message-ID: <b0943d9e0612041413p4f303176x3d0fa95afd1c4a1@mail.gmail.com>
URL: https://gitlist.dev/e/b0943d9e0612041413p4f303176x3d0fa95afd1c4a1%40mail.gmail.com
In-Reply-To: <e5bfff550612041034g727a1bebg464f7c523c0fac7f@mail.gmail.com>

```
On 04/12/06, Marco Costalba <mcostalba@gmail.com> wrote:
> On 12/4/06, Karl Hasselström <kha@treskal.com> wrote:
> > I introduced this since I wanted to divert the output to a file, and
> > the progress message had no business being written to that file. But a
> > command line option to suppress progress messages would work just as
> > well if that's what git does.
>
> If you don't mind I would prefer a command line option to _enable_
> progress messages, something like -v or --verbose so to keep back
> compatibility with current versions of tools that do not expect stderr
> messages.

I'll first move the message back to stdout. Does qgit rely on the
StGIT output to have a certain format/information? Does the progress
message affect it in any way?

I consider many of the other messages to be progress messages (like
"pushing... done") and I haven't differentiated between them until
Karl's patch. For commands like diff or status, you expect the command
to check the working copy anyway and it doesn't output this specific
message.

The best would probably be to add a "verbose" config option to enable
this message (and maybe a command line option later but this means
modifying all the commands to accept this option). I'll try to push
this change tomorrow (together with moving from stgitrc to gitconfig).

-- 

```

## Marco Costalba, 2006-12-05 06:11

Subject: Re: [PATCH] Print progress message to stderr, not stdout
Message-ID: <e5bfff550612042211q4c4e1e79x8e6e08a224209135@mail.gmail.com>
URL: https://gitlist.dev/e/e5bfff550612042211q4c4e1e79x8e6e08a224209135%40mail.gmail.com
In-Reply-To: <b0943d9e0612041413p4f303176x3d0fa95afd1c4a1@mail.gmail.com>

```
On 12/4/06, Catalin Marinas <catalin.marinas@gmail.com> wrote:
> On 04/12/06, Marco Costalba <mcostalba@gmail.com> wrote:
> > On 12/4/06, Karl Hasselström <kha@treskal.com> wrote:
> > > I introduced this since I wanted to divert the output to a file, and
> > > the progress message had no business being written to that file. But a
> > > command line option to suppress progress messages would work just as
> > > well if that's what git does.
> >
> > If you don't mind I would prefer a command line option to _enable_
> > progress messages, something like -v or --verbose so to keep back
> > compatibility with current versions of tools that do not expect stderr
> > messages.
>
> I'll first move the message back to stdout. Does qgit rely on the
> StGIT output to have a certain format/information? Does the progress
> message affect it in any way?
>

No. It just checks stderr for empty.

The only commands whose output is used by qgit are stg series/applied/u
```

## Johannes Schindelin, 2006-12-05 07:41

Subject: Re: [PATCH] Print progress message to stderr, not stdout
Message-ID: <Pine.LNX.4.63.0612050841160.28348@wbgn013.biozentrum.uni-wuerzburg.de>
URL: https://gitlist.dev/e/Pine.LNX.4.63.0612050841160.28348%40wbgn013.biozentrum.uni-wuerzburg.de
In-Reply-To: <b0943d9e0612041413p4f303176x3d0fa95afd1c4a1@mail.gmail.com>

```
Hi,

On Mon, 4 Dec 2006, Catalin Marinas wrote:

> I'll first move the message back to stdout.

In other parts of git, the progress message is only printed if output goes 
to a tty. Why not do the same?

Ciao,
Dscho

```

## Karl Hasselström, 2006-12-05 09:06

Subject: Re: [PATCH] Print progress message to stderr, not stdout
Message-ID: <20061205090608.GA25002@diana.vm.bytemark.co.uk>
URL: https://gitlist.dev/e/20061205090608.GA25002%40diana.vm.bytemark.co.uk
In-Reply-To: <Pine.LNX.4.63.0612050841160.28348@wbgn013.biozentrum.uni-wuerzburg.de>

```
On 2006-12-05 08:41:57 +0100, Johannes Schindelin wrote:

> On Mon, 4 Dec 2006, Catalin Marinas wrote:
>
> > I'll first move the message back to stdout.
>
> In other parts of git, the progress message is only printed if
> output goes to a tty. Why not do the same?

That sounds like a good idea for two reasons:

  1. It will address all concerns raised in this thread (I think).

  2. It will remove an unnecessary difference between git and stgit.

-- 
Karl Hasselström, kha@treskal.com

```

## Catalin Marinas, 2006-12-05 09:06

Subject: Re: [PATCH] Print progress message to stderr, not stdout
Message-ID: <b0943d9e0612050106k1081813ds98aec9272174a9ae@mail.gmail.com>
URL: https://gitlist.dev/e/b0943d9e0612050106k1081813ds98aec9272174a9ae%40mail.gmail.com
In-Reply-To: <Pine.LNX.4.63.0612050841160.28348@wbgn013.biozentrum.uni-wuerzburg.de>

```
On 05/12/06, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> On Mon, 4 Dec 2006, Catalin Marinas wrote:
> > I'll first move the message back to stdout.
>
> In other parts of git, the progress message is only printed if output goes
> to a tty. Why not do the same?

Thanks for the hint. This seems to me like the easiest solution.

-- 

```
