diff options
-rw-r--r-- | Makefile | 6 | ||||
-rw-r--r-- | lib/gall/repository.lua | 14 | ||||
m--------- | libgit2 | 0 | ||||
-rw-r--r-- | test/create_test_repo.sh | 1 | ||||
-rw-r--r-- | test/lorries-broken.tar | bin | 0 -> 81920 bytes | |||
-rw-r--r-- | test/test-gall.repository.lua | 16 | ||||
-rw-r--r-- | test/test_repo.tar | bin | 92160 -> 92160 bytes | |||
-rw-r--r-- | test/withrepo.lua | 9 |
8 files changed, 40 insertions, 6 deletions
@@ -4,7 +4,9 @@ MODULES := gall gall.util gall.ll \ gall.repository gall.object gall.commit gall.tag gall.tree LUA_VER := 5.1 -INST_BASE := /usr/local +PREFIX ?= /usr/local + +INST_BASE := $(PREFIX) INST_ROOT := $(DESTDIR)$(INST_BASE)/share/lua/$(LUA_VER) C_INST_ROOT := $(DESTDIR)$(INST_BASE)/lib/lua/$(LUA_VER) @@ -53,6 +55,8 @@ clean: distclean: clean find . -name "*~" -delete + $(RM) libgit2/tests-clar/clar.h + $(RM) libgit2/tests-clar/clar_main.c .PHONY: example example: diff --git a/lib/gall/repository.lua b/lib/gall/repository.lua index 65e4a42..70f74e5 100644 --- a/lib/gall/repository.lua +++ b/lib/gall/repository.lua @@ -226,8 +226,18 @@ if ll.git2 then if get_all then return old_merge_base(self, sha_1, sha_2, get_all) end - local oid_1 = ll.git2.OID.hex(sha_1) - local oid_2 = ll.git2.OID.hex(sha_2) + local commitish_1 = self:get(sha_1) + local commitish_2 = self:get(sha_2) + pcall(function() + if commitish_1.type == "tag" then + commitish_1 = commitish_1.content.object + end + if commitish_2.type == "tag" then + commitish_2 = commitish_2.content.object + end + end) + local oid_1 = ll.git2.OID.hex(commitish_1.sha) + local oid_2 = ll.git2.OID.hex(commitish_2.sha) local oid_base, err = ll.git2.merge.base(self.git2.repo, oid_1, oid_2) if not oid_base then if tostring(err) == "ENOTFOUND" then diff --git a/libgit2 b/libgit2 -Subproject 056f1b23599891fced002d18d716bdfdb7b8f15 +Subproject 9f20b6d32ce9e971a251dca6b4e41a574bb3511 diff --git a/test/create_test_repo.sh b/test/create_test_repo.sh index 7eedefa..8e01b4d 100644 --- a/test/create_test_repo.sh +++ b/test/create_test_repo.sh @@ -3,3 +3,4 @@ cd test tar xf test_repo.tar +tar xf lorries-broken.tar diff --git a/test/lorries-broken.tar b/test/lorries-broken.tar Binary files differnew file mode 100644 index 0000000..074d1cf --- /dev/null +++ b/test/lorries-broken.tar diff --git a/test/test-gall.repository.lua b/test/test-gall.repository.lua index 8fb6ab9..0f59993 100644 --- a/test/test-gall.repository.lua +++ b/test/test-gall.repository.lua @@ -214,6 +214,22 @@ function suite.merge_base_nobase() assert(ok == true) end +function suite.merge_base_annotated_tags() + local repo = test_repo() + local sha_1 = "annotated-1" + local sha_2 = "annotated-2" + local sha_b = "b972b3345490a898f46df143a7285cb7840b9845" + assert(repo:merge_base(sha_1, sha_2) == sha_b) +end + +function suite.merge_base_lorries_regression() + local repo = test_repo("lorries.git") + local sha_1 = "738022ab867407fc9e906e89268043f72179730a" + local sha_2 = "2f0995c6c852c9b9d6ce584f3b9f38a981a40cf3" + local sha_b = "738022ab867407fc9e906e89268043f72179730a" + assert(repo:merge_base(sha_1, sha_2) == sha_b) +end + function suite.rev_list() local repo = test_repo() local sha_new = "0b65c32b6a5277ff0e75ddad9e3914148914042d" diff --git a/test/test_repo.tar b/test/test_repo.tar Binary files differindex 614b8aa..dcfc172 100644 --- a/test/test_repo.tar +++ b/test/test_repo.tar diff --git a/test/withrepo.lua b/test/withrepo.lua index bf90b0c..0795993 100644 --- a/test/withrepo.lua +++ b/test/withrepo.lua @@ -7,12 +7,15 @@ local _xpcall = xpcall function xpcall(fn, tb) os.execute("rm -rf test/test_repo") + os.execute("rm -rf test/lorries.git") local ok, msg = _xpcall(fn, tb) os.execute("rm -rf test/test_repo") + os.execute("rm -rf test/lorries.git") return ok, msg end -function test_repo() +function test_repo(reponame) + reponame = reponame or "test_repo" os.execute("sh test/create_test_repo.sh") - return assert(require("gall.repository").new "test/test_repo") -end
\ No newline at end of file + return assert(require("gall.repository").new("test/" .. reponame)) +end |