From: Alban Gruin <alban.gruin@gmail.com>
To: Git Mailing List <git@vger.kernel.org>
Cc: Alban Gruin <alban.gruin@gmail.com>
Subject: [RFC PATCH 2/4] commit-list: add a function to check if a commit is in a list
Date: Fri, 1 Mar 2019 18:50:22 +0100 [thread overview]
Message-ID: <20190301175024.17337-3-alban.gruin@gmail.com> (raw)
In-Reply-To: <20190301175024.17337-1-alban.gruin@gmail.com>
To avoid naming some commits, name_rev() will need to check if a commit
is part of a commit list.
Signed-off-by: Alban Gruin <alban.gruin@gmail.com>
---
commit.c | 12 ++++++++++++
commit.h | 1 +
2 files changed, 13 insertions(+)
diff --git a/commit.c b/commit.c
index a5333c7ac6..fcb3e9245f 100644
--- a/commit.c
+++ b/commit.c
@@ -524,6 +524,18 @@ struct commit_list *commit_list_insert(struct commit *item, struct commit_list *
return new_list;
}
+int commit_list_contains(const struct commit_list *l, struct commit *commit)
+{
+ const struct commit_list *item;
+
+ for (item = l; item != NULL; item = item->next) {
+ if (oideq(&item->item->object.oid, &commit->object.oid))
+ return 1;
+ }
+
+ return 0;
+}
+
unsigned commit_list_count(const struct commit_list *l)
{
unsigned c = 0;
diff --git a/commit.h b/commit.h
index 42728c2906..c9df613b0e 100644
--- a/commit.h
+++ b/commit.h
@@ -165,6 +165,7 @@ struct commit_list *commit_list_insert(struct commit *item,
struct commit_list **list);
struct commit_list **commit_list_append(struct commit *commit,
struct commit_list **next);
+int commit_list_contains(const struct commit_list *l, struct commit *commit);
unsigned commit_list_count(const struct commit_list *l);
struct commit_list *commit_list_insert_by_date(struct commit *item,
struct commit_list **list);
--
2.20.1
next prev parent reply other threads:[~2019-03-01 17:50 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-01 17:50 [RFC PATCH 0/4] name-rev: improve memory usage Alban Gruin
2019-03-01 17:50 ` [RFC PATCH 1/4] name-rev: improve name_rev() " Alban Gruin
2019-03-01 18:00 ` Eric Sunshine
2019-03-01 18:44 ` Jeff King
2019-03-02 21:28 ` Johannes Schindelin
2019-03-01 17:50 ` Alban Gruin [this message]
2019-03-01 17:50 ` [RFC PATCH 3/4] name-rev: check if a commit should be named before naming it Alban Gruin
2019-03-01 18:05 ` Eric Sunshine
2019-03-01 18:22 ` Alban Gruin
2019-03-01 18:37 ` Jeff King
2019-03-01 17:50 ` [RFC PATCH 4/4] name-rev: avoid naming from a ref if it’s not a descendant of any commit Alban Gruin
2019-03-01 18:07 ` Eric Sunshine
2019-03-03 19:33 ` Christian Couder
2019-03-03 19:46 ` Christian Couder
2019-03-03 20:27 ` Alban Gruin
2019-03-01 18:42 ` [RFC PATCH 0/4] name-rev: improve memory usage Jeff King
2019-03-01 19:14 ` Alban Gruin
2019-03-01 19:39 ` Jeff King
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=20190301175024.17337-3-alban.gruin@gmail.com \
--to=alban.gruin@gmail.com \
--cc=git@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).