If a commit-graph file exists, check its contents during 'git fsck'.

Signed-off-by: Derrick Stolee <dsto...@microsoft.com>
---
 builtin/fsck.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/builtin/fsck.c b/builtin/fsck.c
index ef78c6c00c..9712f230ba 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -16,6 +16,7 @@
 #include "streaming.h"
 #include "decorate.h"
 #include "packfile.h"
+#include "run-command.h"
 
 #define REACHABLE 0x0001
 #define SEEN      0x0002
@@ -45,6 +46,7 @@ static int name_objects;
 #define ERROR_REACHABLE 02
 #define ERROR_PACK 04
 #define ERROR_REFS 010
+#define ERROR_COMMIT_GRAPH 020
 
 static const char *describe_object(struct object *obj)
 {
@@ -815,5 +817,16 @@ int cmd_fsck(int argc, const char **argv, const char 
*prefix)
        }
 
        check_connectivity();
+
+       if (core_commit_graph) {
+               struct child_process commit_graph_check = CHILD_PROCESS_INIT;
+               const char *check_argv[] = { "commit-graph", "check", NULL, 
NULL };
+               commit_graph_check.argv = check_argv;
+               commit_graph_check.git_cmd = 1;
+
+               if (run_command(&commit_graph_check))
+                       errors_found |= ERROR_COMMIT_GRAPH;
+       }
+
        return errors_found;
 }
-- 
2.17.0.39.g685157f7fb

Reply via email to