style(obj): minor fixes

This commit is contained in:
grimhilt 2024-02-29 09:36:52 +01:00
parent 7951ad0520
commit 8ed86a05ea
2 changed files with 0 additions and 12 deletions

View File

@ -33,14 +33,11 @@ pub trait ObjMethods {
pub struct Obj { pub struct Obj {
name: String, name: String,
ref_path: Option<PathBuf>,
obj_path: PathBuf, obj_path: PathBuf,
obj_type: ObjType, obj_type: ObjType,
file_path: PathBuf, // file here is used as both file and directory file_path: PathBuf, // file here is used as both file and directory
relative_file_path: PathBuf, relative_file_path: PathBuf,
hash_path: String, // hash of the relative path of the file hash_path: String, // hash of the relative path of the file
//tree: Option<&Tree>,
//blob: Option<&Blob>
} }
@ -252,7 +249,6 @@ impl Obj {
fn new() -> Self { fn new() -> Self {
Obj { Obj {
name: String::new(), name: String::new(),
ref_path: None,
obj_path: PathBuf::new(), obj_path: PathBuf::new(),
file_path: PathBuf::new(), file_path: PathBuf::new(),
obj_type: ObjType::DEFAULT, obj_type: ObjType::DEFAULT,
@ -278,7 +274,6 @@ impl Obj {
None => String::new(), None => String::new(),
Some(name) => name.to_str().unwrap().to_owned() Some(name) => name.to_str().unwrap().to_owned()
}, },
ref_path: None,
obj_path, obj_path,
obj_type: match path.exists() { obj_type: match path.exists() {
true => match path.is_dir() { true => match path.is_dir() {
@ -318,7 +313,6 @@ impl Obj {
let obj = Obj { let obj = Obj {
name: String::from(name), name: String::from(name),
ref_path: None,
obj_path, obj_path,
obj_type: match obj_type { obj_type: match obj_type {
"tree" => ObjType::TREE, "tree" => ObjType::TREE,
@ -340,7 +334,6 @@ impl Obj {
pub fn from_head() -> Self { pub fn from_head() -> Self {
Obj { Obj {
name: String::new(), name: String::new(),
ref_path: None,
obj_path: head::path(), obj_path: head::path(),
obj_type: ObjType::TREE, obj_type: ObjType::TREE,
file_path: PathBuf::new(), file_path: PathBuf::new(),

View File

@ -7,7 +7,6 @@ use std::io::{self, BufRead, BufReader, Write, Lines};
pub struct Tree { pub struct Tree {
pub obj: Obj, pub obj: Obj,
pub file: Option<File>,
pub buf_reader: Option<BufReader<File>>, pub buf_reader: Option<BufReader<File>>,
is_head: bool, is_head: bool,
} }
@ -17,7 +16,6 @@ impl Tree {
pub fn new(obj: Obj) -> Self { pub fn new(obj: Obj) -> Self {
Tree { Tree {
obj, obj,
file: None,
buf_reader: None, buf_reader: None,
is_head: false, is_head: false,
} }
@ -26,7 +24,6 @@ impl Tree {
pub fn from_head() -> Self { pub fn from_head() -> Self {
Tree { Tree {
obj: Obj::from_head(), obj: Obj::from_head(),
file: None,
buf_reader: None, buf_reader: None,
is_head: true, is_head: true,
} }
@ -35,7 +32,6 @@ impl Tree {
pub fn from_path<S>(r_path: S) -> Tree where S: IntoPathBuf { pub fn from_path<S>(r_path: S) -> Tree where S: IntoPathBuf {
Tree { Tree {
obj: Obj::from_path(r_path.into()), obj: Obj::from_path(r_path.into()),
file: None,
buf_reader: None, buf_reader: None,
is_head: false, is_head: false,
} }
@ -44,7 +40,6 @@ impl Tree {
pub fn read(&mut self) { pub fn read(&mut self) {
if self.buf_reader.is_none() { if self.buf_reader.is_none() {
if let Ok(file) = File::open(self.get_obj_path()) { if let Ok(file) = File::open(self.get_obj_path()) {
//self.file = Some(file);
self.buf_reader = Some(BufReader::new(file)); self.buf_reader = Some(BufReader::new(file));
// skip first line if is head // skip first line if is head