Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
Auto-detect the current git branch before submitting back to perforce.
author
Simon Hausmann
<simon@lst.de>
Wed, 14 Mar 2007 22:30:23 +0000
(23:30 +0100)
committer
Simon Hausmann
<simon@lst.de>
Wed, 14 Mar 2007 22:30:23 +0000
(23:30 +0100)
Signed-off-by: Simon Hausmann <simon@lst.de>
contrib/fast-import/p4-git-sync.py
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
4d9e5fc
)
diff --git
a/contrib/fast-import/p4-git-sync.py
b/contrib/fast-import/p4-git-sync.py
index a4d126fd463c311d256991aa9dad7fcebebfec66..4f020798956ddf0ccf3968fb3f925578acb9b44b 100755
(executable)
--- a/
contrib/fast-import/p4-git-sync.py
+++ b/
contrib/fast-import/p4-git-sync.py
@@
-33,6
+33,10
@@
def p4Cmd(cmd):
result.update(entry)
return result;
result.update(entry)
return result;
+def die(msg):
+ sys.stderr.write(msg + "\n")
+ sys.exit(1)
+
try:
opts, args = getopt.getopt(sys.argv[1:], "", [ "continue", "git-dir=", "origin=", "reset", "master=",
"submit-log-subst=", "log-substitutions=", "interactive",
try:
opts, args = getopt.getopt(sys.argv[1:], "", [ "continue", "git-dir=", "origin=", "reset", "master=",
"submit-log-subst=", "log-substitutions=", "interactive",
@@
-46,7
+50,7
@@
def p4Cmd(cmd):
logSubstitutions["\tDetails:"] = "\tDetails: %log%"
gitdir = os.environ.get("GIT_DIR", "")
origin = "origin"
logSubstitutions["\tDetails:"] = "\tDetails: %log%"
gitdir = os.environ.get("GIT_DIR", "")
origin = "origin"
-master = "
master
"
+master = ""
firstTime = True
reset = False
interactive = False
firstTime = True
reset = False
interactive = False
@@
-88,9
+92,12
@@
def p4Cmd(cmd):
if len(args) == 1:
origin = args[0]
if len(args) == 1:
origin = args[0]
-def die(msg):
- sys.stderr.write(msg + "\n")
- sys.exit(1)
+if len(master) == 0:
+ sys.stdout.write("Auto-detecting current branch: ")
+ master = os.popen("git-name-rev HEAD").read().split(" ")[1][:-1]
+ if len(master) == 0 or not os.path.exists("%s/refs/heads/%s" % (gitdir, master)):
+ die("\nFailed to detect current branch! Aborting!");
+ sys.stdout.write("%s\n" % master)
def system(cmd):
if os.system(cmd) != 0:
def system(cmd):
if os.system(cmd) != 0: