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

Re: [PATCH] repository: fix free problem with repo_clear(the_repository)

From
Duy Nguyen <pclouds@gmail.com>
Date
May 10, 2018, 06:18 UTC
Message-ID
<CACsJy8CosHdk3DA46aNM3v5d4wnmLumv+6MdJMY=WfVtKqZ8LA@mail.gmail.com>
In-Reply-To
<CACsJy8AdJcQpiGrR3p6xfuqU0=qoP3=StgbWRNCkdfka6di+5w@mail.gmail.com>
On Wed, May 9, 2018 at 8:00 PM, Duy Nguyen <pclouds@gmail.com> wrote:
Show 9 quoted lines
> discard_index(repo->index);
> if (repo->index != &the_index)
>         FREE_AND_NULL(repo->index);
>
>> What is your use case of repo_clear(the_repository)?
>
> No actual use case right now. See [1] for the code that triggered
> this. I do want to free some memory in pack-objects and repo_clear()
> _might_ be the one. I'm not sure yet.

Another use case for repo_clear(the_repository) is "git worktree move". Part of the reason I did not support moving the main repository with that command is because I wanted to shut down every access to $MAIN_WORK_TREE/.git before moving $MAIN_WORK_TREE. It's probably not a problem for linux/mac platforms to move files (on the same file system [1]) with file descriptors still open, but I'm pretty sure it won't work on Windows. If repo_clear() does its job well, I should be able to safely move $GIT_WORK_TREE after that.

[1] if we move across file systems then another set of problems arise: if file descriptors remain open, writing to those will not affect the new copies in the target. We do not support moving across filesystems yet, but we should not shut that door now.

-- 
Duy
Previous: Stefan BellerNext: Junio C Hamano
Message 8 of 11 in “repository: fix free problem with repo_clear(the_repository)”
  1. repository: fix free problem with repo_clear(the_repository)Nguyễn Thái Ngọc Duy, May 9, 2018
  2. Brandon WilliamsMay 9, 2018
  3. Elijah NewrenMay 9, 2018
  4. Duy NguyenMay 9, 2018
  5. Stefan BellerMay 9, 2018
  6. Duy NguyenMay 9, 2018
  7. Stefan BellerMay 9, 2018
  8. Duy NguyenMay 10, 2018
  9. Junio C HamanoMay 10, 2018
  10. Stefan BellerMay 10, 2018
  11. repository: fix free problem with repo_clear(the_repository)Nguyễn Thái Ngọc Duy, May 10, 2018

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.