git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
TGThomas 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;
 }
Next: Junio C Hamano
Message 1 of 13 in “Stop git-rev-list at sha1 match”
  1. Stop git-rev-list at sha1 matchThomas Gleixner, May 11, 2005
  2. Junio C HamanoMay 11, 2005
  3. Thomas GleixnerMay 11, 2005
  4. Junio C HamanoMay 11, 2005
  5. Petr BaudisMay 11, 2005
  6. Thomas GleixnerMay 11, 2005
  7. Petr BaudisMay 11, 2005
  8. Thomas GleixnerMay 11, 2005
  9. Petr BaudisMay 11, 2005
  10. Thomas GleixnerMay 12, 2005
  11. Petr BaudisMay 13, 2005
  12. Junio C HamanoMay 12, 2005
  13. Junio C HamanoMay 12, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.