Handle more file writes correctly in shared repos
[gitweb.git] / builtin / fetch.c
index 9a3869f4ffd81f84f738e54c6405aaedb2514f18..6475a0b65e16e6b41417adcd0b643239c9840f98 100644 (file)
@@ -836,7 +836,7 @@ static void check_not_current_branch(struct ref *ref_map)
 static int truncate_fetch_head(void)
 {
        const char *filename = git_path_fetch_head();
-       FILE *fp = fopen(filename, "w");
+       FILE *fp = fopen_for_writing(filename);
 
        if (!fp)
                return error(_("cannot open %s: %s\n"), filename, strerror(errno));