func ReadTree(oid string, basePath ...string) error {
	path := "."
	if len(basePath) > 0 {
		path = basePath[0]
	}
	log.Printf("Restoring tree {%s} in location %s", oid, path)
	data, _type, err := storage.GetObject(oid)
	if err != nil {
		return err
	}
	if _type != storage.TREE {
		return errors.New("This oid point to a non tree object : " + string(_type))
	}
	if !IsIgnored(path) {
		log.Println("Remove : ", path, os.RemoveAll(path))
	}
	os.Mkdir(path, 0777)

	treeLines := strings.Split(data, "\n")
	for _, line := range treeLines {
		lineSplits := strings.Split(line, " ")
		if len(lineSplits) != 3 {
			continue
		}
		t := storage.ObjectType(lineSplits[0])
		o := lineSplits[1]
		p := lineSplits[2]

		if t == storage.TREE {
			subdir := fmt.Sprintf("%s/%s", path, p)
			if err := ReadTree(o, subdir); err != nil {
				return err
			}
		} else {
			d, _, err := storage.GetObject(o)
			if err != nil {
				return err
			}
			filePath := fmt.Sprintf("%s/%s", path, p)
			log.Println("Creating file ", filePath)
			ioutil.WriteFile(filePath, []byte(d), 0777)
		}
	}
	return nil
}
/*
ReadTree restores the tree contents referenced by the oid into the basepath
*/
ReadTree restores the tree contents referenced by the oid into the basepath
/ * ReadTree restores the tree contents referenced by the oid into the basepath * /
func ReadTree(oid string, basePath ...string) error {
	path := "."
	if len(basePath) > 0 {
		path = basePath[0]
	}
	log.Printf("Restoring tree {%s} in location %s", oid, path)
	data, _type, err := storage.GetObject(oid)
	if err != nil {
		return err
	}
	if _type != storage.TREE {
		return errors.New("This oid point to a non tree object : " + string(_type))
	}
	if !IsIgnored(path) {
		log.Println("Remove : ", path, os.RemoveAll(path))
	}
	os.Mkdir(path, 0777)
	treeLines := strings.Split(data, "\n")
	for _, line := range treeLines {
		lineSplits := strings.Split(line, " ")
		if len(lineSplits) != 3 {
			continue
		}
		t := storage.ObjectType(lineSplits[0])
		o := lineSplits[1]
		p := lineSplits[2]
		if t == storage.TREE {
			subdir := fmt.Sprintf("%s/%s", path, p)
			if err := ReadTree(o, subdir); err != nil {
				return err
			}
		} else {
			d, _, err := storage.GetObject(o)
			if err != nil {
				return err
			}
			filePath := fmt.Sprintf("%s/%s", path, p)
			log.Println("Creating file ", filePath)
			ioutil.WriteFile(filePath, []byte(d), 0777)
		}
	}
	return nil
}
func ReadTree ( oid string , basePath ... string ) error { path := " " if len ( basePath ) > 0 { path = basePath [ 0 ] } log . Printf ( " " , oid , path ) data , _type , err := storage . GetObject ( oid ) if err != nil { return err } if _type != storage . TREE { return errors . New ( " " + string ( _type ) ) } if ! IsIgnored ( path ) { log . Println ( " " , path , os . RemoveAll ( path ) ) } os . Mkdir ( path , 0777 ) treeLines := strings . Split ( data , " \n " ) for _ , line := range treeLines { lineSplits := strings . Split ( line , " " ) if len ( lineSplits ) != 3 { continue } t := storage . ObjectType ( lineSplits [ 0 ] ) o := lineSplits [ 1 ] p := lineSplits [ 2 ] if t == storage . TREE { subdir := fmt . Sprintf ( " " , path , p ) if err := ReadTree ( o , subdir ) ; err != nil { return err } } else { d , _ , err := storage . GetObject ( o ) if err != nil { return err } filePath := fmt . Sprintf ( " " , path , p ) log . Println ( " " , filePath ) ioutil . WriteFile ( filePath , [ ] byte ( d ) , 0777 ) } } return nil }
ReadTree restores the tree contents referenced by the oid into the basepath
ReadTree restores the tree contents referenced by the oid into the basepath