summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pkgrel.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/pkgrel.c b/pkgrel.c
index 78305ca..653a0db 100644
--- a/pkgrel.c
+++ b/pkgrel.c
@@ -9,7 +9,8 @@
enum match_result
{
- MATCH_RESULT_INITIAL,
+ MATCH_RESULT_NEVER,
+ MATCH_RESULT_NEWDIFF,
MATCH_RESULT_NOTFOUND,
MATCH_RESULT_FOUND,
};
@@ -94,16 +95,16 @@ match_line(const git_diff_delta* delta, const git_diff_hunk* hunk, const git_dif
{
static const char* const PKGVER = "pkgver";
static const size_t PKGVER_LEN = 6;
- enum match_result* matched = (enum match_result*) payload;
+ enum match_result* match = (enum match_result*) payload;
switch (line->origin) {
case GIT_DIFF_LINE_ADDITION:
case GIT_DIFF_LINE_DELETION:
if (PKGVER_LEN <= line->content_len && 0 == strncmp(line->content, PKGVER, PKGVER_LEN))
- *matched = MATCH_RESULT_FOUND;
+ *match = MATCH_RESULT_FOUND;
break;
default:
- if (MATCH_RESULT_FOUND != *matched)
- *matched = MATCH_RESULT_NOTFOUND;
+ if (MATCH_RESULT_FOUND > *match)
+ *match = MATCH_RESULT_NOTFOUND;
break;
}
return 0;
@@ -131,8 +132,8 @@ main(int argc, char* argv[])
git_oid oid;
git_tree* earlier = NULL;
git_tree* later = NULL;
- int rel = 1;
- int occurred = 0;
+ int relpkg = 1;
+ enum match_result match = MATCH_RESULT_NEVER;
while (0 == git_revwalk_next(&oid, walker)) {
git_commit* commit;
try_git(git_commit_lookup(&commit, repo, &oid), "finding commit");
@@ -145,21 +146,20 @@ main(int argc, char* argv[])
try_git(git_diff_tree_to_workdir_with_index(&diff, repo, later, &diffopts), "diff");
else
try_git(git_diff_tree_to_tree(&diff, repo, later, earlier, &diffopts), "diff");
- enum match_result matched = MATCH_RESULT_INITIAL;
- try_git(git_diff_foreach(diff, NULL, NULL, NULL, &match_line, &matched), "searching lines");
+ if (MATCH_RESULT_NEVER < match)
+ match = MATCH_RESULT_NEWDIFF;
+ try_git(git_diff_foreach(diff, NULL, NULL, NULL, &match_line, &match), "searching lines");
git_diff_free(diff);
git_commit_free(commit);
- if (MATCH_RESULT_INITIAL != matched)
- occurred = 1;
- if (MATCH_RESULT_FOUND == matched)
+ if (MATCH_RESULT_FOUND == match)
break;
- if (MATCH_RESULT_NOTFOUND == matched)
- rel++;
+ if (MATCH_RESULT_NOTFOUND == match)
+ relpkg++;
}
- if (0 == occurred) {
+ if (MATCH_RESULT_NEVER == match) {
dprintf(2, "PKGBUILD not found\n");
exit(1);
}
else
- printf("%d\n", rel);
+ printf("%d\n", relpkg);
}