git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Mark Ryden" <markryde@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: checking action of git-pull
Date: Sun, 07 Dec 2008 02:51:13 -0800	[thread overview]
Message-ID: <7vprk4cl7i.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <dac45060812070023h7f6a6c86ve2e4ba9f1773f03f@mail.gmail.com> (Mark Ryden's message of "Sun, 7 Dec 2008 10:23:18 +0200")

"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

      reply	other threads:[~2008-12-07 10:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-07  8:23 checking action of git-pull Mark Ryden
2008-12-07 10:51 ` Junio C Hamano [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vprk4cl7i.fsf@gitster.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=markryde@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).