Skip to content

Need some kind of high level "rev-parse" functionality. #8

Description

@TooTallNate

It would be great to get some sort of "rev-parse" functionality that you could pass any revision identifier to and have it resolve to a SHA hash. Maybe something like:

// Resolve 'HEAD', asynchronous
repo.revParse("HEAD", function(err, sha) {
  if (err) throw err;
  repo.getCommit(sha, function(err, commit) {
    // Blah
  });
});

// Resolve the tag 'v1.0.0', synchronous
var sha = repo.revParse("v1.0.0");

// Resolve to an oid and get raw Buffer
repo.getRawObject(repo.revParse("HEAD:package.json")).data;

// This would be awesome too:
// All should return: 37d671c8470ca723b951d25dd882186ec6c65c28
repo.revParse("37d671c8470ca723b951d25d");
repo.revParse("37d671c8470ca72");
repo.revParse("37d671c");

Thoughts?

Activity

  1. samcday commented on Apr 1, 2011

    @samcday
    Contributor

    I really like the sound of this!

    My plan is to implement some high level "convenience" wrappers around the gitteh bindings once they're complete. I was planning on implementing these in JS. Your ideas for revParse would be a great first step!

    I like the idea of revParse processing anything - particularly if you give it any ref and it will automatically peel the ref (if it's symbolic) and load the commit.

    Not too sure about resolving fragment sha1's though - libgit2 doesn't support this. I guess we could scan the git repository on the filesystem and try that - but then we'd also have to scan packfiles too.

  2. samcday commented on Apr 3, 2011

    @samcday
    Contributor

    @TooTallNate

    What do you think if we made revParse just straight up retrieve the object you provide? In such a way that it retrieves

    For example:

    // Gives us a Commit object.
    var commit = repository.revParse("HEAD");
    
    // Gives us the Blob for mydir/blah.txt in HEAD revision:
    var blob = repository.revParse("HEAD:mydir/blah.txt");
    
    // Gives us the Tree for mydir in the v1.0.1 tag:
    var tree = repository.revParse("v1.0.1:mydir");
    
  3. mildsunrise commented on Jul 31, 2012

    @mildsunrise
    Contributor

    @samcday Please, tag this as whishlist!

  4. mbostock commented on Aug 17, 2012

    @mbostock

    This would be a lovely feature. I'm using node-gitteh to implement a simple git-backed static file server, and supporting sha1 fragments in particular would be handy for short URLs. Revisions of the form "HEAD~1" would also be handy for comparing the latest and previous versions.

  5. mildsunrise commented on Aug 17, 2012

    @mildsunrise
    Contributor

    Actually, a rev-parse can be a commit, a branch, a tag, or another reference. Thus, LibGit2 will return you the object (could be a Commit, or a Reference).

  6. samcday commented on Jun 27, 2013

    @samcday
    Contributor

    Revparsing is available in libgit2 0.18.0, so we'll be offering this functionality in node-gitteh once we've released our corresponding 0.18.0 package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions