git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* CR codes from git commands
@ 2009-01-20 16:26 Brent Goodrick
  2009-01-20 17:08 ` Johannes Schindelin
  2009-01-22  4:47 ` Daniel Barkalow
  0 siblings, 2 replies; 24+ messages in thread
From: Brent Goodrick @ 2009-01-20 16:26 UTC (permalink / raw)
  To: git


Hi,

I am considering converting from CVS over to using git. I'm currently
using git version 1.5.6.5 on Debian Linux "testing". One of the first
things I ran into was having to set PAGER to "cat" to avoid the
problems when running git from anything other than a terminal.  The
second thing is that "git pull" (and possibly other commands) are
emitting ^M (octal 013) codes on output, possibly caused by the same
assumption as causes the problem that is fixed by setting PAGER to
"cat".  This is not a big deal on small repos, but on larger ones I
actually do want to see status line output (or be given some option to
see them), so that I can then run "tail -1lf" on the log file that is
written during a long "git pull" operation.

Is there some configuration option or some environment variable I can
set that tells git to stop treating every invocation as if it is
coming from a terminal?

You can reproduce this on Linux with the following script (look for
the CR codes on the final git pull at the end of the script):

-- cut below this line ---
#!/bin/sh

# I could have simply used "set -x" here but then I wouldn't see the
# redirection syntax like ">file1", so instead use a PrintRun
# function:
PrintRun ()
{
    echo "COMMAND: $*"
    eval "$*; exitcode=\$?"
    if [ $exitcode != 0 ]
    then
        echo "ERROR: Command failed: $*"
        exit 1
    fi
}

# Failed attempt at hacking around git insisting on using ^M codes on stderr:
# cat >/tmp/git_pager <<EOF
# sed 's%^% >> %g'
# # This doesn't work either since the output I want to filter is on stderr
# # tr '\013' '\012'
# EOF
# chmod a+x /tmp/git_pager
# GIT_PAGER=/tmp/git_pager; export GIT_PAGER

# Clear out the scratch areas:
PrintRun rm -rf /tmp/git_area1
PrintRun rm -rf /tmp/git_area2
# Populate the initial area:
PrintRun mkdir -p /tmp/git_area1
PrintRun cd /tmp/git_area1
PrintRun git init
PrintRun "echo a new file 1 >file1"
PrintRun "echo a new file 2 >file2"
PrintRun git add file1
PrintRun git add file2
PrintRun git status
PrintRun "git commit -m \"first commit in git_area1\""
PrintRun find .
# Clone from the first area into a second area and add a file there:
PrintRun rm -rf /tmp/git_area2
PrintRun cd /tmp
PrintRun git clone /tmp/git_area1 git_area2
PrintRun cd /tmp/git_area2
PrintRun find .
PrintRun "echo a new file 3 >file3"
PrintRun git add file3
PrintRun git status
PrintRun "git commit -m \"second commit but in git_area2\""
PrintRun "git status; true" # true means don't fail inside PrintRun
PrintRun "git status; true" # true means don't fail inside PrintRun
# Now attempt to somehow refresh (what is the "git" word for "cvs update"?) into the first area:
PrintRun cd /tmp/git_area1
PrintRun "git status; true" # true means don't fail inside PrintRun
PrintRun "git diff; true" # true means don't fail inside PrintRun
# PrintRun "git pull /tmp/git_area2 master 2>&1"
# PrintRun "git pull /tmp/git_area2 master 2>&1 | tr '\013' '\012'"
PrintRun git pull /tmp/git_area2 master
-- cut above this line ---


Attempts at hacking around the problem: Redirecting stderr output from
git and then manually translating CR codes into LF codes yeilds the
following output (but I can't do this in practice and, no, I can't use
aliases in Bourne scripts (Bash/KSH yes, Bourne no)):

git> COMMAND: git pull /tmp/git_area2 master 2>&1
git> remote: Counting objects: 4, done.        
git> remote: Compressing objects:  50% (1/2)           
git>  --> remote: Compressing objects: 100% (2/2)           
git>  --> remote: Compressing objects: 100% (2/2        )Unpacking objects:  33% (1/3)   
git>  --> Unpacking objects:  66% (2/3)   
git>  --> Unpacking objects: 100% (3/3)   
git>  --> Unpacking objects: 100% (3/3), done.
git> remote: , done.        
git> remote: Total 3 (delta 0), reused 0 (delta 0)        
git> From /tmp/git_area2
git>  * branch            master     -> FETCH_HEAD
git> Updating b2f942d..4f9ba90
git> Fast forward
git>  file3 |    1 +
git>  1 files changed, 1 insertions(+), 0 deletions(-)
git>  create mode 100644 file3

Trying to automatically filter this with redirection and use of tr
fails to show the progress output completely which is a non-option
either:

git> COMMAND: git pull /tmp/git_area2 master 2>&1 | tr '\013' '\012'
git> From /tmp/git_area2
git>  * branch            master     -> FETCH_HEAD
git> Updating 49b1897..bb5f57c
git> Fast forward
git>  file3 |    1 +
git>  1 files changed, 1 insertions(+), 0 deletions(-)
git>  create mode 100644 file3

Thanks,
bgoodr

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2009-02-02  7:12 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-20 16:26 CR codes from git commands Brent Goodrick
2009-01-20 17:08 ` Johannes Schindelin
     [not found]   ` <18806.44057.477379.215492@hungover.brentg.com>
     [not found]     ` <alpine.DEB.1.00.0901210930370.7929@racer>
2009-01-21 14:42       ` Brent Goodrick
2009-01-21 15:38         ` Johannes Schindelin
2009-01-22  4:00           ` Brent Goodrick
2009-01-22  4:47 ` Daniel Barkalow
2009-01-22  7:34   ` Brent Goodrick
2009-01-22  7:46     ` Daniel Barkalow
2009-01-22  8:04       ` Junio C Hamano
2009-01-22 10:04         ` Mike Ralphson
2009-01-22 16:13           ` Brent Goodrick
2009-01-22 16:41             ` Mike Ralphson
2009-01-22 16:50               ` Johannes Schindelin
2009-01-22 16:44             ` Daniel Barkalow
2009-01-22 16:52               ` Johannes Schindelin
2009-01-23 16:12                 ` Brent Goodrick
2009-01-23 16:59                   ` Junio C Hamano
2009-01-23 18:41                   ` Johannes Schindelin
2009-01-24 20:54                     ` Brent Goodrick
2009-01-24 21:14                       ` Johannes Schindelin
2009-01-25  9:19                       ` Boyd Stephen Smith Jr.
2009-01-25 18:47                         ` Brent Goodrick
2009-02-02  7:09                         ` Brent Goodrick
2009-01-25 20:35                       ` The lifecycle of a patch and the maintainer involvement Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).