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