Skip to content

Support building on older systems #6

@emorrp1

Description

@emorrp1

Even if you choose not to, here's the fixes for anyone trying with cmake 3.13.4 and libgit2 0.27.7:

CMake Error at CMakeLists.txt:29 (install):
  install TARGETS given no RUNTIME DESTINATION for executable target
  "git-power".
...
git-power/main.cpp: In function ‘void try_commits(size_t, size_t, size_t, char*, size_t)’:
git-power/main.cpp:300:47: error: ‘GIT_OBJECT_COMMIT’ was not declared in this scope
  git_odb_hash(&hash, commit_buf, commit_size, GIT_OBJECT_COMMIT);
                                               ^~~~~~~~~~~~~~~~~
diff --git i/CMakeLists.txt w/CMakeLists.txt
index 4604d57..f5a26d6 100644
--- i/CMakeLists.txt
+++ w/CMakeLists.txt
@@ -26,4 +26,4 @@ if (UNIX AND NOT APPLE)
     target_link_libraries(git-power PRIVATE pthread atomic)
 endif ()
 
-install(TARGETS git-power)
+install(TARGETS git-power RUNTIME DESTINATION bin)
diff --git i/main.cpp w/main.cpp
index 4cf9a9e..983bc9d 100644
--- i/main.cpp
+++ w/main.cpp
@@ -297,7 +297,7 @@ I should not be allowed near this
 
        // Big sanity check here since we think this is a good hash
        git_oid hash;
-       git_odb_hash(&hash, commit_buf, commit_size, GIT_OBJECT_COMMIT);
+       git_odb_hash(&hash, commit_buf, commit_size, GIT_OBJ_COMMIT);
        int test = 0;
        for (size_t n = 0; n < bits; n++) {
                // Test will be the OR of the first `n` bits
@@ -473,7 +473,7 @@ int main(int argc, const char **argv) {
 
                // And make the commit for them
                git_oid hash;
-               git_odb_write(&hash, db, commit_buffer, commit_size, GIT_OBJECT_COMMIT);
+               git_odb_write(&hash, db, commit_buffer, commit_size, GIT_OBJ_COMMIT);
 
                // Fancy print
                char id[0x100];
@@ -486,7 +486,7 @@ int main(int argc, const char **argv) {
 
                // Soft reset to this commit so it is now branch head
                git_object *new_commit;
-               git_object_lookup(&new_commit, repository, &hash, GIT_OBJECT_COMMIT);
+               git_object_lookup(&new_commit, repository, &hash, GIT_OBJ_COMMIT);
 
                git_reset(repository, new_commit, GIT_RESET_SOFT, nullptr);
 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions