Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rev parse #684

Merged
merged 46 commits into from
Jun 7, 2012
Merged

Rev parse #684

merged 46 commits into from
Jun 7, 2012

Conversation

ben
Copy link
Member

@ben ben commented May 11, 2012

Support for the rev-parse revision-specification language, which takes a string and provides a git_object. So far, these are working:

  • a65fedf39aefe402d3bb6e24df4d4f5fe4547750 -> object with that exact hash
  • a65fedf39a -> object with that hash prefix (uses git_object_lookup_prefix)
  • v0.16.0-234-gd98fa70 (output from git describe) -> object with the hash prefix that follows "-g"
  • refs/heads/master or master -> object pointed to by a fully- or partially-named ref
  • tag^{} -> dereference until we find something that isn't a tag
  • tag^{tree} -> dereference until we find an object of the given type
  • tag^ or master^3 -> dereference until we find a commit, then get the Nth parent
  • tag~3 -> commit that is N steps back from the ref, always following the 1st parent
  • HEAD@{2} -> object that was pointed to by a ref N steps back in the reflog
  • branch@{yesterday}, master@{5 minutes ago} -> object that was pointed to by a ref at the specified time
  • @{-3} -> commit pointed to by the Nth branch checked out before the current one
  • tag^{/foo} -> youngest commit whose message matches the regex after "/", which is reachable from the given starting point
  • :/foo -> youngest commit whose message matches the regex after "/", which is reachable from any ref
  • tag:README.md -> dereference to a tree, then return the blob or tree at the given path

Things that are still missing:

  • :2:Makefile -> blob object in the index at the given merge stage

The entry point is git_revparse_single, and it's expected that there will eventually be a git_revparse_range which supports the rev-parse syntax for finding ranges of commits (a la git rev-list).

[This is a rebased version of #648.]

Ben Straub added 28 commits May 11, 2012 11:30
This version supports refspecs of these kinds:
- Full & partial SHAs
- Output from "git describe"
- "/refs/heads/master" (full ref names)
- "master" (partial ref names)
- "FETCH_HEAD" (named heads)
New tests for "foo^2" syntax, but they don't pass
yet. Support for chaining these, i.e.
"foo^2~3^{u}~1' is starting to shape up.
Supported forms:
- "^n"
- "^0"
- "^"

Still missing: all of the "^{…}" variants.
Also extended the test suite to include chaining
operators, e.g. "master^2~3^4".
Added some reflags to the test repo to support
unit tests.
Removed repeated strlen's, and unnecessary loop-termination variable.
Added tracking configuration to the test repo's
config to support unit tests.
Ported date.c (for approxidate_careful) from git.git
revision aa39b85. Trimmed out the parts we're not
using.
Fixed an error where "nonexistant^N" or similar
would fall into an assert. This now properly returns
an error.
@travisbot
Copy link

This pull request fails (merged 72b86ba into fb49bdf).

@ben ben mentioned this pull request May 11, 2012
Conflicts:
	src/util.h
	tests-clar/refs/branches/listall.c

#include "git2/types.h"

int git__date_parse(git_time_t *out, const char *date);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strikes me as a waste of a header. Do you think you could move this to util.h?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@vmg
Copy link
Member

vmg commented Jun 5, 2012

Almost there. 🏩

if (tree2 != tree) git_tree_free(tree2);
if (entry_is_tree(entry)) {
if (git_tree_lookup(&tree2, repo, &entry->oid) < 0) {
free(alloc);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use git__free() instead of free(), please - it is just a #define for now, but I have a branch that uses it to do allocation logging

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@travisbot
Copy link

This pull request passes (merged 56a5000 into 01dbe27).

@travisbot
Copy link

This pull request passes (merged 2c2cde4 into 01dbe27).

Ben Straub added 6 commits June 6, 2012 12:25
This test is intended to verify that 64-bit
machines can handle parsing dates in 2039 and
beyond, and fails on 32-bit machines. It is now
omitted when run on a 32-bit machine to eliminate
an expected failure.
Converted an internal utility to return an oid, 
rather than a tree entry (whose lifetime is tied
to the parent tree, which was freed before 
returning).
@travisbot
Copy link

This pull request passes (merged 9ecf860 into 01dbe27).

if (tree2 != tree) git_tree_free(tree2);
if (git_tree_entry__is_tree(entry)) {
if (git_tree_lookup(&tree2, repo, &entry->oid) < 0) {
free(alloc);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still left.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's still necessary. I'll give it a better name, though.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ehrm... I meant that this is supposed to be git__free...

@vmg
Copy link
Member

vmg commented Jun 7, 2012

Congratulations on your first major libgit2 ship!

🚢✨⛵✨🚢🚢✨⛵✨🚢🚢✨⛵✨🚢🚢✨⛵✨🚢🚢✨⛵✨🚢🚢✨⛵✨🚢🚢✨⛵✨🚢🚢✨⛵✨🚢🚢✨⛵✨🚢🚢✨⛵✨🚢🚢✨⛵✨🚢🚢✨⛵✨🚢🚢✨⛵✨🚢🚢✨⛵✨🚢🚢✨⛵✨🚢🚢✨⛵✨🚢🚢✨⛵✨🚢🚢✨⛵✨🚢🚢✨⛵✨🚢🚢✨⛵✨🚢🚢✨⛵✨🚢🚢✨⛵✨🚢🚢✨⛵✨🚢🚢✨⛵✨🚢🚢✨⛵✨🚢🚢✨⛵✨🚢🚢✨⛵✨🚢🚢✨⛵✨🚢🚢✨⛵✨🚢🚢✨⛵✨🚢

vmg pushed a commit that referenced this pull request Jun 7, 2012
@vmg vmg merged commit b9ebcc5 into libgit2:development Jun 7, 2012
@travisbot
Copy link

This pull request passes (merged 327dc61 into 01dbe27).

@travisbot
Copy link

This pull request fails (merged 31dda64 into 01dbe27).

phatblat pushed a commit to phatblat/libgit2 that referenced this pull request Sep 13, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants