From 183df649ca6f10d07a6d155761eef2d52a4f39cd Mon Sep 17 00:00:00 2001 From: Taylor Blau Date: Thu, 30 Apr 2020 15:11:28 -0600 Subject: commit: make 'commit_graft_pos' non-static In the next patch, some functions will be moved from 'commit.c' to have prototypes in a new 'shallow.h' and their implementations in 'shallow.c'. Three functions in 'commit.c' use 'commit_graft_pos()' (they are 'register_commit_graft()', 'lookup_commit_graft()', and 'unregister_shallow()'). The first two of these will stay in 'commit.c', but the latter will move to 'shallow.c', and thus needs 'commit_graft_pos' to be non-static. Prepare for that by making 'commit_graft_pos' non-static so that it can be called from both 'commit.c' and 'shallow.c'. Signed-off-by: Taylor Blau Signed-off-by: Junio C Hamano --- commit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'commit.c') diff --git a/commit.c b/commit.c index a6cfa41a4e..efa9ea7dcf 100644 --- a/commit.c +++ b/commit.c @@ -110,7 +110,7 @@ static const unsigned char *commit_graft_sha1_access(size_t index, void *table) return commit_graft_table[index]->oid.hash; } -static int commit_graft_pos(struct repository *r, const unsigned char *sha1) +int commit_graft_pos(struct repository *r, const unsigned char *sha1) { return sha1_pos(sha1, r->parsed_objects->grafts, r->parsed_objects->grafts_nr, -- cgit v1.2.3 From 120ad2b0f13b60266fec9760bba3b5abfcd6fb78 Mon Sep 17 00:00:00 2001 From: Taylor Blau Date: Thu, 30 Apr 2020 13:48:50 -0600 Subject: shallow: extract a header file for shallow-related functions There are many functions in commit.h that are more related to shallow repositories than they are to any sort of generic commit machinery. Likely this began when there were only a few shallow-related functions, and commit.h seemed a reasonable enough place to put them. But, now there are a good number of shallow-related functions, and placing them all in 'commit.h' doesn't make sense. This patch extracts a 'shallow.h', which takes all of the declarations from 'commit.h' for functions which already exist in 'shallow.c'. We will bring the remaining shallow-related functions defined in 'commit.c' in a subsequent patch. For now, move only the ones that already are implemented in 'shallow.c', and update the necessary includes. Signed-off-by: Taylor Blau Signed-off-by: Junio C Hamano --- commit.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) (limited to 'commit.c') diff --git a/commit.c b/commit.c index efa9ea7dcf..aa969b32a3 100644 --- a/commit.c +++ b/commit.c @@ -20,6 +20,7 @@ #include "refs.h" #include "commit-reach.h" #include "run-command.h" +#include "shallow.h" static struct commit_extra_header *read_commit_extra_header_lines(const char *buf, size_t len, const char **); @@ -245,19 +246,6 @@ int for_each_commit_graft(each_commit_graft_fn fn, void *cb_data) return ret; } -int unregister_shallow(const struct object_id *oid) -{ - int pos = commit_graft_pos(the_repository, oid->hash); - if (pos < 0) - return -1; - if (pos + 1 < the_repository->parsed_objects->grafts_nr) - MOVE_ARRAY(the_repository->parsed_objects->grafts + pos, - the_repository->parsed_objects->grafts + pos + 1, - the_repository->parsed_objects->grafts_nr - pos - 1); - the_repository->parsed_objects->grafts_nr--; - return 0; -} - struct commit_buffer { void *buffer; unsigned long size; -- cgit v1.2.3