Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarthik Nayak <knayak@gitlab.com>2023-06-14 23:49:09 +0300
committerKarthik Nayak <knayak@gitlab.com>2023-06-16 13:25:25 +0300
commitea1ec7d0cffa2dae407a2c773887d7c70659a3ce (patch)
treef7fecdc36bc351b16e710149f9ac8c31505d8400
parent129b6b59b4be08ffbb8570e479f74c3cfcffdbd0 (diff)
localrepo: Parse `MergeTree` errors only for exit status 1
The manual page for git-merge-tree(1) states that the exit status is set to 1, only when there is conflicts. If there are other errors, the exit status is neither 0 (which is used to denote no conflicts) or 1. In the `MergeTree` however we default to parsing conflict errors when the status is not >1. This shouldn't matter as long as `ExecAndWait()` doesn't return an exist status of 0 plus an error. But is confusing nevertheless. Let's rewrite the code to explicitly check for exit status 1.
-rw-r--r--internal/git/localrepo/merge.go13
1 files changed, 7 insertions, 6 deletions
diff --git a/internal/git/localrepo/merge.go b/internal/git/localrepo/merge.go
index 4b09f1b01..6cc922357 100644
--- a/internal/git/localrepo/merge.go
+++ b/internal/git/localrepo/merge.go
@@ -104,14 +104,15 @@ func (repo *Repo) MergeTree(
return "", errors.New("could not parse exit status of merge-tree(1)")
}
- if exitCode > 1 {
- if text.ChompBytes(stderr.Bytes()) == "fatal: refusing to merge unrelated histories" {
- return "", ErrMergeTreeUnrelatedHistory
- }
- return "", fmt.Errorf("merge-tree: %w", err)
+ if exitCode == 1 {
+ return parseMergeTreeError(objectHash, config, stdout.String())
+ }
+
+ if text.ChompBytes(stderr.Bytes()) == "fatal: refusing to merge unrelated histories" {
+ return "", ErrMergeTreeUnrelatedHistory
}
- return parseMergeTreeError(objectHash, config, stdout.String())
+ return "", fmt.Errorf("merge-tree: %w", err)
}
oid, err := objectHash.FromHex(strings.Split(stdout.String(), "\x00")[0])