Re: How to pre-empt git pull merge error?
- From
Thomas Rast <tr@thomasrast.ch>
- Date
- Nov 27, 2013, 19:06 UTC
- Message-ID
- <878uw9hdf0.fsf@thomasrast.ch>
- In-Reply-To
- <CALWbr2wNODeLSmQ5ztQmKVxBSguNJ1bbSbvY66sdsP09dSUUgA@mail.gmail.com>
Antoine Pelisse <apelisse@gmail.com> writes:
Show 20 quoted lines
>>> On Wed, 27 Nov 2013 15:17:27 +0000 >>> Pete Forman <petef4+usenet@gmail.com> wrote: >>> >>>> I am looking for a way of detecting up front whether a git pull or git >>>> merge would fail. The sort of script I want to perform is to update a >>>> server. >>>> >>>> git fetch >>>> git okay >>>> stop server >>>> backup data >>>> git merge >>>> start server >>>> >> I don't know a simple way to do the pre-merge check without actually >> doing the merge (other than patching git merge to add a --dry-run >> option) > > Wouldn't that be a nice use-case for git-recursive-merge --index-only > ($gmane/236753) ?
Possibly, but most of the use-cases for merge --dry-run are better answered by the XY Problem question:
Can you step back and explain what the *underlying* goal is?
The above sounds a lot like a deployment script, and such scripts are almost always better served by using an actual deployment tool, or failing that, by using some form of checkout -f instead, to ensure that they get whatever they are supposed to deploy.
(Using a merge to update is really terrible in the face of non-fast-forward updates, especially when caused by rewriting history to not include some commits.)
-- Thomas Rast tr@thomasrast.ch