From: Kousik Sanagavarapu <five231003@gmail.com>
To: git@vger.kernel.org
Cc: gitster@pobox.com, newren@gmail.com, five231003@gmail.com
Subject: [GSoC][PATCH] commit: warn the usage of reverse_commit_list() helper
Date: Tue, 7 Feb 2023 20:33:59 +0530 [thread overview]
Message-ID: <20230207150359.177641-1-five231003@gmail.com> (raw)
The helper function reverse_commit_list() has destructive behavior when
used to reverse a list in-place. Warn about this behavior.
Signed-off-by: Kousik Sanagavarapu <five231003@gmail.com>
---
This patch has been sent based on the confusion that can be caused while
using the reverse_commit_list() helper function. One example of this is
a recent patch that I submitted[1] where the use of this function broke
try_merge_strategy() in merge.
It is also based on the discussions[2] there that I send this patch.
[1]: https://lore.kernel.org/git/20230202165137.118741-1-five231003@gmail.com/
[2]: https://lore.kernel.org/git/xmqqmt5uo9ea.fsf@gitster.g/
commit.h | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/commit.h b/commit.h
index fa39202fa6..9dba07748f 100644
--- a/commit.h
+++ b/commit.h
@@ -198,7 +198,12 @@ void commit_list_sort_by_date(struct commit_list **list);
/* Shallow copy of the input list */
struct commit_list *copy_commit_list(struct commit_list *list);
-/* Modify list in-place to reverse it, returning new head; list will be tail */
+/*
+ * Modify list in-place to reverse it, returning new head; list will be tail.
+ *
+ * NOTE! The reversed list is constructed using the elements of the original
+ * list, hence losing the original list.
+ */
struct commit_list *reverse_commit_list(struct commit_list *list);
void free_commit_list(struct commit_list *list);
--
2.25.1
next reply other threads:[~2023-02-07 15:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-07 15:03 Kousik Sanagavarapu [this message]
2023-02-07 17:56 ` [GSoC][PATCH] commit: warn the usage of reverse_commit_list() helper Ævar Arnfjörð Bjarmason
2023-02-08 15:53 ` Kousik Sanagavarapu
2023-02-07 18:53 ` Junio C Hamano
2023-02-08 16:00 ` Kousik Sanagavarapu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230207150359.177641-1-five231003@gmail.com \
--to=five231003@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=newren@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.