From: Junio C Hamano <gitster@pobox.com>
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 12:24:26 -0700 [thread overview]
Message-ID: <xmqqlds7om51.fsf@gitster.g> (raw)
In-Reply-To: <jreR52go49E9pIfAmIdRaoqIgKnVV7uOhR4Mbl9_p2dLG_7mPgO8qsUk7CaWC0nGbJD-2F4nGdQ8X65UtIQ5XOBNQXXzrnHnKbOCLCfEil0=@proton.me> (Ross Goldberg's message of "Thu, 10 Apr 2025 17:49:23 +0000")
Ross Goldberg <ross.goldberg@proton.me> writes:
> 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.)?
With the "possibly with options" part, I doubt there is. Once you
start having to specify options, you admit that the problem space is
no longer simple. Depending on occasion, you would be caring
different kind of cleanliness.
If you want to know if there are changes added to the index, "git
diff --cached --quiet" would be a way to ask about it. If you want
to know if there are changes in the working tree relative to the
index, "git diff --quiet" would be a way to ask about it. If you
want to know if there are changes in the working tree relative to
the HEAD commit, "git diff --quiet HEAD" would be. You can use them
to ask about various things you care about, and you can combine
yourself, instead of using a single command with options to specify
which questions to ask.
Having said all that, if what you care the most is simplicity, you
can probably use "git describe --always --dirty", and see if the
output ends with "-dirty" suffix, perhaps? I suspect that it does
not care about untracked files, which you may have to independently
ask command like "git clean -n".
next prev parent reply other threads:[~2025-04-10 19:24 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 [this message]
2025-04-10 22:11 ` brian m. carlson
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=xmqqlds7om51.fsf@gitster.g \
--to=gitster@pobox.com \
--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