mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 16:34:47 +01:00
Explaining --exit-code return values
This commit is contained in:
parent
50420249ae
commit
fdf5622ee8
1 changed files with 4 additions and 1 deletions
|
@ -166,7 +166,7 @@ def current_branch():
|
||||||
def _git_dirty_working_directory(q, include_untracked):
|
def _git_dirty_working_directory(q, include_untracked):
|
||||||
denv = builtins.__xonsh__.env.detype()
|
denv = builtins.__xonsh__.env.detype()
|
||||||
try:
|
try:
|
||||||
# Borrowing this conversation
|
# Borrowed from this conversation
|
||||||
# https://github.com/sindresorhus/pure/issues/115
|
# https://github.com/sindresorhus/pure/issues/115
|
||||||
if include_untracked:
|
if include_untracked:
|
||||||
cmd = [
|
cmd = [
|
||||||
|
@ -179,6 +179,9 @@ def _git_dirty_working_directory(q, include_untracked):
|
||||||
else:
|
else:
|
||||||
cmd = ["git", "diff", "--no-ext-diff", "--quiet"]
|
cmd = ["git", "diff", "--no-ext-diff", "--quiet"]
|
||||||
child = subprocess.run(cmd, stderr=subprocess.DEVNULL, env=denv)
|
child = subprocess.run(cmd, stderr=subprocess.DEVNULL, env=denv)
|
||||||
|
# "--quiet" git commands imply "--exit-code", which returns:
|
||||||
|
# 1 if there are differences
|
||||||
|
# 0 if there are no differences
|
||||||
dwd = bool(child.returncode)
|
dwd = bool(child.returncode)
|
||||||
except (subprocess.CalledProcessError, OSError, FileNotFoundError):
|
except (subprocess.CalledProcessError, OSError, FileNotFoundError):
|
||||||
q.put(None)
|
q.put(None)
|
||||||
|
|
Loading…
Add table
Reference in a new issue