threads / discuss / 3936

git-log produces no output

Subject: git-log produces no output

## tl;dr

10 messages between Apr 21, 2006 and Apr 21, 2006.

replies: 9people: 4as markdown or json

Bob Portmann· Apr 21, 2006, 17:20 UTC · lore
I am just starting out with git and have a noob question about got-log.
 I cannot get any output out of it and am wondering if I am using it
correctly or it is broken.  As I understand it, git-log should just
print out the log messages but not the changes, whereas git-whatchanged
will print out both.  But while git-whatchanged works, git-log never
does.  I have a trivial example below which shows what I mean.  But I
get the same result using my real archives and out of git.git as well.

Thanks, Bob

PS I'm using git 1.3.0 and have tried this on both Mac OS X and Linux with the same results.

Trivial example:
git-test> mkdir test-log
git-test> cd test-log
test-log> git-init-db
defaulting to local storage area
test-log> echo "Hello World" >hello
test-log> git add .
test-log> git commit -a -m 'One line hello'
Committing initial tree 117c62a8c5e01758bd284126a6af69deab9dbbe2
test-log> echo "Hello World 2" >>hello
test-log> git commit -a -m 'Two line hello'
test-log> git whatchanged -p
diff-tree 9a4d7602fff052b6796c2862edddd11ae2e45d08 (from
a38306518c5e5e8eb630c02Author: Bob Portmann <portmann@xxxx.xx.xx>
Date:   Fri Apr 21 10:56:11 2006 -0600
    Two line hello
diff --git a/hello b/hello
index 557db03..514e5c5 100644
--- a/hello
+++ b/hello
@@ -1 +1,2 @@
 Hello World
+Hello World 2
test-log> git log
test-log> 

As you can see git log produces no output.  I've tried it with other
options with the same result.


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
Linus Torvalds· Apr 21, 2006, 18:11 UTC · re: Bob Portmann · lore

Re: git-log produces no output

On Fri, 21 Apr 2006, Bob Portmann wrote:
>
>  I cannot get any output out of it and am wondering if I am using it
> correctly or it is broken.
You're using it correctly, but it isn't broken for me. 
> As I understand it, git-log should just print out the log messages but 
> not the changes, whereas git-whatchanged will print out both.

Well, in 1.3.0, "git log" can actually do both, and you can get the whatchanged output by just saying "git log -p".

But yes, without the "-p", you should get just the log.

And that's exactly what I get, both with current HEAD git, and with a v1.3.0 checkout.

Show 5 quoted lines
> test-log> git log
> test-log> 
> 
> As you can see git log produces no output.  I've tried it with other
> options with the same result.
Very strange indeed. Can you do
	git log > file

to see if that changes (and see if the file contains anything)? The reason I mention that is that by default "git log" will start a pager for you, and if you somehow have a broken PAGER setup, I could imagine exactly the behaviour you see (although I don't see why "git whatchanged" would work either, in that case).

Finally, if that doesn't output anything either, please do (for just that small repository, so that the trace is also small)

	strace -o git-trace git log > /dev/null

and send out the result. Again, for PAGER reasons, that "> /dev/null" is actually important, because we don't want to trigger the pager code.

		Linus
Bob Portmann· Apr 21, 2006, 18:48 UTC · re: Linus Torvalds · lore

Re: git-log produces no output

--- Linus Torvalds <torvalds@osdl.org> wrote:
Show 41 quoted lines
> On Fri, 21 Apr 2006, Bob Portmann wrote:
> >
> >  I cannot get any output out of it and am wondering if I am using
> it
> > correctly or it is broken.
> 
> You're using it correctly, but it isn't broken for me. 
> 
> > As I understand it, git-log should just print out the log messages
> but 
> > not the changes, whereas git-whatchanged will print out both.
> 
> Well, in 1.3.0, "git log" can actually do both, and you can get the 
> whatchanged output by just saying "git log -p".
> 
> But yes, without the "-p", you should get just the log.
> 
> And that's exactly what I get, both with current HEAD git, and with a
> 
> v1.3.0 checkout.
> 
> > test-log> git log
> > test-log> 
> > 
> > As you can see git log produces no output.  I've tried it with
> other
> > options with the same result.
> 
> Very strange indeed. Can you do
> 
> 	git log > file
> 
> to see if that changes (and see if the file contains anything)? The
> reason 
> I mention that is that by default "git log" will start a pager for
> you, 
> and if you somehow have a broken PAGER setup, I could imagine exactly
> the 
> behaviour you see (although I don't see why "git whatchanged" would
> work 
> either, in that case).

Yes, this is the problem. It works when I send it to a file. It seems to be that having any extra options my PAGER command that messes it up (see below). If get-log was a shell script I would imagine that some quotes are missing:-)

Bob
test-log> export PAGER='more'
test-log> git log
commit 9a4d7602fff052b6796c2862edddd11ae2e45d08
Author: Bob Portmann <portmann@removed>
Date:   Fri Apr 21 10:56:11 2006 -0600
    Two line hello
commit a38306518c5e5e8eb630c02a47bec2a9fc292025
Author: Bob Portmann <portmann@removed>
Date:   Fri Apr 21 10:55:44 2006 -0600
    One line hello

test-log> export PAGER='more -i' test-log> git log test-log>

Adding the option -i (which should do nothing) has eliminated the output.

Show 12 quoted lines
> Finally, if that doesn't output anything either, please do (for just
> that 
> small repository, so that the trace is also small)
> 
> 	strace -o git-trace git log > /dev/null
> 
> and send out the result. Again, for PAGER reasons, that "> /dev/null"
> is 
> actually important, because we don't want to trigger the pager code.
> 
> 		Linus
> 

__________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com

Paolo Ciarrocchi· Apr 21, 2006, 18:58 UTC · re: Bob Portmann · lore

Re: git-log produces no output

On 4/21/06, Bob Portmann <bportmann@yahoo.com> wrote: [...]

Show 6 quoted lines
> test-log> export PAGER='more -i'
> test-log> git log
> test-log>
>
> Adding the option -i (which should do nothing) has eliminated the
> output.

Well, on my machine: paolo@Italia:~/gkernel$ more -i more: unknown option "-i" usage: more [-dflpcsu] [+linenum | +/pattern] name1 name2 ...

Ciao, -- Paolo http://paolociarrocchi.googlepages.com

Bob Portmann· Apr 21, 2006, 19:13 UTC · re: Paolo Ciarrocchi · lore

Re: git-log produces no output

--- Paolo Ciarrocchi <paolo.ciarrocchi@gmail.com> wrote:
Show 13 quoted lines
> On 4/21/06, Bob Portmann <bportmann@yahoo.com> wrote:
> [...]
> > test-log> export PAGER='more -i'
> > test-log> git log
> > test-log>
> >
> > Adding the option -i (which should do nothing) has eliminated the
> > output.
> 
> Well, on my machine:
> paolo@Italia:~/gkernel$ more -i
> more: unknown option "-i"
> usage: more [-dflpcsu] [+linenum | +/pattern] name1 name2 ...

Well, then try an option that does work. On my system less and more are essentially the same and -i just causes it to ignore case on searches. The PAGER is automatically setup to 'less -XRse' on my system (not sure why). Changing it to 'more' makes git-log work, but it should work with 'less -XRse' as well since that works with other commands on the system (e.g. man) and git-whatchanged as well.

Bob
 
Show 5 quoted lines
> Ciao,
> --
> Paolo
> http://paolociarrocchi.googlepages.com
> 

__________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com

Linus Torvalds· Apr 21, 2006, 19:18 UTC · re: Bob Portmann · lore

Re: git-log produces no output

On Fri, 21 Apr 2006, Bob Portmann wrote:
Show 5 quoted lines
> 
> Yes, this is the problem.  It works when I send it to a file.  It seems
> to be that having any extra options my PAGER command that messes it up
> (see below).  If get-log was a shell script I would imagine that some
> quotes are missing:-)
It's the other way around: it's got "too much" quoting.

"git log" will literally _execute_ the PAGER environment, not pass it to a shell, and not interpret any arguments.

So it will look for a program called "more -i" (space and all), and no such program exists, so the execve fails, and git log ends up being silent.

This patch would have made things a lot more obvious.
Junio?
		Linus
---
diff --git a/pager.c b/pager.c
index b063353..9204641 100644
--- a/pager.c
+++ b/pager.c
@@ -47,5 +47,6 @@ void setup_pager(void)
 
 	setenv("LESS", "-S", 0);
 	run_pager(pager);
+	die("unable to execute pager '%s'", pager);
 	exit(255);
 }
Linus Torvalds· Apr 21, 2006, 19:25 UTC · re: Linus Torvalds · lore

Re: git-log produces no output

On Fri, 21 Apr 2006, Linus Torvalds wrote:
> 
> This patch would have made things a lot more obvious.

Actually, scratch that one, and use this one instead. Much better, and actually allows Bob's crazy PAGER environment variable to work, rather than just reporting an error about it.

		Linus
---
diff --git a/pager.c b/pager.c
index b063353..9a30939 100644
--- a/pager.c
+++ b/pager.c
@@ -8,6 +8,7 @@ #include "cache.h"
 static void run_pager(const char *pager)
 {
 	execlp(pager, pager, NULL);
+	execl("/bin/sh", "sh", "-c", pager, NULL);
 }
 
 void setup_pager(void)
@@ -47,5 +48,6 @@ void setup_pager(void)
 
 	setenv("LESS", "-S", 0);
 	run_pager(pager);
+	die("unable to execute pager '%s'", pager);
 	exit(255);
 }
Bob Portmann· Apr 21, 2006, 19:38 UTC · re: Linus Torvalds · lore

Re: git-log produces no output

Yes, that fixes it, even with the crazy PAGER (which is going to be plain 'more' from now on:-)

Thanks, Bob

--- Linus Torvalds <torvalds@osdl.org> wrote:
Show 32 quoted lines
> On Fri, 21 Apr 2006, Linus Torvalds wrote:
> > 
> > This patch would have made things a lot more obvious.
> 
> Actually, scratch that one, and use this one instead. Much better,
> and 
> actually allows Bob's crazy PAGER environment variable to work,
> rather 
> than just reporting an error about it.
> 
> 		Linus
> ---
> diff --git a/pager.c b/pager.c
> index b063353..9a30939 100644
> --- a/pager.c
> +++ b/pager.c
> @@ -8,6 +8,7 @@ #include "cache.h"
>  static void run_pager(const char *pager)
>  {
>  	execlp(pager, pager, NULL);
> +	execl("/bin/sh", "sh", "-c", pager, NULL);
>  }
>  
>  void setup_pager(void)
> @@ -47,5 +48,6 @@ void setup_pager(void)
>  
>  	setenv("LESS", "-S", 0);
>  	run_pager(pager);
> +	die("unable to execute pager '%s'", pager);
>  	exit(255);
>  }
> 

__________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com

Junio C Hamano· Apr 21, 2006, 20:05 UTC · re: Linus Torvalds · lore

Re: git-log produces no output

Linus Torvalds <torvalds@osdl.org> writes:
Show 7 quoted lines
> On Fri, 21 Apr 2006, Linus Torvalds wrote:
>> 
>> This patch would have made things a lot more obvious.
>
> Actually, scratch that one, and use this one instead. Much better, and 
> actually allows Bob's crazy PAGER environment variable to work, rather 
> than just reporting an error about it.
Agreed, this is much better than just punting.  Sign-off?
BTW: The extended extended SHA1 is a great addition.  I do not
usually have contrib/colordiff checked out (it is in "pu", not
in "next"), but I can easily do:
	git tar-tree pu:contrib/colordiff colordiff | tar xf -

Of course "git tar-tree pu | tar xf - contrib/colordiff" would work for this particular case, but that is besides the point.

BTW: Allow me to try "git fmt-patch -1" ;-).
-- >8 --
From 34fd1c9ac5845d541e3196983df7f993e751b544  Thu Apr 7 15:13:13 2005
From: Linus Torvalds <torvalds@osdl.org>
Date: Fri Apr 21 12:25:13 2006 -0700
Subject: git-log produces no output

When $PAGER is set to 'less -i', we used to fail because we assumed the $PAGER is a command and simply exec'ed it.

Try exec first, and then run it through shell if it fails. This allows even funkier PAGERs like these ;-):

	PAGER='sed -e "s/^/`date`: /" | more'
	PAGER='contrib/colordiff.perl | less -RS'
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
 pager.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/pager.c b/pager.c
index e5ba273..f7b8e78 100644
--- a/pager.c
+++ b/pager.c
@@ -8,6 +8,7 @@ #include "cache.h"
 static void run_pager(const char *pager)
 {
 	execlp(pager, pager, NULL);
+	execl("/bin/sh", "sh", "-c", pager, NULL);
 }
 
 void setup_pager(void)
@@ -47,5 +48,6 @@ void setup_pager(void)
 
 	setenv("LESS", "-S", 0);
 	run_pager(pager);
+	die("unable to execute pager '%s'", pager);
 	exit(255);
 }
-- 
1.3.0.gd1e3
Linus Torvalds· Apr 21, 2006, 20:25 UTC · re: Junio C Hamano · lore

Re: git-log produces no output

On Fri, 21 Apr 2006, Junio C Hamano wrote:
Show 12 quoted lines
>
> Linus Torvalds <torvalds@osdl.org> writes:
> 
> > On Fri, 21 Apr 2006, Linus Torvalds wrote:
> >> 
> >> This patch would have made things a lot more obvious.
> >
> > Actually, scratch that one, and use this one instead. Much better, and 
> > actually allows Bob's crazy PAGER environment variable to work, rather 
> > than just reporting an error about it.
> 
> Agreed, this is much better than just punting.  Sign-off?
Yup, you can just go wild with the 
	Signed-off-by: Linus Torvalds <torvalds@osdl.org>

lines. My employment contract requires that everything I produce is open source ;)

Show 5 quoted lines
> BTW: The extended extended SHA1 is a great addition.  I do not
> usually have contrib/colordiff checked out (it is in "pu", not
> in "next"), but I can easily do:
> 
> 	git tar-tree pu:contrib/colordiff colordiff | tar xf -

Ahh, yes. That is one situation where a sub-tree SHA1 makes more sense than most (the fact that it works with "git diff" and directory renames is likely more of a curiosity than anything widely useful, I think)

> BTW: Allow me to try "git fmt-patch -1" ;-).
Looks good to me.
		Linus

← back to recent threads