git_store: avoid confusing delegation from write_conflict() to write_file()

Very little code was saved by reusing `write_file()` and it made it
confusing (needed to provide an unused filename). Also, I'll soon want
access to the `locked_repo` variable in `write_conflict()`.
This commit is contained in:
Martin von Zweigbergk 2020-12-24 23:28:00 -08:00
parent 8cca56ee77
commit 3613fe3f59

View File

@ -371,10 +371,11 @@ impl Store for GitStore {
"adds": conflict_part_list_to_json(&conflict.adds),
});
let json_string = json.to_string();
let mut bytes = json_string.as_bytes();
let bytes = json_string.as_bytes();
let locked_repo = self.repo.lock().unwrap();
// TODO: add a ref pointing to it so it won't get GC'd
let file_id = self.write_file(&FileRepoPath::from("unused"), &mut bytes)?;
Ok(ConflictId(file_id.0))
let oid = locked_repo.blob(bytes).unwrap();
Ok(ConflictId(oid.as_bytes().to_vec()))
}
}