From 98f6297ab4bc566f3496f4cfa4e6d7d8b41fdbe6 Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Wed, 26 Sep 2012 14:04:58 +0100 Subject: REPOSITORY: Support annotated tags in :merge_base() --- lib/gall/repository.lua | 14 ++++++++++++-- test/test-gall.repository.lua | 8 ++++++++ test/test_repo.tar | Bin 92160 -> 92160 bytes 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/lib/gall/repository.lua b/lib/gall/repository.lua index 0e2c2d5..70381cb 100644 --- a/lib/gall/repository.lua +++ b/lib/gall/repository.lua @@ -218,8 +218,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/test/test-gall.repository.lua b/test/test-gall.repository.lua index 8fb6ab9..f945864 100644 --- a/test/test-gall.repository.lua +++ b/test/test-gall.repository.lua @@ -214,6 +214,14 @@ 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.rev_list() local repo = test_repo() local sha_new = "0b65c32b6a5277ff0e75ddad9e3914148914042d" diff --git a/test/test_repo.tar b/test/test_repo.tar index 614b8aa..dcfc172 100644 Binary files a/test/test_repo.tar and b/test/test_repo.tar differ -- cgit v1.2.1 From 2cf7b10b5b0cbb8f49c869977ef9c4dcd97e9222 Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Sun, 14 Apr 2013 09:46:20 +0100 Subject: PREFIX, not INST_ROOT, please --- Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index ec3f5bc..eb45159 100644 --- a/Makefile +++ b/Makefile @@ -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) -- cgit v1.2.1 From 09c1dbe8ed459b16201b7d6c7408da544d6c711c Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Thu, 25 Apr 2013 20:59:42 +0100 Subject: More clean --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index eb45159..74ed18d 100644 --- a/Makefile +++ b/Makefile @@ -55,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: -- cgit v1.2.1 From d6490495f37e1ae503a2357c74077f4be720b258 Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Thu, 29 May 2014 14:05:28 +0100 Subject: Demonstrate the issue --- test/create_test_repo.sh | 1 + test/lorries-broken.tar | Bin 0 -> 81920 bytes test/test-gall.repository.lua | 8 ++++++++ test/withrepo.lua | 9 ++++++--- 4 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 test/lorries-broken.tar 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 new file mode 100644 index 0000000..074d1cf Binary files /dev/null and b/test/lorries-broken.tar differ diff --git a/test/test-gall.repository.lua b/test/test-gall.repository.lua index f945864..0f59993 100644 --- a/test/test-gall.repository.lua +++ b/test/test-gall.repository.lua @@ -222,6 +222,14 @@ function suite.merge_base_annotated_tags() 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/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 -- cgit v1.2.1 From 87354411a3c378093e666706119124f929e34368 Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Thu, 29 May 2014 15:47:28 +0100 Subject: Update for off-by-one fix --- libgit2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libgit2 b/libgit2 index 056f1b2..9f20b6d 160000 --- a/libgit2 +++ b/libgit2 @@ -1 +1 @@ -Subproject commit 056f1b23599891fced002d18d716bdfdb7b8f15d +Subproject commit 9f20b6d32ce9e971a251dca6b4e41a574bb3511d -- cgit v1.2.1