Message ID | cover.1728492617.git.code@khaugsbakk.name (mailing list archive) |
---|---|
State | New |
Headers | show |
On Wed, Oct 9, 2024 at 9:54 AM Kristoffer Haugsbakk <code@khaugsbakk.name> wrote: > > § Changes since v2 > > • Squash into one patch > • Use `vi message.txt` before `git commit-tree` > • Also declare the branches > • Fully qualified for `BRANCH1` since it is passed to > git-update-ref(1) > > Kristoffer Haugsbakk (1): > doc: merge-tree: improve example script > > Documentation/git-merge-tree.txt | 12 +++++++++--- > 1 file changed, 9 insertions(+), 3 deletions(-) > > Interdiff against v2: > diff --git a/Documentation/git-merge-tree.txt b/Documentation/git-merge-tree.txt > index 41dfb16476d..0b6a8a19b1f 100644 > --- a/Documentation/git-merge-tree.txt > +++ b/Documentation/git-merge-tree.txt > @@ -211,11 +211,14 @@ 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: > > + vi message.txt > + BRANCH1=refs/heads/test > + BRANCH2=main > 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 \ > + NEWCOMMIT=$(git commit-tree $NEWTREE -F message.txt \ > -p $BRANCH1 -p $BRANCH2) > git update-ref $BRANCH1 $NEWCOMMIT > > Range-diff against v2: > 1: b1ca5cae768 < -: ----------- doc: merge-tree: provide a commit message > 2: 13e0f3bed5d ! 1: c7e0d76e71e doc: merge-tree: use || directly > @@ Metadata > Author: Kristoffer Haugsbakk <code@khaugsbakk.name> > > ## Commit message ## > - doc: merge-tree: use || directly > + doc: merge-tree: improve example script > > - Use `||` directly since that is more straightforward than checking the > - last exit status. > + • Provide a commit message in the example command. > > - Also use `echo` and `exit` since `die` is not defined. > + 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> > > @@ Documentation/git-merge-tree.txt: linkgit:git-commit-tree[1], linkgit:git-write- > > - NEWTREE=$(git merge-tree --write-tree $BRANCH1 $BRANCH2) > - test $? -eq 0 || die "There were conflicts..." > +- NEWCOMMIT=$(git commit-tree $NEWTREE -p $BRANCH1 -p $BRANCH2) > ++ vi message.txt > ++ BRANCH1=refs/heads/test > ++ BRANCH2=main > + 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) > ++ NEWCOMMIT=$(git commit-tree $NEWTREE -F message.txt \ > ++ -p $BRANCH1 -p $BRANCH2) > git update-ref $BRANCH1 $NEWCOMMIT > + > + Note that when the exit status is non-zero, `NEWTREE` in this sequence > -- > 2.46.1.641.g54e7913fcb6 This round looks good to me; thanks.
Elijah Newren <newren@gmail.com> writes: > On Wed, Oct 9, 2024 at 9:54 AM Kristoffer Haugsbakk > <code@khaugsbakk.name> wrote: >> ... >> 2.46.1.641.g54e7913fcb6 > > This round looks good to me; thanks. Thanks.
diff --git a/Documentation/git-merge-tree.txt b/Documentation/git-merge-tree.txt index 41dfb16476d..0b6a8a19b1f 100644 --- a/Documentation/git-merge-tree.txt +++ b/Documentation/git-merge-tree.txt @@ -211,11 +211,14 @@ 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: + vi message.txt + BRANCH1=refs/heads/test + BRANCH2=main 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 \ + NEWCOMMIT=$(git commit-tree $NEWTREE -F message.txt \ -p $BRANCH1 -p $BRANCH2) git update-ref $BRANCH1 $NEWCOMMIT
§ Changes since v2 • Squash into one patch • Use `vi message.txt` before `git commit-tree` • Also declare the branches • Fully qualified for `BRANCH1` since it is passed to git-update-ref(1) Kristoffer Haugsbakk (1): doc: merge-tree: improve example script Documentation/git-merge-tree.txt | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) Interdiff against v2: Range-diff against v2: 1: b1ca5cae768 < -: ----------- doc: merge-tree: provide a commit message 2: 13e0f3bed5d ! 1: c7e0d76e71e doc: merge-tree: use || directly @@ Metadata Author: Kristoffer Haugsbakk <code@khaugsbakk.name> ## Commit message ## - doc: merge-tree: use || directly + doc: merge-tree: improve example script - Use `||` directly since that is more straightforward than checking the - last exit status. + • Provide a commit message in the example command. - Also use `echo` and `exit` since `die` is not defined. + 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> @@ Documentation/git-merge-tree.txt: linkgit:git-commit-tree[1], linkgit:git-write- - NEWTREE=$(git merge-tree --write-tree $BRANCH1 $BRANCH2) - test $? -eq 0 || die "There were conflicts..." +- NEWCOMMIT=$(git commit-tree $NEWTREE -p $BRANCH1 -p $BRANCH2) ++ vi message.txt ++ BRANCH1=refs/heads/test ++ BRANCH2=main + 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) ++ NEWCOMMIT=$(git commit-tree $NEWTREE -F message.txt \ ++ -p $BRANCH1 -p $BRANCH2) git update-ref $BRANCH1 $NEWCOMMIT + + Note that when the exit status is non-zero, `NEWTREE` in this sequence