DORMANTno replies

[PATCH] Stop git-rev-list at sha1 match

From: Thomas Gleixner <hidden>
Date: 2016-06-15 22:41:57

The patch adds an option to stop the output of git-rev-list
on a sha1 match. 

Signed-Off: Thomas Gleixner [off-list ref]
--- 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;
 }

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help