git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[RFC PATCH 1/2] patch-ids: add const modifier to commit

From
Michael McClimon <michael@mcclimon.org>
Date
Oct 22, 2023, 02:27 UTC
Message-ID
<20231022022800.69219-2-michael@mcclimon.org>
In-Reply-To
<20231022022800.69219-1-michael@mcclimon.org>

These aren't modified by these functions, and I want to use them somewhere where the commit is in fact a const.

Signed-off-by: Michael McClimon <michael@mcclimon.org>
---
 patch-ids.c | 4 ++--
 patch-ids.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/patch-ids.c b/patch-ids.c
index c3e1a0dd..ecfd7ba0 100644
--- a/patch-ids.c
+++ b/patch-ids.c
@@ -6,13 +6,13 @@
 #include "hex.h"
 #include "patch-ids.h"
 
-static int patch_id_defined(struct commit *commit)
+static int patch_id_defined(const struct commit *commit)
 {
 	/* must be 0 or 1 parents */
 	return !commit->parents || !commit->parents->next;
 }
 
-int commit_patch_id(struct commit *commit, struct diff_options *options,
+int commit_patch_id(const struct commit *commit, struct diff_options *options,
 		    struct object_id *oid, int diff_header_only)
 {
 	if (!patch_id_defined(commit))
diff --git a/patch-ids.h b/patch-ids.h
index 490d7393..3f61d88a 100644
--- a/patch-ids.h
+++ b/patch-ids.h
@@ -19,7 +19,7 @@ struct patch_ids {
 	struct diff_options diffopts;
 };
 
-int commit_patch_id(struct commit *commit, struct diff_options *options,
+int commit_patch_id(const struct commit *commit, struct diff_options *options,
 		    struct object_id *oid, int);
 int init_patch_ids(struct repository *, struct patch_ids *);
 int free_patch_ids(struct patch_ids *);
-- 
2.42.0.424.gceadf0f3
Previous: Michael McClimonNext: Michael McClimon
Message 2 of 4 in “pretty: add %I formatting for patch-id”
  1. 0/2 pretty: add %I formatting for patch-idMichael McClimon, Oct 22, 2023
  2. 1/2 patch-ids: add const modifier to commitMichael McClimon, Oct 22, 2023
  3. 2/2 pretty: add 'I' placeholder for patch-idMichael McClimon, Oct 22, 2023
  4. Jeff KingOct 25, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.