From 530f3618a8f4c7d9c8d3981548112439b22e09e7 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Mon, 16 Dec 2024 17:50:57 -0600 Subject: update to libgit2 version 1.8.4. dump old github and vendor stuff go install go.wit.com/apps/go-clone@latest go install go.wit.com/apps/go-mod-clean@latest go-clone --recusive go.wit.com/lib/git2go Signed-off-by: Jeff Carr --- rebase_test.go | 104 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 52 insertions(+), 52 deletions(-) (limited to 'rebase_test.go') diff --git a/rebase_test.go b/rebase_test.go index efe93cf..9c1b85e 100644 --- a/rebase_test.go +++ b/rebase_test.go @@ -19,73 +19,73 @@ func TestRebaseInMemoryWithConflict(t *testing.T) { defer cleanupTestRepo(t, repo) seedTestRepo(t, repo) - // Create two branches with common history, where both modify "common-file" - // in a conflicting way. - _, err := commitSomething(repo, "common-file", "a\nb\nc\n", commitOptions{}) - checkFatal(t, err) + // Create two branches with common history, where both modify "common-file" + // in a conflicting way. + _, err := commitSomething(repo, "common-file", "a\nb\nc\n", commitOptions{}) + checkFatal(t, err) checkFatal(t, createBranch(repo, "branch-a")) checkFatal(t, createBranch(repo, "branch-b")) checkFatal(t, repo.SetHead("refs/heads/branch-a")) - _, err = commitSomething(repo, "common-file", "1\nb\nc\n", commitOptions{}) - checkFatal(t, err) + _, err = commitSomething(repo, "common-file", "1\nb\nc\n", commitOptions{}) + checkFatal(t, err) checkFatal(t, repo.SetHead("refs/heads/branch-b")) - _, err = commitSomething(repo, "common-file", "x\nb\nc\n", commitOptions{}) - checkFatal(t, err) + _, err = commitSomething(repo, "common-file", "x\nb\nc\n", commitOptions{}) + checkFatal(t, err) branchA, err := repo.LookupBranch("branch-a", BranchLocal) - checkFatal(t, err) + checkFatal(t, err) onto, err := repo.AnnotatedCommitFromRef(branchA.Reference) - checkFatal(t, err) + checkFatal(t, err) - // We then rebase "branch-b" onto "branch-a" in-memory, which should result - // in a conflict. - rebase, err := repo.InitRebase(nil, nil, onto, &RebaseOptions{InMemory: 1}) - checkFatal(t, err) + // We then rebase "branch-b" onto "branch-a" in-memory, which should result + // in a conflict. + rebase, err := repo.InitRebase(nil, nil, onto, &RebaseOptions{InMemory: 1}) + checkFatal(t, err) - _, err = rebase.Next() + _, err = rebase.Next() checkFatal(t, err) - index, err := rebase.InmemoryIndex() + index, err := rebase.InmemoryIndex() checkFatal(t, err) - // We simply resolve the conflict and commit the rebase. - if !index.HasConflicts() { - t.Fatal("expected index to have conflicts") - } - - conflict, err := index.Conflict("common-file") - checkFatal(t, err) - - resolvedBlobID, err := repo.CreateBlobFromBuffer([]byte("resolved contents")) - checkFatal(t, err) - - resolvedEntry := *conflict.Our - resolvedEntry.Id = resolvedBlobID - checkFatal(t, index.Add(&resolvedEntry)) - checkFatal(t, index.RemoveConflict("common-file")) - - var commitID Oid - checkFatal(t, rebase.Commit(&commitID, signature(), signature(), "rebased message")) - checkFatal(t, rebase.Finish()) - - // And then assert that we can look up the new merge commit, and that the - // "common-file" has the expected contents. - commit, err := repo.LookupCommit(&commitID) - checkFatal(t, err) - if commit.Message() != "rebased message" { - t.Fatalf("unexpected commit message %q", commit.Message()) - } - - tree, err := commit.Tree() - checkFatal(t, err) - - blob, err := repo.LookupBlob(tree.EntryByName("common-file").Id) - checkFatal(t, err) - if string(blob.Contents()) != "resolved contents" { - t.Fatalf("unexpected resolved blob contents %q", string(blob.Contents())) - } + // We simply resolve the conflict and commit the rebase. + if !index.HasConflicts() { + t.Fatal("expected index to have conflicts") + } + + conflict, err := index.Conflict("common-file") + checkFatal(t, err) + + resolvedBlobID, err := repo.CreateBlobFromBuffer([]byte("resolved contents")) + checkFatal(t, err) + + resolvedEntry := *conflict.Our + resolvedEntry.Id = resolvedBlobID + checkFatal(t, index.Add(&resolvedEntry)) + checkFatal(t, index.RemoveConflict("common-file")) + + var commitID Oid + checkFatal(t, rebase.Commit(&commitID, signature(), signature(), "rebased message")) + checkFatal(t, rebase.Finish()) + + // And then assert that we can look up the new merge commit, and that the + // "common-file" has the expected contents. + commit, err := repo.LookupCommit(&commitID) + checkFatal(t, err) + if commit.Message() != "rebased message" { + t.Fatalf("unexpected commit message %q", commit.Message()) + } + + tree, err := commit.Tree() + checkFatal(t, err) + + blob, err := repo.LookupBlob(tree.EntryByName("common-file").Id) + checkFatal(t, err) + if string(blob.Contents()) != "resolved contents" { + t.Fatalf("unexpected resolved blob contents %q", string(blob.Contents())) + } } func TestRebaseAbort(t *testing.T) { -- cgit v1.2.3