From: Junio C Hamano <gitster@pobox.com>
To: Nick Andrew <nick@nick-andrew.net>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] Enable git rev-list to parse --quiet
Date: Sun, 20 Jul 2008 11:31:38 -0700 [thread overview]
Message-ID: <7vwsjg76gl.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: 20080720120437.GC15586@mail.local.tull.net
Nick Andrew <nick@nick-andrew.net> writes:
> Exiting a process from within a callback function seems to me to violate
> the principle of least surprise.
Huh? Who is surprised?
I do not know who taught you that "do not exit in a callback" dogma, but I
suspect it was misrepresented when it was taught to you.
A library that calls your function back could be structured this way:
lib() {
perform some set-up that affects external world;
call your callback function;
clean-up the effect of previous set-up action;
}
and exiting from your callback function is not a good idea as it prevents
the library from doing the necessary clean-up in such a case.
But that is true just in a(n extremely) general case. Your generalization
is not particularly useful, methinks, and use of exit(0) in the patch is
very well justified (rather, I do not think they even need justifying).
- The callback you are looking at is not a general purpose callback for
other program's use, but written for a specific use of rev-list;
- The purpose of that exit(0) is to signal "there is something" as
quickly as possible, which was what you wanted out of rev-list;
- Revision traversal is a read-only operation and we know that there is
no externally visible set-up done in the function you are calling to
get your callback called, that needs cleaning up later --- this is not
expected to change, as there are longstanding existing callback
functions supplied to traverse_commit_list() that die() upon seeing
errors already.
prev parent reply other threads:[~2008-07-20 18:32 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-18 4:05 [PATCH] Enable git rev-list to parse --quiet Nick Andrew
2008-07-18 5:42 ` Junio C Hamano
2008-07-18 6:10 ` Junio C Hamano
2008-07-18 9:20 ` Nick Andrew
2008-07-18 10:50 ` Johannes Schindelin
2008-07-20 7:56 ` Junio C Hamano
2008-07-20 12:04 ` Nick Andrew
2008-07-20 18:31 ` Junio C Hamano [this message]
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=7vwsjg76gl.fsf@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=nick@nick-andrew.net \
/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).