From: Jeff King Date: Thu, 07 Jan 2016 12:41:18 GMT Subject: Re: [PATCH v2 1/2] commit: allow editing the commit message even in shared repos Message-ID: <20160107124117.GA14421@sigill.intra.peff.net> In-Reply-To: <38701d9358765af334ce405eb4a29f0063dae670.1452085713.git.johannes.schindelin@gmx.de> On Wed, Jan 06, 2016 at 02:09:43PM +0100, Johannes Schindelin wrote: > It was pointed out by Yaroslav Halchenko that the file containing the > commit message is writable only by the owner, which means that we have > to rewrite it from scratch in a shared repository. > [...] > diff --git a/wrapper.c b/wrapper.c > index b43d437..29a45d2 100644 > --- a/wrapper.c > +++ b/wrapper.c > @@ -391,6 +391,19 @@ FILE *xfdopen(int fd, const char *mode) > return stream; > } > > +FILE *fopen_for_writing(const char *path) > +{ > + FILE *ret = fopen(path, "w"); > + > + if (!ret && errno == EPERM) { > + if (!unlink(path)) > + ret = fopen(path, "w"); > + else > + errno = EPERM; > + } > + return ret; > +} Thanks, this looks good to me. Having seen the implementation, it really is just "try harder to fopen()". I guess calling it "fopen_me_harder()" would be too obscure. :) -Peff