[PATCH v6 0/2] send-email: fix threads breaking in case user edits emails and improvements to outlook ID fix.
From: Aditya Garg <hidden>
Date: 2025-05-29 14:57:06
Hi all,
This patch series fixes two minor issues with git-send-email.
The first patch fixes a bug that caused the message number to increase
when a user edits an email. As a result of this bug, threads would
break when a user edits an email.
The second patch improves the logging of the new message ID assigned by
Outlook when a user edits an email.
v2 - Change the bugfix logic used to fix the threading bug.
v3 - Add additional patch to improve the logging of the new
message ID assigned by Outlook.
v4 - Completely rewrite the commit message of the first patch to
explain the bug in detail and how it is fixed. Also, add
example logs to explain the second patch.
v5 - Fix numerous spelling and grammatical errors in the commit
message of the first patch.
v6 - Change the subject of the first patch.
- Prefer using "increment" instead of "increase" in the commit
message of the first patch.
- Avoid decreasing the `$message_id_serial` variable in the first patch.
Aditya Garg (2):
send-email: fix bug resulting in broken threads if a message is edited
send-email: show the new message id assigned by outlook in the logs
git-send-email.perl | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
Range-diff against v5:
1: 5103ea4034 ! 1: d965439f76 send-email: fix bug resulting in increased message number if a message is edited
@@ Metadata
Author: Aditya Garg [off-list ref]
## Commit message ##
- send-email: fix bug resulting in increased message number if a message is edited
+ send-email: fix bug resulting in broken threads if a message is edited
Whenever we send a thread of emails using send-email, a message number
is internally assigned to each email. This number is used to track the
order of the emails in the thread. Whenever a new message is processed
- in a thread, the current script logic increases the message number by
+ in a thread, the current script logic increments the message number by
one, which is intended.
But, if a message is edited and then resent, its message number again
- gets increased. This is because the script uses the same logic to
+ gets incrmented. This is because the script uses the same logic to
process the edited message, which it uses to send the next message.
- This minor bug is usually harmless, unless some special situations arise.
- One such situation is when the first message in a thread is edited
- and resent, and an `--in-reply-to` argument is also passed to send-email.
+ This minor bug is usually harmless, unless a special situations arises.
+ That situation is when the first message in a thread is edited and
+ resent, and an `--in-reply-to` argument is also passed to send-email.
In this case, if the user has chosen shallow threading, the threading
does not work as expected, and all messages become replies to the
Message-ID specified in the `--in-reply-to` argument.
@@ Commit message
greater than 1, and the whole set of conditions is false. Therefore, the
`$in_reply_to` variable remains as the first message's ID. This is what
we expect in shallow threading. But if the user edits the first message
- and resends it, the `$message_num` variable gets increased by 1, and
+ and resends it, the `$message_num` variable gets incremented by 1, and
thus the condition `$message_num == 1` becomes false. This means that
the `$in_reply_to` variable is not set to the first message's ID. As a
result the next message in the thread is not a reply to the first
@@ Commit message
variable is set to the first message's ID, and the threading works
as expected, regardless of the message number.
- Just like the `$message_num` variable, the `$message_id_serial` variable
- also increases by 1 whenever a new message is sent. This variable
- displays the message number in the Message-ID of the email.
-
To fix this bug, we need to ensure that the `$message_num` variable is
- not increased by 1 when a message is edited and resent. We do this by
- decreasing both the `$message_num` and `$message_id_serial` variables
- by 1 whenever the request to edit a message is received. This way, the
- next message in the thread will have the same message number as the
- edited message. Therefore the threading will work as expected.
+ not incremented by 1 when a message is edited and resent. We do this by
+ decreasing the `$message_num` variable by 1 whenever the request to edit
+ a message is received. This way, the next message in the thread will
+ have the same message number as the edited message. Therefore the
+ threading will work as expected.
The same logic has also been applied in case the user drops a single
message from the thread by choosing the "[n]o" option during
@@ git-send-email.perl: sub send_message {
+ # the next message is treated as the successor to the
+ # previously sent message, and not the skipped message.
+ $message_num--;
-+ $message_id_serial--;
return 0;
} elsif (/^e/i) {
+ # Since the same message will be sent again, we need to
@@ git-send-email.perl: sub send_message {
+ # different message sent after the original non-edited
+ # message.
+ $message_num--;
-+ $message_id_serial--;
return -1;
} elsif (/^q/i) {
cleanup_compose_files();
2: 6f2668de07 = 2: caf46596a7 send-email: show the new message id assigned by outlook in the logs
--
2.49.0.635.g48fa2f4343