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:
authorJunio C Hamano <gitster@pobox.com>2022-03-29 22:22:03 +0300
committerJunio C Hamano <gitster@pobox.com>2022-03-29 22:22:03 +0300
commit5fe35fcc790f6df1839ff984896f9d5e6710d012 (patch)
treec974a750116a6a13c9b53d40d447d7ee146d0bef
parentd62966735d0f2c9a632d34023336bc0387a4bd5a (diff)
parent2a69ff09d5654de31361365e3faf9f8495f03ed7 (diff)
Merge branch 'jt/reset-grafts-when-resetting-shallow'
When "shallow" information is updated, we forgot to update the in-core equivalent, which has been corrected. * jt/reset-grafts-when-resetting-shallow: shallow: reset commit grafts when shallow is reset
-rw-r--r--commit.c10
-rw-r--r--commit.h1
-rw-r--r--shallow.c1
-rw-r--r--submodule.c1
-rwxr-xr-xt/t5537-fetch-shallow.sh9
5 files changed, 22 insertions, 0 deletions
diff --git a/commit.c b/commit.c
index 98b2e55665..ffcc4a97cd 100644
--- a/commit.c
+++ b/commit.c
@@ -249,6 +249,16 @@ int for_each_commit_graft(each_commit_graft_fn fn, void *cb_data)
return ret;
}
+void reset_commit_grafts(struct repository *r)
+{
+ int i;
+
+ for (i = 0; i < r->parsed_objects->grafts_nr; i++)
+ free(r->parsed_objects->grafts[i]);
+ r->parsed_objects->grafts_nr = 0;
+ r->parsed_objects->commit_graft_prepared = 0;
+}
+
struct commit_buffer {
void *buffer;
unsigned long size;
diff --git a/commit.h b/commit.h
index 3b174135bc..21e4d25ce7 100644
--- a/commit.h
+++ b/commit.h
@@ -249,6 +249,7 @@ int commit_graft_pos(struct repository *r, const struct object_id *oid);
int register_commit_graft(struct repository *r, struct commit_graft *, int);
void prepare_commit_graft(struct repository *r);
struct commit_graft *lookup_commit_graft(struct repository *r, const struct object_id *oid);
+void reset_commit_grafts(struct repository *r);
struct commit *get_fork_point(const char *refname, struct commit *commit);
diff --git a/shallow.c b/shallow.c
index 71e5876f37..e158be58b0 100644
--- a/shallow.c
+++ b/shallow.c
@@ -90,6 +90,7 @@ static void reset_repository_shallow(struct repository *r)
{
r->parsed_objects->is_shallow = -1;
stat_validity_clear(r->parsed_objects->shallow_stat);
+ reset_commit_grafts(r);
}
int commit_shallow_file(struct repository *r, struct shallow_lock *lk)
diff --git a/submodule.c b/submodule.c
index 93c78a4dc3..86c8f0f89d 100644
--- a/submodule.c
+++ b/submodule.c
@@ -22,6 +22,7 @@
#include "parse-options.h"
#include "object-store.h"
#include "commit-reach.h"
+#include "shallow.h"
static int config_update_recurse_submodules = RECURSE_SUBMODULES_OFF;
static int initialized_fetch_ref_tips;
diff --git a/t/t5537-fetch-shallow.sh b/t/t5537-fetch-shallow.sh
index 11d5ea54a9..92948de7a0 100755
--- a/t/t5537-fetch-shallow.sh
+++ b/t/t5537-fetch-shallow.sh
@@ -161,6 +161,15 @@ test_expect_success 'fetch --update-shallow' '
)
'
+test_expect_success 'fetch --update-shallow into a repo with submodules' '
+ git init a-submodule &&
+ test_commit -C a-submodule foo &&
+ git init repo-with-sub &&
+ git -C repo-with-sub submodule add ../a-submodule a-submodule &&
+ git -C repo-with-sub commit -m "added submodule" &&
+ git -C repo-with-sub fetch --update-shallow ../shallow/.git refs/heads/*:refs/remotes/shallow/*
+'
+
test_expect_success 'fetch --update-shallow (with fetch.writeCommitGraph)' '
(
cd shallow &&