Skip to content

Commit c4b8fb6

Browse files
LemmingAvalanchegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4f71522 commit c4b8fb6

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

Documentation/git-merge-tree.txt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,15 @@ linkgit:git-commit-tree[1], linkgit:git-write-tree[1],
211211
linkgit:git-update-ref[1], and linkgit:git-mktag[1]. Thus, it can be
212212
used as a part of a series of steps such as:
213213

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)
217223
git update-ref $BRANCH1 $NEWCOMMIT
218224

219225
Note that when the exit status is non-zero, `NEWTREE` in this sequence

0 commit comments

Comments
 (0)