-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Rev parse #684
Conversation
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.
in the test repo.
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.
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); |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
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); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
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).
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is still left.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
...
Congratulations on your first major libgit2 ship! 🚢✨⛵✨🚢🚢✨⛵✨🚢🚢✨⛵✨🚢🚢✨⛵✨🚢🚢✨⛵✨🚢🚢✨⛵✨🚢🚢✨⛵✨🚢🚢✨⛵✨🚢🚢✨⛵✨🚢🚢✨⛵✨🚢🚢✨⛵✨🚢🚢✨⛵✨🚢🚢✨⛵✨🚢🚢✨⛵✨🚢🚢✨⛵✨🚢🚢✨⛵✨🚢🚢✨⛵✨🚢🚢✨⛵✨🚢🚢✨⛵✨🚢🚢✨⛵✨🚢🚢✨⛵✨🚢🚢✨⛵✨🚢🚢✨⛵✨🚢🚢✨⛵✨🚢🚢✨⛵✨🚢🚢✨⛵✨🚢🚢✨⛵✨🚢🚢✨⛵✨🚢🚢✨⛵✨🚢🚢✨⛵✨🚢 |
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 hasha65fedf39a
-> object with that hash prefix (usesgit_object_lookup_prefix
)v0.16.0-234-gd98fa70
(output fromgit describe
) -> object with the hash prefix that follows "-g"refs/heads/master
ormaster
-> object pointed to by a fully- or partially-named reftag^{}
-> dereference until we find something that isn't a tagtag^{tree}
-> dereference until we find an object of the given typetag^
ormaster^3
-> dereference until we find a commit, then get the Nth parenttag~3
-> commit that is N steps back from the ref, always following the 1st parentHEAD@{2}
-> object that was pointed to by a ref N steps back in the reflogbranch@{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 onetag^{/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 reftag:README.md
-> dereference to a tree, then return the blob or tree at the given pathThings that are still missing:
:2:Makefile
-> blob object in the index at the given merge stageThe entry point is
git_revparse_single
, and it's expected that there will eventually be agit_revparse_range
which supports the rev-parse syntax for finding ranges of commits (a lagit rev-list
).[This is a rebased version of #648.]