All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: "Jeff King" <peff@peff.net>,
	git@vger.kernel.org, "Yaroslav Halchenko" <yoh@onerussian.com>,
	"SZEDER Gábor" <szeder@ira.uka.de>
Subject: Re: [PATCH] commit: ensure correct permissions of the commit message
Date: Tue, 05 Jan 2016 11:39:17 -0800	[thread overview]
Message-ID: <xmqq37ubke8q.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <alpine.DEB.2.20.1601051342050.14434@virtualbox> (Johannes Schindelin's message of "Tue, 5 Jan 2016 13:52:06 +0100 (CET)")

Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:

> Hi Junio,
>
> On Mon, 4 Jan 2016, Junio C Hamano wrote:
>
>> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
>> 
>> >> I do not know fcreate_or_truncate() is a good name, though.
>> >
>> > So what would be a good name?
>> 
>> Have been thinking about it, but I did not come up with anything.  I
>> just know fcreate_or_truncate() is not a good name for multiple
>> reasons I already explained X-<.  sane_fopen_for_writing() perhaps?
>
> That implies that fopen() is insane, though ;-)

Well, sane_X() does not imply X() is "insane".  The reason why we
introduce sane_X() wrapper often is because X is inconvenient to use
sanely as-is.

Look at sane_istest(), sane_case(), etc.  We have one byte and want
to see if that is space, digit, etc., but we have to cast (possibly
signed) char to unsigned char and always doing so in the callers is
inconvenient.  Look at sane_grep.  We have a string and want to see
that appears in its input, but some implementations of "grep" can
be configured in an inconvenient/unsuitable way to be used in
scripts via environment variables, so we disable it not in the
callers but in a wrapper.

All we want to do here is to get a writable filehandle FILE * for a
path and store the contents we will generate without having to worry
about the possibility that the path is already there and we may have
to first unlink it to use fopen(3) to do so.

So in the sense, fopen(3) is inconvenient to use sanely as-is.  You
can call it insane, too ;-)

If we want to follow the X_or_Y() pattern, fopen_or_create() may
describe what it does better.  I do not have strong preference
either way, but again I am not good at naming things (and I suspect
you aren't either), so...

  reply	other threads:[~2016-01-05 19:39 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-19 18:21 [PATCH] commit: ensure correct permissions of the commit message Johannes Schindelin
2015-12-20  7:45 ` Jeff King
2015-12-20 14:21   ` Johannes Schindelin
2015-12-20 22:57     ` Torsten Bögershausen
2015-12-30 14:57       ` Johannes Schindelin
2015-12-21  1:31   ` Junio C Hamano
2015-12-21  6:59     ` Jeff King
2015-12-21 17:22       ` Junio C Hamano
2015-12-30 14:50         ` Johannes Schindelin
2015-12-30 22:56           ` Junio C Hamano
2016-01-01 15:04             ` Johannes Schindelin
2016-01-04 18:34               ` Junio C Hamano
2016-01-05 12:52                 ` Johannes Schindelin
2016-01-05 19:39                   ` Junio C Hamano [this message]
2016-01-06  8:20                     ` Johannes Schindelin
2016-01-06  8:23                       ` Jeff King
2016-01-06  8:50                         ` Johannes Schindelin
2016-01-15  1:12     ` SZEDER Gábor
2016-01-15  1:29       ` Junio C Hamano
2016-01-15  6:51         ` Johannes Schindelin
2016-01-15 10:51         ` SZEDER Gábor
2016-01-15 12:18           ` Johannes Schindelin
2016-01-06 13:09 ` [PATCH v2 0/2] Correctly handle transient files in shared repositories Johannes Schindelin
2016-01-06 13:09   ` [PATCH v2 1/2] commit: allow editing the commit message even in shared repos Johannes Schindelin
2016-01-07 12:41     ` Jeff King
2016-01-07 21:35       ` Junio C Hamano
2016-01-06 13:09   ` [PATCH v2 2/2] Handle more file writes correctly " Johannes Schindelin
2016-01-07 12:46     ` Jeff King
2016-01-08 16:04       ` Johannes Schindelin
2016-01-07 21:52     ` Junio C Hamano
2016-01-08 16:05       ` Johannes Schindelin
2016-01-08 17:59         ` Junio C Hamano
2016-01-11  9:28           ` Johannes Schindelin
2016-01-11 15:57             ` Junio C Hamano
2016-01-11 17:06               ` Junio C Hamano
2016-01-11 18:35   ` [PATCH v3 0/2] Correctly handle transient files in shared repositories Johannes Schindelin
2016-01-11 18:35     ` [PATCH v3 1/2] commit: allow editing the commit message even in shared repos Johannes Schindelin
2016-01-11 18:35     ` [PATCH v3 2/2] Handle more file writes correctly " Johannes Schindelin
2016-01-11 20:22     ` [PATCH v3 0/2] Correctly handle transient files in shared repositories Jeff King
2016-01-11 21:12     ` Junio C Hamano
2016-01-11 21:22       ` Junio C Hamano
2016-01-11 21:38         ` Jeff King
2016-01-11 21:54           ` Junio C Hamano
2016-01-11 22:06             ` Jeff King
2016-01-12  8:05               ` Johannes Schindelin

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=xmqq37ubke8q.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    --cc=szeder@ira.uka.de \
    --cc=yoh@onerussian.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.