pub fn cat_file(flag: CatFlags, object_hash: &str) -> String {
    let git_object = object_util::read_object_file(object_hash);
    let decoded = object_util::decode_object(git_object);

    let mut split = decoded.split(|num| num == &0u8);
    let header = split.next().unwrap();
    let object_type = object_util::get_header_type(header);

    match flag {
        CatFlags::Print => {
            // Assume the file has valid contents
            if object_type == Object::Tree {
                ls_tree::format_tree(&decoded)
            } else {
                let content = split.next().unwrap();
                return str::from_utf8(content).unwrap().to_owned();
            }
        }
        CatFlags::Type => return format!("{}\n", object_type),
        CatFlags::Size => return format!("{}\n", object_util::get_header_size(header)),
    }
}
/// Returns various properties of the passed object.
///
/// Current properties are file contents, header type, and content size.
///
/// # Arguments
///
/// * `flag` - Controls which property will be returned
/// * `object_hash` - The object in the object database to read
Returns various properties of the passed object.
Current properties are file contents, header type, and content size.
Returns various properties of the passed object . Current properties are file contents header type and content size .
pub fn cat_file(flag: CatFlags, object_hash: &str) -> String {
    let git_object = object_util::read_object_file(object_hash);
    let decoded = object_util::decode_object(git_object);
    let mut split = decoded.split(|num| num == &0u8);
    let header = split.next().unwrap();
    let object_type = object_util::get_header_type(header);
    match flag {
        CatFlags::Print => {
            // Assume the file has valid contents
            if object_type == Object::Tree {
                ls_tree::format_tree(&decoded)
            } else {
                let content = split.next().unwrap();
                return str::from_utf8(content).unwrap().to_owned();
            }
        }
        CatFlags::Type => return format!("{}\n", object_type),
        CatFlags::Size => return format!("{}\n", object_util::get_header_size(header)),
    }
}
pub fn cat_file ( flag : CatFlags , object_hash : & str ) -> String { let git_object = object_util :: read_object_file ( object_hash ) ; let decoded = object_util :: decode_object ( git_object ) ; let mut split = decoded . split ( | num | num == & 0u8 ) ; let header = split . next ( ) . unwrap ( ) ; let object_type = object_util :: get_header_type ( header ) ; match flag { CatFlags :: Print => { // Assume the file has valid contents if object_type == Object :: Tree { ls_tree :: format_tree ( & decoded ) } else { let content = split . next ( ) . unwrap ( ) ; return str :: from_utf8 ( content ) . unwrap ( ) . to_owned ( ) ; } } CatFlags :: Type => return format ! ( " \n " object_type ) , CatFlags :: Size => return format ! ( " \n " object_util get_header_size ( header ) ) , } }
Returns various properties of the passed object.
Returns various properties of the passed object .
flag
CatFlags
object_hash
&str
flag
CatFlags
object_hash
&str