revert: Make pick_commits functionally act on a commit list
commit21b14778a9b033d80b3e5757d9576da13ba446cd
authorRamkumar Ramachandra <artagnon@gmail.com>
Thu, 4 Aug 2011 10:39:10 +0000 (4 16:09 +0530)
committerJunio C Hamano <gitster@pobox.com>
Thu, 4 Aug 2011 22:40:45 +0000 (4 15:40 -0700)
tree84084078e031b9f6ff1b695a0a3ec69e3bfe08cc
parent6f0322633b2659d26d1c7b20d4af1fba33978690
revert: Make pick_commits functionally act on a commit list

Apart from its central objective of calling into the picking
mechanism, pick_commits creates a sequencer directory, prepares a todo
list, and even acts upon the "--reset" subcommand.  This makes for a
bad API since the central worry of callers is to figure out whether or
not any conflicts were encountered during the cherry picking.  The
current API is like:

  if (pick_commits(opts) < 0)
     print "Something failed, we're not sure what"

So, change pick_commits so that it's only responsible for picking
commits in a loop and reporting any errors, leaving the rest to a new
function called pick_revisions.  Consequently, the API of pick_commits
becomes much clearer:

  act_on_subcommand(opts->subcommand);
  todo_list = prepare_todo_list();
  if (pick_commits(todo_list, opts) < 0)
     print "Error encountered while picking commits"

Now, callers can easily call-in to the cherry-picking machinery by
constructing an arbitrary todo list along with some options.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/revert.c