From: Junio C Hamano <gitster@pobox.com>
To: Andrew Schein <andrew@andrewschein.com>
Cc: git@vger.kernel.org
Subject: Re: git default behavior seems odd from a Unix command line point of view
Date: Tue, 12 May 2009 09:12:47 -0700 [thread overview]
Message-ID: <7vd4ae8fls.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <4e963a650905120818m70b75892gb4e052187910b9a5@mail.gmail.com> (Andrew Schein's message of "Tue\, 12 May 2009 11\:18\:25 -0400")
Andrew Schein <andrew@andrewschein.com> writes:
> ais@ace:bio$ git status
> # On branch master
> nothing to commit (working directory clean)
> ais@ace:bio[1]$ git commit -a
This is merely a historical accident that you cannot change. "git status"
was originally a dual-purpose implementation detail of "git commit"
command to:
(1) report if there is anything you can commit with its exit code; and
(2) if there is something to be committed, show what will and what won't
be committed.
For the purpose of (1), the calling command "commit" was told by the user
to make a commit, so the situation where there is nothing to commit was
signalled as an error. The code conceptually looked like:
(git-commit.sh)
do the preparation
if git-status
then
# message "there is nothing to commit" already given
revert the preparation
exit 1
fi
really make a commit
These days, "git commit" has been rewritten and the logic to see if there
is anything to commit is built-in, but people still use "git status"
primarily for purpose (2), the listing of what's committed and what's
left.
Oh, and your example is wrong. If you are going to commit with -a, and if
you want to see if such a "git commit" has actually something to commit,
then you should be giving -a to status as well, like:
git status -a && git commit -a
Also, unless you ask explicitly, "git commit" will not make an empty
commit, so you can always omit the "git status -a &&" part and have "git
commit" itself do the checking.
next prev parent reply other threads:[~2009-05-12 16:12 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-12 15:18 git default behavior seems odd from a Unix command line point of view Andrew Schein
2009-05-12 16:12 ` Junio C Hamano [this message]
2009-05-12 16:24 ` Andrew Schein
2009-05-12 16:34 ` Jeff King
2009-05-12 18:26 ` Daniel Barkalow
2009-05-12 20:05 ` Andrew Schein
2009-05-12 20:50 ` Daniel Barkalow
2009-05-12 16:24 ` Jeff King
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=7vd4ae8fls.fsf@alter.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=andrew@andrewschein.com \
--cc=git@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).