-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Closed
Description
The git_revparse_single
function seems to ignore any content before the @
symbol if it is the last character in the string. It treats this as the bare @
alias for HEAD
. I would expect it to fail with a bad revision.
Reproduction steps
#include <assert.h>
#include <git2/repository.h>
#include <git2/errors.h>
#include <git2/revparse.h>
#include <git2/oid.h>
#include <git2/global.h>
#include <stdio.h>
#include <unistd.h>
int main() {
git_repository *repo;
assert(git_libgit2_init() == 1);
assert(git_repository_open(&repo, "..") == 0);
git_object *obj;
if (git_revparse_single(&obj, repo, "abcd@") == 0) {
char oidstr[GIT_OID_SHA1_HEXSIZE+1] = {0};
git_oid_tostr(oidstr, sizeof(oidstr), git_object_id(obj));
fprintf(stderr, "oid: %s", oidstr);
}
return 0;
}
Expected behavior
git_revparse_single
returns an error (same as git rev-parse foo@
).
Actual behavior
git_revparse_single
returns the object for HEAD.
Version of libgit2 (release number or SHA1)
8535fdb (current 1.8 dev).
Operating system(s) tested
any
Metadata
Metadata
Assignees
Labels
No labels