Merge branch 'es/worktree-add' into maint
[gitweb.git] / builtin / worktree.c
index 430b51e7a74bb28ac1532ac836e9770121977096..33d2d3705afacfb49973141a546f281d871e8eb6 100644 (file)
@@ -10,7 +10,7 @@
 #include "refs.h"
 
 static const char * const worktree_usage[] = {
-       N_("git worktree add [<options>] <path> <branch>"),
+       N_("git worktree add [<options>] <path> [<branch>]"),
        N_("git worktree prune [<options>]"),
        NULL
 };
@@ -238,7 +238,7 @@ static int add_worktree(const char *path, const char *refname,
         * after the preparation is over.
         */
        strbuf_addf(&sb, "%s/locked", sb_repo.buf);
-       write_file(sb.buf, 1, "initializing\n");
+       write_file(sb.buf, "initializing");
 
        strbuf_addf(&sb_git, "%s/.git", path);
        if (safe_create_leading_directories_const(sb_git.buf))
@@ -248,8 +248,8 @@ static int add_worktree(const char *path, const char *refname,
 
        strbuf_reset(&sb);
        strbuf_addf(&sb, "%s/gitdir", sb_repo.buf);
-       write_file(sb.buf, 1, "%s\n", real_path(sb_git.buf));
-       write_file(sb_git.buf, 1, "gitdir: %s/worktrees/%s\n",
+       write_file(sb.buf, "%s", real_path(sb_git.buf));
+       write_file(sb_git.buf, "gitdir: %s/worktrees/%s",
                   real_path(get_git_common_dir()), name);
        /*
         * This is to keep resolve_ref() happy. We need a valid HEAD
@@ -260,10 +260,10 @@ static int add_worktree(const char *path, const char *refname,
         */
        strbuf_reset(&sb);
        strbuf_addf(&sb, "%s/HEAD", sb_repo.buf);
-       write_file(sb.buf, 1, "0000000000000000000000000000000000000000\n");
+       write_file(sb.buf, "0000000000000000000000000000000000000000");
        strbuf_reset(&sb);
        strbuf_addf(&sb, "%s/commondir", sb_repo.buf);
-       write_file(sb.buf, 1, "../..\n");
+       write_file(sb.buf, "../..");
 
        fprintf_ln(stderr, _("Preparing %s (identifier %s)"), path, name);