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

[PATCH v2 15/16] refs/files: remove references to `the_hash_algo`

From
Patrick Steinhardt <ps@pks.im>
Date
May 17, 2024, 08:19 UTC
Message-ID
<20c2bb4cbbb8eb1604c9a6a650b36cb05cd1dbf0.1715929858.git.ps@pks.im>
In-Reply-To
<cover.1715929858.git.ps@pks.im>

Remove references to `the_hash_algo` in favor of the hash algo specified by the repository associated with the files ref store.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 refs/files-backend.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/refs/files-backend.c b/refs/files-backend.c
index 235c8580d1..735a5acefe 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -1822,7 +1822,7 @@ static int write_ref_to_lockfile(struct files_ref_store *refs,
 		}
 	}
 	fd = get_lock_file_fd(&lock->lk);
-	if (write_in_full(fd, oid_to_hex(oid), the_hash_algo->hexsz) < 0 ||
+	if (write_in_full(fd, oid_to_hex(oid), refs->base.repo->hash_algo->hexsz) < 0 ||
 	    write_in_full(fd, &term, 1) < 0 ||
 	    fsync_component(FSYNC_COMPONENT_REFERENCE, get_lock_file_fd(&lock->lk)) < 0 ||
 	    close_ref_gently(lock) < 0) {
@@ -3223,7 +3223,7 @@ static int files_reflog_expire(struct ref_store *ref_store,
 			rollback_lock_file(&reflog_lock);
 		} else if (update &&
 			   (write_in_full(get_lock_file_fd(&lock->lk),
-				oid_to_hex(&cb.last_kept_oid), the_hash_algo->hexsz) < 0 ||
+				oid_to_hex(&cb.last_kept_oid), refs->base.repo->hash_algo->hexsz) < 0 ||
 			    write_str_in_full(get_lock_file_fd(&lock->lk), "\n") < 0 ||
 			    close_ref_gently(lock) < 0)) {
 			status |= error("couldn't write %s",
-- 
2.45.1.190.g19fe900cfc.dirty
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 16 of 17 in “refs: drop all references to `the_repository`”
  1. 00/16 refs: drop all references to `the_repository`Patrick Steinhardt, May 17, 2024
  2. 01/16 refs: adjust names for `init` and `init_db` callbacksPatrick Steinhardt, May 17, 2024
  3. 02/16 refs: rename `init_db` callback to avoid confusionPatrick Steinhardt, May 17, 2024
  4. 03/16 refs: implement releasing ref storagesPatrick Steinhardt, May 17, 2024
  5. 04/16 refs: track ref stores via strmapPatrick Steinhardt, May 17, 2024
  6. 05/16 refs: pass repo when retrieving submodule ref storePatrick Steinhardt, May 17, 2024
  7. 06/16 refs: refactor `resolve_gitlink_ref()` to accept a repositoryPatrick Steinhardt, May 17, 2024
  8. 07/16 refs: retrieve worktree ref stores via associated repositoryPatrick Steinhardt, May 17, 2024
  9. 08/16 refs: convert iteration over replace refs to accept ref storePatrick Steinhardt, May 17, 2024
  10. 09/16 refs: pass ref store when detecting dangling symrefsPatrick Steinhardt, May 17, 2024
  11. 10/16 refs: move object peeling into "object.c"Patrick Steinhardt, May 17, 2024
  12. 11/16 refs: pass repo when peeling objectsPatrick Steinhardt, May 17, 2024
  13. 12/16 refs: drop `git_default_branch_name()`Patrick Steinhardt, May 17, 2024
  14. 13/16 refs: remove `dwim_log()`Patrick Steinhardt, May 17, 2024
  15. 14/16 refs/files: use correct repositoryPatrick Steinhardt, May 17, 2024
  16. 15/16 refs/files: remove references to `the_hash_algo`Patrick Steinhardt, May 17, 2024
  17. 16/16 refs/packed: remove references to `the_hash_algo`Patrick Steinhardt, May 17, 2024

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.