Thread (4 messages) flat view 4 messages, 3 authors, 2016-06-15

Re: Best way to check for a "dirty" working tree?

From: Ramkumar Ramachandra <hidden>
Date: 2016-06-15 22:51:28

Hi Dirk,

Dirk Süsserott writes:
A) if ! git diff-index --quiet HEAD -- foo.bar; then
      dirty=1
  fi

and

B) if ! git diff --quiet -- foo.bar; then
      dirty=1
  fi

Both A) and B) work. But which one is better/faster/more reliable? Or is
there a better solution? For my purpose, I cannot see a difference
between diff and diff-index, except the syntax.
diff is a more porcelain'ish command, while diff-index is closer to
the plumbing.  Therefore, diff contains some extra argument parsing/
pretty printing code that your script doesn't utilize -- use
diff-index.  Also, look at the various scripts in git.git to see what
they use; for example, require_clean_work_tree in git-sh-setup.sh.

-- Ram
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help