Skip to contentSkip to conversation

doc: merge-tree: improve the script example

PATCH Superseded Kristoffer Haugsbakk 6 participants 27 messages Oct 7, 2024 – Oct 10, 2024 Documentation

lore
Share & tools
lore
#0 lore raw

cover doc: merge-tree: improve the script example

From: Kristoffer Haugsbakk <[email protected]>

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

#1 lore raw

PATCH 1/3 doc: merge-tree: provide a commit message

From: Kristoffer Haugsbakk <[email protected]>

From: Kristoffer Haugsbakk <[email protected]>

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.

---

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(-)
Documentation/git-merge-tree.txt +1 -1
index 84cb2edf6d0..590cbf5df79 100644
@@ -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
Signature · 1 line
2.46.1.641.g54e7913fcb6
#2 lore raw

Re: [PATCH 1/3] doc: merge-tree: provide a commit message

Quoted 3 lines · Kristoffer Haugsbakk

From: Kristoffer Haugsbakk <[email protected]>

From: Kristoffer Haugsbakk <[email protected]>

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.

Signature · 1 line
Kristoffer Haugsbakk
#3 lore raw

Re: [PATCH 1/3] doc: merge-tree: provide a commit message

In reply to Kristoffer Haugsbakk
Quoted 10 lines · Kristoffer Haugsbakk

From: Kristoffer Haugsbakk <[email protected]>

From: Kristoffer Haugsbakk <[email protected]>

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...

Quoted 17 lines

---

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(-)
Documentation/git-merge-tree.txt +0 -0
index 84cb2edf6d0..590cbf5df79 100644

Documentation/git-merge-tree.txt used as a part of a series of steps such as: · line 216

Quoted 5 lines
Documentation/git-merge-tree.txt +1 -1
@@ -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.

Quoted 5 lines
Documentation/git-merge-tree.txt +0 -1
        git update-ref $BRANCH1 $NEWCOMMIT
 
 Note that when the exit status is non-zero, `NEWTREE` in this sequence
--

2.46.1.641.g54e7913fcb6

#4 lore raw

Re: [PATCH 1/3] doc: merge-tree: provide a commit message

Quoted 9 lines · Elijah Newren

Documentation/git-merge-tree.txt used as a part of a series of steps such as: · line 216

Quoted 4 lines
        NEWTREE=$(git merge-tree --write-tree $BRANCH1 $BRANCH2)
        test $? -eq 0 || die "There were conflicts..."
Documentation/git-merge-tree.txt +1 -1
-       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

Signature · 1 line
Kristoffer Haugsbakk
#5 lore raw

PATCH 2/3 doc: merge-tree: use lower-case variables

In reply to Kristoffer Haugsbakk

From: Kristoffer Haugsbakk <[email protected]>

From: Kristoffer Haugsbakk <[email protected]>

This is easier to read.

---
 Documentation/git-merge-tree.txt | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
Documentation/git-merge-tree.txt +4 -4
index 590cbf5df79..10f8ac7f80a 100644
@@ -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
Signature · 1 line
2.46.1.641.g54e7913fcb6
#6 lore raw

Re: [PATCH 2/3] doc: merge-tree: use lower-case variables

Hi Kristoffer

Quoted 5 lines · Kristoffer Haugsbakk

From: Kristoffer Haugsbakk <[email protected]>

From: Kristoffer Haugsbakk <[email protected]>

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

Quoted 26 lines
---
  Documentation/git-merge-tree.txt | 8 ++++----
  1 file changed, 4 insertions(+), 4 deletions(-)
Documentation/git-merge-tree.txt +4 -4
index 590cbf5df79..10f8ac7f80a 100644
@@ -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
#7 lore raw

Re: [PATCH 2/3] doc: merge-tree: use lower-case variables

Quoted 6 lines · Phillip Wood

Hi Kristoffer

Quoted 2 lines · Kristoffer Haugsbakk

From: Kristoffer Haugsbakk <[email protected]>

Quoted 7 lines
Quoted 3 lines

From: Kristoffer Haugsbakk <[email protected]>

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.

#8 lore raw

PATCH 3/3 doc: merge-tree: use || directly

In reply to Kristoffer Haugsbakk

From: Kristoffer Haugsbakk <[email protected]>

From: Kristoffer Haugsbakk <[email protected]>

Use || directly since that is more straightforward than checking the last exit status.

Also use echo and exit since die is not defined.

---
 Documentation/git-merge-tree.txt | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
Documentation/git-merge-tree.txt +4 -2
index 10f8ac7f80a..46091da022d 100644
@@ -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
 
Signature · 1 line
2.46.1.641.g54e7913fcb6
#9 lore raw

Re: [PATCH 3/3] doc: merge-tree: use || directly

Quoted 9 lines · Kristoffer Haugsbakk

From: Kristoffer Haugsbakk <[email protected]>

From: Kristoffer Haugsbakk <[email protected]>

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.

Quoted 10 lines
---
 Documentation/git-merge-tree.txt | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
Documentation/git-merge-tree.txt +0 -0
index 10f8ac7f80a..46091da022d 100644

Documentation/git-merge-tree.txt linkgit:git-commit-tree[1], linkgit:git-write-tree[1], · line 217

Quoted 9 lines
Documentation/git-merge-tree.txt +4 -2
@@ -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.

#10 lore raw

Re: [PATCH 3/3] doc: merge-tree: use || directly

Quoted 7 lines · Elijah Newren
Quoted 5 lines · Kristoffer Haugsbakk

From: Kristoffer Haugsbakk <[email protected]>

From: Kristoffer Haugsbakk <[email protected]>

Quoted 8 lines
Quoted 4 lines

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.

Signature · 1 line
Kristoffer Haugsbakk
#11 lore raw
In reply to Kristoffer Haugsbakk

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

Quoted 14 lines · Kristoffer Haugsbakk

From: Kristoffer Haugsbakk <[email protected]>

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

#12 lore raw
Quoted 9 lines · Phillip Wood

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

Thanks for taking a look!

Signature · 1 line
Kristoffer Haugsbakk
#13 lore raw

v2 cover doc: merge-tree: improve the script example

In reply to Kristoffer Haugsbakk

§ 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:

Documentation/git-merge-tree.txt +5 -4
index 46091da022d..41dfb16476d 100644
@@ -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 <[email protected]>

## 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.

+
+ ## 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

Signature · 1 line
2.46.1.641.g54e7913fcb6
#14 lore raw

PATCH v2 1/2 doc: merge-tree: provide a commit message

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.

---

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(-)
Documentation/git-merge-tree.txt +2 -1
index 84cb2edf6d0..d1157f1398a 100644
@@ -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
Signature · 1 line
2.46.1.641.g54e7913fcb6
#15 lore raw

Re: [PATCH v2 1/2] doc: merge-tree: provide a commit message

Quoted 8 lines · Kristoffer Haugsbakk

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.

---

Makes sense.

Documentation/git-merge-tree.txt used as a part of a series of steps such as: · line 218

Quoted 4 lines
Documentation/git-merge-tree.txt +2 -1
-       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.

#16 lore raw

Re: [PATCH v2 1/2] doc: merge-tree: provide a commit message

Quoted 4 lines · Junio C Hamano

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.

Quoted 4 lines

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 :)

Signature · 2 lines
  Kristoffer Haugsbakk
  [email protected]
#17 lore raw

Re: [PATCH v2 1/2] doc: merge-tree: provide a commit message

In reply to Junio C Hamano
Quoted 18 lines · Junio C Hamano
Quoted 8 lines · Kristoffer Haugsbakk

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.

---

Makes sense.

Documentation/git-merge-tree.txt used as a part of a series of steps such as: · line 218

Quoted 4 lines
Documentation/git-merge-tree.txt +2 -1
-       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
Quoted 4 lines

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.

Quoted 5 lines

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?

Quoted 7 lines

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

#18 lore raw

Re: [PATCH v2 1/2] doc: merge-tree: provide a commit message

Quoted 10 lines · Kristoffer Haugsbakk
Quoted 8 lines

Documentation/git-merge-tree.txt used as a part of a series of steps such as: · line 218

Quoted 3 lines
Documentation/git-merge-tree.txt +2 -0
+       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.

Quoted 9 lines
Quoted 7 lines

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.

#19 lore raw

Re: [PATCH v2 1/2] doc: merge-tree: provide a commit message

In reply to Junio C Hamano
Quoted 9 lines · Junio C Hamano

Documentation/git-merge-tree.txt used as a part of a series of steps such as: · line 218

Quoted 4 lines
Documentation/git-merge-tree.txt +2 -1
-       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.

Signature · 3 lines
Andreas Schwab, [email protected]
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."
#20 lore raw

PATCH v2 2/2 doc: merge-tree: use || directly

In reply to Kristoffer Haugsbakk

Use || directly since that is more straightforward than checking the last exit status.

Also use echo and exit since die is not defined.

---
 Documentation/git-merge-tree.txt | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
Documentation/git-merge-tree.txt +4 -2
index d1157f1398a..41dfb16476d 100644
@@ -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
Signature · 1 line
2.46.1.641.g54e7913fcb6
#21 lore raw

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

Documentation/git-merge-tree.txt linkgit:git-commit-tree[1], linkgit:git-write-tree[1], · line 217

Quoted 6 lines · Kristoffer Haugsbakk
Documentation/git-merge-tree.txt +4 -2
-       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.

#22 lore raw

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

Quoted 9 lines · Junio C Hamano

Documentation/git-merge-tree.txt linkgit:git-commit-tree[1], linkgit:git-write-tree[1], · line 217

Quoted 6 lines · Kristoffer Haugsbakk
Documentation/git-merge-tree.txt +4 -2
-       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
+       }
Quoted 4 lines

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.

Signature · 2 lines
  Kristoffer Haugsbakk
  [email protected]
#23 lore raw

v3 cover doc: merge-tree: improve the script example

In reply to Kristoffer Haugsbakk

§ 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:

Documentation/git-merge-tree.txt +4 -1
index 41dfb16476d..0b6a8a19b1f 100644
@@ -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 <[email protected]>

## 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.

@@ 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

Signature · 1 line
2.46.1.641.g54e7913fcb6
#24 lore raw

PATCH v3 1/1 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.

---
 Documentation/git-merge-tree.txt | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
Documentation/git-merge-tree.txt +9 -3
index 84cb2edf6d0..0b6a8a19b1f 100644
@@ -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
Signature · 1 line
2.46.1.641.g54e7913fcb6
#25 lore raw
In reply to Kristoffer Haugsbakk
Quoted 75 lines · Kristoffer Haugsbakk

§ 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:

Documentation/git-merge-tree.txt +4 -1
index 41dfb16476d..0b6a8a19b1f 100644
@@ -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 <[email protected]>

## 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.

@@ 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 \

Quoted 8 lines

- -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.

#26 lore raw
Quoted 6 lines · Elijah Newren
Quoted 2 lines · Kristoffer Haugsbakk

...
2.46.1.641.g54e7913fcb6

This round looks good to me; thanks.

Thanks.