- 
      
- 
        Save michael-k/31cf86a57ff6da30e479 to your computer and use it in GitHub Desktop. 
Revisions
- 
        michael-k revised this gist May 18, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -71,7 +71,7 @@ func main(){ fmt.Printf("obj: %s\n", obj) fmt.Printf("Type: %s\n", obj.Type()) fmt.Printf("Id: %s\n", obj.Id()) fmt.Printf(" EntryCount: %s\n", obj.EntryCount()) } return nil }) 
- 
        michael-k revised this gist May 18, 2014 . 1 changed file with 16 additions and 16 deletions.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -46,32 +46,32 @@ func main(){ case *git.Blob: break fmt.Printf("==================================\n") fmt.Printf("obj: %s\n", obj) fmt.Printf("Type: %s\n", obj.Type()) fmt.Printf("Id: %s\n", obj.Id()) fmt.Printf("Size: %s\n", obj.Size()) case *git.Commit: fmt.Printf("==================================\n") fmt.Printf("obj: %s\n", obj) fmt.Printf("Type: %s\n", obj.Type()) fmt.Printf("Id: %s\n", obj.Id()) author := obj.Author() fmt.Printf(" Author:\n Name: %s\n Email: %s\n Date: %s\n", author.Name, author.Email, author.When) committer := obj.Committer() fmt.Printf(" Committer:\n Name: %s\n Email: %s\n Date: %s\n", committer.Name, committer.Email, committer.When) fmt.Printf(" ParentCount: %s\n", int(obj.ParentCount())) fmt.Printf(" TreeId: %s\n", obj.TreeId()) fmt.Printf(" Message:\n\n %s\n\n", strings.Replace(obj.Message(),"\n","\n ", -1)) //fmt.Printf("obj.Parent: %s\n", obj.Parent()) //fmt.Printf("obj.ParentId: %s\n", obj.ParentId()) //fmt.Printf("obj.Tree: %s\n", obj.Tree()) case *git.Tree: break fmt.Printf("==================================\n") fmt.Printf("obj: %s\n", obj) fmt.Printf("Type: %s\n", obj.Type()) fmt.Printf("Id: %s\n", obj.Id()) fmt.Printf(" EntryCount: %s\n",o bj.EntryCount()) } return nil }) 
- 
        michael-k revised this gist May 18, 2014 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,5 @@ /* requires libgit2 */ @@ -31,10 +29,12 @@ func main(){ log.Fatal(err) } fmt.Println(repo) odb, err := repo.Odb() if err != nil { log.Fatal(err) } err = odb.ForEach(func(oid *git.Oid) error { obj, err := repo.Lookup(oid) if err != nil { 
- 
        michael-k revised this gist May 18, 2014 . 1 changed file with 7 additions and 2 deletions.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -35,10 +35,10 @@ func main(){ if err != nil { log.Fatal(err) } err = odb.ForEach(func(oid *git.Oid) error { obj, err := repo.Lookup(oid) if err != nil { return err } switch obj := obj.(type) { @@ -73,5 +73,10 @@ func main(){ fmt.Printf("Id: %s\n",obj.Id()) fmt.Printf(" EntryCount: %s\n",obj.EntryCount()) } return nil }) if err != nil { log.Fatal("Lookup:", err) } } 
- 
        timhughes revised this gist Apr 2, 2014 . 1 changed file with 7 additions and 0 deletions.There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,10 @@ /* requires libgit2 */ package main import ( 
- 
        timhughes renamed this gist Apr 2, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewingFile renamed without changes.
- 
        timhughes created this gist Apr 2, 2014 .There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,70 @@ package main import ( "github.com/libgit2/git2go" "fmt" "log" "flag" "strings" ) type Blob struct { *git.Blob id *git.Oid } func main(){ repoPath := flag.String("repo", "~/git/testrepo", "path to the git repository") flag.Parse() repo, err := git.OpenRepository(*repoPath) if err != nil { log.Fatal(err) } fmt.Println(repo) odb, err := repo.Odb() if err != nil { log.Fatal(err) } for oid := range odb.ForEach() { obj, err := repo.Lookup(oid) if err != nil { log.Fatal("Lookup:", err) } switch obj := obj.(type) { default: case *git.Blob: break fmt.Printf("==================================\n") fmt.Printf("obj: %s\n",obj) fmt.Printf("Type: %s\n",obj.Type()) fmt.Printf("Id: %s\n",obj.Id()) fmt.Printf("Size: %s\n",obj.Size()) case *git.Commit: fmt.Printf("==================================\n") fmt.Printf("obj: %s\n",obj) fmt.Printf("Type: %s\n",obj.Type()) fmt.Printf("Id: %s\n",obj.Id()) author := obj.Author() fmt.Printf(" Author:\n Name: %s\n Email: %s\n Date: %s\n", author.Name, author.Email, author.When) committer := obj.Committer() fmt.Printf(" Committer:\n Name: %s\n Email: %s\n Date: %s\n", committer.Name, committer.Email, committer.When) fmt.Printf(" ParentCount: %s\n",obj.ParentCount()) fmt.Printf(" TreeId: %s\n",obj.TreeId()) fmt.Printf(" Message:\n\n %s\n\n", strings.Replace(obj.Message(),"\n","\n ", -1)) //fmt.Printf("obj.Parent: %s\n",obj.Parent()) //fmt.Printf("obj.ParentId: %s\n",obj.ParentId()) //fmt.Printf("obj.Tree: %s\n",obj.Tree()) case *git.Tree: break fmt.Printf("==================================\n") fmt.Printf("obj: %s\n",obj) fmt.Printf("Type: %s\n",obj.Type()) fmt.Printf("Id: %s\n",obj.Id()) fmt.Printf(" EntryCount: %s\n",obj.EntryCount()) } } }