git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCHv8 6/6] submodule: add absorb-git-dir function

From
Duy Nguyen <pclouds@gmail.com>
Date
Dec 19, 2016, 05:35 UTC
Message-ID
<20161219053507.GA2335@duynguyen.vn.dektech.internal>
In-Reply-To
<20161212190435.10358-7-sbeller@google.com>
On Mon, Dec 12, 2016 at 11:04:35AM -0800, Stefan Beller wrote:
Show 19 quoted lines
> 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

Previous: Stefan BellerNext: Stefan Beller
Message 8 of 12 in “[PATCHv7 0/6] submodule absorbgitdirs”
  1. Stefan BellerDec 12, 2016
  2. 1/6 submodule: use absolute path for computing relative path connectingStefan Beller, Dec 12, 2016
  3. 2/6 submodule helper: support super prefixStefan Beller, Dec 12, 2016
  4. 4/6 worktree: check if a submodule uses worktreesStefan Beller, Dec 12, 2016
  5. 5/6 move connect_work_tree_and_git_dir to dir.hStefan Beller, Dec 12, 2016
  6. 3/6 test-lib-functions.sh: teach test_commit -C <dir>Stefan Beller, Dec 12, 2016
  7. 6/6 submodule: add absorb-git-dir functionStefan Beller, Dec 12, 2016
  8. Duy NguyenDec 19, 2016
  9. Stefan BellerDec 19, 2016
  10. Duy NguyenDec 20, 2016
  11. Brandon WilliamsDec 12, 2016
  12. Stefan BellerDec 12, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.