write_file(): drop "fatal" parameter

All callers except three passed 1 for the "fatal" parameter to ask
this function to die upon error, but to a casual reader of the code,
it was not all obvious what that 1 meant.  Instead, split the
function into two based on a common write_file_v() that takes the
flag, introduce write_file_gently() as a new way to attempt creating
a file without dying on error, and make three callers to call it.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Junio C Hamano
2015-08-24 13:03:07 -07:00
parent 57c867efe4
commit 12d6ce1dba
10 changed files with 40 additions and 19 deletions

View File

@ -1103,7 +1103,7 @@ void connect_work_tree_and_git_dir(const char *work_tree, const char *git_dir)
/* Update gitfile */
strbuf_addf(&file_name, "%s/.git", work_tree);
write_file(file_name.buf, 1, "gitdir: %s\n",
write_file(file_name.buf, "gitdir: %s\n",
relative_path(git_dir, real_work_tree, &rel_path));
/* Update core.worktree setting */