git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH 1/2] bisect--helper: `is_expected_rev` shell function in C
@ 2016-06-08 15:24 Pranit Bauva
  2016-06-08 15:24 ` [PATCH 2/2] bisect--helper: `check_expected_revs` " Pranit Bauva
  2016-06-09 21:33 ` [PATCH 1/2] bisect--helper: `is_expected_rev` " Eric Sunshine
  0 siblings, 2 replies; 9+ messages in thread
From: Pranit Bauva @ 2016-06-08 15:24 UTC (permalink / raw)
  To: git; +Cc: Pranit Bauva, christian.couder, chriscool, larsxschneider

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

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2016-06-11 12:18 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-08 15:24 [PATCH 1/2] bisect--helper: `is_expected_rev` shell function in C Pranit Bauva
2016-06-08 15:24 ` [PATCH 2/2] bisect--helper: `check_expected_revs` " Pranit Bauva
2016-06-09 21:54   ` Eric Sunshine
2016-06-10  7:52     ` Pranit Bauva
2016-06-09 21:33 ` [PATCH 1/2] bisect--helper: `is_expected_rev` " Eric Sunshine
2016-06-09 21:39   ` Eric Sunshine
2016-06-10 13:39   ` Pranit Bauva
2016-06-10 19:14     ` Eric Sunshine
2016-06-11 12:18       ` Pranit Bauva

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).