git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Martin von Zweigbergk <martinvonz@gmail.com>
To: git@vger.kernel.org
Subject: exit code from git reset
Date: Sun, 9 Dec 2012 14:23:41 -0800	[thread overview]
Message-ID: <CANiSa6i0LXE18Pyb5norRTm7PM+TMo3JvxDjoS5JOWt_qjHLHw@mail.gmail.com> (raw)

Hi,

"git reset" currently returns 0 (if successful) while "git reset
$pathspec" returns 0 iff the index matches HEAD after resetting (on
all paths, not just those matching $pathspec). The exit code doesn't
seem to be documented. Is there a reason they should behave
differently? If not, what would be the better behavior? I don't see
when the "git reset $pathspec" behavior" would be useful and it seems
safer for any existing scripts out there not to change the status code
for "git reset" (w/o paths). Scripts that run "git reset $pathspec"
probably already know to ignore (or use?) the exit code. Also, having
any non-zero exit code signal failure might actually be useful.

Changing "git reset $pathspec" to return 0 on success, regardless of
diff between HEAD and index, breaks 10 test cases (in
t2013-checkout-submodule.sh and t7102-reset.sh). These seem to do
"test_must_fail git reset $pathspec", but I have not been able to find
any motivation for expecting the failure.

It seems like this behavior has been there at least since the tests
were added in 359048d (Add tests for documented features of "git
reset"., 2007-09-11), just before reset became built-in.

Would a patch to change the exit code from "git reset $pathspec" be appreciated?

Martin

             reply	other threads:[~2012-12-09 22:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-09 22:23 Martin von Zweigbergk [this message]
2012-12-09 23:04 ` exit code from git reset Junio C Hamano
2012-12-09 23:12   ` Martin von Zweigbergk

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=CANiSa6i0LXE18Pyb5norRTm7PM+TMo3JvxDjoS5JOWt_qjHLHw@mail.gmail.com \
    --to=martinvonz@gmail.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).