From 44f8afdc44d4d7dd0124fac984356c18b966f2db Mon Sep 17 00:00:00 2001 From: Aki Date: Fri, 8 Jul 2022 22:42:44 +0200 Subject: Added file presence check --- pkgrel.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkgrel.c b/pkgrel.c index d7551e1..89ce797 100644 --- a/pkgrel.c +++ b/pkgrel.c @@ -114,12 +114,19 @@ match_line(const git_diff_delta* delta, const git_diff_hunk* hunk, const git_dif int main(int argc, char* argv[]) { + FILE* file = fopen("PKGBUILD", "r"); + if (NULL == file) { + dprintf(2, "PKGBUILD not found or cannot be opened\n"); + exit(1); + } + fclose(file); git_libgit2_init(); git_repository* repo = NULL; try_git(git_repository_open_ext(&repo, NULL, GIT_REPOSITORY_OPEN_FROM_ENV, NULL), "opening repo"); git_diff_options diffopts = GIT_DIFF_OPTIONS_INIT; diffopts.pathspec.strings = (char*[1]){relative_path_in_current_dir(repo, "PKGBUILD")}; diffopts.pathspec.count = 1; + diffopts.flags |= GIT_DIFF_SHOW_UNTRACKED_CONTENT; if (NULL == diffopts.pathspec.strings[0]) { dprintf(2, "finding PKGBUILD in repo\n"); exit(1); @@ -159,7 +166,7 @@ main(int argc, char* argv[]) relpkg++; } if (MATCH_RESULT_INIT == match) { - dprintf(2, "PKGBUILD not found\n"); + dprintf(2, "PKGBUILD not found in history\n"); exit(1); } else -- cgit v1.1