Commit Diff


commit - bf0668dd8c753e49753724e72e408bf8a568c700
commit + df0b3d8ac9d4da612a6c67d95dc66b75dd989ca3
blob - a263a2bf7dcd603a72c89b25889b7d2464731d49
blob + da9425a64c72070a47ca2ee6ababa9edf5f07295
--- tog/tog.1
+++ tog/tog.1
@@ -107,7 +107,8 @@ Show log entries for the parent directory of the curre
 .It Cm /
 Prompt for a search pattern and start searching for matching commits.
 The search pattern is an extended regular expression which is matched
-against a commit's author name, committer name, and log message.
+against a commit's author name, committer name, log message, and
+commit ID SHA1 hash.
 Regular expression syntax is documented in
 .Xr re_format 7 .
 .It Cm n
blob - 3c2a6b3464a2461663080cce1dce43ba62137281
blob + 2b8c94f44e82e0ff7557e3eacacc02797976838a
--- tog/tog.c
+++ tog/tog.c
@@ -1723,7 +1723,8 @@ search_start_log_view(struct tog_view *view)
 }
 
 static int
-match_commit(struct got_commit_object *commit, regex_t *regex)
+match_commit(struct got_commit_object *commit, const char *id_str,
+    regex_t *regex)
 {
 	regmatch_t regmatch;
 
@@ -1732,7 +1733,8 @@ match_commit(struct got_commit_object *commit, regex_t
 	    regexec(regex, got_object_commit_get_committer(commit), 1,
 	    &regmatch, 0) == 0 ||
 	    regexec(regex, got_object_commit_get_logmsg(commit), 1,
-	    &regmatch, 0) == 0)
+	    &regmatch, 0) == 0 ||
+	    regexec(regex, id_str, 1, &regmatch, 0) == 0)
 		return 1;
 
 	return 0;
@@ -1764,6 +1766,7 @@ search_next_log_view(struct tog_view *view)
 	}
 
 	while (1) {
+		char *id_str;
 		if (entry == NULL) {
 			if (s->thread_args.log_complete ||
 			    view->searching == TOG_SEARCH_BACKWARD) {
@@ -1777,11 +1780,17 @@ search_next_log_view(struct tog_view *view)
 			    &s->thread_args.need_commits);
 		}
 
-		if (match_commit(entry->commit, &view->regex)) {
+		err = got_object_id_str(&id_str, entry->id);
+		if (err)
+			return err;
+
+		if (match_commit(entry->commit, id_str, &view->regex)) {
 			view->search_next_done = 1;
 			s->matched_entry = entry;
+			free(id_str);
 			break;
 		}
+		free(id_str);
 		if (view->searching == TOG_SEARCH_FORWARD)
 			entry = TAILQ_NEXT(entry, entry);
 		else