GithubHelp home page GithubHelp logo

gogit's Issues

Support packed-refs

Refs can be recorded in the packed-refs file. gogit doesn't look there, which causes it to be unable to open my repo.

The README says the project is "not really actively maintained". Is a PR adding support for this likely to be reviewed? If not, I'll just use git2go...but I'd rather have pure Go if I can arrange it.

log.Fatal?

So... your library returns error vars but nonetheless you use log.Fatal in a number of places which prevents calling code to make decisions about how to exit.

Any chance you'll reconsider that?

Feature: git clone

It would be great to have git clone support. Are there any plans for this?

io.EOF error opening raw objects

Short Version

Go Version: 1.7
GoGit @ 1396c97

readObjectFile fails with an io.EOF error when reading the zlib file reader into the buffer.
The attached diff patch shows what changes I made to get my program running again.

I think there either needs to be proper handling of the EOF error, or perhaps some education on what I might have done wrong in my program. Details below...

Background

I recently upgraded Go to 1.7 and tried re-running a project I've been working on. I've been slowly transitioning away from git2go so I can get away from the cgo dependency.

At this part of the code, I'm really just trying to open the commit pointed to by the master ref--regardless of what branch I might currently be in--so I can compare its date with the current HEAD.

Usage

My client code looks like this (ignore rg.maybeRunMany. Its job is just to keep an internal error value and run the chain of functions until the first errors):

    rg.maybeRunMany(
        func() {
            baseRef, rg.err = r.RepoGogit.LookupReference("refs/heads/master")
            if rg.err != nil {
                rg.msg = "unable to open master branch"
            }
        },
        func() {
            baseCommit, rg.err = r.RepoGogit.LookupCommit(baseRef.Oid)
            if rg.err != nil {
                rg.msg = "unable to open master commit"
            }
        },
        func() {
            headRef, rg.err = r.RepoGogit.LookupReference("HEAD")
            if rg.err != nil {
                rg.msg = "unable to open HEAD ref"
            }
        },
        func() {
            headCommit, rg.err = r.RepoGogit.LookupCommit(headRef.Oid)
            if rg.err != nil {
                rg.msg = "unable to open HEAD commit"
            }
        },
        func() {
            behind = headCommit.Committer.When.Before(baseCommit.Committer.When)
        },
    )
    if rg.err != nil {
        fmt.Println("Error in GoGit chain:", rg.msg)
        fmt.Println(rg.err)
    }
    return behind, rg.err

Result

The output from running this is as follows:

$ go run main.go
Error in GoGit chain: unable to open master commit
EOF

I added some logging to my gogit installation to narrow down to this function:

$ go run main.go
[GoGit] Searching for OID object. Looking in path /Users/davidpierce/Development/go/src/github.com/thedahv/git-reviewer/.git
[GoGit] objPath /Users/davidpierce/Development/go/src/github.com/thedahv/git-reviewer/.git/objects/99/01bf79f808a8339b9820c08e209f5ec9649bda
[GoGit] os.Stat error false
[GoGit][readObjectFile] File open issue for /Users/davidpierce/Development/go/src/github.com/thedahv/git-reviewer/.git/objects/99/01bf79f808a8339b9820c08e209f5ec9649bda: false
[GoGit][readObjectFile] first_buffer_size: 1024
[GoGit][readObjectFile] First buffer read error
[GoGit][readObjectFile] Bytes read 271
[GoGit] Opening raw for OID 9901bf79f808a8339b9820c08e209f5ec9649bda
[GoGit] OID open error EOF
Error in GoGit chain: unable to open master commit
EOF
There was an error determining branch state: EOF

So what do you think? Did I break something or am I misunderstanding how this should work? Why have I not seen this before upgrading to Go 1.7?

Again, handling the EOF error in readObjectFile fixes it for me locally. If you examine the patch, you'll see the logging I added, and a simple naive check to look for an EOF error and ignore it when encountered.

Why LookupCommit method loads tree object?

In commit.go when commit object is loaded from repository, method also load the tree object.

What was the concern of doing so?

It generates additional useless overheat when collecting a commit list.

Can we modify the method to avoid usage of parseTreeData?

How to lookup HEAD^1 etc

Firstly thanks for the super library. Just having an issue with accessing previous commits. For example:

	ref, err := repository.LookupReference("HEAD^2")
	if err != nil {
		log.Fatal(err)
	}

Will cause

ref not found

Even when HEAD^2 exists. Any idea how to achieve this? Or to list through all the previous commits of a reference?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.