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 20, 2016, 01:39 UTC
Message-ID
<CACsJy8BWMXBN8gXRavGbtuSJkV6AcYaqgGohA5mhEw8MNrQMzg@mail.gmail.com>
In-Reply-To
<CAGZ79kYPEiUGXR-qTbbHzaeOwbHH88mdx7GP8QX2Ff1bypcrwQ@mail.gmail.com>
On Tue, Dec 20, 2016 at 1:15 AM, Stefan Beller <sbeller@google.com> wrote:
Show 26 quoted lines
> On Sun, Dec 18, 2016 at 9:35 PM, Duy Nguyen <pclouds@gmail.com> wrote:
>> 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?
>
> What if the move back fails?

That's when you pray the UNIX gods that recovery steps don't fail :-) This is why I don't _suggest_ to do things but just wonder about it. In theory though, if we keep recovery to dead simple operations (e.g. a series of rename() and nothing else) then it's less likely to fail. I'll look at the new patches when I get home.

-- 
Duy
Previous: Stefan BellerNext: Brandon Williams
Message 10 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.