@matheusbsbs / matheus-bagliano / commits / 09e16455e0
Fork 0

Improved the git dir detection.

Signed-off-by: Simon Hausmann <hausmann@kde.org>

Simon Hausmann committed Mar 19, 2007 at 11:57 UTC 09e16455e028ae264347067a8c86a7b9a1e5889c
1 file changed +13
contrib/fast-import/p4-git-sync.py
+13
@@ -37,6 +37,11 @@ def die(msg):
37 sys.stderr.write(msg + "\n")
38 sys.exit(1)
39
40 +def tryGitDir(path):
41 + if os.path.exists(path + "/HEAD") and os.path.exists(path + "/refs") and os.path.exists(path + "/objects"):
42 + return True;
43 + return False
44 +
45 try:
46 opts, args = getopt.getopt(sys.argv[1:], "", [ "continue", "git-dir=", "origin=", "reset", "master=",
47 "submit-log-subst=", "log-substitutions=", "noninteractive",
@@ -86,6 +91,14 @@ if len(gitdir) == 0:
91 else:
92 os.environ["GIT_DIR"] = gitdir
93
94 +if not tryGitDir(gitdir):
95 + if tryGitDir(gitdir + "/.git"):
96 + gitdir += "/.git"
97 + os.environ["GIT_DIR"] = gitdir
98 + else:
99 + die("fatal: %s seems not to be a git repository." % gitdir)
100 +
101 +
102 configFile = gitdir + "/p4-git-sync.cfg"
103
104 origin = "origin"