Merge branch 'rj/path-cleanup'
authorJunio C Hamano <gitster@pobox.com>
Fri, 14 Sep 2012 18:53:53 +0000 (11:53 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 14 Sep 2012 18:53:53 +0000 (11:53 -0700)
* rj/path-cleanup:
Call mkpathdup() rather than xstrdup(mkpath(...))
Call git_pathdup() rather than xstrdup(git_path("..."))
path.c: Use vsnpath() in the implementation of git_path()
path.c: Don't discard the return value of vsnpath()
path.c: Remove the 'git_' prefix from a file scope function

1  2 
builtin/add.c
builtin/branch.c
builtin/clone.c
builtin/prune.c
merge-recursive.c
diff --combined builtin/add.c
index 2816789b9d8e0976e24e110ce21de12a4eb9bafe,2fc267742239c6360c4a38cab7a0277d3407bac2..e664100c7122d6c4116763716c2260756feffac2
@@@ -16,7 -16,7 +16,7 @@@
  #include "bulk-checkin.h"
  
  static const char * const builtin_add_usage[] = {
 -      "git add [options] [--] <filepattern>...",
 +      N_("git add [options] [--] <filepattern>..."),
        NULL
  };
  static int patch_interactive, add_interactive, edit_interactive;
@@@ -260,7 -260,7 +260,7 @@@ int interactive_add(int argc, const cha
  
  static int edit_patch(int argc, const char **argv, const char *prefix)
  {
-       char *file = xstrdup(git_path("ADD_EDIT.patch"));
+       char *file = git_pathdup("ADD_EDIT.patch");
        const char *apply_argv[] = { "apply", "--recount", "--cached",
                NULL, NULL };
        struct child_process child;
                die (_("Could not apply '%s'"), file);
  
        unlink(file);
+       free(file);
        return 0;
  }
  
@@@ -315,19 -316,19 +316,19 @@@ static int verbose = 0, show_only = 0, 
  static int ignore_add_errors, addremove, intent_to_add, ignore_missing = 0;
  
  static struct option builtin_add_options[] = {
 -      OPT__DRY_RUN(&show_only, "dry run"),
 -      OPT__VERBOSE(&verbose, "be verbose"),
 +      OPT__DRY_RUN(&show_only, N_("dry run")),
 +      OPT__VERBOSE(&verbose, N_("be verbose")),
        OPT_GROUP(""),
 -      OPT_BOOLEAN('i', "interactive", &add_interactive, "interactive picking"),
 -      OPT_BOOLEAN('p', "patch", &patch_interactive, "select hunks interactively"),
 -      OPT_BOOLEAN('e', "edit", &edit_interactive, "edit current diff and apply"),
 -      OPT__FORCE(&ignored_too, "allow adding otherwise ignored files"),
 -      OPT_BOOLEAN('u', "update", &take_worktree_changes, "update tracked files"),
 -      OPT_BOOLEAN('N', "intent-to-add", &intent_to_add, "record only the fact that the path will be added later"),
 -      OPT_BOOLEAN('A', "all", &addremove, "add changes from all tracked and untracked files"),
 -      OPT_BOOLEAN( 0 , "refresh", &refresh_only, "don't add, only refresh the index"),
 -      OPT_BOOLEAN( 0 , "ignore-errors", &ignore_add_errors, "just skip files which cannot be added because of errors"),
 -      OPT_BOOLEAN( 0 , "ignore-missing", &ignore_missing, "check if - even missing - files are ignored in dry run"),
 +      OPT_BOOLEAN('i', "interactive", &add_interactive, N_("interactive picking")),
 +      OPT_BOOLEAN('p', "patch", &patch_interactive, N_("select hunks interactively")),
 +      OPT_BOOLEAN('e', "edit", &edit_interactive, N_("edit current diff and apply")),
 +      OPT__FORCE(&ignored_too, N_("allow adding otherwise ignored files")),
 +      OPT_BOOLEAN('u', "update", &take_worktree_changes, N_("update tracked files")),
 +      OPT_BOOLEAN('N', "intent-to-add", &intent_to_add, N_("record only the fact that the path will be added later")),
 +      OPT_BOOLEAN('A', "all", &addremove, N_("add changes from all tracked and untracked files")),
 +      OPT_BOOLEAN( 0 , "refresh", &refresh_only, N_("don't add, only refresh the index")),
 +      OPT_BOOLEAN( 0 , "ignore-errors", &ignore_add_errors, N_("just skip files which cannot be added because of errors")),
 +      OPT_BOOLEAN( 0 , "ignore-missing", &ignore_missing, N_("check if - even missing - files are ignored in dry run")),
        OPT_END(),
  };
  
diff --combined builtin/branch.c
index 5cb6d78f2c472cc6e579bf6618898f0e44e5ef03,bdf8495aa6662456c81e5cbe2279e43da86bd342..ffd26849c7ad20ff470323621486ae8a2aeb2501
  #include "revision.h"
  #include "string-list.h"
  #include "column.h"
 +#include "utf8.h"
  
  static const char * const builtin_branch_usage[] = {
 -      "git branch [options] [-r | -a] [--merged | --no-merged]",
 -      "git branch [options] [-l] [-f] <branchname> [<start-point>]",
 -      "git branch [options] [-r] (-d | -D) <branchname>...",
 -      "git branch [options] (-m | -M) [<oldbranch>] <newbranch>",
 +      N_("git branch [options] [-r | -a] [--merged | --no-merged]"),
 +      N_("git branch [options] [-l] [-f] <branchname> [<start-point>]"),
 +      N_("git branch [options] [-r] (-d | -D) <branchname>..."),
 +      N_("git branch [options] (-m | -M) [<oldbranch>] <newbranch>"),
        NULL
  };
  
@@@ -130,7 -129,7 +130,7 @@@ static int branch_merged(int kind, cons
        if (!reference_rev)
                reference_rev = head_rev;
  
 -      merged = in_merge_bases(rev, &reference_rev, 1);
 +      merged = in_merge_bases(rev, reference_rev);
  
        /*
         * After the safety valve is fully redefined to "check with
         * a gentle reminder is in order.
         */
        if ((head_rev != reference_rev) &&
 -          in_merge_bases(rev, &head_rev, 1) != merged) {
 +          in_merge_bases(rev, head_rev) != merged) {
                if (merged)
                        warning(_("deleting branch '%s' that has been merged to\n"
                                "         '%s', but not yet merged to HEAD."),
@@@ -197,7 -196,7 +197,7 @@@ static int delete_branches(int argc, co
  
                free(name);
  
-               name = xstrdup(mkpath(fmt, bname.buf));
+               name = mkpathdup(fmt, bname.buf);
                if (read_ref(name, sha1)) {
                        error(remote_branch
                              ? _("remote branch '%s' not found.")
  struct ref_item {
        char *name;
        char *dest;
 -      unsigned int kind, len;
 +      unsigned int kind, width;
        struct commit *commit;
  };
  
@@@ -355,14 -354,14 +355,14 @@@ static int append_ref(const char *refna
        newitem->name = xstrdup(refname);
        newitem->kind = kind;
        newitem->commit = commit;
 -      newitem->len = strlen(refname);
 +      newitem->width = utf8_strwidth(refname);
        newitem->dest = resolve_symref(orig_refname, prefix);
        /* adjust for "remotes/" */
        if (newitem->kind == REF_REMOTE_BRANCH &&
            ref_list->kinds != REF_REMOTE_BRANCH)
 -              newitem->len += 8;
 -      if (newitem->len > ref_list->maxwidth)
 -              ref_list->maxwidth = newitem->len;
 +              newitem->width += 8;
 +      if (newitem->width > ref_list->maxwidth)
 +              ref_list->maxwidth = newitem->width;
  
        return 0;
  }
@@@ -491,12 -490,11 +491,12 @@@ static void print_ref_item(struct ref_i
        }
  
        strbuf_addf(&name, "%s%s", prefix, item->name);
 -      if (verbose)
 +      if (verbose) {
 +              int utf8_compensation = strlen(name.buf) - utf8_strwidth(name.buf);
                strbuf_addf(&out, "%c %s%-*s%s", c, branch_get_color(color),
 -                          maxwidth, name.buf,
 +                          maxwidth + utf8_compensation, name.buf,
                            branch_get_color(BRANCH_COLOR_RESET));
 -      else
 +      else
                strbuf_addf(&out, "%c %s%s%s", c, branch_get_color(color),
                            name.buf, branch_get_color(BRANCH_COLOR_RESET));
  
@@@ -521,8 -519,8 +521,8 @@@ static int calc_maxwidth(struct ref_lis
        for (i = 0; i < refs->index; i++) {
                if (!matches_merge_filter(refs->list[i].commit))
                        continue;
 -              if (refs->list[i].len > w)
 -                      w = refs->list[i].len;
 +              if (refs->list[i].width > w)
 +                      w = refs->list[i].width;
        }
        return w;
  }
@@@ -535,12 -533,12 +535,12 @@@ static void show_detached(struct ref_li
        if (head_commit && is_descendant_of(head_commit, ref_list->with_commit)) {
                struct ref_item item;
                item.name = xstrdup(_("(no branch)"));
 -              item.len = strlen(item.name);
 +              item.width = utf8_strwidth(item.name);
                item.kind = REF_LOCAL_BRANCH;
                item.dest = NULL;
                item.commit = head_commit;
 -              if (item.len > ref_list->maxwidth)
 -                      ref_list->maxwidth = item.len;
 +              if (item.width > ref_list->maxwidth)
 +                      ref_list->maxwidth = item.width;
                print_ref_item(&item, ref_list->maxwidth, ref_list->verbose, ref_list->abbrev, 1, "");
                free(item.name);
        }
@@@ -714,65 -712,62 +714,65 @@@ int cmd_branch(int argc, const char **a
        int delete = 0, rename = 0, force_create = 0, list = 0;
        int verbose = 0, abbrev = -1, detached = 0;
        int reflog = 0, edit_description = 0;
 -      int quiet = 0;
 +      int quiet = 0, unset_upstream = 0;
 +      const char *new_upstream = NULL;
        enum branch_track track;
        int kinds = REF_LOCAL_BRANCH;
        struct commit_list *with_commit = NULL;
  
        struct option options[] = {
 -              OPT_GROUP("Generic options"),
 +              OPT_GROUP(N_("Generic options")),
                OPT__VERBOSE(&verbose,
 -                      "show hash and subject, give twice for upstream branch"),
 -              OPT__QUIET(&quiet, "suppress informational messages"),
 -              OPT_SET_INT('t', "track",  &track, "set up tracking mode (see git-pull(1))",
 +                      N_("show hash and subject, give twice for upstream branch")),
 +              OPT__QUIET(&quiet, N_("suppress informational messages")),
 +              OPT_SET_INT('t', "track",  &track, N_("set up tracking mode (see git-pull(1))"),
                        BRANCH_TRACK_EXPLICIT),
 -              OPT_SET_INT( 0, "set-upstream",  &track, "change upstream info",
 +              OPT_SET_INT( 0, "set-upstream",  &track, N_("change upstream info"),
                        BRANCH_TRACK_OVERRIDE),
 -              OPT__COLOR(&branch_use_color, "use colored output"),
 -              OPT_SET_INT('r', "remotes",     &kinds, "act on remote-tracking branches",
 +              OPT_STRING('u', "set-upstream-to", &new_upstream, "upstream", "change the upstream info"),
 +              OPT_BOOLEAN(0, "unset-upstream", &unset_upstream, "Unset the upstream info"),
 +              OPT__COLOR(&branch_use_color, N_("use colored output")),
 +              OPT_SET_INT('r', "remotes",     &kinds, N_("act on remote-tracking branches"),
                        REF_REMOTE_BRANCH),
                {
 -                      OPTION_CALLBACK, 0, "contains", &with_commit, "commit",
 -                      "print only branches that contain the commit",
 +                      OPTION_CALLBACK, 0, "contains", &with_commit, N_("commit"),
 +                      N_("print only branches that contain the commit"),
                        PARSE_OPT_LASTARG_DEFAULT,
                        parse_opt_with_commit, (intptr_t)"HEAD",
                },
                {
 -                      OPTION_CALLBACK, 0, "with", &with_commit, "commit",
 -                      "print only branches that contain the commit",
 +                      OPTION_CALLBACK, 0, "with", &with_commit, N_("commit"),
 +                      N_("print only branches that contain the commit"),
                        PARSE_OPT_HIDDEN | PARSE_OPT_LASTARG_DEFAULT,
                        parse_opt_with_commit, (intptr_t) "HEAD",
                },
                OPT__ABBREV(&abbrev),
  
 -              OPT_GROUP("Specific git-branch actions:"),
 -              OPT_SET_INT('a', "all", &kinds, "list both remote-tracking and local branches",
 +              OPT_GROUP(N_("Specific git-branch actions:")),
 +              OPT_SET_INT('a', "all", &kinds, N_("list both remote-tracking and local branches"),
                        REF_REMOTE_BRANCH | REF_LOCAL_BRANCH),
 -              OPT_BIT('d', "delete", &delete, "delete fully merged branch", 1),
 -              OPT_BIT('D', NULL, &delete, "delete branch (even if not merged)", 2),
 -              OPT_BIT('m', "move", &rename, "move/rename a branch and its reflog", 1),
 -              OPT_BIT('M', NULL, &rename, "move/rename a branch, even if target exists", 2),
 -              OPT_BOOLEAN(0, "list", &list, "list branch names"),
 -              OPT_BOOLEAN('l', "create-reflog", &reflog, "create the branch's reflog"),
 +              OPT_BIT('d', "delete", &delete, N_("delete fully merged branch"), 1),
 +              OPT_BIT('D', NULL, &delete, N_("delete branch (even if not merged)"), 2),
 +              OPT_BIT('m', "move", &rename, N_("move/rename a branch and its reflog"), 1),
 +              OPT_BIT('M', NULL, &rename, N_("move/rename a branch, even if target exists"), 2),
 +              OPT_BOOLEAN(0, "list", &list, N_("list branch names")),
 +              OPT_BOOLEAN('l', "create-reflog", &reflog, N_("create the branch's reflog")),
                OPT_BOOLEAN(0, "edit-description", &edit_description,
 -                          "edit the description for the branch"),
 -              OPT__FORCE(&force_create, "force creation (when already exists)"),
 +                          N_("edit the description for the branch")),
 +              OPT__FORCE(&force_create, N_("force creation (when already exists)")),
                {
                        OPTION_CALLBACK, 0, "no-merged", &merge_filter_ref,
 -                      "commit", "print only not merged branches",
 +                      N_("commit"), N_("print only not merged branches"),
                        PARSE_OPT_LASTARG_DEFAULT | PARSE_OPT_NONEG,
                        opt_parse_merge_filter, (intptr_t) "HEAD",
                },
                {
                        OPTION_CALLBACK, 0, "merged", &merge_filter_ref,
 -                      "commit", "print only merged branches",
 +                      N_("commit"), N_("print only merged branches"),
                        PARSE_OPT_LASTARG_DEFAULT | PARSE_OPT_NONEG,
                        opt_parse_merge_filter, (intptr_t) "HEAD",
                },
 -              OPT_COLUMN(0, "column", &colopts, "list branches in columns"),
 +              OPT_COLUMN(0, "column", &colopts, N_("list branches in columns")),
                OPT_END(),
        };
  
        argc = parse_options(argc, argv, prefix, options, builtin_branch_usage,
                             0);
  
 -      if (!delete && !rename && !edit_description && argc == 0)
 +      if (!delete && !rename && !edit_description && !new_upstream && !unset_upstream && argc == 0)
                list = 1;
  
 -      if (!!delete + !!rename + !!force_create + !!list > 1)
 +      if (!!delete + !!rename + !!force_create + !!list + !!new_upstream + !!unset_upstream > 1)
                usage_with_options(builtin_branch_usage, options);
  
        if (abbrev == -1)
                        rename_branch(argv[0], argv[1], rename > 1);
                else
                        usage_with_options(builtin_branch_usage, options);
 +      } else if (new_upstream) {
 +              struct branch *branch = branch_get(argv[0]);
 +
 +              if (!ref_exists(branch->refname))
 +                      die(_("branch '%s' does not exist"), branch->name);
 +
 +              /*
 +               * create_branch takes care of setting up the tracking
 +               * info and making sure new_upstream is correct
 +               */
 +              create_branch(head, branch->name, new_upstream, 0, 0, 0, quiet, BRANCH_TRACK_OVERRIDE);
 +      } else if (unset_upstream) {
 +              struct branch *branch = branch_get(argv[0]);
 +              struct strbuf buf = STRBUF_INIT;
 +
 +              if (!branch_has_merge_config(branch)) {
 +                      die(_("Branch '%s' has no upstream information"), branch->name);
 +              }
 +
 +              strbuf_addf(&buf, "branch.%s.remote", branch->name);
 +              git_config_set_multivar(buf.buf, NULL, NULL, 1);
 +              strbuf_reset(&buf);
 +              strbuf_addf(&buf, "branch.%s.merge", branch->name);
 +              git_config_set_multivar(buf.buf, NULL, NULL, 1);
 +              strbuf_release(&buf);
        } else if (argc > 0 && argc <= 2) {
 +              struct branch *branch = branch_get(argv[0]);
 +              int branch_existed = 0, remote_tracking = 0;
 +              struct strbuf buf = STRBUF_INIT;
 +
                if (kinds != REF_LOCAL_BRANCH)
                        die(_("-a and -r options to 'git branch' do not make sense with a branch name"));
 +
 +              if (track == BRANCH_TRACK_OVERRIDE)
 +                      fprintf(stderr, _("The --set-upstream flag is deprecated and will be removed. Consider using --track or --set-upstream-to\n"));
 +
 +              strbuf_addf(&buf, "refs/remotes/%s", branch->name);
 +              remote_tracking = ref_exists(buf.buf);
 +              strbuf_release(&buf);
 +
 +              branch_existed = ref_exists(branch->refname);
                create_branch(head, argv[0], (argc == 2) ? argv[1] : head,
                              force_create, reflog, 0, quiet, track);
 +
 +              /*
 +               * We only show the instructions if the user gave us
 +               * one branch which doesn't exist locally, but is the
 +               * name of a remote-tracking branch.
 +               */
 +              if (argc == 1 && track == BRANCH_TRACK_OVERRIDE &&
 +                  !branch_existed && remote_tracking) {
 +                      fprintf(stderr, _("\nIf you wanted to make '%s' track '%s', do this:\n\n"), head, branch->name);
 +                      fprintf(stderr, _("    git branch -d %s\n"), branch->name);
 +                      fprintf(stderr, _("    git branch --set-upstream-to %s\n"), branch->name);
 +              }
 +
        } else
                usage_with_options(builtin_branch_usage, options);
  
diff --combined builtin/clone.c
index 5e8f3ba22c3df9ee5ec7b6ae061c97ccc1740fdd,c819757b3aeb1c4a011d73a0bcfee279b290e309..5a9b2bce2495cac1a343b10300804867e0f067e7
@@@ -33,7 -33,7 +33,7 @@@
   *
   */
  static const char * const builtin_clone_usage[] = {
 -      "git clone [options] [--] <repo> [<dir>]",
 +      N_("git clone [options] [--] <repo> [<dir>]"),
        NULL
  };
  
@@@ -61,43 -61,43 +61,43 @@@ static int opt_parse_reference(const st
  static struct option builtin_clone_options[] = {
        OPT__VERBOSITY(&option_verbosity),
        OPT_BOOL(0, "progress", &option_progress,
 -               "force progress reporting"),
 +               N_("force progress reporting")),
        OPT_BOOLEAN('n', "no-checkout", &option_no_checkout,
 -                  "don't create a checkout"),
 -      OPT_BOOLEAN(0, "bare", &option_bare, "create a bare repository"),
 +                  N_("don't create a checkout")),
 +      OPT_BOOLEAN(0, "bare", &option_bare, N_("create a bare repository")),
        { OPTION_BOOLEAN, 0, "naked", &option_bare, NULL,
 -              "create a bare repository",
 +              N_("create a bare repository"),
                PARSE_OPT_NOARG | PARSE_OPT_HIDDEN },
        OPT_BOOLEAN(0, "mirror", &option_mirror,
 -                  "create a mirror repository (implies bare)"),
 +                  N_("create a mirror repository (implies bare)")),
        OPT_BOOL('l', "local", &option_local,
 -              "to clone from a local repository"),
 +              N_("to clone from a local repository")),
        OPT_BOOLEAN(0, "no-hardlinks", &option_no_hardlinks,
 -                  "don't use local hardlinks, always copy"),
 +                  N_("don't use local hardlinks, always copy")),
        OPT_BOOLEAN('s', "shared", &option_shared,
 -                  "setup as shared repository"),
 +                  N_("setup as shared repository")),
        OPT_BOOLEAN(0, "recursive", &option_recursive,
 -                  "initialize submodules in the clone"),
 +                  N_("initialize submodules in the clone")),
        OPT_BOOLEAN(0, "recurse-submodules", &option_recursive,
 -                  "initialize submodules in the clone"),
 -      OPT_STRING(0, "template", &option_template, "template-directory",
 -                 "directory from which templates will be used"),
 -      OPT_CALLBACK(0 , "reference", &option_reference, "repo",
 -                   "reference repository", &opt_parse_reference),
 -      OPT_STRING('o', "origin", &option_origin, "name",
 -                 "use <name> instead of 'origin' to track upstream"),
 -      OPT_STRING('b', "branch", &option_branch, "branch",
 -                 "checkout <branch> instead of the remote's HEAD"),
 -      OPT_STRING('u', "upload-pack", &option_upload_pack, "path",
 -                 "path to git-upload-pack on the remote"),
 -      OPT_STRING(0, "depth", &option_depth, "depth",
 -                  "create a shallow clone of that depth"),
 +                  N_("initialize submodules in the clone")),
 +      OPT_STRING(0, "template", &option_template, N_("template-directory"),
 +                 N_("directory from which templates will be used")),
 +      OPT_CALLBACK(0 , "reference", &option_reference, N_("repo"),
 +                   N_("reference repository"), &opt_parse_reference),
 +      OPT_STRING('o', "origin", &option_origin, N_("name"),
 +                 N_("use <name> instead of 'origin' to track upstream")),
 +      OPT_STRING('b', "branch", &option_branch, N_("branch"),
 +                 N_("checkout <branch> instead of the remote's HEAD")),
 +      OPT_STRING('u', "upload-pack", &option_upload_pack, N_("path"),
 +                 N_("path to git-upload-pack on the remote")),
 +      OPT_STRING(0, "depth", &option_depth, N_("depth"),
 +                  N_("create a shallow clone of that depth")),
        OPT_BOOL(0, "single-branch", &option_single_branch,
 -                  "clone only one branch, HEAD or --branch"),
 -      OPT_STRING(0, "separate-git-dir", &real_git_dir, "gitdir",
 -                 "separate git dir from working tree"),
 -      OPT_STRING_LIST('c', "config", &option_config, "key=value",
 -                      "set config inside the new repository"),
 +                  N_("clone only one branch, HEAD or --branch")),
 +      OPT_STRING(0, "separate-git-dir", &real_git_dir, N_("gitdir"),
 +                 N_("separate git dir from working tree")),
 +      OPT_STRING_LIST('c', "config", &option_config, N_("key=value"),
 +                      N_("set config inside the new repository")),
        OPT_END()
  };
  
@@@ -236,7 -236,7 +236,7 @@@ static int add_one_reference(struct str
        /* Beware: real_path() and mkpath() return static buffer */
        ref_git = xstrdup(real_path(item->string));
        if (is_directory(mkpath("%s/.git/objects", ref_git))) {
-               char *ref_git_git = xstrdup(mkpath("%s/.git", ref_git));
+               char *ref_git_git = mkpathdup("%s/.git", ref_git);
                free(ref_git);
                ref_git = ref_git_git;
        } else if (!is_directory(mkpath("%s/objects", ref_git)))
@@@ -700,7 -700,7 +700,7 @@@ int cmd_clone(int argc, const char **ar
                git_dir = xstrdup(dir);
        else {
                work_tree = dir;
-               git_dir = xstrdup(mkpath("%s/.git", dir));
+               git_dir = mkpathdup("%s/.git", dir);
        }
  
        if (!option_bare) {
diff --combined builtin/prune.c
index 9a03d24dadaaba8bc1fc0c778dbfe33b1651607e,f66ff676eb283692304c99e77d12b325d9f4a7b3..8cb8b9186a3a268630680e4b224d3767017e1e38
@@@ -9,7 -9,7 +9,7 @@@
  #include "dir.h"
  
  static const char * const prune_usage[] = {
 -      "git prune [-n] [-v] [--expire <time>] [--] [<head>...]",
 +      N_("git prune [-n] [-v] [--expire <time>] [--] [<head>...]"),
        NULL
  };
  static int show_only;
@@@ -25,8 -25,7 +25,8 @@@ static int prune_tmp_object(const char 
                return error("Could not stat '%s'", fullpath);
        if (st.st_mtime > expire)
                return 0;
 -      printf("Removing stale temporary file %s\n", fullpath);
 +      if (show_only || verbose)
 +              printf("Removing stale temporary file %s\n", fullpath);
        if (!show_only)
                unlink_or_warn(fullpath);
        return 0;
@@@ -129,11 -128,11 +129,11 @@@ int cmd_prune(int argc, const char **ar
        struct rev_info revs;
        struct progress *progress = NULL;
        const struct option options[] = {
 -              OPT__DRY_RUN(&show_only, "do not remove, show only"),
 -              OPT__VERBOSE(&verbose, "report pruned objects"),
 -              OPT_BOOL(0, "progress", &show_progress, "show progress"),
 +              OPT__DRY_RUN(&show_only, N_("do not remove, show only")),
 +              OPT__VERBOSE(&verbose, N_("report pruned objects")),
 +              OPT_BOOL(0, "progress", &show_progress, N_("show progress")),
                OPT_DATE(0, "expire", &expire,
 -                       "expire objects older than <time>"),
 +                       N_("expire objects older than <time>")),
                OPT_END()
        };
        char *s;
  
        prune_packed_objects(show_only);
        remove_temporary_files(get_object_directory());
-       s = xstrdup(mkpath("%s/pack", get_object_directory()));
+       s = mkpathdup("%s/pack", get_object_directory());
        remove_temporary_files(s);
        free(s);
        return 0;
diff --combined merge-recursive.c
index 7866ca1026730e2e0446f711e3c621e44cef9f60,2f8febe0e0a64e869b33585fa43ca22b922cec8d..d8820604ca3535ce25796012412fe69f1cbdd37b
@@@ -493,7 -493,8 +493,7 @@@ static struct string_list *get_renames(
        opts.rename_score = o->rename_score;
        opts.show_rename_progress = o->show_rename_progress;
        opts.output_format = DIFF_FORMAT_NO_OUTPUT;
 -      if (diff_setup_done(&opts) < 0)
 -              die(_("diff setup failed"));
 +      diff_setup_done(&opts);
        diff_tree_sha1(o_tree->object.sha1, tree->object.sha1, "", &opts);
        diffcore_std(&opts);
        if (opts.needed_rename_limit > o->needed_rename_limit)
@@@ -613,6 -614,23 +613,6 @@@ static char *unique_path(struct merge_o
        return newpath;
  }
  
 -static void flush_buffer(int fd, const char *buf, unsigned long size)
 -{
 -      while (size > 0) {
 -              long ret = write_in_full(fd, buf, size);
 -              if (ret < 0) {
 -                      /* Ignore epipe */
 -                      if (errno == EPIPE)
 -                              break;
 -                      die_errno("merge-recursive");
 -              } else if (!ret) {
 -                      die(_("merge-recursive: disk full?"));
 -              }
 -              size -= ret;
 -              buf += ret;
 -      }
 -}
 -
  static int dir_in_way(const char *path, int check_working_copy)
  {
        int pos, pathlen = strlen(path);
@@@ -771,7 -789,7 +771,7 @@@ static void update_file_flags(struct me
                        fd = open(path, O_WRONLY | O_TRUNC | O_CREAT, mode);
                        if (fd < 0)
                                die_errno(_("failed to open '%s'"), path);
 -                      flush_buffer(fd, buf, size);
 +                      write_in_full(fd, buf, size);
                        close(fd);
                } else if (S_ISLNK(mode)) {
                        char *lnk = xmemdupz(buf, size);
@@@ -844,14 -862,14 +844,14 @@@ static int merge_3way(struct merge_opti
        if (strcmp(a->path, b->path) ||
            (o->ancestor != NULL && strcmp(a->path, one->path) != 0)) {
                base_name = o->ancestor == NULL ? NULL :
-                       xstrdup(mkpath("%s:%s", o->ancestor, one->path));
-               name1 = xstrdup(mkpath("%s:%s", branch1, a->path));
-               name2 = xstrdup(mkpath("%s:%s", branch2, b->path));
+                       mkpathdup("%s:%s", o->ancestor, one->path);
+               name1 = mkpathdup("%s:%s", branch1, a->path);
+               name2 = mkpathdup("%s:%s", branch2, b->path);
        } else {
                base_name = o->ancestor == NULL ? NULL :
-                       xstrdup(mkpath("%s", o->ancestor));
-               name1 = xstrdup(mkpath("%s", branch1));
-               name2 = xstrdup(mkpath("%s", branch2));
+                       mkpathdup("%s", o->ancestor);
+               name1 = mkpathdup("%s", branch1);
+               name2 = mkpathdup("%s", branch2);
        }
  
        read_mmblob(&orig, one->sha1);
        merge_status = ll_merge(result_buf, a->path, &orig, base_name,
                                &src1, name1, &src2, name2, &ll_opts);
  
+       free(base_name);
        free(name1);
        free(name2);
        free(orig.ptr);