Re: git-log to go forward instead of reverse?

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

Re: git-log to go forward instead of reverse?

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:42:33

merlyn@stonehenge.com (Randal L. Schwartz) writes:
Well, this is for a "I'm connected to the net right now: please
refresh all of my git mirrors" script:

        ## (code here to cd to the right dir omitted)
                git-fetch
                if git-status | grep -v 'nothing to commit'
git-status exits non-zero for "nothing to commit" case, so do
not grep its output, but check the status of the command, to see
if your tree is in a good shape to do a pull.
                then echo UPDATE SKIPPED
                else
                    if git-pull . origin | egrep -v 'up-to-date'
                    then git-log --pretty=short ORIG_HEAD..HEAD | cat
                    fi
                fi

The log is just so I can quickly eyeball the interesting changes.
Do we not leave ORIG_HEAD when we are already up-to-date?  If so
that would be confusing...  No, we do leave ORIG_HEAD no matter
what, so you do not have to have this inner if to grep
up-to-date (on the other hand, you might want to do intelligent
things when git-pull fails).  So just drop the if and say
something like:

	else
        	PAGER= ; export PAGER
                git pull . origin &&
                git log --pretty ORIG_HEAD..HEAD |
                git shortlog
	fi
The "cat"
is to keep git-log from starting a pager.  (If there's a switch that does
*that* that I've overlooked, that'd be good too.)
BTW,

        PAGER=cat
        export PAGER

This should work as more efficiently -- see pager.c ;-)

Re: git-log to go forward instead of reverse?

From: Randal L. Schwartz <hidden>
Date: 2016-06-15 22:42:33

quoted
quoted
quoted
quoted
"Junio" == Junio C Hamano [off-list ref] writes:
quoted
## (code here to cd to the right dir omitted)
git-fetch
if git-status | grep -v 'nothing to commit'
Junio> git-status exits non-zero for "nothing to commit" case, so do
Junio> not grep its output, but check the status of the command, to see
Junio> if your tree is in a good shape to do a pull.

No, this is deliberate.  I want to see nothing if we're up to date, but if
not, I want to see *everything else* that git-status said.  This nice "grep
-v" does precisely the right thing.

Junio> Do we not leave ORIG_HEAD when we are already up-to-date?  If so
Junio> that would be confusing...  No, we do leave ORIG_HEAD no matter
Junio> what, so you do not have to have this inner if to grep
Junio> up-to-date (on the other hand, you might want to do intelligent
Junio> things when git-pull fails).  So just drop the if and say
Junio> something like:

Junio> 	else
Junio>         	PAGER= ; export PAGER
Junio>                 git pull . origin &&
Junio>                 git log --pretty ORIG_HEAD..HEAD |
Junio>                 git shortlog
Junio> 	fi

However, this is good to know.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
[off-list ref] <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help