def find_submodule_git_dir(d):
 if is_git_dir(d):
  return d
 try:
  with open(d) as fp:
   content = fp.read().rstrip()
 except (IOError, OSError):
  pass
 else:
  if content.startswith('gitdir: '):
   path = content[8:]
   if Git.is_cygwin():
    path = decygpath(path)
   if (not osp.isabs(path)):
    path = osp.join(osp.dirname(d), path)
   return find_submodule_git_dir(path)
 return None

def find_submodule_git_dir ( d ) : if is_git_dir ( d ) : return d try : with open ( d ) as fp : content = fp . read ( ) . rstrip ( ) except ( IOError , OSError ) : pass else : if content . startswith ( 'gitdir: ' ) : path = content [ 8 : ] if Git . is_cygwin ( ) : path = decygpath ( path ) if ( not osp . isabs ( path ) ) : path = osp . join ( osp . dirname ( d ) , path ) return find_submodule_git_dir ( path ) return None
search for a submodule repo .