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

[PATCH] Use const qualifier for 'sha1' parameter in delete_ref function

From
JJas <jasampler@gmail.com>
Date
Apr 18, 2007, 03:34 UTC
Message-ID
<1b46aba20704172034k3b55fe9eye84b6ce1207238aa@mail.gmail.com>

delete_ref function does not change the 'sha1' parameter. Non-const pointer causes a compiler warning if you call to the function using a const argument.

Signed-off-by: Carlos Rica <jasampler@gmail.com>
---
 cache.h |    2 +-
 refs.c  |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/cache.h b/cache.h
index eb57507..db8ea48 100644
--- a/cache.h
+++ b/cache.h
@@ -217,7 +217,7 @@ extern int commit_locked_index(struct lock_file *);
 extern void set_alternate_index_output(const char *);

 extern void rollback_lock_file(struct lock_file *);
-extern int delete_ref(const char *, unsigned char *sha1);
+extern int delete_ref(const char *, const unsigned char *sha1);

 /* Environment bits from configuration mechanism */
 extern int use_legacy_headers;
diff --git a/refs.c b/refs.c
index d2b7b7f..d7be284 100644
--- a/refs.c
+++ b/refs.c
@@ -705,7 +705,7 @@ static int repack_without_ref(const char *refname)
 	return commit_lock_file(&packlock);
 }

-int delete_ref(const char *refname, unsigned char *sha1)
+int delete_ref(const char *refname, const unsigned char *sha1)
 {
 	struct ref_lock *lock;
 	int err, i, ret = 0, flag = 0;
-- 
1.5.0
Message 1 of 1 in “Use const qualifier for 'sha1' parameter in delete_ref function”
  1. Use const qualifier for 'sha1' parameter in delete_ref functionJas, Apr 18, 2007

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.