git-log produces no output
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 <[email protected]>
Date: Fri Apr 21 10:56:11 2006 -0600
Two line hello
hello +1 -0
@@ -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
Quoted 3 lines · Bob Portmann
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.
Quoted 2 lines
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.
Quoted 5 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
Quoted 32 lines · --- Linus Torvalds
Quoted 2 lines · Bob Portmann
I cannot get any output out of it and am wondering if I am using
it
Quoted 1 line
correctly or it is broken.
You're using it correctly, but it isn't broken for me.
Quoted 1 line
As I understand it, git-log should just print out the log messages
but
Quoted 1 line
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.
Quoted 4 lines
test-log> git log
test-log>As you can see git log produces no output. I've tried it with
other
Quoted 1 line
options with the same result.
Very strange indeed. Can you do
git log > file
Quoted 9 lines
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.
Quoted 4 lines
Finally, if that doesn't output anything either, please do (for just that
small repository, so that the trace is also small)
Quoted 8 lines
strace -o git-trace git log >
/dev/nulland 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
On 4/21/06, Bob Portmann <[email protected]> wrote:
[...]
Quoted 6 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
Quoted 6 lines · --- Paolo Ciarrocchi
On 4/21/06, Bob Portmann <[email protected]> wrote:
[...]Quoted 4 lines
test-log> export PAGER='more -i'
test-log> git log
test-log>
Quoted 7 lines
Quoted 2 lines
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
Quoted 5 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
Quoted 5 lines · Bob Portmann
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
---
pager.c +1 -0
@@ -47,5 +47,6 @@ void setup_pager(void)setenv ("LESS" ,"-S" ,0 );run_pager (pager); +die ("unable to execute pager '%s'" , pager);exit (255 ); }
Quoted 2 lines · Linus Torvalds
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
---
pager.c +2 -0
@@ -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 ); }
Yes, that fixes it, even with the crazy PAGER (which is going to be plain 'more' from now on:-)
Thanks,
Bob
Quoted 26 lines · --- Linus Torvalds
Quoted 2 lines · Linus Torvalds
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
---pager.c +1
-0@@ -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 )
pager.c void setup_pager(void) · line 53
Quoted 6 lines
pager.c +1
-0@@ -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
Quoted 7 lines · Linus Torvalds
Quoted 2 lines · Linus Torvalds
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 <[email protected]>
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'
--- pager.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
pager.c +2 -0
@@ -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 ); }
Signature · 1 line
1.3.0.gd1e3
Quoted 5 lines · Junio C Hamano
Quoted 2 lines · Linus Torvalds
Quoted 1 line · Linus Torvalds
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
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
lines. My employment contract requires that everything I produce is open source ;)
Quoted 5 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)
Quoted 1 line
BTW: Allow me to try "git fmt-patch -1" ;-).
Looks good to me.
Linus