From 837e909714b268a9a44d0e4e0e1e3e3c01d08f51 Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Thu, 2 Dec 2010 18:01:41 -0500 Subject: [PATCH] Refuse branch/tag names that start with a dot 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 --- cmd/save-cmd.py | 3 ++- cmd/split-cmd.py | 2 ++ cmd/tag-cmd.py | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/save-cmd.py b/cmd/save-cmd.py index df51a6c74..676aedd5d 100755 --- a/cmd/save-cmd.py +++ b/cmd/save-cmd.py @@ -40,6 +40,8 @@ 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 @@ def wantrecurse_during(ent): 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') diff --git a/cmd/split-cmd.py b/cmd/split-cmd.py index 035e8de4b..7ecc5d018 100755 --- a/cmd/split-cmd.py +++ b/cmd/split-cmd.py @@ -78,6 +78,8 @@ def prog(filenum, nbytes): 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 diff --git a/cmd/tag-cmd.py b/cmd/tag-cmd.py index ad01d6c5a..a624e8b8a 100755 --- a/cmd/tag-cmd.py +++ b/cmd/tag-cmd.py @@ -58,6 +58,9 @@ 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: