doc: merge-tree: improve example script

• Provide a commit message in the example command. The command will hang since it is waiting for a commit message on stdin. Which is usable but not straightforward enough since this is example code. • Use `||` directly since that is more straightforward than checking the last exit status. Also use `echo` and `exit` since `die` is not defined. • Expose variable declarations. Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Kristoffer Haugsbakk committed Oct 9, 2024 at 18:53 UTC c4b8fb6ef2114a4df4dc7a0a07233e91a272a29e
1 file changed +9 -3
Documentation/git-merge-tree.txt
+9 -3
@@ -211,9 +211,15 @@ linkgit:git-commit-tree[1], linkgit:git-write-tree[1],
211 linkgit:git-update-ref[1], and linkgit:git-mktag[1]. Thus, it can be
212 used as a part of a series of steps such as:
213
214 - NEWTREE=$(git merge-tree --write-tree $BRANCH1 $BRANCH2)
215 - test $? -eq 0 || die "There were conflicts..."
216 - NEWCOMMIT=$(git commit-tree $NEWTREE -p $BRANCH1 -p $BRANCH2)
214 + vi message.txt
215 + BRANCH1=refs/heads/test
216 + BRANCH2=main
217 + NEWTREE=$(git merge-tree --write-tree $BRANCH1 $BRANCH2) || {
218 + echo "There were conflicts..." 1>&2
219 + exit 1
220 + }
221 + NEWCOMMIT=$(git commit-tree $NEWTREE -F message.txt \
222 + -p $BRANCH1 -p $BRANCH2)
223 git update-ref $BRANCH1 $NEWCOMMIT
224
225 Note that when the exit status is non-zero, `NEWTREE` in this sequence