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

[PATCH 1/2] bisect--helper: `is_expected_rev` shell function in C

From
Pranit Bauva <pranit.bauva@gmail.com>
Date
Jun 8, 2016, 15:24 UTC
Message-ID
<20160608152415.7770-1-pranit.bauva@gmail.com>

Reimplement `is_expected_rev` shell function in C. This will further be called from `check_expected_revs` function. This is a quite small function thus subcommand facility is redundant.

Mentored-by: Lars Schneider <larsxschneider@gmail.com>
Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Pranit Bauva <pranit.bauva@gmail.com>
---
This applies on the previous patches.
 builtin/bisect--helper.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c
index 4153e8a..06bc9b8 100644
--- a/builtin/bisect--helper.c
+++ b/builtin/bisect--helper.c
@@ -160,6 +160,20 @@ int bisect_reset(const char *commit)
 	return bisect_clean_state();
 }
 
+static int is_expected_rev(const char *expected_hex)
+{
+	struct strbuf actual_hex = STRBUF_INIT;
+
+	if (!file_exists(git_path_bisect_expected_rev()))
+		return 0;
+
+	if (!strbuf_read_file(&actual_hex, git_path_bisect_expected_rev(), 0))
+		return 0;
+
+	strbuf_trim(&actual_hex);
+	return !strcmp(actual_hex.buf, expected_hex);
+}
+
 int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
 {
 	enum {
-- 
2.8.3
Next: Pranit Bauva
Message 1 of 9 in “bisect--helper: `is_expected_rev` shell function in C”
  1. 1/2 bisect--helper: `is_expected_rev` shell function in CPranit Bauva, Jun 8, 2016
  2. 2/2 bisect--helper: `check_expected_revs` shell function in CPranit Bauva, Jun 8, 2016
  3. Eric SunshineJun 9, 2016
  4. Pranit BauvaJun 10, 2016
  5. Eric SunshineJun 9, 2016
  6. Eric SunshineJun 9, 2016
  7. Pranit BauvaJun 10, 2016
  8. Eric SunshineJun 10, 2016
  9. Pranit BauvaJun 11, 2016

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.