Skip to content

Commit

Permalink
dolt merge doesn't fail if unable to get hash
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephanie You committed Jul 20, 2023
1 parent 508630b commit ea418cd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
20 changes: 11 additions & 9 deletions go/cmd/dolt/commands/merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,19 +149,21 @@ func (cmd MergeCmd) Exec(ctx context.Context, commandStr string, args []string,

// calculate merge stats
if !apr.Contains(cli.AbortParam) {
mergeHash, err := getHashOf(queryist, sqlCtx, apr.Arg(0))
if err != nil {
//todo: refs with the `remotes/` prefix will fail to get a hash
mergeHash, mergeHashErr := getHashOf(queryist, sqlCtx, apr.Arg(0))
if mergeHashErr != nil {
cli.Println("merge finished, but failed to get hash of merge ref")
cli.Println(err.Error())
return 0
cli.Println(mergeHashErr.Error())
}
headHash, err := getHashOf(queryist, sqlCtx, "HEAD")
if err != nil {
headHash, headhHashErr := getHashOf(queryist, sqlCtx, "HEAD")
if headhHashErr != nil {
cli.Println("merge finished, but failed to get hash of HEAD")
cli.Println(err.Error())
return 0
cli.Println(headhHashErr.Error())
}
if mergeHashErr == nil && headhHashErr == nil {
cli.Println("Updating", headHash+".."+mergeHash)
}
cli.Println("Updating", headHash+".."+mergeHash)

if apr.Contains(cli.SquashParam) {
cli.Println("Squash commit -- not updating HEAD")
}
Expand Down
8 changes: 4 additions & 4 deletions integration-tests/bats/remotes.bats
Original file line number Diff line number Diff line change
Expand Up @@ -940,12 +940,12 @@ SQL
[[ ! "$output" =~ "test commit" ]] || false
run dolt merge origin/main
[ "$status" -eq 0 ]
[[ "$output" =~ "up-to-date" ]]
[[ "$output" =~ "Already up to date." ]] || false
run dolt fetch
[ "$status" -eq 0 ]
run dolt merge origin/main
[ "$status" -eq 0 ]
[[ "$output" =~ "Fast-forward" ]]
[[ "$output" =~ "Fast-forward" ]] || false
run dolt log
[ "$status" -eq 0 ]
[[ "$output" =~ "test commit" ]] || false
Expand Down Expand Up @@ -974,12 +974,12 @@ SQL
cd "dolt-repo-clones/test-repo"
run dolt merge remotes/origin/main
[ "$status" -eq 0 ]
[[ "$output" =~ "Everything up-to-date" ]]
[[ "$output" =~ "Already up to date." ]] || false
run dolt fetch origin main
[ "$status" -eq 0 ]
run dolt merge remotes/origin/main
[ "$status" -eq 0 ]
[[ "$output" =~ "Fast-forward" ]]
[[ "$output" =~ "Fast-forward" ]] || false
}

@test "remotes: try to push a remote that is behind tip" {
Expand Down

0 comments on commit ea418cd

Please sign in to comment.