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

[PATCH v4 01/12] sha1_file: convert pretend_sha1_file to object_id

From
Patryk Obara <patryk.obara@gmail.com>
Date
Jan 28, 2018, 00:13 UTC
Message-ID
<d154b8b52844dfe5ed73f66ab223fcc92e986e7d.1517097306.git.patryk.obara@gmail.com>
In-Reply-To
<cover.1517097306.git.patryk.obara@gmail.com>

Convert the declaration and definition of pretend_sha1_file to use struct object_id and adjust all usages of this function. Rename it to pretend_object_file.

Signed-off-by: Patryk Obara <patryk.obara@gmail.com>
---
 Documentation/technical/api-object-access.txt |  2 +-
 blame.c                                       |  2 +-
 cache.h                                       |  5 ++++-
 sha1_file.c                                   | 10 +++++-----
 4 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/Documentation/technical/api-object-access.txt b/Documentation/technical/api-object-access.txt
index 03bb0e950d..a1162e5bcd 100644
--- a/Documentation/technical/api-object-access.txt
+++ b/Documentation/technical/api-object-access.txt
@@ -7,7 +7,7 @@ Talk about <sha1_file.c> and <object.h> family, things like
 * read_object_with_reference()
 * has_sha1_file()
 * write_sha1_file()
-* pretend_sha1_file()
+* pretend_object_file()
 * lookup_{object,commit,tag,blob,tree}
 * parse_{object,commit,tag,blob,tree}
 * Use of object flags
diff --git a/blame.c b/blame.c
index 2893f3c103..1fc22b304b 100644
--- a/blame.c
+++ b/blame.c
@@ -232,7 +232,7 @@ static struct commit *fake_working_tree_commit(struct diff_options *opt,
 	convert_to_git(&the_index, path, buf.buf, buf.len, &buf, 0);
 	origin->file.ptr = buf.buf;
 	origin->file.size = buf.len;
-	pretend_sha1_file(buf.buf, buf.len, OBJ_BLOB, origin->blob_oid.hash);
+	pretend_object_file(buf.buf, buf.len, OBJ_BLOB, &origin->blob_oid);
 
 	/*
 	 * Read the current index, replace the path entry with
diff --git a/cache.h b/cache.h
index d8b975a571..e4e03ac51d 100644
--- a/cache.h
+++ b/cache.h
@@ -1241,7 +1241,10 @@ 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, struct object_id *oid, unsigned flags);
-extern int pretend_sha1_file(void *, unsigned long, enum object_type, unsigned char *);
+
+extern int pretend_object_file(void *, unsigned long, enum object_type,
+			       struct object_id *oid);
+
 extern int force_object_loose(const unsigned char *sha1, time_t mtime);
 extern int git_open_cloexec(const char *name, int flags);
 #define git_open(name) git_open_cloexec(name, O_RDONLY)
diff --git a/sha1_file.c b/sha1_file.c
index 3da70ac650..830b93b428 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -1312,13 +1312,13 @@ static void *read_object(const unsigned char *sha1, enum object_type *type,
 	return content;
 }
 
-int pretend_sha1_file(void *buf, unsigned long len, enum object_type type,
-		      unsigned char *sha1)
+int pretend_object_file(void *buf, unsigned long len, enum object_type type,
+			struct object_id *oid)
 {
 	struct cached_object *co;
 
-	hash_sha1_file(buf, len, typename(type), sha1);
-	if (has_sha1_file(sha1) || find_cached_object(sha1))
+	hash_sha1_file(buf, len, typename(type), oid->hash);
+	if (has_sha1_file(oid->hash) || find_cached_object(oid->hash))
 		return 0;
 	ALLOC_GROW(cached_objects, cached_object_nr + 1, cached_object_alloc);
 	co = &cached_objects[cached_object_nr++];
@@ -1326,7 +1326,7 @@ int pretend_sha1_file(void *buf, unsigned long len, enum object_type type,
 	co->type = type;
 	co->buf = xmalloc(len);
 	memcpy(co->buf, buf, len);
-	hashcpy(co->sha1, sha1);
+	hashcpy(co->sha1, oid->hash);
 	return 0;
 }
 
-- 
2.14.3
Previous: Patryk ObaraNext: Patryk Obara
Message 64 of 75 in “Some fixes and bunch of object_id conversions”
  1. 00/11 Some fixes and bunch of object_id conversionsPatryk Obara, Jan 18, 2018
  2. 01/11 http-push: improve error logPatryk Obara, Jan 18, 2018
  3. 02/11 clang-format: adjust penalty for return type line breakPatryk Obara, Jan 18, 2018
  4. 04/11 dir: convert struct sha1_stat to use object_idPatryk Obara, Jan 18, 2018
  5. 06/11 cache: clear whole hash buffer with oidclrPatryk Obara, Jan 18, 2018
  6. 07/11 match-trees: convert splice_tree to object_idPatryk Obara, Jan 18, 2018
  7. 09/11 notes: convert combine_notes_* to object_idPatryk Obara, Jan 18, 2018
  8. 08/11 commit: convert commit_tree* to object_idPatryk Obara, Jan 18, 2018
  9. 11/11 sha1_file: convert write_sha1_file to object_idPatryk Obara, Jan 18, 2018
  10. brian m. carlsonJan 20, 2018
  11. Patryk ObaraJan 21, 2018
  12. 10/11 notes: convert write_notes_tree to object_idPatryk Obara, Jan 18, 2018
  13. 05/11 sha1_file: convert hash_sha1_file to object_idPatryk Obara, Jan 18, 2018
  14. 03/11 sha1_file: convert pretend_sha1_file to object_idPatryk Obara, Jan 18, 2018
  15. Jonathan TanJan 18, 2018
  16. brian m. carlsonJan 20, 2018
  17. Patryk ObaraJan 21, 2018
  18. 00/14 Some fixes and bunch of object_id conversionsPatryk Obara, Jan 22, 2018
  19. 02/14 clang-format: adjust penalty for return type line breakPatryk Obara, Jan 22, 2018
  20. 03/14 sha1_file: convert pretend_sha1_file to object_idPatryk Obara, Jan 22, 2018
  21. 07/14 match-trees: convert splice_tree to object_idPatryk Obara, Jan 22, 2018
  22. Duy NguyenJan 22, 2018
  23. Patryk ObaraJan 22, 2018
  24. Duy NguyenJan 23, 2018
  25. 09/14 notes: convert combine_notes_* to object_idPatryk Obara, Jan 22, 2018
  26. 10/14 notes: convert write_notes_tree to object_idPatryk Obara, Jan 22, 2018
  27. Duy NguyenJan 22, 2018
  28. 11/14 sha1_file: convert write_sha1_file to object_idPatryk Obara, Jan 22, 2018
  29. 14/14 sha1_file: rename hash_sha1_file_literallyPatryk Obara, Jan 22, 2018
  30. 12/14 sha1_file: convert force_object_loose to object_idPatryk Obara, Jan 22, 2018
  31. 13/14 sha1_file: convert write_loose_object to object_idPatryk Obara, Jan 22, 2018
  32. 04/14 dir: convert struct sha1_stat to use object_idPatryk Obara, Jan 22, 2018
  33. 05/14 sha1_file: convert hash_sha1_file to object_idPatryk Obara, Jan 22, 2018
  34. Duy NguyenJan 22, 2018
  35. Patryk ObaraJan 22, 2018
  36. Duy NguyenJan 22, 2018
  37. 08/14 commit: convert commit_tree* to object_idPatryk Obara, Jan 22, 2018
  38. 06/14 cache: clear whole hash buffer with oidclrPatryk Obara, Jan 22, 2018
  39. 01/14 http-push: improve error logPatryk Obara, Jan 22, 2018
  40. Duy NguyenJan 22, 2018
  41. Patryk ObaraJan 22, 2018
  42. 00/14 Some fixes and bunch of object_id conversionsPatryk Obara, Jan 24, 2018
  43. 02/14 clang-format: adjust penalty for return type line breakPatryk Obara, Jan 24, 2018
  44. 07/14 match-trees: convert splice_tree to object_idPatryk Obara, Jan 24, 2018
  45. 11/14 sha1_file: convert write_sha1_file to object_idPatryk Obara, Jan 24, 2018
  46. 10/14 notes: convert write_notes_tree to object_idPatryk Obara, Jan 24, 2018
  47. 08/14 commit: convert commit_tree* to object_idPatryk Obara, Jan 24, 2018
  48. 09/14 notes: convert combine_notes_* to object_idPatryk Obara, Jan 24, 2018
  49. 13/14 sha1_file: convert write_loose_object to object_idPatryk Obara, Jan 24, 2018
  50. brian m. carlsonJan 26, 2018
  51. 12/14 sha1_file: convert force_object_loose to object_idPatryk Obara, Jan 24, 2018
  52. 14/14 sha1_file: rename hash_sha1_file_literallyPatryk Obara, Jan 24, 2018
  53. 01/14 http-push: improve error logPatryk Obara, Jan 24, 2018
  54. 05/14 sha1_file: convert hash_sha1_file to object_idPatryk Obara, Jan 24, 2018
  55. 03/14 sha1_file: convert pretend_sha1_file to object_idPatryk Obara, Jan 24, 2018
  56. 04/14 dir: convert struct sha1_stat to use object_idPatryk Obara, Jan 24, 2018
  57. Junio C HamanoJan 24, 2018
  58. 06/14 cache: clear whole hash buffer with oidclrPatryk Obara, Jan 24, 2018
  59. Junio C HamanoJan 24, 2018
  60. Junio C HamanoJan 24, 2018
  61. Duy NguyenJan 25, 2018
  62. brian m. carlsonJan 27, 2018
  63. 00/12 A bunch of object_id conversionsPatryk Obara, Jan 28, 2018
  64. 01/12 sha1_file: convert pretend_sha1_file to object_idPatryk Obara, Jan 28, 2018
  65. 03/12 sha1_file: convert hash_sha1_file to object_idPatryk Obara, Jan 28, 2018
  66. 05/12 match-trees: convert splice_tree to object_idPatryk Obara, Jan 28, 2018
  67. 08/12 notes: convert write_notes_tree to object_idPatryk Obara, Jan 28, 2018
  68. 04/12 cache: clear whole hash buffer with oidclrPatryk Obara, Jan 28, 2018
  69. 09/12 sha1_file: convert write_sha1_file to object_idPatryk Obara, Jan 28, 2018
  70. 07/12 notes: convert combine_notes_* to object_idPatryk Obara, Jan 28, 2018
  71. 10/12 sha1_file: convert force_object_loose to object_idPatryk Obara, Jan 28, 2018
  72. 11/12 sha1_file: convert write_loose_object to object_idPatryk Obara, Jan 28, 2018
  73. 12/12 sha1_file: rename hash_sha1_file_literallyPatryk Obara, Jan 28, 2018
  74. 06/12 commit: convert commit_tree* to object_idPatryk Obara, Jan 28, 2018
  75. 02/12 dir: convert struct sha1_stat to use object_idPatryk Obara, Jan 28, 2018

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.