SORU
7 EKİM 2010, PERŞEMBE


Nasıl programlı olarak eğer uncommited değişiklik olup olmadığını belirleyebilirim?

Bir Makefile, uncommited değişiklikleri (ya da ağaç veya dizin) yoksa belirli eylemleri gerçekleştirmek istiyorum. Bunu en verimli ve en temiz yolu nedir? Bir durumda, dönüş değeri sıfır çıkar ve sıfır olmayan başka bir komut benim amacım uygun olurdu.

git status boru grep, çıkış koşabilirim ama daha iyi bir yolu olmalı gibi hissediyorum.

CEVAP
7 EKİM 2010, PERŞEMBE


"" Anlamına gelir . programlı ^strong>asla ve asla porcelain commands güveniyor.
Her zaman plumbing commands güvenmek.

Ayrıca "" alternatifler (git status --porcelain). Checking for a dirty index or untracked files with Git bakın

İlham from the new "require_clean_work_tree function" which is written as we speak ;) alabilir (erken Ekim 2010)

require_clean_work_tree () {
    # Update the index
    git update-index -q --ignore-submodules --refresh
    err=0

    # Disallow unstaged changes in the working tree
    if ! git diff-files --quiet --ignore-submodules --
    then
        echo >&2 "cannot $1: you have unstaged changes."
        git diff-files --name-status -r --ignore-submodules -- >&2
        err=1
    fi

    # Disallow uncommitted changes in the index
    if ! git diff-index --cached --quiet HEAD --ignore-submodules --
    then
        echo >&2 "cannot $1: your index contains uncommitted changes."
        git diff-index --cached --name-status -r --ignore-submodules HEAD -- >&2
        err=1
    fi

    if [ $err = 1 ]
    then
        echo >&2 "Please commit or stash them."
        exit 1
    fi
}

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:
Git

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Barnacules Nerdgasm

    Barnacules N

    20 Temmuz 2006
  • Ben Schoon

    Ben Schoon

    23 Kasım 2012
  • psidot

    psidot

    2 Kasım 2006