On Wed, Apr 13, 2016 at 9:15 AM, Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx> wrote: > Similar to "mv a b/", which is actually "mv a b/a", we extract basename > of source worktree and create a directory of the same name at > destination if dst path is a directory. > > Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx> > --- > diff --git a/builtin/worktree.c b/builtin/worktree.c > @@ -538,7 +538,13 @@ static int move_worktree(int ac, const char **av, const char *prefix) > - if (file_exists(dst.buf)) > + if (is_directory(dst.buf)) > + /* > + * keep going, dst will be appended after we get the > + * source's absolute path > + */ > + ; > + else if (file_exists(dst.buf)) > die(_("target '%s' already exists"), av[1]); > @@ -558,6 +564,17 @@ static int move_worktree(int ac, const char **av, const char *prefix) > + if (is_directory(dst.buf)) { > + const char *sep = strrchr(wt->path, '/'); Does this need to take Windows into account? Perhaps git_find_last_dir_sep()? > + > + if (!sep) > + die(_("could not figure out destination name from '%s'"), > + wt->path); > + strbuf_addstr(&dst, sep); > + if (file_exists(dst.buf)) > + die(_("target '%s' already exists"), dst.buf); > + } -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html