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

Re: [msysGit] [PATCH] fix deletion of .git/objects sub-directories in git-prune/repack

From
Johannes Sixt <j6t@kdbg.org>
Date
Mar 6, 2012, 18:32 UTC
Message-ID
<4F565849.80303@kdbg.org>
In-Reply-To
<OF93114E93.E64C1F7D-ONC12579B9.0032A592-C12579B9.00332D78@dcon.de>
Am 06.03.2012 10:18, schrieb karsten.blees@dcon.de:
Show 6 quoted lines
> On some systems (e.g. Windows XP), directories cannot be deleted while
> they're open. Both git-prune and git-repack (and thus, git-gc) try to
> rmdir while holding a DIR* handle on the directory, leaving dangling
> empty directories in the .git/objects store.
> 
> Fix it by swapping the rmdir / closedir calls.

The reasoning makes a lot of sense. I wonder why object directories are pruned nevertheless when I run git gc --prune (I run git master plus a few topics from pu).

Show 10 quoted lines
> diff --git a/builtin/prune-packed.c b/builtin/prune-packed.c
> index f9463de..a834417 100644
> --- a/builtin/prune-packed.c
> +++ b/builtin/prune-packed.c
> @@ -36,7 +36,6 @@ static void prune_dir(int i, DIR *dir, char *pathname, 
> int len, int opts)
>                 display_progress(progress, i + 1);
>         }
>         pathname[len] = 0;
> -       rmdir(pathname);

After moving the rmdir() away from prune_dir(), the truncation of the pathname does not logically belong here anymore. It should be moved with the rmdir(). Looks good otherwise.

Show 27 quoted lines
>  }
>  
>  void prune_packed_objects(int opts)
> @@ -65,6 +64,7 @@ void prune_packed_objects(int opts)
>                         continue;
>                 prune_dir(i, d, pathname, len + 3, opts);
>                 closedir(d);
> +               rmdir(pathname);
>         }
>         stop_progress(&progress);
>  }
> diff --git a/builtin/prune.c b/builtin/prune.c
> index 58d7cb8..b99b635 100644
> --- a/builtin/prune.c
> +++ b/builtin/prune.c
> @@ -85,9 +85,9 @@ static int prune_dir(int i, char *path)
>                 }
>                 fprintf(stderr, "bad sha1 file: %s/%s\n", path, 
> de->d_name);
>         }
> +       closedir(dir);
>         if (!show_only)
>                 rmdir(path);
> -       closedir(dir);
>         return 0;
>  }
>  
Previous: karsten.blees@dcon.deNext: Junio C Hamano
Message 2 of 9 in “fix deletion of .git/objects sub-directories in git-prune/repack”
  1. fix deletion of .git/objects sub-directories in git-prune/repackkarsten.blees@dcon.de, Mar 6, 2012
  2. Johannes SixtMar 6, 2012
  3. Junio C HamanoMar 6, 2012
  4. Johannes SixtMar 6, 2012
  5. karsten.blees@dcon.deMar 6, 2012
  6. Junio C HamanoMar 6, 2012
  7. karsten.blees@dcon.deMar 7, 2012
  8. Junio C HamanoMar 6, 2012
  9. karsten.blees@dcon.deMar 6, 2012

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.