git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* checking action of git-pull
@ 2008-12-07  8:23 Mark Ryden
  2008-12-07 10:51 ` Junio C Hamano
  0 siblings, 1 reply; 2+ messages in thread
From: Mark Ryden @ 2008-12-07  8:23 UTC (permalink / raw)
  To: git

Hello,
  I am working against a git repository which is updated at non regular
intervals; sometimes it takes a day and sometimes a week or two.

I have a script in crontab which runs daily which tries "git pull" of
this repository.

I want write a bash script which echoes yhe  result of this git pull
to a log file in such
a way that in case that any files were pulled, a short message
saying "files were pulled at date ddmmyyyy" will be added to a log file.
In case that there there were no changes, a message saying
"Already up-to-date (ddmmyyyy) will be added to a log file.

How can it be done ?
can I test somehow the return value of git pull in a bash script for
these two different
cases?

Regards,
Mark

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

* Re: checking action of git-pull
  2008-12-07  8:23 checking action of git-pull Mark Ryden
@ 2008-12-07 10:51 ` Junio C Hamano
  0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2008-12-07 10:51 UTC (permalink / raw)
  To: Mark Ryden; +Cc: git

"Mark Ryden" <markryde@gmail.com> writes:

> Hello,
>   I am working against a git repository which is updated at non regular
> intervals; sometimes it takes a day and sometimes a week or two.
>
> I have a script in crontab which runs daily which tries "git pull" of
> this repository.
>
> I want write a bash script which echoes yhe  result of this git pull
> to a log file in such
> a way that in case that any files were pulled, a short message
> saying "files were pulled at date ddmmyyyy" will be added to a log file.
> In case that there there were no changes, a message saying
> "Already up-to-date (ddmmyyyy) will be added to a log file.
>
> How can it be done ?
> can I test somehow the return value of git pull in a bash script for
> these two different
> cases?

You know that a no-op pull does not update HEAD and a successful pull
does.  So your script would do something like:

	#!/bin/sh

        original_head=$(git rev-parse HEAD) || exit
        git pull origin || exit
        updated_head=$(git rev-parse HEAD) || exit
        if test "$updated_head" = "$original_head"
        then
        	echo Upstream is idling
	else
        	echo These new commits were brought in
                git shortlog $original_head..$updated_head
	fi

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

end of thread, other threads:[~2008-12-07 10:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-07  8:23 checking action of git-pull Mark Ryden
2008-12-07 10:51 ` 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).