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

[PATCH 5/6] sha1_file: convert hash_sha1_file_literally to struct object_id

From
Patryk Obara <patryk.obara@gmail.com>
Date
Aug 20, 2017, 20:09 UTC
Message-ID
<0cbcf737983cd0a76269010f6a9028a03c8cac1d.1503258223.git.patryk.obara@gmail.com>
In-Reply-To
<cover.1503258223.git.patryk.obara@gmail.com>
Convert all remaining callers as well.
Signed-off-by: Patryk Obara <patryk.obara@gmail.com>
---
 builtin/hash-object.c | 2 +-
 cache.h               | 2 +-
 sha1_file.c           | 8 ++++----
 3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/builtin/hash-object.c b/builtin/hash-object.c
index 8a58ce0..c532ff9 100644
--- a/builtin/hash-object.c
+++ b/builtin/hash-object.c
@@ -24,7 +24,7 @@ static int hash_literally(struct object_id *oid, int fd, const char *type, unsig
 	if (strbuf_read(&buf, fd, 4096) < 0)
 		ret = -1;
 	else
-		ret = hash_sha1_file_literally(buf.buf, buf.len, type, oid->hash, flags);
+		ret = hash_sha1_file_literally(buf.buf, buf.len, type, oid, flags);
 	strbuf_release(&buf);
 	return ret;
 }
diff --git a/cache.h b/cache.h
index eaf3603..237adb5 100644
--- a/cache.h
+++ b/cache.h
@@ -1199,7 +1199,7 @@ static inline const unsigned char *lookup_replace_object(const unsigned char *sh
 extern int sha1_object_info(const unsigned char *, unsigned long *);
 extern int hash_sha1_file(const void *buf, unsigned long len, const char *type, unsigned char *sha1);
 extern int write_sha1_file(const void *buf, unsigned long len, const char *type, unsigned char *return_sha1);
-extern int hash_sha1_file_literally(const void *buf, unsigned long len, const char *type, unsigned char *sha1, unsigned flags);
+extern int hash_sha1_file_literally(const void *buf, unsigned long len, const char *type, struct object_id *oid, unsigned flags);
 extern int pretend_sha1_file(void *, unsigned long, enum object_type, unsigned char *);
 extern int force_object_loose(const unsigned char *sha1, time_t mtime);
 extern int git_open_cloexec(const char *name, int flags);
diff --git a/sha1_file.c b/sha1_file.c
index 11995e5..3e2ef4e 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -3437,7 +3437,7 @@ int write_sha1_file(const void *buf, unsigned long len, const char *type, unsign
 }
 
 int hash_sha1_file_literally(const void *buf, unsigned long len, const char *type,
-			     unsigned char *sha1, unsigned flags)
+                             struct object_id *oid, unsigned flags)
 {
 	char *header;
 	int hdrlen, status = 0;
@@ -3445,13 +3445,13 @@ int hash_sha1_file_literally(const void *buf, unsigned long len, const char *typ
 	/* type string, SP, %lu of the length plus NUL must fit this */
 	hdrlen = strlen(type) + 32;
 	header = xmalloc(hdrlen);
-	write_sha1_file_prepare(buf, len, type, sha1, header, &hdrlen);
+	write_sha1_file_prepare(buf, len, type, oid->hash, header, &hdrlen);
 
 	if (!(flags & HASH_WRITE_OBJECT))
 		goto cleanup;
-	if (freshen_packed_object(sha1) || freshen_loose_object(sha1))
+	if (freshen_packed_object(oid->hash) || freshen_loose_object(oid->hash))
 		goto cleanup;
-	status = write_loose_object(sha1, header, hdrlen, buf, len, 0);
+	status = write_loose_object(oid->hash, header, hdrlen, buf, len, 0);
 
 cleanup:
 	free(header);
-- 
2.9.5
Previous: Patryk ObaraNext: brian m. carlson
Message 5 of 10 in “Convert hash-object to struct object_id”
  1. 0/6 Convert hash-object to struct object_idPatryk Obara, Aug 20, 2017
  2. 1/6 builtin/hash-object: convert to struct object_idPatryk Obara, Aug 20, 2017
  3. 3/6 sha1_file: convert index_path to struct object_idPatryk Obara, Aug 20, 2017
  4. 6/6 sha1_file: convert index_stream to struct object_idPatryk Obara, Aug 20, 2017
  5. 5/6 sha1_file: convert hash_sha1_file_literally to struct object_idPatryk Obara, Aug 20, 2017
  6. brian m. carlsonAug 20, 2017
  7. 2/6 read-cache: convert to struct object_idPatryk Obara, Aug 20, 2017
  8. 4/6 sha1_file: convert index_fd to struct object_idPatryk Obara, Aug 20, 2017
  9. brian m. carlsonAug 20, 2017
  10. Junio C HamanoAug 21, 2017

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.