Re: [PATCH 11/14] revert: Introduce a layer of indirection over pick_commits

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

Re: [PATCH 11/14] revert: Introduce a layer of indirection over pick_commits

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:51:33

Ramkumar Ramachandra [off-list ref] writes:
quoted hunk
Write a new function called process_continuation to prepare a
todo_list to call pick_commits with; the job of pick_commits is
simplified into performing the tasks listed in todo_list.  This will
be useful when continuation functionality like "--continue" is
introduced later in the series.

Helped-by: Jonathan Nieder [off-list ref]
Signed-off-by: Ramkumar Ramachandra <redacted>
---
 builtin/revert.c |   36 +++++++++++++++++++++++++-----------
 1 files changed, 25 insertions(+), 11 deletions(-)
diff --git a/builtin/revert.c b/builtin/revert.c
index 7d76f92..8cdcdb6 100644
--- a/builtin/revert.c
+++ b/builtin/revert.c
@@ -677,10 +677,8 @@ static int cleanup_sequencer_data(void)
 	return 0;
 }
 
-static int pick_commits(struct replay_opts *opts)
+static int pick_commits(struct commit_list *todo_list, struct replay_opts *opts)
 {
-	struct commit_list *todo_list = NULL;
-	unsigned char sha1[20];
 	struct commit_list *cur;
 	int res;
 
@@ -690,12 +688,6 @@ static int pick_commits(struct replay_opts *opts)
 				opts->record_origin || opts->edit));
 	read_and_refresh_cache(me, opts);
 
-	walk_revs_populate_todo(&todo_list, opts);
-	create_seq_dir();
-	if (!get_sha1("HEAD", sha1))
-		save_head(sha1_to_hex(sha1));
-	save_todo(todo_list, opts);
-
 	for (cur = todo_list; cur; cur = cur->next) {
 		save_todo(cur, opts);
 		res = do_pick_commit(cur->item, opts);
@@ -710,6 +702,22 @@ static int pick_commits(struct replay_opts *opts)
 	return cleanup_sequencer_data();
 }
 
+static int process_continuation(struct replay_opts *opts)
+{
+	struct commit_list *todo_list = NULL;
+	unsigned char sha1[20];
+
+	read_and_refresh_cache(me, opts);
+
+	walk_revs_populate_todo(&todo_list, opts);
+	create_seq_dir();
+	if (!get_sha1("HEAD", sha1))
+		persist_head(sha1_to_hex(sha1));
+	persist_todo(todo_list, opts);
Don't these two need forward declarations before their use?

Re: [PATCH 11/14] revert: Introduce a layer of indirection over pick_commits

From: Ramkumar Ramachandra <hidden>
Date: 2016-06-15 22:51:33

Hi Junio,

Junio C Hamano writes:
Ramkumar Ramachandra [off-list ref] writes:
quoted
diff --git a/builtin/revert.c b/builtin/revert.c
index 7d76f92..8cdcdb6 100644
--- a/builtin/revert.c
+++ b/builtin/revert.c
@@ -677,10 +677,8 @@ static int cleanup_sequencer_data(void)
      return 0;
 }

-static int pick_commits(struct replay_opts *opts)
+static int pick_commits(struct commit_list *todo_list, struct replay_opts *opts)
 {
-     struct commit_list *todo_list = NULL;
-     unsigned char sha1[20];
      struct commit_list *cur;
      int res;
@@ -690,12 +688,6 @@ static int pick_commits(struct replay_opts *opts)
                              opts->record_origin || opts->edit));
      read_and_refresh_cache(me, opts);

-     walk_revs_populate_todo(&todo_list, opts);
-     create_seq_dir();
-     if (!get_sha1("HEAD", sha1))
-             save_head(sha1_to_hex(sha1));
-     save_todo(todo_list, opts);
-
      for (cur = todo_list; cur; cur = cur->next) {
              save_todo(cur, opts);
              res = do_pick_commit(cur->item, opts);
@@ -710,6 +702,22 @@ static int pick_commits(struct replay_opts *opts)
      return cleanup_sequencer_data();
 }

+static int process_continuation(struct replay_opts *opts)
+{
+     struct commit_list *todo_list = NULL;
+     unsigned char sha1[20];
+
+     read_and_refresh_cache(me, opts);
+
+     walk_revs_populate_todo(&todo_list, opts);
+     create_seq_dir();
+     if (!get_sha1("HEAD", sha1))
+             persist_head(sha1_to_hex(sha1));
+     persist_todo(todo_list, opts);
Don't these two need forward declarations before their use?
Good catch.  I'm surprised the compiler didn't catch these.

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