branch: fix segfault when resolving an invalid HEAD
[gitweb.git] / git-p4import.py
index 74172ab4500dced73bd678ebb2ee9cc910bcb8ba..60a758bfe3bf535733612d4a0843fb42055f4c80 100644 (file)
@@ -23,7 +23,6 @@
 if s != default_int_handler:
    signal(SIGINT, s)
 
-
 def die(msg, *args):
     for a in args:
         msg = "%s %s" % (msg, a)
@@ -38,6 +37,7 @@ def usage():
 logfile = "/dev/null"
 ignore_warnings = False
 stitch = 0
+tagall = True
 
 def report(level, msg, *args):
     global verbosity
@@ -163,7 +163,7 @@ def __init__(self):
             self.gitdir = self.get_single("rev-parse --git-dir")
             report(2, "gdir:", self.gitdir)
         except:
-            die("Not a git repository... did you forget to \"git init-db\" ?")
+            die("Not a git repository... did you forget to \"git init\" ?")
         try:
             self.cdup = self.get_single("rev-parse --show-cdup")
             if self.cdup != "":
@@ -193,13 +193,13 @@ def current_branch(self):
 
     def get_config(self, variable):
         try:
-            return self.git("repo-config --get %s" % variable)[0].rstrip()
+            return self.git("config --get %s" % variable)[0].rstrip()
         except:
             return None
 
     def set_config(self, variable, value):
         try:
-            self.git("repo-config %s %s"%(variable, value) )
+            self.git("config %s %s"%(variable, value) )
         except:
             die("Could not set %s to " % variable, value)
 
@@ -261,10 +261,9 @@ def commit(self, author, email, date, msg, id):
         self.make_tag("p4/%s"%id, commit)
         self.git("update-ref HEAD %s %s" % (commit, current) )
 
-
 try:
     opts, args = getopt.getopt(sys.argv[1:], "qhvt:",
-                    ["authors=","help","stitch=","timezone=","log=","ignore"])
+            ["authors=","help","stitch=","timezone=","log=","ignore","notags"])
 except getopt.GetoptError:
     usage()
 
@@ -275,6 +274,8 @@ def commit(self, author, email, date, msg, id):
         verbosity += 1
     if o in ("--log"):
         logfile = a
+    if o in ("--notags"):
+        tagall = False
     if o in ("-h", "--help"):
         usage()
     if o in ("--ignore"):
@@ -350,7 +351,10 @@ def commit(self, author, email, date, msg, id):
     report(1, "Importing changeset", id)
     change = p4.describe(id)
     p4.sync(id)
-    git.commit(change.author, change.email, change.date, change.msg, id)
+    if tagall :
+            git.commit(change.author, change.email, change.date, change.msg, id)
+    else:
+            git.commit(change.author, change.email, change.date, change.msg, "import")
     if stitch == 1:
         git.clean_directories()
         stitch = 0