diff mbox series

[v2,2/2] doc: merge-tree: use || directly

Message ID 13e0f3bed5dd894ee692c672b301697e0a909e04.1728413450.git.code@khaugsbakk.name (mailing list archive)
State New
Headers show
Series [v2,1/2] doc: merge-tree: provide a commit message | expand

Commit Message

Kristoffer Haugsbakk Oct. 8, 2024, 7:06 p.m. UTC
Use `||` directly since that is more straightforward than checking the
last exit status.

Also use `echo` and `exit` since `die` is not defined.

Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
---
 Documentation/git-merge-tree.txt | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Junio C Hamano Oct. 8, 2024, 8:44 p.m. UTC | #1
Kristoffer Haugsbakk <code@khaugsbakk.name> writes:

> -       NEWTREE=$(git merge-tree --write-tree $BRANCH1 $BRANCH2)
> -       test $? -eq 0 || die "There were conflicts..."
> +       NEWTREE=$(git merge-tree --write-tree $BRANCH1 $BRANCH2) || {
> +           echo "There were conflicts..." 1>&2
> +           exit 1
> +       }

Makes sense.  Was there a particular reason why these two patches
had to be done in two separate steps?

Looking good otherwise.  Thanks.
Kristoffer Haugsbakk Oct. 8, 2024, 8:48 p.m. UTC | #2
On Tue, Oct 8, 2024, at 22:44, Junio C Hamano wrote:
> Kristoffer Haugsbakk <code@khaugsbakk.name> writes:
>
>> -       NEWTREE=$(git merge-tree --write-tree $BRANCH1 $BRANCH2)
>> -       test $? -eq 0 || die "There were conflicts..."
>> +       NEWTREE=$(git merge-tree --write-tree $BRANCH1 $BRANCH2) || {
>> +           echo "There were conflicts..." 1>&2
>> +           exit 1
>> +       }
>
> Makes sense.  Was there a particular reason why these two patches
> had to be done in two separate steps?
>
> Looking good otherwise.  Thanks.

Just my usual do-one-thing-per-commit.

In this case a simple Also-paragraph can connect the two. So squashing
them is fine too.
diff mbox series

Patch

diff --git a/Documentation/git-merge-tree.txt b/Documentation/git-merge-tree.txt
index d1157f1398a..41dfb16476d 100644
--- a/Documentation/git-merge-tree.txt
+++ b/Documentation/git-merge-tree.txt
@@ -211,8 +211,10 @@  linkgit:git-commit-tree[1], linkgit:git-write-tree[1],
 linkgit:git-update-ref[1], and linkgit:git-mktag[1].  Thus, it can be
 used as a part of a series of steps such as:
 
-       NEWTREE=$(git merge-tree --write-tree $BRANCH1 $BRANCH2)
-       test $? -eq 0 || die "There were conflicts..."
+       NEWTREE=$(git merge-tree --write-tree $BRANCH1 $BRANCH2) || {
+           echo "There were conflicts..." 1>&2
+           exit 1
+       }
        NEWCOMMIT=$(git commit-tree $NEWTREE -F $FILE_WITH_COMMIT_MESSAGE \
            -p $BRANCH1 -p $BRANCH2)
        git update-ref $BRANCH1 $NEWCOMMIT