summaryrefslogtreecommitdiff
path: root/wrapper.c
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2016-01-06 14:09:43 +0100
committerJunio C Hamano <gitster@pobox.com>2016-01-07 13:52:55 -0800
commit79d7582e32ca84eacf032298c8ae3d26816f48d0 (patch)
tree370b19ccf775725f0a2a28e21e7443b330dffe1a /wrapper.c
parent833e48259e23aea76f3765d28d1b2200332301f7 (diff)
downloadgit-79d7582e32ca84eacf032298c8ae3d26816f48d0.tar.gz
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 <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'wrapper.c')
-rw-r--r--wrapper.c13
1 files changed, 13 insertions, 0 deletions
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;