From: Barret Rhoden <brho@google.com>
To: git@vger.kernel.org
Cc: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
"David Kastrup" <dak@gnu.org>, "Jeff King" <peff@peff.net>,
"Jeff Smith" <whydoubt@gmail.com>,
"Johannes Schindelin" <Johannes.Schindelin@gmx.de>,
"Junio C Hamano" <gitster@pobox.com>,
"René Scharfe" <l.s.r@web.de>,
"Stefan Beller" <stefanbeller@gmail.com>,
"Michael Platings" <michael@platin.gs>
Subject: [PATCH v9 2/9] Move oidset_parse_file() to oidset.c
Date: Thu, 20 Jun 2019 12:38:13 -0400 [thread overview]
Message-ID: <20190620163820.231316-3-brho@google.com> (raw)
In-Reply-To: <20190620163820.231316-1-brho@google.com>
Signed-off-by: Barret Rhoden <brho@google.com>
---
fsck.c | 35 -----------------------------------
oidset.c | 35 +++++++++++++++++++++++++++++++++++
oidset.h | 8 ++++++++
3 files changed, 43 insertions(+), 35 deletions(-)
diff --git a/fsck.c b/fsck.c
index a28cba6b05dd..58ff3c4de992 100644
--- a/fsck.c
+++ b/fsck.c
@@ -181,41 +181,6 @@ static int fsck_msg_type(enum fsck_msg_id msg_id,
return msg_type;
}
-void oidset_parse_file(struct oidset *set, const char *path)
-{
- FILE *fp;
- struct strbuf sb = STRBUF_INIT;
- struct object_id oid;
-
- fp = fopen(path, "r");
- if (!fp)
- die("could not open object name list: %s", path);
- while (!strbuf_getline(&sb, fp)) {
- const char *p;
- const char *name;
-
- /*
- * Allow trailing comments, leading whitespace
- * (including before commits), and empty or whitespace
- * only lines.
- */
- name = strchr(sb.buf, '#');
- if (name)
- strbuf_setlen(&sb, name - sb.buf);
- strbuf_trim(&sb);
- if (!sb.len)
- continue;
-
- if (parse_oid_hex(sb.buf, &oid, &p) || *p != '\0')
- die("invalid object name: %s", sb.buf);
- oidset_insert(set, &oid);
- }
- if (ferror(fp))
- die_errno("Could not read '%s'", path);
- fclose(fp);
- strbuf_release(&sb);
-}
-
static int parse_msg_type(const char *str)
{
if (!strcmp(str, "error"))
diff --git a/oidset.c b/oidset.c
index fe4eb921df81..584be63e520a 100644
--- a/oidset.c
+++ b/oidset.c
@@ -35,3 +35,38 @@ void oidset_clear(struct oidset *set)
kh_release_oid(&set->set);
oidset_init(set, 0);
}
+
+void oidset_parse_file(struct oidset *set, const char *path)
+{
+ FILE *fp;
+ struct strbuf sb = STRBUF_INIT;
+ struct object_id oid;
+
+ fp = fopen(path, "r");
+ if (!fp)
+ die("could not open object name list: %s", path);
+ while (!strbuf_getline(&sb, fp)) {
+ const char *p;
+ const char *name;
+
+ /*
+ * Allow trailing comments, leading whitespace
+ * (including before commits), and empty or whitespace
+ * only lines.
+ */
+ name = strchr(sb.buf, '#');
+ if (name)
+ strbuf_setlen(&sb, name - sb.buf);
+ strbuf_trim(&sb);
+ if (!sb.len)
+ continue;
+
+ if (parse_oid_hex(sb.buf, &oid, &p) || *p != '\0')
+ die("invalid object name: %s", sb.buf);
+ oidset_insert(set, &oid);
+ }
+ if (ferror(fp))
+ die_errno("Could not read '%s'", path);
+ fclose(fp);
+ strbuf_release(&sb);
+}
diff --git a/oidset.h b/oidset.h
index 14f18f791fea..2dbca84d798f 100644
--- a/oidset.h
+++ b/oidset.h
@@ -61,6 +61,14 @@ int oidset_remove(struct oidset *set, const struct object_id *oid);
*/
void oidset_clear(struct oidset *set);
+/**
+ * Add the contents of the file 'path' to an initialized oidset. Each line is
+ * an unabbreviated object name. Comments begin with '#', and trailing comments
+ * are allowed. Leading whitespace and empty or white-space only lines are
+ * ignored.
+ */
+void oidset_parse_file(struct oidset *set, const char *path);
+
struct oidset_iter {
kh_oid_t *set;
khiter_t iter;
--
2.22.0.410.gd8fdbe21b5-goog
next prev parent reply other threads:[~2019-06-20 16:38 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-20 16:38 [PATCH v9 0/9] blame: add the ability to ignore commits Barret Rhoden
2019-06-20 16:38 ` [PATCH v9 1/9] fsck: rename and touch up init_skiplist() Barret Rhoden
2019-06-20 16:38 ` Barret Rhoden [this message]
2019-06-20 16:38 ` [PATCH v9 3/9] blame: use a helper function in blame_chunk() Barret Rhoden
2019-06-20 16:38 ` [PATCH v9 4/9] blame: add the ability to ignore commits and their changes Barret Rhoden
2019-06-20 16:38 ` [PATCH v9 5/9] blame: add config options for the output of ignored or unblamable lines Barret Rhoden
2019-06-20 16:38 ` [PATCH v9 6/9] blame: optionally track line fingerprints during fill_blame_origin() Barret Rhoden
2019-06-20 16:38 ` [PATCH v9 7/9] blame: add a fingerprint heuristic to match ignored lines Barret Rhoden
2019-06-29 17:19 ` SZEDER Gábor
2019-06-30 18:17 ` [PATCH] t8014: remove unnecessary braces michael
2019-07-01 14:16 ` Barret Rhoden
2019-06-20 16:38 ` [PATCH v9 8/9] blame: use the fingerprint heuristic to match ignored lines Barret Rhoden
2019-06-20 16:38 ` [PATCH v9 9/9] blame: add a test to cover blame_coalesce() Barret Rhoden
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=20190620163820.231316-3-brho@google.com \
--to=brho@google.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=avarab@gmail.com \
--cc=dak@gnu.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=l.s.r@web.de \
--cc=michael@platin.gs \
--cc=peff@peff.net \
--cc=stefanbeller@gmail.com \
--cc=whydoubt@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.