write_file(): drop caller-supplied LF from calls to create a one-liner file
All of the callsites covered by this change call write_file() or write_file_gently() to create a one-liner file. Drop the caller supplied LF and let these callees to append it as necessary. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
Aug 24, 2015 at 13:20 UTC
1f76a10b2d72245332ac41bd79249cb82f3946f0
6 files changed
+10
-10
builtin/init-db.c
+1
-1
@@ -378,7 +378,7 @@ static void separate_git_dir(const char *git_dir)
378
die_errno(_("unable to move %s to %s"), src, git_dir);
379
}
380
381
- write_file(git_link, "gitdir: %s\n", git_dir);
381
+ write_file(git_link, "gitdir: %s", git_dir);
382
}
383
384
int init_db(const char *template_dir, unsigned int flags)
builtin/worktree.c
+5
-5
@@ -213,7 +213,7 @@ static int add_worktree(const char *path, const char **child_argv)
213
* after the preparation is over.
214
*/
215
strbuf_addf(&sb, "%s/locked", sb_repo.buf);
216
- write_file(sb.buf, "initializing\n");
216
+ write_file(sb.buf, "initializing");
217
218
strbuf_addf(&sb_git, "%s/.git", path);
219
if (safe_create_leading_directories_const(sb_git.buf))
@@ -223,8 +223,8 @@ static int add_worktree(const char *path, const char **child_argv)
223
224
strbuf_reset(&sb);
225
strbuf_addf(&sb, "%s/gitdir", sb_repo.buf);
226
- write_file(sb.buf, "%s\n", real_path(sb_git.buf));
227
- write_file(sb_git.buf, "gitdir: %s/worktrees/%s\n",
226
+ write_file(sb.buf, "%s", real_path(sb_git.buf));
227
+ write_file(sb_git.buf, "gitdir: %s/worktrees/%s",
228
real_path(get_git_common_dir()), name);
229
/*
230
* This is to keep resolve_ref() happy. We need a valid HEAD
@@ -241,10 +241,10 @@ static int add_worktree(const char *path, const char **child_argv)
241
die(_("unable to resolve HEAD"));
242
strbuf_reset(&sb);
243
strbuf_addf(&sb, "%s/HEAD", sb_repo.buf);
244
- write_file(sb.buf, "%s\n", sha1_to_hex(rev));
244
+ write_file(sb.buf, "%s", sha1_to_hex(rev));
245
strbuf_reset(&sb);
246
strbuf_addf(&sb, "%s/commondir", sb_repo.buf);
247
- write_file(sb.buf, "../..\n");
247
+ write_file(sb.buf, "../..");
248
249
fprintf_ln(stderr, _("Enter %s (identifier %s)"), path, name);
250
daemon.c
+1
-1
@@ -1376,7 +1376,7 @@ int main(int argc, char **argv)
1376
sanitize_stdfds();
1377
1378
if (pid_file)
1379
- write_file(pid_file, "%"PRIuMAX"\n", (uintmax_t) getpid());
1379
+ write_file(pid_file, "%"PRIuMAX, (uintmax_t) getpid());
1380
1381
/* prepare argv for serving-processes */
1382
cld_argv = xmalloc(sizeof (char *) * (argc + 2));
setup.c
+1
-1
@@ -404,7 +404,7 @@ static void update_linked_gitdir(const char *gitfile, const char *gitdir)
404
405
strbuf_addf(&path, "%s/gitfile", gitdir);
406
if (stat(path.buf, &st) || st.st_mtime + 24 * 3600 < time(NULL))
407
- write_file_gently(path.buf, "%s\n", gitfile);
407
+ write_file_gently(path.buf, "%s", gitfile);
408
strbuf_release(&path);
409
}
410
submodule.c
+1
-1
@@ -1103,7 +1103,7 @@ void connect_work_tree_and_git_dir(const char *work_tree, const char *git_dir)
1103
1104
/* Update gitfile */
1105
strbuf_addf(&file_name, "%s/.git", work_tree);
1106
- write_file(file_name.buf, "gitdir: %s\n",
1106
+ write_file(file_name.buf, "gitdir: %s",
1107
relative_path(git_dir, real_work_tree, &rel_path));
1108
1109
/* Update core.worktree setting */
transport.c
+1
-1
@@ -291,7 +291,7 @@ static int write_one_ref(const char *name, const struct object_id *oid,
291
292
strbuf_addstr(buf, name);
293
if (safe_create_leading_directories(buf->buf) ||
294
- write_file_gently(buf->buf, "%s\n", oid_to_hex(oid)))
294
+ write_file_gently(buf->buf, "%s", oid_to_hex(oid)))
295
return error("problems writing temporary file %s: %s",
296
buf->buf, strerror(errno));
297
strbuf_setlen(buf, len);