mirror of
https://github.com/libgit2/libgit2.git
synced 2026-06-22 06:26:26 +00:00
sha256: indirection for experimental functions
The experimental function signature is only available when `GIT_EXPERIMENTAL_SHA256` is enabled.
This commit is contained in:
@@ -142,7 +142,11 @@ static void oid_parsing(git_oid *oid)
|
||||
* this throughout the example for storing the value of the current SHA
|
||||
* key we're working with.
|
||||
*/
|
||||
#ifdef GIT_EXPERIMENTAL_SHA256
|
||||
git_oid_fromstr(oid, hex, GIT_OID_SHA1);
|
||||
#else
|
||||
git_oid_fromstr(oid, hex);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Once we've converted the string into the oid value, we can get the raw
|
||||
@@ -287,9 +291,14 @@ static void commit_writing(git_repository *repo)
|
||||
* parents. Here we're creating oid objects to create the commit with,
|
||||
* but you can also use
|
||||
*/
|
||||
#ifdef GIT_EXPERIMENTAL_SHA256
|
||||
git_oid_fromstr(&tree_id, "f60079018b664e4e79329a7ef9559c8d9e0378d1", GIT_OID_SHA1);
|
||||
git_tree_lookup(&tree, repo, &tree_id);
|
||||
git_oid_fromstr(&parent_id, "5b5b025afb0b4c913b4c338a42934a3863bf3644", GIT_OID_SHA1);
|
||||
#else
|
||||
git_oid_fromstr(&tree_id, "f60079018b664e4e79329a7ef9559c8d9e0378d1");
|
||||
git_oid_fromstr(&parent_id, "5b5b025afb0b4c913b4c338a42934a3863bf3644");
|
||||
#endif
|
||||
git_tree_lookup(&tree, repo, &tree_id);
|
||||
git_commit_lookup(&parent, repo, &parent_id);
|
||||
|
||||
/**
|
||||
@@ -353,7 +362,11 @@ static void commit_parsing(git_repository *repo)
|
||||
|
||||
printf("\n*Commit Parsing*\n");
|
||||
|
||||
#ifdef GIT_EXPERIMENTAL_SHA256
|
||||
git_oid_fromstr(&oid, "8496071c1b46c854b31185ea97743be6a8774479", GIT_OID_SHA1);
|
||||
#else
|
||||
git_oid_fromstr(&oid, "8496071c1b46c854b31185ea97743be6a8774479");
|
||||
#endif
|
||||
|
||||
error = git_commit_lookup(&commit, repo, &oid);
|
||||
check_error(error, "looking up commit");
|
||||
@@ -422,7 +435,11 @@ static void tag_parsing(git_repository *repo)
|
||||
* We create an oid for the tag object if we know the SHA and look it up
|
||||
* the same way that we would a commit (or any other object).
|
||||
*/
|
||||
#ifdef GIT_EXPERIMENTAL_SHA256
|
||||
git_oid_fromstr(&oid, "b25fa35b38051e4ae45d4222e795f9df2e43f1d1", GIT_OID_SHA1);
|
||||
#else
|
||||
git_oid_fromstr(&oid, "b25fa35b38051e4ae45d4222e795f9df2e43f1d1");
|
||||
#endif
|
||||
|
||||
error = git_tag_lookup(&tag, repo, &oid);
|
||||
check_error(error, "looking up tag");
|
||||
@@ -470,7 +487,11 @@ static void tree_parsing(git_repository *repo)
|
||||
/**
|
||||
* Create the oid and lookup the tree object just like the other objects.
|
||||
*/
|
||||
#ifdef GIT_EXPERIMENTAL_SHA256
|
||||
git_oid_fromstr(&oid, "f60079018b664e4e79329a7ef9559c8d9e0378d1", GIT_OID_SHA1);
|
||||
#else
|
||||
git_oid_fromstr(&oid, "f60079018b664e4e79329a7ef9559c8d9e0378d1");
|
||||
#endif
|
||||
git_tree_lookup(&tree, repo, &oid);
|
||||
|
||||
/**
|
||||
@@ -524,7 +545,11 @@ static void blob_parsing(git_repository *repo)
|
||||
|
||||
printf("\n*Blob Parsing*\n");
|
||||
|
||||
#ifdef GIT_EXPERIMENTAL_SHA256
|
||||
git_oid_fromstr(&oid, "1385f264afb75a56a5bec74243be9b367ba4ca08", GIT_OID_SHA1);
|
||||
#else
|
||||
git_oid_fromstr(&oid, "1385f264afb75a56a5bec74243be9b367ba4ca08");
|
||||
#endif
|
||||
git_blob_lookup(&blob, repo, &oid);
|
||||
|
||||
/**
|
||||
@@ -566,7 +591,11 @@ static void revwalking(git_repository *repo)
|
||||
|
||||
printf("\n*Revwalking*\n");
|
||||
|
||||
#ifdef GIT_EXPERIMENTAL_SHA256
|
||||
git_oid_fromstr(&oid, "5b5b025afb0b4c913b4c338a42934a3863bf3644", GIT_OID_SHA1);
|
||||
#else
|
||||
git_oid_fromstr(&oid, "5b5b025afb0b4c913b4c338a42934a3863bf3644");
|
||||
#endif
|
||||
|
||||
/**
|
||||
* To use the revwalker, create a new walker, tell it how you want to sort
|
||||
|
||||
@@ -140,8 +140,14 @@ static int revwalk_parse_revs(git_repository *repo, git_revwalk *walk, struct ar
|
||||
if (push_spec(repo, walk, curr, hide) == 0)
|
||||
continue;
|
||||
|
||||
#ifdef GIT_EXPERIMENTAL_SHA256
|
||||
if ((error = git_oid_fromstr(&oid, curr, GIT_OID_SHA1)))
|
||||
return error;
|
||||
#else
|
||||
if ((error = git_oid_fromstr(&oid, curr)))
|
||||
return error;
|
||||
#endif
|
||||
|
||||
if ((error = push_commit(walk, &oid, hide)))
|
||||
return error;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user