Skip to content

Commit 7b472da

Browse files
committed
Merge branch 'ps/use-the-repository'
A CPP macro USE_THE_REPOSITORY_VARIABLE is introduced to help transition the codebase to rely less on the availability of the singleton the_repository instance. * ps/use-the-repository: hex: guard declarations with `USE_THE_REPOSITORY_VARIABLE` t/helper: remove dependency on `the_repository` in "proc-receive" t/helper: fix segfault in "oid-array" command without repository t/helper: use correct object hash in partial-clone helper compat/fsmonitor: fix socket path in networked SHA256 repos replace-object: use hash algorithm from passed-in repository protocol-caps: use hash algorithm from passed-in repository oidset: pass hash algorithm when parsing file http-fetch: don't crash when parsing packfile without a repo hash-ll: merge with "hash.h" refs: avoid include cycle with "repository.h" global: introduce `USE_THE_REPOSITORY_VARIABLE` macro hash: require hash algorithm in `empty_tree_oid_hex()` hash: require hash algorithm in `is_empty_{blob,tree}_oid()` hash: make `is_null_oid()` independent of `the_repository` hash: convert `oidcmp()` and `oideq()` to compare whole hash global: ensure that object IDs are always padded hash: require hash algorithm in `oidread()` and `oidclr()` hash: require hash algorithm in `hasheq()`, `hashcmp()` and `hashclr()` hash: drop (mostly) unused `is_empty_{blob,tree}_sha1()` functions
2 parents ae447ed + dc89b7d commit 7b472da

File tree

228 files changed

+1004
-617
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

228 files changed

+1004
-617
lines changed

add-interactive.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#define USE_THE_REPOSITORY_VARIABLE
2+
13
#include "git-compat-util.h"
24
#include "add-interactive.h"
35
#include "color.h"
@@ -557,7 +559,7 @@ static int get_modified_files(struct repository *r,
557559
s.skip_unseen = filter && i;
558560

559561
opt.def = is_initial ?
560-
empty_tree_oid_hex() : oid_to_hex(&head_oid);
562+
empty_tree_oid_hex(the_repository->hash_algo) : oid_to_hex(&head_oid);
561563

562564
repo_init_revisions(r, &rev, NULL);
563565
setup_revisions(0, NULL, &rev, &opt);

add-patch.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#define USE_THE_REPOSITORY_VARIABLE
2+
13
#include "git-compat-util.h"
24
#include "add-interactive.h"
35
#include "advice.h"
@@ -421,7 +423,7 @@ static int parse_diff(struct add_p_state *s, const struct pathspec *ps)
421423
/* could be on an unborn branch */
422424
!strcmp("HEAD", s->revision) &&
423425
repo_get_oid(the_repository, "HEAD", &oid) ?
424-
empty_tree_oid_hex() : s->revision);
426+
empty_tree_oid_hex(the_repository->hash_algo) : s->revision);
425427
}
426428
color_arg_index = args.nr;
427429
/* Use `--no-color` explicitly, just in case `diff.color = always`. */

apply.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
*
88
*/
99

10+
#define USE_THE_REPOSITORY_VARIABLE
11+
1012
#include "git-compat-util.h"
1113
#include "abspath.h"
1214
#include "base85.h"
@@ -3680,7 +3682,7 @@ static int try_threeway(struct apply_state *state,
36803682
if (status) {
36813683
patch->conflicted_threeway = 1;
36823684
if (patch->is_new)
3683-
oidclr(&patch->threeway_stage[0]);
3685+
oidclr(&patch->threeway_stage[0], the_repository->hash_algo);
36843686
else
36853687
oidcpy(&patch->threeway_stage[0], &pre_oid);
36863688
oidcpy(&patch->threeway_stage[1], &our_oid);

apply.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef APPLY_H
22
#define APPLY_H
33

4-
#include "hash-ll.h"
4+
#include "hash.h"
55
#include "lockfile.h"
66
#include "string-list.h"
77
#include "strmap.h"

archive-tar.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
/*
22
* Copyright (c) 2005, 2006 Rene Scharfe
33
*/
4+
5+
#define USE_THE_REPOSITORY_VARIABLE
6+
47
#include "git-compat-util.h"
58
#include "config.h"
69
#include "gettext.h"

archive-zip.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
/*
22
* Copyright (c) 2006 Rene Scharfe
33
*/
4+
5+
#define USE_THE_REPOSITORY_VARIABLE
6+
47
#include "git-compat-util.h"
58
#include "config.h"
69
#include "archive.h"

archive.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#define USE_THE_REPOSITORY_VARIABLE
2+
13
#include "git-compat-util.h"
24
#include "abspath.h"
35
#include "config.h"

attr.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
* an insanely large number of attributes.
77
*/
88

9+
#define USE_THE_REPOSITORY_VARIABLE
10+
911
#include "git-compat-util.h"
1012
#include "config.h"
1113
#include "environment.h"

bisect.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#define USE_THE_REPOSITORY_VARIABLE
2+
13
#include "git-compat-util.h"
24
#include "config.h"
35
#include "commit.h"

blame.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#define USE_THE_REPOSITORY_VARIABLE
2+
13
#include "git-compat-util.h"
24
#include "refs.h"
35
#include "object-store-ll.h"
@@ -1246,7 +1248,7 @@ static int fill_blob_sha1_and_mode(struct repository *r,
12461248
goto error_out;
12471249
return 0;
12481250
error_out:
1249-
oidclr(&origin->blob_oid);
1251+
oidclr(&origin->blob_oid, the_repository->hash_algo);
12501252
origin->mode = S_IFINVALID;
12511253
return -1;
12521254
}

0 commit comments

Comments
 (0)