step thirty seven: set head to master on init

This commit is contained in:
Gonçalo Valério 2020-11-13 20:21:39 +00:00
parent b54604ac72
commit e0392ead71
3 changed files with 15 additions and 2 deletions

2
.gitignore vendored
View File

@ -1,3 +1,3 @@
/target /target
/test /test*
.rgit .rgit

View File

@ -215,6 +215,19 @@ pub fn create_branch(name: String, oid: String) {
); );
} }
pub fn init() -> std::io::Result<()> {
data::init()?;
data::update_ref(
"HEAD".to_owned(),
data::RefValue {
symbolic: true,
value: "refs/heads/master".to_owned(),
},
true,
);
Ok(())
}
fn is_ignored(path: &String) -> bool { fn is_ignored(path: &String) -> bool {
if path.contains(".rgit") { if path.contains(".rgit") {
true true

View File

@ -83,7 +83,7 @@ fn main() {
} }
fn init() { fn init() {
match data::init() { match base::init() {
Ok(()) => println!("Repository created"), Ok(()) => println!("Repository created"),
_ => println!("Failed. Perhaps the repository already exists."), _ => println!("Failed. Perhaps the repository already exists."),
} }