From: Duy Nguyen <pclouds@gmail.com>
To: Stefan Beller <sbeller@google.com>
Cc: gitster@pobox.com, git@vger.kernel.org, bmwill@google.com
Subject: Re: [PATCHv8 6/6] submodule: add absorb-git-dir function
Date: Mon, 19 Dec 2016 12:35:07 +0700 [thread overview]
Message-ID: <20161219053507.GA2335@duynguyen.vn.dektech.internal> (raw)
In-Reply-To: <20161212190435.10358-7-sbeller@google.com>
On Mon, Dec 12, 2016 at 11:04:35AM -0800, Stefan Beller wrote:
> diff --git a/dir.c b/dir.c
> index e0efd3c2c3..d872cc1570 100644
> --- a/dir.c
> +++ b/dir.c
> @@ -2773,3 +2773,15 @@ void connect_work_tree_and_git_dir(const char *work_tree_, const char *git_dir_)
> free(work_tree);
> free(git_dir);
> }
> +
> +/*
> + * Migrate the git directory of the given path from old_git_dir to new_git_dir.
> + */
> +void relocate_gitdir(const char *path, const char *old_git_dir, const char *new_git_dir)
> +{
> + if (rename(old_git_dir, new_git_dir) < 0)
> + die_errno(_("could not migrate git directory from '%s' to '%s'"),
> + old_git_dir, new_git_dir);
> +
> + connect_work_tree_and_git_dir(path, new_git_dir);
Should we worry about recovering (e.g. maybe move new_git_dir back to
old_git_dir) if this connect_work_tree_and_git_dir() fails?
Both write_file() and git_config_set_.. in this function may die(). In
such a case the repo is in broken state and the user needs pretty good
submodule understanding to recover from it, I think.
Recovering is not easy (nor entirely safe) either, though I suppose if
we keep original copies for modified files, then we could restore them
after moving the directory back and pray the UNIX gods that all
operations succeed.
--
Duy
next prev parent reply other threads:[~2016-12-19 5:36 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-12 19:04 [PATCHv7 0/6] submodule absorbgitdirs Stefan Beller
2016-12-12 19:04 ` [PATCHv8 1/6] submodule: use absolute path for computing relative path connecting Stefan Beller
2016-12-12 19:04 ` [PATCHv8 2/6] submodule helper: support super prefix Stefan Beller
2016-12-12 19:04 ` [PATCHv8 3/6] test-lib-functions.sh: teach test_commit -C <dir> Stefan Beller
2016-12-12 19:04 ` [PATCHv8 4/6] worktree: check if a submodule uses worktrees Stefan Beller
2016-12-12 19:04 ` [PATCHv8 5/6] move connect_work_tree_and_git_dir to dir.h Stefan Beller
2016-12-12 19:04 ` [PATCHv8 6/6] submodule: add absorb-git-dir function Stefan Beller
2016-12-19 5:35 ` Duy Nguyen [this message]
2016-12-19 18:15 ` Stefan Beller
2016-12-20 1:39 ` Duy Nguyen
2016-12-12 20:35 ` [PATCHv7 0/6] submodule absorbgitdirs Brandon Williams
2016-12-12 20:37 ` Stefan Beller
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161219053507.GA2335@duynguyen.vn.dektech.internal \
--to=pclouds@gmail.com \
--cc=bmwill@google.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=sbeller@google.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.
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 NNTP newsgroup(s).