@@ -7,7 +7,11 @@ use gix_ref::{
77 Category , FullName , Target ,
88} ;
99
10- use crate :: { bstr:: BString , config:: tree:: Init , ThreadSafeRepository } ;
10+ use crate :: {
11+ bstr:: { BString , ByteSlice } ,
12+ config:: tree:: Init ,
13+ ThreadSafeRepository ,
14+ } ;
1115
1216/// The name of the branch to use if non is configured via git configuration.
1317///
@@ -75,12 +79,17 @@ impl ThreadSafeRepository {
7579 . string ( Init :: DEFAULT_BRANCH )
7680 . unwrap_or_else ( || Cow :: Borrowed ( DEFAULT_BRANCH_NAME . into ( ) ) ) ;
7781 if branch_name. as_ref ( ) != DEFAULT_BRANCH_NAME {
82+ let configured_branch_name = branch_name. into_owned ( ) ;
7883 let sym_ref: FullName = Category :: LocalBranch
79- . to_full_name ( branch_name . as_ref ( ) )
84+ . to_full_name ( configured_branch_name . as_bstr ( ) )
8085 . map_err ( |err| Error :: InvalidBranchName {
81- name : branch_name . into_owned ( ) ,
86+ name : configured_branch_name . clone ( ) ,
8287 source : err,
8388 } ) ?;
89+ gix_validate:: reference:: branch_name ( sym_ref. as_bstr ( ) ) . map_err ( |err| Error :: InvalidBranchName {
90+ name : configured_branch_name,
91+ source : err,
92+ } ) ?;
8493 let mut repo = repo. to_thread_local ( ) ;
8594 let prev_write_reflog = repo. refs . write_reflog ;
8695 repo. refs . write_reflog = WriteReflog :: Disable ;
0 commit comments