diff options
author | Simon Hausmann <simon@lst.de> | 2007-03-14 23:30:23 +0100 |
---|---|---|
committer | Simon Hausmann <simon@lst.de> | 2007-03-14 23:30:23 +0100 |
commit | d566209e7fecffb61a3209766cc937bf027e2c6c (patch) | |
tree | ac1659e5b0cb59954bc3a030d6fb81bc4ea5a6b1 /contrib/fast-import | |
parent | Ignore Apple resource files when importing from perforce to git. (diff) | |
download | tgif-d566209e7fecffb61a3209766cc937bf027e2c6c.tar.xz |
Auto-detect the current git branch before submitting back to perforce.
Signed-off-by: Simon Hausmann <simon@lst.de>
Diffstat (limited to 'contrib/fast-import')
-rwxr-xr-x | contrib/fast-import/p4-git-sync.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/contrib/fast-import/p4-git-sync.py b/contrib/fast-import/p4-git-sync.py index a4d126fd46..4f02079895 100755 --- 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; +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", @@ -46,7 +50,7 @@ logSubstitutions["<enter description here>"] = "%log%" logSubstitutions["\tDetails:"] = "\tDetails: %log%" gitdir = os.environ.get("GIT_DIR", "") origin = "origin" -master = "master" +master = "" firstTime = True reset = False interactive = False @@ -88,9 +92,12 @@ origin = "origin" 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: |