mirror of
https://github.com/git/git.git
synced 2025-12-12 20:36:24 +01:00
treewide: pass strvecs around for setup_revisions_from_strvec()
The previous commit converted callers of setup_revisions() with a strvec to use the safer and easier _from_strvec() variant. Let's now convert spots that don't directly have a strvec, but receive an argc/argv pair that eventually comes from one. We'll instead pass the strvec down to the point where we call setup_revisions(). That makes these functions slightly less flexible if they were to grow other callers that don't use strvecs, but this rigidity is buying us some safety. It is only safe to pass the free_removed_argv_elements option to setup_revisions() if we know the elements of argv/argc are allocated on the heap. That isn't communicated in the type system when we are passed the bare elements. But if we get a strvec, we know that the elements are allocated strings. And at any rate, each of these modified functions has only a single caller (that has a strvec), so the loss of flexibility is unlikely to ever matter. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
b553332f82
commit
18068139f2
@@ -4650,7 +4650,7 @@ static void get_object_list_path_walk(struct rev_info *revs)
|
||||
die(_("failed to pack objects via path-walk"));
|
||||
}
|
||||
|
||||
static void get_object_list(struct rev_info *revs, int ac, const char **av)
|
||||
static void get_object_list(struct rev_info *revs, struct strvec *argv)
|
||||
{
|
||||
struct setup_revision_opt s_r_opt = {
|
||||
.allow_exclude_promisor_objects = 1,
|
||||
@@ -4660,7 +4660,7 @@ static void get_object_list(struct rev_info *revs, int ac, const char **av)
|
||||
int save_warning;
|
||||
|
||||
save_commit_buffer = 0;
|
||||
setup_revisions(ac, av, revs, &s_r_opt);
|
||||
setup_revisions_from_strvec(argv, revs, &s_r_opt);
|
||||
|
||||
/* make sure shallows are read */
|
||||
is_repository_shallow(the_repository);
|
||||
@@ -5229,7 +5229,7 @@ int cmd_pack_objects(int argc,
|
||||
revs.include_check = is_not_in_promisor_pack;
|
||||
revs.include_check_obj = is_not_in_promisor_pack_obj;
|
||||
}
|
||||
get_object_list(&revs, rp.nr, rp.v);
|
||||
get_object_list(&revs, &rp);
|
||||
release_revisions(&revs);
|
||||
}
|
||||
cleanup_preferred_base();
|
||||
|
||||
@@ -299,8 +299,7 @@ static int do_interactive_rebase(struct rebase_options *opts, unsigned flags)
|
||||
oid_to_hex(&opts->restrict_revision->object.oid));
|
||||
|
||||
ret = sequencer_make_script(the_repository, &todo_list.buf,
|
||||
make_script_args.nr, make_script_args.v,
|
||||
flags);
|
||||
&make_script_args, flags);
|
||||
if (ret) {
|
||||
error(_("could not generate todo list"));
|
||||
goto cleanup;
|
||||
|
||||
@@ -6063,8 +6063,8 @@ static int make_script_with_merges(struct pretty_print_context *pp,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sequencer_make_script(struct repository *r, struct strbuf *out, int argc,
|
||||
const char **argv, unsigned flags)
|
||||
int sequencer_make_script(struct repository *r, struct strbuf *out,
|
||||
struct strvec *argv, unsigned flags)
|
||||
{
|
||||
char *format = NULL;
|
||||
struct pretty_print_context pp = {0};
|
||||
@@ -6105,7 +6105,8 @@ int sequencer_make_script(struct repository *r, struct strbuf *out, int argc,
|
||||
pp.fmt = revs.commit_format;
|
||||
pp.output_encoding = get_log_output_encoding();
|
||||
|
||||
if (setup_revisions(argc, argv, &revs, NULL) > 1) {
|
||||
setup_revisions_from_strvec(argv, &revs, NULL);
|
||||
if (argv->nr > 1) {
|
||||
ret = error(_("make_script: unhandled options"));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
@@ -186,8 +186,8 @@ int sequencer_remove_state(struct replay_opts *opts);
|
||||
#define TODO_LIST_REAPPLY_CHERRY_PICKS (1U << 7)
|
||||
#define TODO_LIST_WARN_SKIPPED_CHERRY_PICKS (1U << 8)
|
||||
|
||||
int sequencer_make_script(struct repository *r, struct strbuf *out, int argc,
|
||||
const char **argv, unsigned flags);
|
||||
int sequencer_make_script(struct repository *r, struct strbuf *out,
|
||||
struct strvec *argv, unsigned flags);
|
||||
|
||||
int complete_action(struct repository *r, struct replay_opts *opts, unsigned flags,
|
||||
const char *shortrevisions, const char *onto_name,
|
||||
|
||||
@@ -213,7 +213,7 @@ static void show_commit(struct commit *commit, void *data)
|
||||
* are marked with shallow_flag. The list of border/shallow commits
|
||||
* are also returned.
|
||||
*/
|
||||
struct commit_list *get_shallow_commits_by_rev_list(int ac, const char **av,
|
||||
struct commit_list *get_shallow_commits_by_rev_list(struct strvec *argv,
|
||||
int shallow_flag,
|
||||
int not_shallow_flag)
|
||||
{
|
||||
@@ -232,7 +232,7 @@ struct commit_list *get_shallow_commits_by_rev_list(int ac, const char **av,
|
||||
|
||||
repo_init_revisions(the_repository, &revs, NULL);
|
||||
save_commit_buffer = 0;
|
||||
setup_revisions(ac, av, &revs, NULL);
|
||||
setup_revisions_from_strvec(argv, &revs, NULL);
|
||||
|
||||
if (prepare_revision_walk(&revs))
|
||||
die("revision walk setup failed");
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "strbuf.h"
|
||||
|
||||
struct oid_array;
|
||||
struct strvec;
|
||||
|
||||
void set_alternate_shallow_file(struct repository *r, const char *path, int override);
|
||||
int register_shallow(struct repository *r, const struct object_id *oid);
|
||||
@@ -36,8 +37,8 @@ void rollback_shallow_file(struct repository *r, struct shallow_lock *lk);
|
||||
|
||||
struct commit_list *get_shallow_commits(struct object_array *heads,
|
||||
int depth, int shallow_flag, int not_shallow_flag);
|
||||
struct commit_list *get_shallow_commits_by_rev_list(
|
||||
int ac, const char **av, int shallow_flag, int not_shallow_flag);
|
||||
struct commit_list *get_shallow_commits_by_rev_list(struct strvec *argv,
|
||||
int shallow_flag, int not_shallow_flag);
|
||||
int write_shallow_commits(struct strbuf *out, int use_pack_protocol,
|
||||
const struct oid_array *extra);
|
||||
|
||||
|
||||
@@ -914,13 +914,12 @@ static void deepen(struct upload_pack_data *data, int depth)
|
||||
}
|
||||
|
||||
static void deepen_by_rev_list(struct upload_pack_data *data,
|
||||
int ac,
|
||||
const char **av)
|
||||
struct strvec *argv)
|
||||
{
|
||||
struct commit_list *result;
|
||||
|
||||
disable_commit_graph(the_repository);
|
||||
result = get_shallow_commits_by_rev_list(ac, av, SHALLOW, NOT_SHALLOW);
|
||||
result = get_shallow_commits_by_rev_list(argv, SHALLOW, NOT_SHALLOW);
|
||||
send_shallow(data, result);
|
||||
free_commit_list(result);
|
||||
send_unshallow(data);
|
||||
@@ -956,7 +955,7 @@ static int send_shallow_list(struct upload_pack_data *data)
|
||||
struct object *o = data->want_obj.objects[i].item;
|
||||
strvec_push(&av, oid_to_hex(&o->oid));
|
||||
}
|
||||
deepen_by_rev_list(data, av.nr, av.v);
|
||||
deepen_by_rev_list(data, &av);
|
||||
strvec_clear(&av);
|
||||
ret = 1;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user