Skip to content

Commit 432f666

Browse files
KarthikNayakgitster
authored andcommitted
loose: don't rely on repository global state
In `loose.c`, we rely on the global variable `the_hash_algo`. As such we have guarded the file with the 'USE_THE_REPOSITORY_VARIABLE' definition. Let's derive the hash algorithm from the available repository variable and remove this guard. This brings us one step closer to removing the global 'the_repository' variable. Signed-off-by: Karthik Nayak <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 777489f commit 432f666

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

loose.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
#define USE_THE_REPOSITORY_VARIABLE
2-
31
#include "git-compat-util.h"
42
#include "hash.h"
53
#include "path.h"
64
#include "object-store.h"
75
#include "hex.h"
6+
#include "repository.h"
87
#include "wrapper.h"
98
#include "gettext.h"
109
#include "loose.h"
@@ -142,8 +141,8 @@ int repo_write_loose_object_map(struct repository *repo)
142141

143142
for (; iter != kh_end(map); iter++) {
144143
if (kh_exist(map, iter)) {
145-
if (oideq(&kh_key(map, iter), the_hash_algo->empty_tree) ||
146-
oideq(&kh_key(map, iter), the_hash_algo->empty_blob))
144+
if (oideq(&kh_key(map, iter), repo->hash_algo->empty_tree) ||
145+
oideq(&kh_key(map, iter), repo->hash_algo->empty_blob))
147146
continue;
148147
strbuf_addf(&buf, "%s %s\n", oid_to_hex(&kh_key(map, iter)), oid_to_hex(kh_value(map, iter)));
149148
if (write_in_full(fd, buf.buf, buf.len) < 0)

0 commit comments

Comments
 (0)