{"thread":{"id":"16622","subject":"checking action of git-pull","startedAt":"2008-12-07T08:23:18Z","lastAt":"2008-12-07T10:51:13Z","messageCount":2,"participants":["Mark Ryden","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"97294","messageId":"dac45060812070023h7f6a6c86ve2e4ba9f1773f03f@mail.gmail.com","threadId":"16622","inReplyTo":null,"subject":"checking action of git-pull","fromName":"Mark Ryden","fromEmail":"markryde@gmail.com","sentAt":"2008-12-07T08:23:18Z","receivedAt":"2008-12-07T08:23:18Z","isPatch":false,"sender":{"key":"markryde@gmail.com","avatar":null},"body":"Hello,\n  I am working against a git repository which is updated at non regular\nintervals; sometimes it takes a day and sometimes a week or two.\n\nI have a script in crontab which runs daily which tries \"git pull\" of\nthis repository.\n\nI want write a bash script which echoes yhe  result of this git pull\nto a log file in such\na way that in case that any files were pulled, a short message\nsaying \"files were pulled at date ddmmyyyy\" will be added to a log file.\nIn case that there there were no changes, a message saying\n\"Already up-to-date (ddmmyyyy) will be added to a log file.\n\nHow can it be done ?\ncan I test somehow the return value of git pull in a bash script for\nthese two different\ncases?\n\nRegards,\nMark\n"},{"id":"97298","messageId":"7vprk4cl7i.fsf@gitster.siamese.dyndns.org","threadId":"16622","inReplyTo":"dac45060812070023h7f6a6c86ve2e4ba9f1773f03f@mail.gmail.com","subject":"Re: checking action of git-pull","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-12-07T10:51:13Z","receivedAt":"2008-12-07T10:51:13Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Mark Ryden\" <markryde@gmail.com> writes:\n\n> Hello,\n>   I am working against a git repository which is updated at non regular\n> intervals; sometimes it takes a day and sometimes a week or two.\n>\n> I have a script in crontab which runs daily which tries \"git pull\" of\n> this repository.\n>\n> I want write a bash script which echoes yhe  result of this git pull\n> to a log file in such\n> a way that in case that any files were pulled, a short message\n> saying \"files were pulled at date ddmmyyyy\" will be added to a log file.\n> In case that there there were no changes, a message saying\n> \"Already up-to-date (ddmmyyyy) will be added to a log file.\n>\n> How can it be done ?\n> can I test somehow the return value of git pull in a bash script for\n> these two different\n> cases?\n\nYou know that a no-op pull does not update HEAD and a successful pull\ndoes.  So your script would do something like:\n\n\t#!/bin/sh\n\n        original_head=$(git rev-parse HEAD) || exit\n        git pull origin || exit\n        updated_head=$(git rev-parse HEAD) || exit\n        if test \"$updated_head\" = \"$original_head\"\n        then\n        \techo Upstream is idling\n\telse\n        \techo These new commits were brought in\n                git shortlog $original_head..$updated_head\n\tfi\n"}]}