]> arthur.barton.de Git - bup.git/commitdiff
Refuse branch/tag names that start with a dot
authorGabriel Filion <lelutin@gmail.com>
Thu, 2 Dec 2010 23:01:41 +0000 (18:01 -0500)
committerAvery Pennarun <apenwarr@gmail.com>
Mon, 3 Jan 2011 04:44:12 +0000 (20:44 -0800)
In git, branch and tag names are not allowed to start with a dot.

In bup, we also want to enforce this since we want to avoid collision with the
top-level special directories (.commit and .tag).

Also, in save-cmd, there was an unused variable at line 286. 'oldref' is used
and contains the same thing so get rid of 'ref'.

Signed-off-by: Gabriel Filion <lelutin@gmail.com>
cmd/save-cmd.py
cmd/split-cmd.py
cmd/tag-cmd.py

index df51a6c74934c8aca99631e70122752e9986c815..676aedd5da9fe7073a1b7c723ea48d6a3f98039a 100755 (executable)
@@ -40,6 +40,8 @@ is_reverse = os.environ.get('BUP_SERVER_REVERSE')
 if is_reverse and opt.remote:
     o.fatal("don't use -r in reverse mode; it's automatic")
 
+if opt.name and opt.name.startswith('.'):
+    o.fatal("'%s' is not a valid branch name" % opt.name)
 refname = opt.name and 'refs/heads/%s' % opt.name or None
 if opt.remote or is_reverse:
     cli = client.Client(opt.remote)
@@ -283,7 +285,6 @@ if opt.tree:
     print tree.encode('hex')
 if opt.commit or opt.name:
     msg = 'bup save\n\nGenerated by command:\n%r' % sys.argv
-    ref = opt.name and ('refs/heads/%s' % opt.name) or None
     commit = w.new_commit(oldref, tree, date, msg)
     if opt.commit:
         print commit.encode('hex')
index 035e8de4b97cf95d6532e5909a9149de8cadc1c2..7ecc5d018cc865a76727580c2c612eb04a2c060e 100755 (executable)
@@ -78,6 +78,8 @@ if is_reverse and opt.remote:
     o.fatal("don't use -r in reverse mode; it's automatic")
 start_time = time.time()
 
+if opt.name and opt.name.startswith('.'):
+    o.fatal("'%s' is not a valid branch name." % opt.name)
 refname = opt.name and 'refs/heads/%s' % opt.name or None
 if opt.noop or opt.copy:
     cli = pack_writer = oldref = None
index ad01d6c5ac710dabf778876fb4921d32f01b4dc6..a624e8b8ace127d1ea434cad72723468448a61c9 100755 (executable)
@@ -58,6 +58,9 @@ if tag_name in tags:
     log("bup: error: tag '%s' already exists" % tag_name)
     sys.exit(1)
 
+if tag_name.startswith('.'):
+    o.fatal("'%s' is not a valid tag name." % tag_name)
+
 try:
     hash = git.rev_parse(commit)
 except git.GitError, e: