git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pete Forman <petef4+usenet@gmail.com>
To: git@vger.kernel.org
Subject: Re: How to pre-empt git pull merge error?
Date: Thu, 28 Nov 2013 08:25:39 +0000	[thread overview]
Message-ID: <864n6x2arg.fsf@gmail.com> (raw)
In-Reply-To: 878uw9hdf0.fsf@thomasrast.ch

Thomas Rast <tr@thomasrast.ch> writes:

> Antoine Pelisse <apelisse@gmail.com> writes:
>
>>>> 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.)

It is a deployment script and updates are fast-forward. There was a
problem on a test server where a file had been hacked to investigate an
issue. The next deploy failed with the merge error.

There are three approaches, which might all be done with git or an
actual deployment tool.

1. test early, bail out if deploy would fail
2. set target to good state before applying the merge
2a. discard changes
2b. stash changes

I intend to use (1). First I will need to clean up the stray files or add
more entries into .gitignore.

  test -z "$(git status --porcelain)"


-- 
Pete Forman
http://petef.22web.org/payg.html

  reply	other threads:[~2013-11-28  8:25 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-27 15:17 How to pre-empt git pull merge error? Pete Forman
2013-11-27 15:42 ` Konstantin Khomoutov
2013-11-27 15:54   ` Matthieu Moy
2013-11-27 16:38     ` Antoine Pelisse
2013-11-27 19:06       ` Thomas Rast
2013-11-28  8:25         ` Pete Forman [this message]
2013-11-27 20:09       ` Junio C Hamano

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=864n6x2arg.fsf@gmail.com \
    --to=petef4+usenet@gmail.com \
    --cc=git@vger.kernel.org \
    /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).