git-p4 debug doesn't need a git repository
Signed-off-by: Simon Hausmann <hausmann@kde.org>
Simon Hausmann committed
Mar 26, 2007 at 08:18 UTC
8910ac0e888daeefdbe6f7391bece150b12b1ad0
1 file changed
+16
-13
contrib/fast-import/git-p4
+16
-13
@@ -107,6 +107,7 @@ def gitBranchExists(branch):
107
class Command:
108
def __init__(self):
109
self.usage = "usage: %prog [options]"
110
+ self.needsGit = True
111
112
class P4Debug(Command):
113
def __init__(self):
@@ -114,6 +115,7 @@ class P4Debug(Command):
115
self.options = [
116
]
117
self.description = "A tool to debug the output of p4 -G."
118
+ self.needsGit = False
119
120
def run(self, args):
121
for output in p4CmdList(" ".join(args)):
@@ -1031,21 +1033,22 @@ if len(options) > 0:
1033
1034
(cmd, args) = parser.parse_args(sys.argv[2:], cmd);
1035
1034
-gitdir = cmd.gitdir
1035
-if len(gitdir) == 0:
1036
- gitdir = ".git"
1037
- if not isValidGitDir(gitdir):
1038
- cdup = os.popen("git rev-parse --show-cdup").read()[:-1]
1039
- if isValidGitDir(cdup + "/" + gitdir):
1040
- os.chdir(cdup)
1036
+if cmd.needsGit:
1037
+ gitdir = cmd.gitdir
1038
+ if len(gitdir) == 0:
1039
+ gitdir = ".git"
1040
+ if not isValidGitDir(gitdir):
1041
+ cdup = os.popen("git rev-parse --show-cdup").read()[:-1]
1042
+ if isValidGitDir(cdup + "/" + gitdir):
1043
+ os.chdir(cdup)
1044
1042
-if not isValidGitDir(gitdir):
1043
- if isValidGitDir(gitdir + "/.git"):
1044
- gitdir += "/.git"
1045
- else:
1046
- die("fatal: cannot locate git repository at %s" % gitdir)
1045
+ if not isValidGitDir(gitdir):
1046
+ if isValidGitDir(gitdir + "/.git"):
1047
+ gitdir += "/.git"
1048
+ else:
1049
+ die("fatal: cannot locate git repository at %s" % gitdir)
1050
1048
-os.environ["GIT_DIR"] = gitdir
1051
+ os.environ["GIT_DIR"] = gitdir
1052
1053
if not cmd.run(args):
1054
parser.print_help()