git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* exit code from git reset
@ 2012-12-09 22:23 Martin von Zweigbergk
  2012-12-09 23:04 ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Martin von Zweigbergk @ 2012-12-09 22:23 UTC (permalink / raw)
  To: git

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-12-09 23:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-09 22:23 exit code from git reset Martin von Zweigbergk
2012-12-09 23:04 ` Junio C Hamano
2012-12-09 23:12   ` Martin von Zweigbergk

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).