From: Fredrik Gustafsson <iveqy@iveqy.com>
To: Jens Lehmann <Jens.Lehmann@web.de>
Cc: Git Mailing List <git@vger.kernel.org>,
Junio C Hamano <gitster@pobox.com>,
Heiko Voigt <hvoigt@hvoigt.net>,
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
Subject: Re: [PATCH v3 2/5] Teach mv to move submodules using a gitfile
Date: Wed, 31 Jul 2013 11:43:14 +0200 [thread overview]
Message-ID: <20130731094314.GD19369@paksenarrion.iveqy.com> (raw)
In-Reply-To: <51F818EB.8010101@web.de>
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: iveqy@iveqy.com
next prev parent reply other threads:[~2013-07-31 9:40 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-30 19:48 [PATCH v3 0/5] Teach mv to move submodules Jens Lehmann
2013-07-30 19:49 ` [PATCH v3 1/5] Teach mv to move submodules together with their work trees Jens Lehmann
2013-07-30 19:50 ` [PATCH v3 2/5] Teach mv to move submodules using a gitfile Jens Lehmann
2013-07-31 9:43 ` Fredrik Gustafsson [this message]
2013-07-30 19:50 ` [PATCH v3 3/5] submodule.c: add .gitmodules staging helper functions Jens Lehmann
2013-07-30 21:37 ` Junio C Hamano
2013-07-30 23:13 ` Jens Lehmann
2013-07-30 19:51 ` [PATCH v3 4/5] Teach mv to update the path entry in .gitmodules for moved submodules Jens Lehmann
2013-08-06 19:15 ` [PATCH v4 " Jens Lehmann
2013-07-30 19:51 ` [PATCH v3 5/5] rm: delete .gitmodules entry of submodules removed from the work tree Jens Lehmann
2013-07-30 20:15 ` Fredrik Gustafsson
2013-07-30 23:06 ` Jens Lehmann
2013-08-06 19:15 ` [PATCH v4 " Jens Lehmann
2013-08-06 21:11 ` Junio C Hamano
2013-08-07 16:51 ` Jens Lehmann
2013-08-07 18:28 ` Fredrik Gustafsson
2013-08-08 17:11 ` Jens Lehmann
2013-08-08 18:55 ` Fredrik Gustafsson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130731094314.GD19369@paksenarrion.iveqy.com \
--to=iveqy@iveqy.com \
--cc=Jens.Lehmann@web.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=hvoigt@hvoigt.net \
--cc=pclouds@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).