# How can I tell, from a script, if “git cherry-pick” fails?

3 messages from 2016-11-02 to 2016-11-02. Participants: Kevin Layer, Pranit Bauva.
Thread: https://gitlist.dev/t/44414

## Kevin Layer, 2016-11-02 15:14

Subject: How can I tell, from a script, if “git cherry-pick” fails?
Message-ID: <CAGSZTjKg1=tMYgFiwys=ePVT+3p6KTa1mQ0fP9pPns-Nvd+6fA@mail.gmail.com>
URL: https://gitlist.dev/e/CAGSZTjKg1%3DtMYgFiwys%3DePVT%2B3p6KTa1mQ0fP9pPns-Nvd%2B6fA%40mail.gmail.com

```
If the cherry-pick fails due to a merge conflict, it just returns an
exit status of 0.  I have a script that does a series of cherry-picks
and I need to know if they succeed.

I'm sure this has been covered before.

Using git version 1.8.3.1.

Thank you.

Kevin

```

## Kevin Layer, 2016-11-02 15:32

Subject: Re: How can I tell, from a script, if “git cherry-pick” fails?
Message-ID: <CAGSZTjLreF1Uj5cARt6=1vMUDCrbSQ11ZbCin7YzYGZdEmR3fg@mail.gmail.com>
URL: https://gitlist.dev/e/CAGSZTjLreF1Uj5cARt6%3D1vMUDCrbSQ11ZbCin7YzYGZdEmR3fg%40mail.gmail.com
In-Reply-To: <CAGSZTjKg1=tMYgFiwys=ePVT+3p6KTa1mQ0fP9pPns-Nvd+6fA@mail.gmail.com>

```
Nevermind.  It's working as it should.  The script that was doing the
cherry-pick was doing it in an if and I neglected to exit with a
non-zero status.  Sorry for the noise.

On Wed, Nov 2, 2016 at 8:14 AM, Kevin Layer <layer@known.net> wrote:
> If the cherry-pick fails due to a merge conflict, it just returns an
> exit status of 0.  I have a script that does a series of cherry-picks
> and I need to know if they succeed.
>
> I'm sure this has been covered before.
>
> Using git version 1.8.3.1.
>
> Thank you.
>
> Kevin

```

## Pranit Bauva, 2016-11-02 15:36

Subject: Re: How can I tell, from a script, if “git cherry-pick” fails?
Message-ID: <CAFZEwPP1XyE+X6ipes4JNsUz3JVS+ErbLfQ-zYXZ3KA75bho5Q@mail.gmail.com>
URL: https://gitlist.dev/e/CAFZEwPP1XyE%2BX6ipes4JNsUz3JVS%2BErbLfQ-zYXZ3KA75bho5Q%40mail.gmail.com
In-Reply-To: <CAGSZTjKg1=tMYgFiwys=ePVT+3p6KTa1mQ0fP9pPns-Nvd+6fA@mail.gmail.com>

```
Hey Kevin,

On Wed, Nov 2, 2016 at 8:44 PM, Kevin Layer <layer@known.net> wrote:
> If the cherry-pick fails due to a merge conflict, it just returns an
> exit status of 0.  I have a script that does a series of cherry-picks
> and I need to know if they succeed.

Well, I haven't checked what it returns in git 2.10, but you can
always redirect the stdout and stderr to the output and grep for the
text which it shows in the actual output. Here[1] is an example of how
to do it.

[1]: https://github.com/git/git/blob/master/t/t3507-cherry-pick-conflict.sh#L42-L55

Regards,
Pranit Bauva

```
