Bug: git branch returns EXIT_SUCCESS when no branches found

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dear Sirs/Madams,

A common use case of git branch – for me – is to use it to test whether
a particular branch satisfies some conditions. A recent example is this:

    if ! git branch "$DEV_BRANCH" --contains master; then
        echo "The development branch ($DEV_BRANCH) is not up to date"
        echo "with the latest master."
        exit 1
    fi

Except this doesn't work, because git branch returns success even though
it failed to list any branches satisfying the condition. My workaround
has been to rewrite the condition as

    git branch "$DEV_BRANCH" --contains master \
        | grep -xE '\* *'"$DEV_BRANCH"

but this is obviously not desirable in comparison.

The syntax of e.g. --contains makes it seem almost like this use case of
mine was intended, but the exit code makes me doubt it. Is there any
consideration I'm missing that's a reason for not returning a failure
code when not matching any branches?

Yours faithfully,
Chris

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux