From 79d7582e32ca84eacf032298c8ae3d26816f48d0 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 6 Jan 2016 14:09:43 +0100 Subject: commit: allow editing the commit message even in shared repos 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. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- wrapper.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'wrapper.c') diff --git a/wrapper.c b/wrapper.c index dae5675a96..371a7f0b63 100644 --- a/wrapper.c +++ b/wrapper.c @@ -375,6 +375,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; +} + int xmkstemp(char *template) { int fd; -- cgit v1.2.3