{"thread":{"id":"2276","subject":"git-pull (or cg-fetch?) with exit status","startedAt":"2005-10-30T13:24:54Z","lastAt":"2005-10-30T20:05:45Z","messageCount":3,"participants":["Randal L. Schwartz","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"10812","messageId":"86fyqjt9w9.fsf@blue.stonehenge.com","threadId":"2276","inReplyTo":null,"subject":"git-pull (or cg-fetch?) with exit status","fromName":"Randal L. Schwartz","fromEmail":"merlyn@stonehenge.com","sentAt":"2005-10-30T13:24:54Z","receivedAt":"2005-10-30T13:24:54Z","isPatch":false,"sender":{"key":"merlyn@stonehenge.com","avatar":"https://gravatar.com/avatar/dc528d210743ff0333e6213f9ee7b33b23f1b7bc1f3c5a8c2d819074ecd7ab19?d=mp&s=160"},"body":"\nOther than grep the output of the \"pull\" commands, I'd like to have a\nflag added that will also set an exit status to \"successful\" if new\nthings were pulled.  That way, I can automate a \"make install\"\nresulting from a successful new pull, ala:\n\n        git-pull --silent && make install\n\n-- \nRandal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095\n<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>\nPerl/Unix/security consulting, Technical writing, Comedy, etc. etc.\nSee PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!\n"},{"id":"10815","messageId":"7v3bmiudl1.fsf@assigned-by-dhcp.cox.net","threadId":"2276","inReplyTo":"86fyqjt9w9.fsf@blue.stonehenge.com","subject":"Re: git-pull (or cg-fetch?) with exit status","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-10-30T17:19:54Z","receivedAt":"2005-10-30T17:19:54Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"merlyn@stonehenge.com (Randal L. Schwartz) writes:\n\n> Other than grep the output of the \"pull\" commands, I'd like to have a\n> flag added that will also set an exit status to \"successful\" if new\n> things were pulled.  That way, I can automate a \"make install\"\n> resulting from a successful new pull, ala:\n>\n>         git-pull --silent && make install\n\nHow about this instead of your one-liner?\n\n\told_head=$(git-rev-parse --verify HEAD) &&\n        git-pull -n >/dev/null 2>&1 || exit\n        new_head=$(git-rev-parse --verify HEAD)\n\ttest \"$old_head\" = \"$new_head\" || make test install\n\ngit-pull has at least 4 different possible outcomes, and its\nexit code talks about its success/failure right now.\n\n 1. fetch did not succeed, so pull should result in failure. In\n    this case there is no change in your repository, and no\n    point rebuilding.\n\n 2. fetch contacted the other end and concluded conversation\n    correctly.\n\n    2-a. There was no change upstream (or you were up-to-date --\n         the other side was behind you).  This is a successful\n         pull, but you probably do not want to rebuild.\n\n    2-b. There were changes upstream and we tried to merge.\n         Merge was successful.  This case you would want to\n         rebuild.\n\n    2-c. There were changes upstream and automerge failed.  You\n         cannot rebuild in this case.\n\nWith your proposal we should need to exit non-zero in case 2-a\nwhen we are running with --silent.  This feels somewhat\ncounter-intuitive if not wrong, even if it is only done under a\nparticular flag.\n"},{"id":"10818","messageId":"86ll0asrc6.fsf@blue.stonehenge.com","threadId":"2276","inReplyTo":"7v3bmiudl1.fsf@assigned-by-dhcp.cox.net","subject":"Re: git-pull (or cg-fetch?) with exit status","fromName":"Randal L. Schwartz","fromEmail":"merlyn@stonehenge.com","sentAt":"2005-10-30T20:05:45Z","receivedAt":"2005-10-30T20:05:45Z","isPatch":false,"sender":{"key":"merlyn@stonehenge.com","avatar":"https://gravatar.com/avatar/dc528d210743ff0333e6213f9ee7b33b23f1b7bc1f3c5a8c2d819074ecd7ab19?d=mp&s=160"},"body":">>>>> \"Junio\" == Junio C Hamano <junkio@cox.net> writes:\n\nJunio> \told_head=$(git-rev-parse --verify HEAD) &&\nJunio>         git-pull -n >/dev/null 2>&1 || exit\nJunio>         new_head=$(git-rev-parse --verify HEAD)\nJunio> \ttest \"$old_head\" = \"$new_head\" || make test install\n\nThis looks like it might work.  I'll try it out next time.  Thanks.\n\n-- \nRandal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095\n<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>\nPerl/Unix/security consulting, Technical writing, Comedy, etc. etc.\nSee PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!\n"}]}