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

  • buttheadgsxr1000

    buttheadgsxr

    24 Ocak 2008
  • Max Lee

    Max Lee

    18 AĞUSTOS 2006
  • UsherVEVO

    UsherVEVO

    15 EKİM 2009