lib/git-hooks.js
function getClosestGitPath(currentPath) {
    currentPath = currentPath || process.cwd();

    var dirnamePath = path.join(currentPath, '.git');

    if (fsHelpers.exists(dirnamePath)) {
        return dirnamePath;
    }

    var nextPath = path.resolve(currentPath, '..');

    if (nextPath === currentPath) {
        return;
    }

    return getClosestGitPath(nextPath);
}
function getClosestGitPath(currentPath) {
    currentPath = currentPath || process.cwd();

    var dirnamePath = path.join(currentPath, '.git');

    if (fsHelpers.exists(dirnamePath)) {
        return dirnamePath;
    }

    var nextPath = path.resolve(currentPath, '..');

    if (nextPath === currentPath) {
        return;
    }

    return getClosestGitPath(nextPath);
}
function getClosestGitPath ( currentPath ) { currentPath = currentPath || process . cwd ( ) ; var dirnamePath = path . join ( currentPath , '.git' ) ; if ( fsHelpers . exists ( dirnamePath ) ) { return dirnamePath ; } var nextPath = path . resolve ( currentPath , '..' ) ; if ( nextPath === currentPath ) { return ; } return getClosestGitPath ( nextPath ) ; }
Returns the closest git directory.
It starts looking from the current directory and does it up to the fs root.
It returns undefined in case where the specified directory isn't found.

@param {String} [currentPath] Current started path to search.
@returns {String|undefined}
Returns the closest git directory . It starts looking from the current directory and does it up to the fs root . It returns undefined in case where the specified directory isn t found .