From: Junio C Hamano <gitster@pobox.com>
To: Kenneth Lorber <keni@his.com>
Cc: git@vger.kernel.org
Subject: Re: bug & patch: exit codes from internal commands are handled incorrectly
Date: Thu, 18 Dec 2014 11:18:32 -0800 [thread overview]
Message-ID: <xmqqegrw7omv.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <885593BD-3024-4811-83A5-D3A0C4CE6AC1@his.com> (Kenneth Lorber's message of "Wed, 17 Dec 2014 21:15:47 -0500")
Kenneth Lorber <keni@his.com> writes:
>> Bug: exit codes from (at least) internal commands are handled incorrectly.
>> E.g. git-merge-file, docs say:
>> The exit value of this program is negative on error, and the number of
>> conflicts otherwise. If the merge was clean, the exit value is 0.
>> But only 8 bits get carried through exit, so 256 conflicts gives
>> exit(0), which means the merge was clean.
Wouldn't any cmd_foo() that returns negative to main() be buggy?
Your change sweeps such problems under the rug, which is not a
healthy thing to do.
Expecting that the exit code can signal small positive integers and
other generic kinds of failures is a losing proposition. I think it
is a better fix to update cmd_merge_file() to return 1 (when ret is
positive), 0 (when ret is zero) or 128 (when ret is negative), or
something simple like that, and update the documentation to match
that, without touching git.c::main().
Among the in-tree users, I notice git-cvsserver.perl is already
using the command incorrectly. It does this:
my $return = system("git", "merge-file", $file_local, $file_old, $file_new);
$return >>= 8;
cleanupTmpDir();
if ( $return == 0 )
{
$log->info("Merged successfully");
...
}
elsif ( $return == 1 )
{
$log->info("Merged with conflicts");
...
}
else
{
$log->warn("Merge failed");
next;
}
which assumes $return == 1 is special "half-good", which is not
consistent with the documented interface. It will incorrectly
say "Merge failed" when there are two or more conflicts.
And with such a "1 or 0 or -1" change, you will fix that caller as
well ;-)
next prev parent reply other threads:[~2014-12-18 19:18 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-16 19:28 bug & patch: exit codes from internal commands are handled incorrectly Kenneth Lorber
2014-12-18 2:15 ` Kenneth Lorber
2014-12-18 17:43 ` Torsten Bögershausen
2014-12-18 19:18 ` Junio C Hamano [this message]
2014-12-20 12:39 ` Kenneth Lorber
2015-02-01 22:32 ` Kenneth Lorber
2015-04-01 0:10 ` Kenneth Lorber
2015-04-01 0:40 ` Junio C Hamano
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=xmqqegrw7omv.fsf@gitster.dls.corp.google.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=keni@his.com \
/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).