summaryrefslogtreecommitdiff
path: root/sequencer.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2018-07-09 19:48:19 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-07-11 15:37:47 (GMT)
commit8530c73915ab88b920411c6bbdf02ff4c396ca81 (patch)
treee01118e95d07d2c17b877b3bb2dc136413011e37 /sequencer.c
parenta42a58d7b62cc1d6301440e81a83feed9d7c118c (diff)
downloadgit-8530c73915ab88b920411c6bbdf02ff4c396ca81.zip
git-8530c73915ab88b920411c6bbdf02ff4c396ca81.tar.gz
git-8530c73915ab88b920411c6bbdf02ff4c396ca81.tar.bz2
sequencer: handle empty-set cases consistently
If the user gives us a set that prepare_revision_walk() takes to be empty, like: git cherry-pick base..base then we report an error. It's nonsense, and there's nothing to pick. But if they use revision options that later cull the list, like: git cherry-pick --author=nobody base~2..base then we quietly create an empty todo list and return success. Arguably either behavior is acceptable, but we should definitely be consistent about it. Reporting an error seems to match the original intent, which dates all the way back to 7e2bfd3f99 (revert: allow cherry-picking more than one commit, 2010-06-02). That in turn was trying to match the single-commit case that existed before then (and which continues to issue an error). Signed-off-by: Jeff King <peff@peff.net> Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sequencer.c')
-rw-r--r--sequencer.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/sequencer.c b/sequencer.c
index 4d3f605..7fbacc1 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -1176,8 +1176,6 @@ static int prepare_revs(struct replay_opts *opts)
if (prepare_revision_walk(opts->revs))
return error(_("revision walk setup failed"));
- if (!opts->revs->commits)
- return error(_("empty commit set passed"));
return 0;
}
@@ -1560,6 +1558,10 @@ static int walk_revs_populate_todo(struct todo_list *todo_list,
short_commit_name(commit), subject_len, subject);
unuse_commit_buffer(commit, commit_buffer);
}
+
+ if (!todo_list->nr)
+ return error(_("empty commit set passed"));
+
return 0;
}