Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTaylor Blau <me@ttaylorr.com>2020-04-30 22:48:50 +0300
committerJunio C Hamano <gitster@pobox.com>2020-05-01 00:19:13 +0300
commit120ad2b0f13b60266fec9760bba3b5abfcd6fb78 (patch)
treec966775ae5c66ee3264655227ca7184920900982 /shallow.c
parent183df649ca6f10d07a6d155761eef2d52a4f39cd (diff)
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 <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'shallow.c')
-rw-r--r--shallow.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/shallow.c b/shallow.c
index 5010a6c732..76e00893fe 100644
--- a/shallow.c
+++ b/shallow.c
@@ -14,6 +14,7 @@
#include "commit-slab.h"
#include "list-objects.h"
#include "commit-reach.h"
+#include "shallow.h"
void set_alternate_shallow_file(struct repository *r, const char *path, int override)
{
@@ -38,6 +39,19 @@ int register_shallow(struct repository *r, const struct object_id *oid)
return register_commit_graft(r, graft, 0);
}
+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;
+}
+
int is_repository_shallow(struct repository *r)
{
FILE *fp;