From ea08a6fd194991f9d800e4cac5ae55fdb02dd235 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Thu, 2 Aug 2007 23:37:21 -0400 Subject: [PATCH] Actually allow TAG_FIXUP branches in fast-import Michael Haggerty noticed while debugging a Git backend for cvs2svn that fast-import was barfing when he tried to use "TAG_FIXUP" as a branch name for temporary work needed to cleanup the tree prior to creating an annotated tag object. The reason we were rejecting the branch name was check_ref_format() returns -2 when there are less than 2 '/' characters in the input name. TAG_FIXUP has 0 '/' characters, but is technically just as valid of a ref as HEAD and MERGE_HEAD, so we really should permit it (and any other similar looking name) during import. New test cases have been added to make sure we still detect very wrong branch names (e.g. containing [ or starting with .) and yet still permit reasonable names (e.g. TAG_FIXUP). Signed-off-by: Shawn O. Pearce --- fast-import.c | 6 +++++- t/t9300-fast-import.sh | 47 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/fast-import.c b/fast-import.c index b28f90dc2..7e136a616 100644 --- a/fast-import.c +++ b/fast-import.c @@ -524,8 +524,12 @@ static struct branch *new_branch(const char *name) if (b) die("Invalid attempt to create duplicate branch: %s", name); - if (check_ref_format(name)) + switch (check_ref_format(name)) { + case 0: break; /* its valid */ + case -2: break; /* valid, but too few '/', allow anyway */ + default: die("Branch name doesn't conform to GIT standards: %s", name); + } b = pool_calloc(1, sizeof(struct branch)); b->name = pool_strdup(name); diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh index 6f95305bf..dac6135b2 100755 --- a/t/t9300-fast-import.sh +++ b/t/t9300-fast-import.sh @@ -170,6 +170,53 @@ test_expect_failure \ 'git-fast-import input < $GIT_COMMITTER_DATE +data <input < $GIT_COMMITTER_DATE +data <input < $GIT_COMMITTER_DATE +data <