[PATCH] Stop git-rev-list at sha1 match
- From
- Thomas Gleixner <tglx@linutronix.de>
- Date
- May 11, 2005, 19:24 UTC
- Message-ID
- <1115839456.22180.79.camel@tglx>
The patch adds an option to stop the output of git-rev-list on a sha1 match.
Signed-Off: Thomas Gleixner <tglx@linutronix.de>
--- a/rev-list.c +++ b/rev-list.c @@ -7,6 +7,8 @@ int main(int argc, char **argv) struct commit_list *list = NULL; struct commit *commit; char *commit_arg = NULL; + char *sha1hex; + char *to_sha1 = NULL; int i; unsigned long max_age = -1; unsigned long min_age = -1; @@ -21,6 +23,8 @@ int main(int argc, char **argv) max_age = atoi(arg + 10); } else if (!strncmp(arg, "--min-age=", 10)) { min_age = atoi(arg + 10); + } else if (!strncmp(arg, "--to_sha1=", 10)) { + to_sha1 = arg + 10; } else { commit_arg = arg; } @@ -30,7 +34,8 @@ int main(int argc, char **argv) usage("usage: rev-list [OPTION] commit-id\n" " --max-count=nr\n" " --max-age=epoch\n" - " --min-age=epoch\n"); + " --min-age=epoch\n" + " --to-sha1=sha1\n"); commit = lookup_commit(sha1); if (!commit || parse_commit(commit) < 0) @@ -46,7 +51,10 @@ int main(int argc, char **argv) break; if (max_count != -1 && !max_count--) break; - printf("%s\n", sha1_to_hex(commit->object.sha1)); + sha1hex = sha1_to_hex(commit->object.sha1); + if (to_sha1 != NULL && strcmp(to_sha1, sha1hex) == 0) + break; + printf("%s\n", sha1hex); } while (list); return 0; }