git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Junio C Hamano <junkio@cox.net>
Date
Jul 10, 2006, 20:26 UTC
Message-ID
<7vpsgdb40s.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<86mzbhntxu.fsf@blue.stonehenge.com>
merlyn@stonehenge.com (Randal L. Schwartz) writes:
Show 6 quoted lines
> 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.

Show 8 quoted lines
>                 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 ;-)
Previous: Junio C HamanoNext: Randal L. Schwartz
Message 9 of 11 in “git-log to go forward instead of reverse?”
  1. Randal L. SchwartzJul 10, 2006
  2. Linus TorvaldsJul 10, 2006
  3. Randal L. SchwartzJul 10, 2006
  4. Linus TorvaldsJul 10, 2006
  5. Randal L. SchwartzJul 10, 2006
  6. Linus TorvaldsJul 10, 2006
  7. Randal L. SchwartzJul 10, 2006
  8. Junio C HamanoJul 10, 2006
  9. Junio C HamanoJul 10, 2006
  10. Randal L. SchwartzJul 10, 2006
  11. Linus TorvaldsJul 10, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.