On Tue, Jul 30, 2013 at 09:50:03PM +0200, Jens Lehmann wrote:
> +/* Update gitfile and core.worktree setting to connect work tree and git dir 
> */
> +void connect_work_tree_and_git_dir(const char *work_tree, const char 
> *git_dir)
> +{
> +     struct strbuf file_name = STRBUF_INIT;
> +     struct strbuf rel_path = STRBUF_INIT;
> +     const char *real_work_tree = xstrdup(real_path(work_tree));
> +     FILE *fp;
> +
> +     /* Update gitfile */
> +     strbuf_addf(&file_name, "%s/.git", work_tree);
> +     fp = fopen(file_name.buf, "w");
> +     if (!fp)
> +             die(_("Could not create git link %s"), file_name.buf);
> +     fprintf(fp, "gitdir: %s\n", relative_path(git_dir, real_work_tree,
> +                                               &rel_path));
> +     fclose(fp);
> +
> +     /* Update core.worktree setting */
> +     strbuf_reset(&file_name);
> +     strbuf_addf(&file_name, "%s/config", git_dir);
> +     if (git_config_set_in_file(file_name.buf, "core.worktree",
> +                                relative_path(real_work_tree, git_dir,
> +                                              &rel_path)))
> +             die(_("Could not set core.worktree in %s"),
> +                 file_name.buf);
> +
> +     strbuf_release(&file_name);
> +     strbuf_release(&rel_path);
> +     free((void *)real_work_tree);
> +}

Would it make sense to return an int here and do the dying in
builtin/mv.c instead? Again thinking of "libgit" and the die_errno for
non-submodule errors are in mv.c and not in rename().

If that's the case the same applies for stage_updated_gitmodules() and
update_path_in_gitmodules().

update_path_in_gitmodules() also needs a strbuf_release() if you haven't
already found it.

-- 
Med vänliga hälsningar
Fredrik Gustafsson

tel: 0733-608274
e-post: iv...@iveqy.com
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to