commit-graph: close_commit_graph before shallow walk
Call close_commit_graph() when about to start a rev-list walk that includes shallow commits. This is necessary in code paths that "fake" shallow commits for the sake of fetch. Specifically, test 351 in t5500-fetch-pack.sh runs git fetch --shallow-exclude one origin with a file-based transfer. When the "remote" has a commit-graph, we do not prevent the commit-graph from being loaded, but then the commits are intended to be dynamically transferred into shallow commits during get_shallow_commits_by_rev_list(). By closing the commit-graph before this call, we prevent this interaction. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Derrick Stolee committed
Aug 20, 2018 at 18:24 UTC
829a321569d8e8f2c582aef9f0c990df976ab842
3 files changed
+7
-4
commit-graph.c
+4
-4
@@ -260,10 +260,10 @@ static int prepare_commit_graph(struct repository *r)
260
return !!r->objects->commit_graph;
261
}
262
263
-static void close_commit_graph(void)
263
+void close_commit_graph(struct repository *r)
264
{
265
- free_commit_graph(the_repository->objects->commit_graph);
266
- the_repository->objects->commit_graph = NULL;
265
+ free_commit_graph(r->objects->commit_graph);
266
+ r->objects->commit_graph = NULL;
267
}
268
269
static int bsearch_graph(struct commit_graph *g, struct object_id *oid, uint32_t *pos)
@@ -875,7 +875,7 @@ void write_commit_graph(const char *obj_dir,
875
write_graph_chunk_data(f, GRAPH_OID_LEN, commits.list, commits.nr);
876
write_graph_chunk_large_edges(f, commits.list, commits.nr);
877
878
- close_commit_graph();
878
+ close_commit_graph(the_repository);
879
finalize_hashfile(f, NULL, CSUM_HASH_IN_STREAM | CSUM_FSYNC);
880
commit_lock_file(&lk);
881
commit-graph.h
+1
@@ -59,6 +59,7 @@ void write_commit_graph(const char *obj_dir,
59
60
int verify_commit_graph(struct repository *r, struct commit_graph *g);
61
62
+void close_commit_graph(struct repository *);
63
void free_commit_graph(struct commit_graph *);
64
65
#endif
upload-pack.c
+2
@@ -24,6 +24,7 @@
24
#include "quote.h"
25
#include "upload-pack.h"
26
#include "serve.h"
27
+#include "commit-graph.h"
28
29
/* Remember to update object flag allocation in object.h */
30
#define THEY_HAVE (1u << 11)
@@ -740,6 +741,7 @@ static void deepen_by_rev_list(int ac, const char **av,
741
{
742
struct commit_list *result;
743
744
+ close_commit_graph(the_repository);
745
result = get_shallow_commits_by_rev_list(ac, av, SHALLOW, NOT_SHALLOW);
746
send_shallow(result);
747
free_commit_list(result);