#!/usr/bin/env python3

import sys
import os

"""
Recursive directory traversal just in order to find clones. Works quite fast
because we stop at the clones.
"""

def recurse_dir(pathname):
    if os.path.exists(os.path.join(pathname, ".git")):
        print(pathname)
        return

    names = os.listdir(pathname)
    for name in names:
        fullname = os.path.join(pathname, name)
        if os.path.islink(fullname):
            continue
        if os.path.isdir(fullname):
            recurse_dir(fullname)

def main(args):
    if len(args) == 1:
        cwd = "."
    else:
        cwd = args[1]
    recurse_dir(cwd)

if __name__ == "__main__":
    main(sys.argv)
