From: "brian m. carlson" <sandals@crustytoothpaste.net>
To: Ross Goldberg <ross.goldberg@proton.me>
Cc: "git@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: Command whose exit code indicates clean or dirty working directory
Date: Thu, 10 Apr 2025 22:11:02 +0000 [thread overview]
Message-ID: <Z_hB9gZL6FE7PezC@tapette.crustytoothpaste.net> (raw)
In-Reply-To: <jreR52go49E9pIfAmIdRaoqIgKnVV7uOhR4Mbl9_p2dLG_7mPgO8qsUk7CaWC0nGbJD-2F4nGdQ8X65UtIQ5XOBNQXXzrnHnKbOCLCfEil0=@proton.me>
[-- Attachment #1: Type: text/plain, Size: 840 bytes --]
On 2025-04-10 at 17:49:23, Ross Goldberg wrote:
> What is the simplest git command that returns 0 if the working directory is completely clean, or nonzero if it is dirty in any way (staged diff, unstaged diff, file that is both untracked & not ignored, etc.), with nothing printed to stdout or to stderr?
> If the simplest such command is complex, is there any feature request to create a simple command, possibly with options that specify what is considered dirty (staged diffs, unstaged diffs, untracked & not ignored, etc.)?
Here's what I've used:
[ -z "$(git status --porcelain)" ]
That assumes you know the directory is a non-bare working tree.
`git status --porcelain` prints nothing if the working directory is
clean and prints what's dirty otherwise.
--
brian m. carlson (they/them)
Toronto, Ontario, CA
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 263 bytes --]
prev parent reply other threads:[~2025-04-10 22:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-10 17:49 Command whose exit code indicates clean or dirty working directory Ross Goldberg
2025-04-10 19:24 ` Junio C Hamano
2025-04-10 22:11 ` brian m. carlson [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Z_hB9gZL6FE7PezC@tapette.crustytoothpaste.net \
--to=sandals@crustytoothpaste.net \
--cc=git@vger.kernel.org \
--cc=ross.goldberg@proton.me \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox