* git-pull (or cg-fetch?) with exit status
@ 2005-10-30 13:24 Randal L. Schwartz
2005-10-30 17:19 ` Junio C Hamano
0 siblings, 1 reply; 3+ messages in thread
From: Randal L. Schwartz @ 2005-10-30 13:24 UTC (permalink / raw)
To: git
Other than grep the output of the "pull" commands, I'd like to have a
flag added that will also set an exit status to "successful" if new
things were pulled. That way, I can automate a "make install"
resulting from a successful new pull, ala:
git-pull --silent && make install
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: git-pull (or cg-fetch?) with exit status
2005-10-30 13:24 git-pull (or cg-fetch?) with exit status Randal L. Schwartz
@ 2005-10-30 17:19 ` Junio C Hamano
2005-10-30 20:05 ` Randal L. Schwartz
0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2005-10-30 17:19 UTC (permalink / raw)
To: Randal L. Schwartz; +Cc: git
merlyn@stonehenge.com (Randal L. Schwartz) writes:
> Other than grep the output of the "pull" commands, I'd like to have a
> flag added that will also set an exit status to "successful" if new
> things were pulled. That way, I can automate a "make install"
> resulting from a successful new pull, ala:
>
> git-pull --silent && make install
How about this instead of your one-liner?
old_head=$(git-rev-parse --verify HEAD) &&
git-pull -n >/dev/null 2>&1 || exit
new_head=$(git-rev-parse --verify HEAD)
test "$old_head" = "$new_head" || make test install
git-pull has at least 4 different possible outcomes, and its
exit code talks about its success/failure right now.
1. fetch did not succeed, so pull should result in failure. In
this case there is no change in your repository, and no
point rebuilding.
2. fetch contacted the other end and concluded conversation
correctly.
2-a. There was no change upstream (or you were up-to-date --
the other side was behind you). This is a successful
pull, but you probably do not want to rebuild.
2-b. There were changes upstream and we tried to merge.
Merge was successful. This case you would want to
rebuild.
2-c. There were changes upstream and automerge failed. You
cannot rebuild in this case.
With your proposal we should need to exit non-zero in case 2-a
when we are running with --silent. This feels somewhat
counter-intuitive if not wrong, even if it is only done under a
particular flag.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: git-pull (or cg-fetch?) with exit status
2005-10-30 17:19 ` Junio C Hamano
@ 2005-10-30 20:05 ` Randal L. Schwartz
0 siblings, 0 replies; 3+ messages in thread
From: Randal L. Schwartz @ 2005-10-30 20:05 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
>>>>> "Junio" == Junio C Hamano <junkio@cox.net> writes:
Junio> old_head=$(git-rev-parse --verify HEAD) &&
Junio> git-pull -n >/dev/null 2>&1 || exit
Junio> new_head=$(git-rev-parse --verify HEAD)
Junio> test "$old_head" = "$new_head" || make test install
This looks like it might work. I'll try it out next time. Thanks.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-10-30 20:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-30 13:24 git-pull (or cg-fetch?) with exit status Randal L. Schwartz
2005-10-30 17:19 ` Junio C Hamano
2005-10-30 20:05 ` Randal L. Schwartz
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).