Optimization for "git clean -ffdx"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dear git Developers,

In a big repository with a lot of untracked directories and files
(build in tree), "git clean -ffdx" can be optimized. Indeed, "git
clean" goes recursively into all untracked and nested directories to
look for .git files even if "-ff" is specified.
Using breakpoint on stat or "strace -e newfstatat", it is possible to
see the recursing search for ".git" and ".git/HEAD". Also it seems to
traverse the untracked directories a few times, which I am not sure
why.

Using "-ff" should not check for nested .git and no need to recurse if
the directory is already untracked.

Doing the following, it seems to avoid looking for nested .git and all
tests are passing.

@@ -1007,6 +1008,12 @@ int cmd_clean(int argc, const char **argv,
const char *prefix)
                 * the code clearer to exclude it, though.
                 */
                dir.flags |= DIR_KEEP_UNTRACKED_CONTENTS;
+
+               /*
+                * No need to go to deeper in directories if already untracked
+                */
+               if (rm_flags == 0)
+                       dir.flags |= DIR_NO_GITLINKS;
        }

        if (read_cache() < 0)

However reading the documentation of DIR_NO_GITLINKS seems to say that
is not the right fix.

Another thing to note is that it shows "Removing XXX" but it shows it
when the directory is already gone. So we could change to "Removed
XXX" or display the "Removing XXX" before starting to remove the
directory.

Thanks in advance for any fix or help in getting it right.
--
Patrick Marlier



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux