Skip to content

Add Merge Command#116

Merged
marstr merged 4 commits intomainfrom
addMerge
Jul 26, 2025
Merged

Add Merge Command#116
marstr merged 4 commits intomainfrom
addMerge

Conversation

@marstr
Copy link
Owner

@marstr marstr commented Jul 26, 2025

Fixes #35

@marstr marstr requested a review from Copilot July 26, 2025 06:10
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a merge command to handle multi-parent commits in the version control system. The implementation allows users to merge multiple refspecs (branches/commits) and manages merge state persistence across operations.

  • Introduces a new merge command that can merge multiple refspecs into the current head
  • Adds merge state tracking with JSON serialization to handle interrupted merge operations
  • Integrates merge functionality with the existing commit command to support multi-parent commits

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
cmd/merge.go New file implementing the merge command with state persistence and refspec handling
cmd/commit.go Modified to detect pending merges and pass additional parents to commit operations
Comments suppressed due to low confidence (1)

Comment on lines +77 to +85
if inProg {
err = MergeUnstowProgress(ctx, repoLoc, &mergeParams)
if err != nil {
logrus.Fatal("couldn't read the currently in-progress merge because: ", err)
}
}

mergeParams.ParentNames = append(mergeParams.ParentNames, heads...)
for _, head := range heads {
Copy link

Copilot AI Jul 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ParentNames slice is being appended to even when a merge is already in progress. This will duplicate the current head and other refspecs on subsequent merge command invocations. The append should only happen when not in progress, or the slice should be reset first.

Suggested change
if inProg {
err = MergeUnstowProgress(ctx, repoLoc, &mergeParams)
if err != nil {
logrus.Fatal("couldn't read the currently in-progress merge because: ", err)
}
}
mergeParams.ParentNames = append(mergeParams.ParentNames, heads...)
for _, head := range heads {
if inProg {
err = MergeUnstowProgress(ctx, repoLoc, &mergeParams)
if err != nil {
logrus.Fatal("couldn't read the currently in-progress merge because: ", err)
}
mergeParams.ParentNames = nil // Reset ParentNames to prevent duplication
}
mergeParams.ParentNames = append(mergeParams.ParentNames, heads...)
for _, head := range heads {

Copilot uses AI. Check for mistakes.
@marstr marstr merged commit 9b0cdc7 into main Jul 26, 2025
3 checks passed
@marstr marstr deleted the addMerge branch July 26, 2025 06:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add merge command

2 participants