diff mbox series

[v2,5/5] MyFirstObjectWalk: add stderr to pipe processing

Message ID 64c36dbf16108353635a7315a3bd5eb60f2aa92e.1710840596.git.dirk@gouders.net (mailing list archive)
State Superseded
Headers show
Series Fixes for Documentation/MyFirstObjectWalk.txt | expand

Commit Message

Dirk Gouders March 19, 2024, 11:23 a.m. UTC
In the last chapter of this document, pipes are used in commands to
filter out the first/last trace messages.  But according to git(1),
trace messages are sent to stderr if GIT_TRACE is set to '1', so those
commands do not produce the described results.

Fix this by redirecting stderr to stdout prior to the pipe operator
to additionally connect stderr to stdin of the latter command.

Signed-off-by: Dirk Gouders <dirk@gouders.net>
---
 Documentation/MyFirstObjectWalk.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Kyle Lippincott March 23, 2024, 7:48 p.m. UTC | #1
On Tue, Mar 19, 2024 at 12:23:15PM +0100, Dirk Gouders wrote:
> In the last chapter of this document, pipes are used in commands to
> filter out the first/last trace messages.  But according to git(1),
> trace messages are sent to stderr if GIT_TRACE is set to '1', so those
> commands do not produce the described results.
> 
> Fix this by redirecting stderr to stdout prior to the pipe operator
> to additionally connect stderr to stdin of the latter command.
> 
> Signed-off-by: Dirk Gouders <dirk@gouders.net>
> ---
>  Documentation/MyFirstObjectWalk.txt | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/Documentation/MyFirstObjectWalk.txt b/Documentation/MyFirstObjectWalk.txt
> index 981dbf917b..2e6ae4d7fc 100644
> --- a/Documentation/MyFirstObjectWalk.txt
> +++ b/Documentation/MyFirstObjectWalk.txt
> @@ -847,7 +847,7 @@ those lines without having to recompile.
>  With only that change, run again (but save yourself some scrollback):
>  
>  ----
> -$ GIT_TRACE=1 ./bin-wrappers/git walken | head -n 10
> +$ GIT_TRACE=1 ./bin-wrappers/git walken 2>&1 | head -n 10
>  ----
>  
>  Take a look at the top commit with `git show` and the object ID you printed; it
> @@ -875,7 +875,7 @@ of the first handful:
>  
>  ----
>  $ make
> -$ GIT_TRACE=1 ./bin-wrappers git walken | tail -n 10
> +$ GIT_TRACE=1 ./bin-wrappers git walken 2>&1 | tail -n 10

I think there's a second issue here: this should be `./bin-wrappers/git`, right?

>  ----
>  
>  The last commit object given should have the same OID as the one we saw at the
> -- 
> 2.43.0
> 
>
Dirk Gouders March 23, 2024, 8:16 p.m. UTC | #2
Kyle Lippincott <spectral@google.com> writes:

> On Tue, Mar 19, 2024 at 12:23:15PM +0100, Dirk Gouders wrote:

>> -$ GIT_TRACE=1 ./bin-wrappers/git walken | head -n 10
>> +$ GIT_TRACE=1 ./bin-wrappers/git walken 2>&1 | head -n 10
>>  ----
>>  
>>  Take a look at the top commit with `git show` and the object ID you printed; it
>> @@ -875,7 +875,7 @@ of the first handful:
>>  
>>  ----
>>  $ make
>> -$ GIT_TRACE=1 ./bin-wrappers git walken | tail -n 10
>> +$ GIT_TRACE=1 ./bin-wrappers git walken 2>&1 | tail -n 10
>
> I think there's a second issue here: this should be `./bin-wrappers/git`, right?

Oh yes, that is a second issue -- thank you very much for spending the
time to look at this series.

Dirk
diff mbox series

Patch

diff --git a/Documentation/MyFirstObjectWalk.txt b/Documentation/MyFirstObjectWalk.txt
index 981dbf917b..2e6ae4d7fc 100644
--- a/Documentation/MyFirstObjectWalk.txt
+++ b/Documentation/MyFirstObjectWalk.txt
@@ -847,7 +847,7 @@  those lines without having to recompile.
 With only that change, run again (but save yourself some scrollback):
 
 ----
-$ GIT_TRACE=1 ./bin-wrappers/git walken | head -n 10
+$ GIT_TRACE=1 ./bin-wrappers/git walken 2>&1 | head -n 10
 ----
 
 Take a look at the top commit with `git show` and the object ID you printed; it
@@ -875,7 +875,7 @@  of the first handful:
 
 ----
 $ make
-$ GIT_TRACE=1 ./bin-wrappers git walken | tail -n 10
+$ GIT_TRACE=1 ./bin-wrappers git walken 2>&1 | tail -n 10
 ----
 
 The last commit object given should have the same OID as the one we saw at the