Skip to content

Commit

Permalink
Refuse branch/tag names that start with a dot
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Gabriel Filion authored and apenwarr committed Jan 3, 2011
1 parent 891e5f3 commit 837e909
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cmd/save-cmd.py
Expand Up @@ -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)
Expand Down Expand Up @@ -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')
Expand Down
2 changes: 2 additions & 0 deletions cmd/split-cmd.py
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions cmd/tag-cmd.py
Expand Up @@ -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:
Expand Down

0 comments on commit 837e909

Please sign in to comment.