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

Re: [PATCH 2/2] Don't clean any untracked submodule's .git dir by default in git-clean

From
Paolo Bonzini <bonzini@gnu.org>
Date
Jun 30, 2009, 06:07 UTC
Message-ID
<4A49AB85.40303@gnu.org>
In-Reply-To
<1246327845-22718-3-git-send-email-jason.k.holden@gmail.com>
Useful indeed.

Note that 'git clean -n -d ' however will still report the directory as being removed. Also, I'm not sure what happens (and what should happen) if an untracked directory foo.git is found.

Probably the best way to fix this is to add an is_dot_git_path function to dir.c like this

int
is_dot_git_path (const char *s, int len);
{
   while (len && s[len - 1] == '/')
     len--;
   return len >= 4 && !memcmp (s + len - 4, ".git", 5) &&
          (len == 4 || s[len - 5] == '/');
}

This function is safer if the directory does not have a trailing slash, as it might be for the paths in builtin-clean.c for the -n case. You can have some adjustments if you decide do keep foo.git (just removing the last && of course).

Thanks!
Paolo
Previous: Jason HoldenNext: Johannes Sixt
Message 4 of 10 in “Don't delete untracked submodule's .git dirs by default”
  1. 0/2 Don't delete untracked submodule's .git dirs by defaultJason Holden, Jun 30, 2009
  2. 1/2 Add option to not delete a .git directory in remove_dir_recursively()Jason Holden, Jun 30, 2009
  3. 2/2 Don't clean any untracked submodule's .git dir by default in git-cleanJason Holden, Jun 30, 2009
  4. Paolo BonziniJun 30, 2009
  5. Johannes SixtJun 30, 2009
  6. Junio C HamanoJun 30, 2009
  7. Junio C HamanoJun 30, 2009
  8. Jason HoldenJul 1, 2009
  9. Junio C HamanoJul 1, 2009
  10. Johannes SixtJun 30, 2009

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.