l2md: warn when revwalk did not succeed in prep step

If we couldn't even start walking the repo, throw a warning to
inform what went wrong. Now that we've bumped the open file limit
this issue should be mitigated, but this indicates that potentially
the repo needs a repack. Once libgit2 supports this, we can actually
do it here instead.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
diff --git a/repo.c b/repo.c
index c5ca8e8..35455f2 100644
--- a/repo.c
+++ b/repo.c
@@ -195,7 +195,7 @@
 	git_commit *commit;
 	git_object *object;
 	uint32_t count = 0;
-	int ret;
+	int ret, it;
 
 	ret = git_repository_open(&repo->git, path);
 	if (ret)
@@ -218,7 +218,7 @@
 
 	gettimeofday(&start, NULL);
 
-	while (!git_revwalk_next(&coid, walker)) {
+	while (!(it = git_revwalk_next(&coid, walker))) {
 		ret = git_commit_lookup(&commit, repo->git, &coid);
 		if (ret)
 			panic_git("Cannot look up commit");
@@ -258,6 +258,9 @@
 		count++;
 	}
 
+	if (it && it != GIT_ITEROVER && !count)
+		warn_git("Performing revwalk did not succeed! Repo might need repack");
+
 	gettimeofday(&end, NULL);
 	timeval_sub(&res, &end, &start);