Make Repository.isValidRefName almost compatible with Git 1.6.3
commite4bf8f6957bbb29362575d641d1e77a02d906739
authorShawn O. Pearce <spearce@spearce.org>
Thu, 7 May 2009 15:05:14 +0000 (7 08:05 -0700)
committerShawn O. Pearce <spearce@spearce.org>
Sun, 10 May 2009 21:40:19 +0000 (10 14:40 -0700)
treead0df31283163acb6dfcccc1ae83cec7b0855368
parent9f0e280a3bada33978b2c0766886a25cd16994b4
Make Repository.isValidRefName almost compatible with Git 1.6.3

In 3e262b95c509 I taught C Git to disallow refs whose names end in
".lock".  This suffix is used by the atomic update mechanism as a
signal that the ref is being modified.  When reading a loose ref
directory both JGit and C Git skip over any files whose names end
with this suffix, as the file is assumed to be one of these magic
locking files from another concurrent process.  Consequently, any
ref that ends with this name will become invisible once created.

In cbdffe4093be Junio disallows names that looks like reflog queries
as well as names that ends with periods.

We also add a suite of tests for the isValidRefName function, fix
its formatting to better conform to current style conventions, and
correct the result for "master"; this is not a valid ref name as it
has only 1 path component.  At least 2 path components is required.

In addition to 1.6.3 we disallow names with a '\' (backslash) since
that is a directory separator in Windows. Allowing JGit users to
create such names is just asking for trouble. This does not necessarily
prevent JGit from working with such refs in other situations.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
org.spearce.jgit.test/tst/org/spearce/jgit/lib/ValidRefNameTest.java [new file with mode: 0644]
org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java