From 4bed23037f0e374d85bce1506e9df98ce0cfcd32 Mon Sep 17 00:00:00 2001 From: John Cai Date: Wed, 5 Jan 2022 16:28:46 -0500 Subject: git: Add Merge with ff-only Add a Merge function that behaves like git merge. This is a first iteration that only supports --ff-only, which is the simplest type of merge. --- options.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'options.go') diff --git a/options.go b/options.go index 635a883..6a7963f 100644 --- a/options.go +++ b/options.go @@ -89,6 +89,13 @@ type CloneOptions struct { Shared bool } +// MergeOptions describes how a merge should be erformed +type MergeOptions struct { + // Requires a merge to be fast forward only. If this is true, then a merge will + // throw an error if ff is not possible. + FFOnly bool +} + // Validate validates the fields and sets the default values. func (o *CloneOptions) Validate() error { if o.URL == "" { -- cgit From 3ee5bc9dd308a5503d60cc26d17d7f10df28c37a Mon Sep 17 00:00:00 2001 From: Paulo Gomes Date: Sat, 9 Mar 2024 09:00:21 +0000 Subject: git: Implement Merge function with initial FastForwardMerge support Introduces the Merge function for merging branches in the codebase. Currently, the function only supports FastForwardMerge strategy, meaning it can efficiently update the target branch pointer if the source branch history is a linear descendant. Support for additional merge strategies (e.g., three-way merge) will be added in future commits. Signed-off-by: Paulo Gomes --- options.go | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'options.go') diff --git a/options.go b/options.go index 6a7963f..02248ad 100644 --- a/options.go +++ b/options.go @@ -89,13 +89,25 @@ type CloneOptions struct { Shared bool } -// MergeOptions describes how a merge should be erformed +// MergeOptions describes how a merge should be performed. type MergeOptions struct { - // Requires a merge to be fast forward only. If this is true, then a merge will - // throw an error if ff is not possible. - FFOnly bool + // Strategy defines the merge strategy to be used. + Strategy MergeStrategy } +// MergeStrategy represents the different types of merge strategies. +type MergeStrategy int8 + +const ( + // FastForwardMerge represents a Git merge strategy where the current + // branch can be simply updated to point to the HEAD of the branch being + // merged. This is only possible if the history of the branch being merged + // is a linear descendant of the current branch, with no conflicting commits. + // + // This is the default option. + FastForwardMerge MergeStrategy = iota +) + // Validate validates the fields and sets the default values. func (o *CloneOptions) Validate() error { if o.URL == "" { -- cgit