* [PATCH 1/3] doc: merge-tree: provide a commit message
2024-10-07 11:10 [PATCH 0/3] doc: merge-tree: improve the script example Kristoffer Haugsbakk
@ 2024-10-07 11:10 ` Kristoffer Haugsbakk
2024-10-07 12:02 ` Kristoffer Haugsbakk
2024-10-07 15:17 ` Elijah Newren
2024-10-07 11:10 ` [PATCH 2/3] doc: merge-tree: use lower-case variables Kristoffer Haugsbakk
` (3 subsequent siblings)
4 siblings, 2 replies; 27+ messages in thread
From: Kristoffer Haugsbakk @ 2024-10-07 11:10 UTC (permalink / raw)
To: git; +Cc: Kristoffer Haugsbakk, newren, Kristoffer Haugsbakk
From: Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com>
From: Kristoffer Haugsbakk <code@khaugsbakk.name>
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.
Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
---
Notes (series):
Unlike on some other manuals you probably won’t end up running these
commands directly to test things out. But you might end up copying and
modifying it when playing around with the command.
Documentation/git-merge-tree.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Documentation/git-merge-tree.txt b/Documentation/git-merge-tree.txt
index 84cb2edf6d0..590cbf5df79 100644
--- a/Documentation/git-merge-tree.txt
+++ b/Documentation/git-merge-tree.txt
@@ -213,7 +213,7 @@ 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..."
- NEWCOMMIT=$(git commit-tree $NEWTREE -p $BRANCH1 -p $BRANCH2)
+ NEWCOMMIT=$(git commit-tree $NEWTREE -mMerge -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
^ permalink raw reply related [flat|nested] 27+ messages in thread
* Re: [PATCH 1/3] doc: merge-tree: provide a commit message
2024-10-07 11:10 ` [PATCH 1/3] doc: merge-tree: provide a commit message Kristoffer Haugsbakk
@ 2024-10-07 12:02 ` Kristoffer Haugsbakk
2024-10-07 15:17 ` Elijah Newren
1 sibling, 0 replies; 27+ messages in thread
From: Kristoffer Haugsbakk @ 2024-10-07 12:02 UTC (permalink / raw)
To: Kristoffer Haugsbakk, git; +Cc: Elijah Newren
On Mon, Oct 7, 2024, at 13:10, Kristoffer Haugsbakk wrote:
> From: Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com>
>
> From: Kristoffer Haugsbakk <code@khaugsbakk.name>
I think these got double upped since I used `--from` in format-patch.
Then I used send-email. format-patch warns against that:
“ Note that this option is only useful if you are actually sending the
emails and want to identify yourself as the sender, but
retain the original author (and git am will correctly pick up
the in-body header). Note also that git send-email already
handles this transformation for you, and this option should
not be used if you are feeding the result to git send-email.
So under the normal use I guess:
• You have someone else’s patches
• send-email sees that you are not that person (because of your config)
• It puts the From in the message body (it just works)
But that wasn’t the case for me since my ident is still the same as the
author.
That went over my head before I sent.
--
Kristoffer Haugsbakk
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 1/3] doc: merge-tree: provide a commit message
2024-10-07 11:10 ` [PATCH 1/3] doc: merge-tree: provide a commit message Kristoffer Haugsbakk
2024-10-07 12:02 ` Kristoffer Haugsbakk
@ 2024-10-07 15:17 ` Elijah Newren
2024-10-07 15:23 ` Kristoffer Haugsbakk
1 sibling, 1 reply; 27+ messages in thread
From: Elijah Newren @ 2024-10-07 15:17 UTC (permalink / raw)
To: Kristoffer Haugsbakk; +Cc: git, Kristoffer Haugsbakk
On Mon, Oct 7, 2024 at 4:11 AM Kristoffer Haugsbakk
<code@khaugsbakk.name> wrote:
>
> From: Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com>
>
> From: Kristoffer Haugsbakk <code@khaugsbakk.name>
>
> 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.
This is fine, but...
>
> Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
> ---
>
> Notes (series):
> Unlike on some other manuals you probably won’t end up running these
> commands directly to test things out. But you might end up copying and
> modifying it when playing around with the command.
>
> Documentation/git-merge-tree.txt | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/Documentation/git-merge-tree.txt b/Documentation/git-merge-tree.txt
> index 84cb2edf6d0..590cbf5df79 100644
> --- a/Documentation/git-merge-tree.txt
> +++ b/Documentation/git-merge-tree.txt
> @@ -213,7 +213,7 @@ 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..."
> - NEWCOMMIT=$(git commit-tree $NEWTREE -p $BRANCH1 -p $BRANCH2)
> + NEWCOMMIT=$(git commit-tree $NEWTREE -mMerge -p $BRANCH1 -p $BRANCH2)
...perhaps this can be -F ${FILE_WITH_COMMIT_MESSAGE} ? I personally
have a problem with writing example code that models horrible commit
messages; I'd rather give them an example that hangs waiting on stdin
than do that.
> git update-ref $BRANCH1 $NEWCOMMIT
>
> Note that when the exit status is non-zero, `NEWTREE` in this sequence
> --
> 2.46.1.641.g54e7913fcb6
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 1/3] doc: merge-tree: provide a commit message
2024-10-07 15:17 ` Elijah Newren
@ 2024-10-07 15:23 ` Kristoffer Haugsbakk
0 siblings, 0 replies; 27+ messages in thread
From: Kristoffer Haugsbakk @ 2024-10-07 15:23 UTC (permalink / raw)
To: Elijah Newren, Kristoffer Haugsbakk, Eric Sunshine; +Cc: git
On Mon, Oct 7, 2024, at 17:17, Elijah Newren wrote:
>> NEWTREE=$(git merge-tree --write-tree $BRANCH1 $BRANCH2)
>> test $? -eq 0 || die "There were conflicts..."
>> - NEWCOMMIT=$(git commit-tree $NEWTREE -p $BRANCH1 -p $BRANCH2)
>> + NEWCOMMIT=$(git commit-tree $NEWTREE -mMerge -p $BRANCH1 -p $BRANCH2)
>
> ...perhaps this can be -F ${FILE_WITH_COMMIT_MESSAGE} ? I personally
> have a problem with writing example code that models horrible commit
> messages; I'd rather give them an example that hangs waiting on stdin
> than do that.
Yes. I’ll do that in the reroll.
Both this part and the uppercase variables.
Cheers
--
Kristoffer Haugsbakk
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH 2/3] doc: merge-tree: use lower-case variables
2024-10-07 11:10 [PATCH 0/3] doc: merge-tree: improve the script example Kristoffer Haugsbakk
2024-10-07 11:10 ` [PATCH 1/3] doc: merge-tree: provide a commit message Kristoffer Haugsbakk
@ 2024-10-07 11:10 ` Kristoffer Haugsbakk
2024-10-07 14:58 ` Phillip Wood
2024-10-07 11:10 ` [PATCH 3/3] doc: merge-tree: use || directly Kristoffer Haugsbakk
` (2 subsequent siblings)
4 siblings, 1 reply; 27+ messages in thread
From: Kristoffer Haugsbakk @ 2024-10-07 11:10 UTC (permalink / raw)
To: git; +Cc: Kristoffer Haugsbakk, newren, Kristoffer Haugsbakk
From: Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com>
From: Kristoffer Haugsbakk <code@khaugsbakk.name>
This is easier to read.
Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
---
Documentation/git-merge-tree.txt | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/Documentation/git-merge-tree.txt b/Documentation/git-merge-tree.txt
index 590cbf5df79..10f8ac7f80a 100644
--- a/Documentation/git-merge-tree.txt
+++ b/Documentation/git-merge-tree.txt
@@ -211,12 +211,12 @@ 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)
+ newtree=$(git merge-tree --write-tree $branch1 $branch2)
test $? -eq 0 || die "There were conflicts..."
- NEWCOMMIT=$(git commit-tree $NEWTREE -mMerge -p $BRANCH1 -p $BRANCH2)
- git update-ref $BRANCH1 $NEWCOMMIT
+ newcommit=$(git commit-tree $newtree -mMerge -p $branch1 -p $branch2)
+ git update-ref $branch1 $newcommit
-Note that when the exit status is non-zero, `NEWTREE` in this sequence
+Note that when the exit status is non-zero, `newtree` in this sequence
will contain a lot more output than just a tree.
For conflicts, the output includes the same information that you'd get
--
2.46.1.641.g54e7913fcb6
^ permalink raw reply related [flat|nested] 27+ messages in thread
* Re: [PATCH 2/3] doc: merge-tree: use lower-case variables
2024-10-07 11:10 ` [PATCH 2/3] doc: merge-tree: use lower-case variables Kristoffer Haugsbakk
@ 2024-10-07 14:58 ` Phillip Wood
2024-10-07 15:22 ` Elijah Newren
0 siblings, 1 reply; 27+ messages in thread
From: Phillip Wood @ 2024-10-07 14:58 UTC (permalink / raw)
To: Kristoffer Haugsbakk, git; +Cc: Kristoffer Haugsbakk, newren
Hi Kristoffer
On 07/10/2024 12:10, Kristoffer Haugsbakk wrote:
> From: Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com>
>
> From: Kristoffer Haugsbakk <code@khaugsbakk.name>
>
> This is easier to read.
I think that is a matter of taste, one could argue that using uppercase
variable names makes them stand out so the user can see which arguments
are parameters more clearly.
Best Wishes
Phillip
> Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
> ---
> Documentation/git-merge-tree.txt | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/Documentation/git-merge-tree.txt b/Documentation/git-merge-tree.txt
> index 590cbf5df79..10f8ac7f80a 100644
> --- a/Documentation/git-merge-tree.txt
> +++ b/Documentation/git-merge-tree.txt
> @@ -211,12 +211,12 @@ 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)
> + newtree=$(git merge-tree --write-tree $branch1 $branch2)
> test $? -eq 0 || die "There were conflicts..."
> - NEWCOMMIT=$(git commit-tree $NEWTREE -mMerge -p $BRANCH1 -p $BRANCH2)
> - git update-ref $BRANCH1 $NEWCOMMIT
> + newcommit=$(git commit-tree $newtree -mMerge -p $branch1 -p $branch2)
> + git update-ref $branch1 $newcommit
>
> -Note that when the exit status is non-zero, `NEWTREE` in this sequence
> +Note that when the exit status is non-zero, `newtree` in this sequence
> will contain a lot more output than just a tree.
>
> For conflicts, the output includes the same information that you'd get
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 2/3] doc: merge-tree: use lower-case variables
2024-10-07 14:58 ` Phillip Wood
@ 2024-10-07 15:22 ` Elijah Newren
0 siblings, 0 replies; 27+ messages in thread
From: Elijah Newren @ 2024-10-07 15:22 UTC (permalink / raw)
To: phillip.wood; +Cc: Kristoffer Haugsbakk, git, Kristoffer Haugsbakk
On Mon, Oct 7, 2024 at 7:58 AM Phillip Wood <phillip.wood123@gmail.com> wrote:
>
> Hi Kristoffer
>
> On 07/10/2024 12:10, Kristoffer Haugsbakk wrote:
> > From: Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com>
> >
> > From: Kristoffer Haugsbakk <code@khaugsbakk.name>
> >
> > This is easier to read.
>
> I think that is a matter of taste, one could argue that using uppercase
> variable names makes them stand out so the user can see which arguments
> are parameters more clearly.
Yeah, I wrote it as uppercase because I thought that was easier to
read for the reasons Phillip gives. It's not a strong preference, but
I do think the commit message needs a more detailed rationale or link
to an agreed project coding style or something, otherwise the commit
message may appear to be false to half the readers.
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH 3/3] doc: merge-tree: use || directly
2024-10-07 11:10 [PATCH 0/3] doc: merge-tree: improve the script example Kristoffer Haugsbakk
2024-10-07 11:10 ` [PATCH 1/3] doc: merge-tree: provide a commit message Kristoffer Haugsbakk
2024-10-07 11:10 ` [PATCH 2/3] doc: merge-tree: use lower-case variables Kristoffer Haugsbakk
@ 2024-10-07 11:10 ` Kristoffer Haugsbakk
2024-10-07 15:24 ` Elijah Newren
2024-10-07 14:59 ` [PATCH 0/3] doc: merge-tree: improve the script example Phillip Wood
2024-10-08 19:06 ` [PATCH v2 0/2] " Kristoffer Haugsbakk
4 siblings, 1 reply; 27+ messages in thread
From: Kristoffer Haugsbakk @ 2024-10-07 11:10 UTC (permalink / raw)
To: git; +Cc: Kristoffer Haugsbakk, newren, Kristoffer Haugsbakk
From: Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com>
From: Kristoffer Haugsbakk <code@khaugsbakk.name>
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(-)
diff --git a/Documentation/git-merge-tree.txt b/Documentation/git-merge-tree.txt
index 10f8ac7f80a..46091da022d 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 -mMerge -p $branch1 -p $branch2)
git update-ref $branch1 $newcommit
--
2.46.1.641.g54e7913fcb6
^ permalink raw reply related [flat|nested] 27+ messages in thread
* Re: [PATCH 3/3] doc: merge-tree: use || directly
2024-10-07 11:10 ` [PATCH 3/3] doc: merge-tree: use || directly Kristoffer Haugsbakk
@ 2024-10-07 15:24 ` Elijah Newren
2024-10-07 15:44 ` Kristoffer Haugsbakk
0 siblings, 1 reply; 27+ messages in thread
From: Elijah Newren @ 2024-10-07 15:24 UTC (permalink / raw)
To: Kristoffer Haugsbakk; +Cc: git, Kristoffer Haugsbakk
On Mon, Oct 7, 2024 at 4:11 AM Kristoffer Haugsbakk
<code@khaugsbakk.name> wrote:
>
> From: Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com>
>
> From: Kristoffer Haugsbakk <code@khaugsbakk.name>
>
> Use `||` directly since that is more straightforward than checking the
> last exit status.
>
> Also use `echo` and `exit` since `die` is not defined.
Not defined where? It's defined in my scripts... ;-)
Just kidding; this is a good change.
> Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
> ---
> Documentation/git-merge-tree.txt | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/Documentation/git-merge-tree.txt b/Documentation/git-merge-tree.txt
> index 10f8ac7f80a..46091da022d 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
> + }
Thanks.
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 3/3] doc: merge-tree: use || directly
2024-10-07 15:24 ` Elijah Newren
@ 2024-10-07 15:44 ` Kristoffer Haugsbakk
0 siblings, 0 replies; 27+ messages in thread
From: Kristoffer Haugsbakk @ 2024-10-07 15:44 UTC (permalink / raw)
To: Elijah Newren, Kristoffer Haugsbakk, Eric Sunshine; +Cc: git
On Mon, Oct 7, 2024, at 17:24, Elijah Newren wrote:
> On Mon, Oct 7, 2024 at 4:11 AM Kristoffer Haugsbakk
> <code@khaugsbakk.name> wrote:
>>
>> From: Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com>
>>
>> From: Kristoffer Haugsbakk <code@khaugsbakk.name>
>>
>> Use `||` directly since that is more straightforward than checking the
>> last exit status.
>>
>> Also use `echo` and `exit` since `die` is not defined.
>
> Not defined where? It's defined in my scripts... ;-)
>
> Just kidding; this is a good change.
:D
Thanks for taking a look! I’ll send the second version tomorrow.
--
Kristoffer Haugsbakk
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 0/3] doc: merge-tree: improve the script example
2024-10-07 11:10 [PATCH 0/3] doc: merge-tree: improve the script example Kristoffer Haugsbakk
` (2 preceding siblings ...)
2024-10-07 11:10 ` [PATCH 3/3] doc: merge-tree: use || directly Kristoffer Haugsbakk
@ 2024-10-07 14:59 ` Phillip Wood
2024-10-07 15:00 ` Kristoffer Haugsbakk
2024-10-08 19:06 ` [PATCH v2 0/2] " Kristoffer Haugsbakk
4 siblings, 1 reply; 27+ messages in thread
From: Phillip Wood @ 2024-10-07 14:59 UTC (permalink / raw)
To: Kristoffer Haugsbakk, git; +Cc: Kristoffer Haugsbakk, newren
Hi Kristoffer
Thanks for working on this. Patches 1 and 3 look like clear improvements
to me, I've left a comment on patch 2 as the improvement is less clear
to me but I wouldn't object to it being merged.
Best Wishes
Phillip
On 07/10/2024 12:10, Kristoffer Haugsbakk wrote:
> From: Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com>
>
>
> Kristoffer Haugsbakk (3):
> doc: merge-tree: provide a commit message
> doc: merge-tree: use lower-case variables
> doc: merge-tree: use || directly
>
> Documentation/git-merge-tree.txt | 14 ++++++++------
> 1 file changed, 8 insertions(+), 6 deletions(-)
>
> --
> 2.46.1.641.g54e7913fcb6
>
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH v2 0/2] doc: merge-tree: improve the script example
2024-10-07 11:10 [PATCH 0/3] doc: merge-tree: improve the script example Kristoffer Haugsbakk
` (3 preceding siblings ...)
2024-10-07 14:59 ` [PATCH 0/3] doc: merge-tree: improve the script example Phillip Wood
@ 2024-10-08 19:06 ` Kristoffer Haugsbakk
2024-10-08 19:06 ` [PATCH v2 1/2] doc: merge-tree: provide a commit message Kristoffer Haugsbakk
` (2 more replies)
4 siblings, 3 replies; 27+ messages in thread
From: Kristoffer Haugsbakk @ 2024-10-08 19:06 UTC (permalink / raw)
To: git; +Cc: Kristoffer Haugsbakk, Eric Sunshine, newren
§ Changes since v1
Patches:
• v1 1: v2 1: use a file instead of `-mMerge` for the commit message
• v1 2: dropped (lower-case variables)
• v1 3: v2 2: no changes
Kristoffer Haugsbakk (2):
doc: merge-tree: provide a commit message
doc: merge-tree: use || directly
Documentation/git-merge-tree.txt | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
Interdiff against v1:
diff --git a/Documentation/git-merge-tree.txt b/Documentation/git-merge-tree.txt
index 46091da022d..41dfb16476d 100644
--- a/Documentation/git-merge-tree.txt
+++ b/Documentation/git-merge-tree.txt
@@ -211,14 +211,15 @@ 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) || {
+ NEWTREE=$(git merge-tree --write-tree $BRANCH1 $BRANCH2) || {
echo "There were conflicts..." 1>&2
exit 1
}
- newcommit=$(git commit-tree $newtree -mMerge -p $branch1 -p $branch2)
- git update-ref $branch1 $newcommit
+ NEWCOMMIT=$(git commit-tree $NEWTREE -F $FILE_WITH_COMMIT_MESSAGE \
+ -p $BRANCH1 -p $BRANCH2)
+ git update-ref $BRANCH1 $NEWCOMMIT
-Note that when the exit status is non-zero, `newtree` in this sequence
+Note that when the exit status is non-zero, `NEWTREE` in this sequence
will contain a lot more output than just a tree.
For conflicts, the output includes the same information that you'd get
Range-diff against v1:
1: 6b05526c327 < -: ----------- doc: merge-tree: provide a commit message
2: 7d4deaee6c4 ! 1: b1ca5cae768 doc: merge-tree: use lower-case variables
@@ Metadata
Author: Kristoffer Haugsbakk <code@khaugsbakk.name>
## Commit message ##
- doc: merge-tree: use lower-case variables
+ doc: merge-tree: provide a commit message
- This is easier to read.
+ 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.
Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
+
+ ## Notes (series) ##
+ Unlike on some other manuals you probably won’t end up running these
+ commands directly to test things out. But you might end up copying and
+ modifying it when playing around with the command.
+
## Documentation/git-merge-tree.txt ##
-@@ Documentation/git-merge-tree.txt: 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:
+@@ Documentation/git-merge-tree.txt: used as a part of a series of steps such as:
-- NEWTREE=$(git merge-tree --write-tree $BRANCH1 $BRANCH2)
-+ newtree=$(git merge-tree --write-tree $branch1 $branch2)
+ NEWTREE=$(git merge-tree --write-tree $BRANCH1 $BRANCH2)
test $? -eq 0 || die "There were conflicts..."
-- NEWCOMMIT=$(git commit-tree $NEWTREE -mMerge -p $BRANCH1 -p $BRANCH2)
-- git update-ref $BRANCH1 $NEWCOMMIT
-+ newcommit=$(git commit-tree $newtree -mMerge -p $branch1 -p $branch2)
-+ git update-ref $branch1 $newcommit
-
--Note that when the exit status is non-zero, `NEWTREE` in this sequence
-+Note that when the exit status is non-zero, `newtree` in this sequence
- will contain a lot more output than just a tree.
+- NEWCOMMIT=$(git commit-tree $NEWTREE -p $BRANCH1 -p $BRANCH2)
++ NEWCOMMIT=$(git commit-tree $NEWTREE -F $FILE_WITH_COMMIT_MESSAGE \
++ -p $BRANCH1 -p $BRANCH2)
+ git update-ref $BRANCH1 $NEWCOMMIT
- For conflicts, the output includes the same information that you'd get
+ Note that when the exit status is non-zero, `NEWTREE` in this sequence
3: 1b60dc810e3 ! 2: 13e0f3bed5d doc: merge-tree: use || directly
@@ Documentation/git-merge-tree.txt: linkgit:git-commit-tree[1], linkgit:git-write-
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)
+- NEWTREE=$(git merge-tree --write-tree $BRANCH1 $BRANCH2)
- test $? -eq 0 || die "There were conflicts..."
-+ newtree=$(git merge-tree --write-tree $branch1 $branch2) || {
++ NEWTREE=$(git merge-tree --write-tree $BRANCH1 $BRANCH2) || {
+ echo "There were conflicts..." 1>&2
+ exit 1
+ }
- newcommit=$(git commit-tree $newtree -mMerge -p $branch1 -p $branch2)
- git update-ref $branch1 $newcommit
-
+ NEWCOMMIT=$(git commit-tree $NEWTREE -F $FILE_WITH_COMMIT_MESSAGE \
+ -p $BRANCH1 -p $BRANCH2)
+ git update-ref $BRANCH1 $NEWCOMMIT
--
2.46.1.641.g54e7913fcb6
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH v2 1/2] doc: merge-tree: provide a commit message
2024-10-08 19:06 ` [PATCH v2 0/2] " Kristoffer Haugsbakk
@ 2024-10-08 19:06 ` Kristoffer Haugsbakk
2024-10-08 20:42 ` Junio C Hamano
2024-10-08 19:06 ` [PATCH v2 2/2] doc: merge-tree: use || directly Kristoffer Haugsbakk
2024-10-09 16:53 ` [PATCH v3 0/1] doc: merge-tree: improve the script example Kristoffer Haugsbakk
2 siblings, 1 reply; 27+ messages in thread
From: Kristoffer Haugsbakk @ 2024-10-08 19:06 UTC (permalink / raw)
To: git; +Cc: Kristoffer Haugsbakk, Eric Sunshine, newren
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.
Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
---
Notes (series):
Unlike on some other manuals you probably won’t end up running these
commands directly to test things out. But you might end up copying and
modifying it when playing around with the command.
Documentation/git-merge-tree.txt | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/Documentation/git-merge-tree.txt b/Documentation/git-merge-tree.txt
index 84cb2edf6d0..d1157f1398a 100644
--- a/Documentation/git-merge-tree.txt
+++ b/Documentation/git-merge-tree.txt
@@ -213,7 +213,8 @@ 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..."
- NEWCOMMIT=$(git commit-tree $NEWTREE -p $BRANCH1 -p $BRANCH2)
+ NEWCOMMIT=$(git commit-tree $NEWTREE -F $FILE_WITH_COMMIT_MESSAGE \
+ -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
^ permalink raw reply related [flat|nested] 27+ messages in thread
* Re: [PATCH v2 1/2] doc: merge-tree: provide a commit message
2024-10-08 19:06 ` [PATCH v2 1/2] doc: merge-tree: provide a commit message Kristoffer Haugsbakk
@ 2024-10-08 20:42 ` Junio C Hamano
2024-10-08 20:44 ` Kristoffer Haugsbakk
` (2 more replies)
0 siblings, 3 replies; 27+ messages in thread
From: Junio C Hamano @ 2024-10-08 20:42 UTC (permalink / raw)
To: Kristoffer Haugsbakk; +Cc: git, Eric Sunshine, newren
Kristoffer Haugsbakk <code@khaugsbakk.name> writes:
> 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.
>
> Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
> ---
Makes sense.
> - NEWCOMMIT=$(git commit-tree $NEWTREE -p $BRANCH1 -p $BRANCH2)
> + NEWCOMMIT=$(git commit-tree $NEWTREE -F $FILE_WITH_COMMIT_MESSAGE \
> + -p $BRANCH1 -p $BRANCH2)
> git update-ref $BRANCH1 $NEWCOMMIT
The shell should know, after seeing $FILE_WITH_COMMIT_MESSAGE and
encountering the end of line, that you haven't completed telling
what you started telling it. Do you need " \" at the end of the
line?
I know that it was suggested to use a file with message, and I agree
with the suggestion, but then I wonder if we want to be more
complete and show that a file gets prepared in the example to avoid
making readers wonder where $FILE_WITH_COMMIT_MESSAGE comes from?
E.g.,
vi message.txt
NEWCOMMIT=$(git comimt-tree $NEWTREE -F message.txt
-p $BRANCH1 -p $BRANCH2)
or something like that?
Other than that, looking good.
Thanks.
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH v2 1/2] doc: merge-tree: provide a commit message
2024-10-08 20:42 ` Junio C Hamano
@ 2024-10-08 20:44 ` Kristoffer Haugsbakk
2024-10-09 16:35 ` Kristoffer Haugsbakk
2024-10-09 16:58 ` Andreas Schwab
2 siblings, 0 replies; 27+ messages in thread
From: Kristoffer Haugsbakk @ 2024-10-08 20:44 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Eric Sunshine, Elijah Newren
On Tue, Oct 8, 2024, at 22:42, Junio C Hamano wrote:
> The shell should know, after seeing $FILE_WITH_COMMIT_MESSAGE and
> encountering the end of line, that you haven't completed telling
> what you started telling it. Do you need " \" at the end of the
> line?
Heh, I’m not sure. I’ll delete it if I don’t.
> I know that it was suggested to use a file with message, and I agree
> with the suggestion, but then I wonder if we want to be more
> complete and show that a file gets prepared in the example to avoid
> making readers wonder where $FILE_WITH_COMMIT_MESSAGE comes from?
Sure thing
Thanks :)
--
Kristoffer Haugsbakk
kristofferhaugsbakk@fastmail.com
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH v2 1/2] doc: merge-tree: provide a commit message
2024-10-08 20:42 ` Junio C Hamano
2024-10-08 20:44 ` Kristoffer Haugsbakk
@ 2024-10-09 16:35 ` Kristoffer Haugsbakk
2024-10-09 17:38 ` Junio C Hamano
2024-10-09 16:58 ` Andreas Schwab
2 siblings, 1 reply; 27+ messages in thread
From: Kristoffer Haugsbakk @ 2024-10-09 16:35 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Eric Sunshine, Elijah Newren, Phillip Wood
On Tue, Oct 8, 2024, at 22:42, Junio C Hamano wrote:
> Kristoffer Haugsbakk <code@khaugsbakk.name> writes:
>
>> 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.
>>
>> Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
>> ---
>
> Makes sense.
>
>> - NEWCOMMIT=$(git commit-tree $NEWTREE -p $BRANCH1 -p $BRANCH2)
>> + NEWCOMMIT=$(git commit-tree $NEWTREE -F $FILE_WITH_COMMIT_MESSAGE \
>> + -p $BRANCH1 -p $BRANCH2)
>> git update-ref $BRANCH1 $NEWCOMMIT
>
> The shell should know, after seeing $FILE_WITH_COMMIT_MESSAGE and
> encountering the end of line, that you haven't completed telling
> what you started telling it. Do you need " \" at the end of the
> line?
I tried that and got an error: `-p: not found`.
> I know that it was suggested to use a file with message, and I agree
> with the suggestion, but then I wonder if we want to be more
> complete and show that a file gets prepared in the example to avoid
> making readers wonder where $FILE_WITH_COMMIT_MESSAGE comes from?
>
> E.g.,
>
> vi message.txt
> NEWCOMMIT=$(git comimt-tree $NEWTREE -F message.txt
> -p $BRANCH1 -p $BRANCH2)
>
> or something like that?
I’ll do that.
--
Kristoffer but any Christopher-variation is fine
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH v2 1/2] doc: merge-tree: provide a commit message
2024-10-09 16:35 ` Kristoffer Haugsbakk
@ 2024-10-09 17:38 ` Junio C Hamano
0 siblings, 0 replies; 27+ messages in thread
From: Junio C Hamano @ 2024-10-09 17:38 UTC (permalink / raw)
To: Kristoffer Haugsbakk; +Cc: git, Eric Sunshine, Elijah Newren, Phillip Wood
"Kristoffer Haugsbakk" <kristofferhaugsbakk@fastmail.com> writes:
>>> + NEWCOMMIT=$(git commit-tree $NEWTREE -F $FILE_WITH_COMMIT_MESSAGE \
>>> + -p $BRANCH1 -p $BRANCH2)
>>> git update-ref $BRANCH1 $NEWCOMMIT
>>
>> The shell should know, after seeing $FILE_WITH_COMMIT_MESSAGE and
>> encountering the end of line, that you haven't completed telling
>> what you started telling it. Do you need " \" at the end of the
>> line?
>
> I tried that and got an error: `-p: not found`.
Thanks for trying. Sorry, but I think I got confused by trying it
with two "echo" (one per line). The newline still acts as a
inter-command separator.
>> E.g.,
>>
>> vi message.txt
>> NEWCOMMIT=$(git comimt-tree $NEWTREE -F message.txt
>> -p $BRANCH1 -p $BRANCH2)
>>
>> or something like that?
>
> I’ll do that.
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH v2 1/2] doc: merge-tree: provide a commit message
2024-10-08 20:42 ` Junio C Hamano
2024-10-08 20:44 ` Kristoffer Haugsbakk
2024-10-09 16:35 ` Kristoffer Haugsbakk
@ 2024-10-09 16:58 ` Andreas Schwab
2 siblings, 0 replies; 27+ messages in thread
From: Andreas Schwab @ 2024-10-09 16:58 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Kristoffer Haugsbakk, git, Eric Sunshine, newren
On Okt 08 2024, Junio C Hamano wrote:
>> - NEWCOMMIT=$(git commit-tree $NEWTREE -p $BRANCH1 -p $BRANCH2)
>> + NEWCOMMIT=$(git commit-tree $NEWTREE -F $FILE_WITH_COMMIT_MESSAGE \
>> + -p $BRANCH1 -p $BRANCH2)
>> git update-ref $BRANCH1 $NEWCOMMIT
>
> The shell should know, after seeing $FILE_WITH_COMMIT_MESSAGE and
> encountering the end of line, that you haven't completed telling
> what you started telling it. Do you need " \" at the end of the
> line?
The contents of $(...) is a (multiline) shell script, with the same
whitespace and newline rules as a regular script.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
"And now for something completely different."
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH v2 2/2] doc: merge-tree: use || directly
2024-10-08 19:06 ` [PATCH v2 0/2] " Kristoffer Haugsbakk
2024-10-08 19:06 ` [PATCH v2 1/2] doc: merge-tree: provide a commit message Kristoffer Haugsbakk
@ 2024-10-08 19:06 ` Kristoffer Haugsbakk
2024-10-08 20:44 ` Junio C Hamano
2024-10-09 16:53 ` [PATCH v3 0/1] doc: merge-tree: improve the script example Kristoffer Haugsbakk
2 siblings, 1 reply; 27+ messages in thread
From: Kristoffer Haugsbakk @ 2024-10-08 19:06 UTC (permalink / raw)
To: git; +Cc: Kristoffer Haugsbakk, Eric Sunshine, newren
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(-)
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
--
2.46.1.641.g54e7913fcb6
^ permalink raw reply related [flat|nested] 27+ messages in thread
* Re: [PATCH v2 2/2] doc: merge-tree: use || directly
2024-10-08 19:06 ` [PATCH v2 2/2] doc: merge-tree: use || directly Kristoffer Haugsbakk
@ 2024-10-08 20:44 ` Junio C Hamano
2024-10-08 20:48 ` Kristoffer Haugsbakk
0 siblings, 1 reply; 27+ messages in thread
From: Junio C Hamano @ 2024-10-08 20:44 UTC (permalink / raw)
To: Kristoffer Haugsbakk; +Cc: git, Eric Sunshine, newren
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.
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH v2 2/2] doc: merge-tree: use || directly
2024-10-08 20:44 ` Junio C Hamano
@ 2024-10-08 20:48 ` Kristoffer Haugsbakk
0 siblings, 0 replies; 27+ messages in thread
From: Kristoffer Haugsbakk @ 2024-10-08 20:48 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Eric Sunshine, Elijah Newren
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.
--
Kristoffer Haugsbakk
kristofferhaugsbakk@fastmail.com
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH v3 0/1] doc: merge-tree: improve the script example
2024-10-08 19:06 ` [PATCH v2 0/2] " Kristoffer Haugsbakk
2024-10-08 19:06 ` [PATCH v2 1/2] doc: merge-tree: provide a commit message Kristoffer Haugsbakk
2024-10-08 19:06 ` [PATCH v2 2/2] doc: merge-tree: use || directly Kristoffer Haugsbakk
@ 2024-10-09 16:53 ` Kristoffer Haugsbakk
2024-10-09 16:53 ` [PATCH v3 1/1] doc: merge-tree: improve example script Kristoffer Haugsbakk
2024-10-09 20:50 ` [PATCH v3 0/1] doc: merge-tree: improve the script example Elijah Newren
2 siblings, 2 replies; 27+ messages in thread
From: Kristoffer Haugsbakk @ 2024-10-09 16:53 UTC (permalink / raw)
To: git; +Cc: Kristoffer Haugsbakk, Eric Sunshine, newren, phillip.wood123,
gitster
§ 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
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH v3 1/1] doc: merge-tree: improve example script
2024-10-09 16:53 ` [PATCH v3 0/1] doc: merge-tree: improve the script example Kristoffer Haugsbakk
@ 2024-10-09 16:53 ` Kristoffer Haugsbakk
2024-10-09 20:50 ` [PATCH v3 0/1] doc: merge-tree: improve the script example Elijah Newren
1 sibling, 0 replies; 27+ messages in thread
From: Kristoffer Haugsbakk @ 2024-10-09 16:53 UTC (permalink / raw)
To: git; +Cc: Kristoffer Haugsbakk, Eric Sunshine, newren, phillip.wood123,
gitster
• 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>
---
Documentation/git-merge-tree.txt | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/Documentation/git-merge-tree.txt b/Documentation/git-merge-tree.txt
index 84cb2edf6d0..0b6a8a19b1f 100644
--- a/Documentation/git-merge-tree.txt
+++ b/Documentation/git-merge-tree.txt
@@ -211,9 +211,15 @@ 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..."
- 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 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
^ permalink raw reply related [flat|nested] 27+ messages in thread
* Re: [PATCH v3 0/1] doc: merge-tree: improve the script example
2024-10-09 16:53 ` [PATCH v3 0/1] doc: merge-tree: improve the script example Kristoffer Haugsbakk
2024-10-09 16:53 ` [PATCH v3 1/1] doc: merge-tree: improve example script Kristoffer Haugsbakk
@ 2024-10-09 20:50 ` Elijah Newren
2024-10-10 0:01 ` Junio C Hamano
1 sibling, 1 reply; 27+ messages in thread
From: Elijah Newren @ 2024-10-09 20:50 UTC (permalink / raw)
To: Kristoffer Haugsbakk; +Cc: git, Eric Sunshine, phillip.wood123, gitster
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.
^ permalink raw reply [flat|nested] 27+ messages in thread