Kill the_index part 5
v2 cover Kill the_index part 5
(Please ignore v1 which contains unrelated patches)
I lied about part 5 being final. This series contains most of my WIP series [2] except sha1-name.c, read-cache.c and merge-recursive.c because there will be conflicts on 'pu' so they will be in part 6. At least this only results in two small conflicts in sequencer.c.
I did start pushing the_repository out of library code [1] in the bottom half of this series. There aren't big surprises except that cache-tree API now take _both_ struct repository and struct index_state. The reason is cache-tree can work on temporary indexes and repo->index is about $GIT_DIR/index.
[1] Stefan and I make a good team. He keeps adding the_repository. I keep removing. We both hold hands leading commit counts (with Brian just a bit behind frantically replacing sha1 with oid to keep up). Meanwhile Junio is crying in the corner because of too many conflicts. :-D
[2] https://public-inbox.org/git/[email protected]/
Nguyễn Thái Ngọc Duy (22):
wt-status.c: remove implicit dependency on the_index wt-status.c: remove implicit dependency the_repository list-objects-filter.c: remove implicit dependency on the_index list-objects.c: reduce the_repository references notes-merge.c: remove implicit dependency on the_index notes-merge.c: remove implicit dependency the_repository transport.c: remove implicit dependency on the_index sequencer.c: remove implicit dependency on the_index sequencer.c: remove implicit dependency on the_repository blame.c: remove implicit dependency the_repository bisect.c: remove the_repository reference
branch.c: remove the_repository reference
bundle.c: remove the_repository references cache-tree.c: remove the_repository references delta-islands.c: remove the_repository references diff-lib.c: remove the_repository references line-log.c: remove the_repository reference notes-cache.c: remove the_repository references pack-check.c: remove the_repository references pack-*.c: remove the_repository references
rerere.c: remove the_repository references rebase-interactive.c: remove the_repository references
bisect.c | 48 ++-- bisect.h | 5 +- blame.c | 39 +-- branch.c | 21 +- branch.h | 8 +- builtin/am.c | 4 +- builtin/bisect--helper.c | 2 +- builtin/branch.c | 6 +- builtin/bundle.c | 7 +- builtin/checkout.c | 5 +- builtin/commit.c | 8 +- builtin/fsck.c | 3 +- builtin/merge-ours.c | 2 +- builtin/merge.c | 2 +- builtin/notes.c | 2 +- builtin/pack-objects.c | 6 +- builtin/pull.c | 3 +- builtin/push.c | 3 +- builtin/read-tree.c | 4 +- builtin/rebase--interactive.c | 19 +- builtin/rebase.c | 13 +- builtin/rerere.c | 10 +- builtin/reset.c | 4 +- builtin/revert.c | 8 +- bundle.c | 26 +- bundle.h | 9 +- cache-tree.c | 26 +- cache-tree.h | 4 +- combine-diff.c | 2 +- delta-islands.c | 24 +- delta-islands.h | 9 +- diff-lib.c | 7 +- diff.c | 12 +- diff.h | 5 +- diffcore-pickaxe.c | 4 +- grep.c | 2 +- line-log.c | 2 +- list-objects-filter.c | 10 +- list-objects-filter.h | 2 + list-objects.c | 13 +- notes-cache.c | 12 +- notes-cache.h | 6 +- notes-merge.c | 16 +- notes-merge.h | 5 +- pack-bitmap-write.c | 6 +- pack-bitmap.c | 13 +- pack-bitmap.h | 3 +- pack-check.c | 9 +- pack-objects.c | 6 +- pack-objects.h | 5 +- pack.h | 4 +- read-cache.c | 2 +- rebase-interactive.c | 6 +- rebase-interactive.h | 5 +- ref-filter.c | 2 +- rerere.c | 26 +- rerere.h | 6 +- sequencer.c | 453 +++++++++++++++++++--------------- sequencer.h | 27 +- transport.c | 9 +- transport.h | 3 +- unpack-trees.c | 2 +- userdiff.c | 5 +- userdiff.h | 4 +- wt-status.c | 94 ++++--- wt-status.h | 21 +- 66 files changed, 650 insertions(+), 489 deletions(-)
Signature · 1 line
2.19.1.1231.g84aef82467
PATCH v2 1/22 wt-status.c: remove implicit dependency on the_index
--- builtin/commit.c | 2 +- builtin/pull.c | 3 +- builtin/rebase.c | 7 +++-- sequencer.c | 8 ++--- wt-status.c | 76 +++++++++++++++++++++++++++--------------------- wt-status.h | 17 +++++++---- 6 files changed, 66 insertions(+), 47 deletions(-)
builtin/commit.c +1 -1
@@ -185,7 +185,7 @@ static void determine_whence(struct wt_status *s)static void status_init_config (struct wt_status *s,config_fn_t fn) { -wt_status_prepare (s); +wt_status_prepare (the_repository, s);init_diff_ui_defaults ();git_config (fn, s);determine_whence (s);
builtin/pull.c +2 -1
@@ -888,7 +888,8 @@ int cmd_pull(int argc, const char **argv, const char *prefix)die (_ ("Updating an unborn branch with changes added to the index." ));if (!autostash) -require_clean_work_tree (N_ ("pull with rebase" ), +require_clean_work_tree (the_repository, +N_ ("pull with rebase" ),_ ("please commit or stash them." ),1 ,0 );if (get_rebase_fork_point (&rebase_fork_point, repo, *refspecs))
builtin/rebase.c +4 -3
@@ -983,7 +983,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) &lock_file);rollback_lock_file (&lock_file); -if (has_unstaged_changes (1 )) { +if (has_unstaged_changes (the_repository,1 )) {puts (_ ("You must edit all merge conflicts and then\n" "mark them as resolved using git add" ));exit (1 );
@@ -1351,7 +1351,8 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)update_index_if_able (&the_index, &lock_file);rollback_lock_file (&lock_file); -if (has_unstaged_changes (1 ) ||has_uncommitted_changes (1 )) { +if (has_unstaged_changes (the_repository,1 ) || +has_uncommitted_changes (the_repository,1 )) {const char *autostash =state_dir_path ("autostash" , &options);struct child_process stash =CHILD_PROCESS_INIT ;
@@ -1397,7 +1398,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) } } -if (require_clean_work_tree ("rebase" , +if (require_clean_work_tree (the_repository,"rebase" ,_ ("Please commit or stash them." ),1 ,1 )) { ret =1 ; goto cleanup;
sequencer.c +4 -4
@@ -2773,7 +2773,7 @@ static int do_exec(const char *command_line)if (discard_cache () <0 ||read_cache () <0 )return error (_ ("could not read index" )); - dirty =require_clean_work_tree ("rebase" ,NULL ,1 ,1 ); + dirty =require_clean_work_tree (the_repository,"rebase" ,NULL ,1 ,1 );if (status) { warning(_("execution failed: %s\n%s"
@@ -3714,10 +3714,10 @@ static int commit_staged_changes(struct replay_opts *opts,unsigned int flags =ALLOW_EMPTY |EDIT_MSG ;unsigned int final_fixup =0 , is_clean; -if (has_unstaged_changes (1 )) +if (has_unstaged_changes (the_repository,1 ))return error (_ ("cannot rebase: You have unstaged changes." )); - is_clean = !has_uncommitted_changes (0 ); + is_clean = !has_uncommitted_changes (the_repository,0 );if (file_exists (rebase_path_amend ())) {struct strbuf rev =STRBUF_INIT ;
@@ -4847,7 +4847,7 @@ int complete_action(struct replay_opts *opts, unsigned flags,if (checkout_onto (opts, onto_name,oid_to_hex (&oid), orig_head))return -1 ; ; -if (require_clean_work_tree ("rebase" ,"" ,1 ,1 )) +if (require_clean_work_tree (the_repository,"rebase" ,"" ,1 ,1 ))return -1 ;return sequencer_continue (opts);
wt-status.c +43 -33
226 lines not on this page · raw message
wt-status.h +12 -5
@@ -7,6 +7,7 @@#include "pathspec.h" #include "remote.h" +struct repository ;struct worktree ;enum color_wt_status {
@@ -83,6 +84,7 @@ struct wt_status_state { };struct wt_status { +struct repository *repo;int is_initial;char *branch;const char *reference;
@@ -128,7 +130,7 @@ struct wt_status {size_t wt_status_locate_end (const char *s,size_t len);void wt_status_add_cut_line (FILE *fp); -void wt_status_prepare (struct wt_status *s); +void wt_status_prepare (struct repository *r,struct wt_status *s);void wt_status_print (struct wt_status *s);void wt_status_collect (struct wt_status *s);void wt_status_collect_free_buffers (struct wt_status *s);
@@ -144,9 +146,14 @@ __attribute__((format (printf, 3, 4)))void status_printf (struct wt_status *s,const char *color,const char *fmt, ...);/* The following functions expect that the caller took care of reading the index. */ -int has_unstaged_changes (int ignore_submodules); -int has_uncommitted_changes (int ignore_submodules); -int require_clean_work_tree (const char *action,const char *hint, -int ignore_submodules,int gently); +int has_unstaged_changes (struct repository *repo, +int ignore_submodules); +int has_uncommitted_changes (struct repository *repo, +int ignore_submodules); +int require_clean_work_tree (struct repository *repo, +const char *action, +const char *hint, +int ignore_submodules, +int gently);#endif /* STATUS_H */
Signature · 1 line
2.19.1.1231.g84aef82467
PATCH v2 2/22 wt-status.c: remove implicit dependency the_repository
In reply to Nguyễn Thái Ngọc Duy--- ref-filter.c | 2 +- wt-status.c | 18 ++++++++++-------- wt-status.h | 4 +++- 3 files changed, 14 insertions(+), 10 deletions(-)
ref-filter.c +1 -1
@@ -1413,7 +1413,7 @@ char *get_head_description(void)struct strbuf desc =STRBUF_INIT ;struct wt_status_state state;memset (&state,0 ,sizeof (state)); -wt_status_get_state (&state,1 ); +wt_status_get_state (the_repository, &state,1 );if (state.rebase_in_progress || state.rebase_interactive_in_progress) {if (state.branch)
wt-status.c +10 -8
@@ -755,7 +755,7 @@ void wt_status_collect(struct wt_status *s)wt_status_collect_changes_index (s);wt_status_collect_untracked (s); -wt_status_get_state (&s->state, s->branch && !strcmp (s->branch,"HEAD" )); +wt_status_get_state (s->repo, &s->state, s->branch && !strcmp (s->branch,"HEAD" ));if (s->state.merge_in_progress && !has_unmerged (s)) s->committable =1 ; }
@@ -1482,7 +1482,8 @@ static int grab_1st_switch(struct object_id *ooid, struct object_id *noid,return 1 ; } -static void wt_status_get_detached_from (struct wt_status_state *state) +static void wt_status_get_detached_from (struct repository *r, +struct wt_status_state *state) {struct grab_1st_switch_cbdata cb;struct commit *commit;
@@ -1499,7 +1500,7 @@ static void wt_status_get_detached_from(struct wt_status_state *state)/* sha1 is a commit? match without further lookup */ (oideq (&cb.noid, &oid) ||/* perhaps sha1 is a tag, try to dereference to a commit */ - ((commit =lookup_commit_reference_gently (the_repository, &oid,1 )) !=NULL && + ((commit =lookup_commit_reference_gently (r, &oid,1 )) !=NULL && oideq(&cb.noid, &commit->object.oid)))) { const char *from = ref;if (!skip_prefix (from,"refs/tags/" , &from))
@@ -1556,30 +1557,31 @@ int wt_status_check_bisect(const struct worktree *wt,return 0 ; } -void wt_status_get_state (struct wt_status_state *state, +void wt_status_get_state (struct repository *r, +struct wt_status_state *state,int get_detached_from) {struct stat st;struct object_id oid; -if (!stat (git_path_merge_head (the_repository), &st)) { +if (!stat (git_path_merge_head (r), &st)) { state->merge_in_progress =1 ; }else if (wt_status_check_rebase (NULL , state)) { ;/* all set */ - }else if (!stat (git_path_cherry_pick_head (the_repository), &st) && + }else if (!stat (git_path_cherry_pick_head (r), &st) && !get_oid ("CHERRY_PICK_HEAD" , &oid)) { state->cherry_pick_in_progress =1 ;oidcpy (&state->cherry_pick_head_oid, &oid); }wt_status_check_bisect (NULL , state); -if (!stat (git_path_revert_head (the_repository), &st) && +if (!stat (git_path_revert_head (r), &st) && !get_oid ("REVERT_HEAD" , &oid)) { state->revert_in_progress =1 ;oidcpy (&state->revert_head_oid, &oid); }if (get_detached_from) -wt_status_get_detached_from (state); +wt_status_get_detached_from (r, state); }static void wt_longstatus_print_state (struct wt_status *s)
wt-status.h +3 -1
@@ -134,7 +134,9 @@ void wt_status_prepare(struct repository *r, struct wt_status *s);void wt_status_print (struct wt_status *s);void wt_status_collect (struct wt_status *s);void wt_status_collect_free_buffers (struct wt_status *s); -void wt_status_get_state (struct wt_status_state *state,int get_detached_from); +void wt_status_get_state (struct repository *repo, +struct wt_status_state *state, +int get_detached_from);int wt_status_check_rebase (const struct worktree *wt,struct wt_status_state *state); int wt_status_check_bisect(const struct worktree *wt,
Signature · 1 line
2.19.1.1231.g84aef82467
PATCH v2 3/22 list-objects-filter.c: remove implicit dependency on the_index
In reply to Nguyễn Thái Ngọc DuyWhile at there, since we have access to struct repository now, eliminate the only the_repository reference in this file.
--- list-objects-filter.c | 10 +++++++--- list-objects-filter.h | 2 ++ list-objects.c | 9 ++++++--- 3 files changed, 15 insertions(+), 6 deletions(-)
list-objects-filter.c +7 -3
@@ -34,6 +34,7 @@ struct filter_blobs_none_data { }; static enum list_objects_filter_result filter_blobs_none( + struct repository *r, enum list_objects_filter_situation filter_situation, struct object *obj, const char *pathname,
@@ -88,6 +89,7 @@ struct filter_trees_none_data { }; static enum list_objects_filter_result filter_trees_none( + struct repository *r, enum list_objects_filter_situation filter_situation, struct object *obj, const char *pathname,
@@ -144,6 +146,7 @@ struct filter_blobs_limit_data { }; static enum list_objects_filter_result filter_blobs_limit( + struct repository *r, enum list_objects_filter_situation filter_situation, struct object *obj, const char *pathname,
@@ -171,7 +174,7 @@ static enum list_objects_filter_result filter_blobs_limit(assert (obj->type ==OBJ_BLOB );assert ((obj->flags &SEEN ) ==0 ); - t =oid_object_info (the_repository, &obj->oid, &object_length); + t =oid_object_info (r, &obj->oid, &object_length);if (t !=OBJ_BLOB ) {/* probably OBJ_NONE */ /* * We DO NOT have the blob locally, so we cannot
@@ -249,6 +252,7 @@ struct filter_sparse_data { }; static enum list_objects_filter_result filter_sparse( + struct repository *r, enum list_objects_filter_situation filter_situation, struct object *obj, const char *pathname,
@@ -268,7 +272,7 @@ static enum list_objects_filter_result filter_sparse( dtype =DT_DIR ; val =is_excluded_from_list (pathname,strlen (pathname), filename, &dtype, &filter_data->el, - &the_index); + r->index);if (val <0 ) val = filter_data->array_frame[filter_data->nr].defval;
@@ -331,7 +335,7 @@ static enum list_objects_filter_result filter_sparse( dtype =DT_REG ; val =is_excluded_from_list (pathname,strlen (pathname), filename, &dtype, &filter_data->el, - &the_index); + r->index);if (val <0 ) val = frame->defval;if (val >0 ) {
list-objects-filter.h +2 -0
@@ -4,6 +4,7 @@struct list_objects_filter_options ;struct object ;struct oidset ; +struct repository ;/* * During list-object traversal we allow certain objects to be
@@ -60,6 +61,7 @@ enum list_objects_filter_situation { }; typedef enum list_objects_filter_result (*filter_object_fn)( + struct repository *r, enum list_objects_filter_situation filter_situation, struct object *obj, const char *pathname,
list-objects.c +6 -3
@@ -55,7 +55,8 @@ static void process_blob(struct traversal_context *ctx, pathlen = path->len;strbuf_addstr (path, name);if ((obj->flags &NOT_USER_GIVEN ) && ctx->filter_fn) - r = ctx->filter_fn (LOFS_BLOB , obj, + r = ctx->filter_fn (ctx->revs->repo, +LOFS_BLOB , obj, path->buf, &path->buf[pathlen], ctx->filter_data);if (r &LOFR_MARK_SEEN )
@@ -175,7 +176,8 @@ static void process_tree(struct traversal_context *ctx,strbuf_addstr (base, name);if ((obj->flags &NOT_USER_GIVEN ) && ctx->filter_fn) - r = ctx->filter_fn (LOFS_BEGIN_TREE , obj, + r = ctx->filter_fn (ctx->revs->repo, +LOFS_BEGIN_TREE , obj, base->buf, &base->buf[baselen], ctx->filter_data);if (r &LOFR_MARK_SEEN )
@@ -191,7 +193,8 @@ static void process_tree(struct traversal_context *ctx,process_tree_contents (ctx, tree, base);if ((obj->flags &NOT_USER_GIVEN ) && ctx->filter_fn) { - r = ctx->filter_fn (LOFS_END_TREE , obj, + r = ctx->filter_fn (ctx->revs->repo, +LOFS_END_TREE , obj, base->buf, &base->buf[baselen], ctx->filter_data);if (r &LOFR_MARK_SEEN )
Signature · 1 line
2.19.1.1231.g84aef82467
PATCH v2 4/22 list-objects.c: reduce the_repository references
In reply to Nguyễn Thái Ngọc Duy--- list-objects.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
list-objects.c +2 -2
@@ -123,7 +123,7 @@ static void process_tree_contents(struct traversal_context *ctx, }if (S_ISDIR (entry.mode)) { -struct tree *t =lookup_tree (the_repository, entry.oid); +struct tree *t =lookup_tree (ctx->revs->repo, entry.oid); t->object.flags |=NOT_USER_GIVEN ;process_tree (ctx, t, base, entry.path); }
@@ -131,7 +131,7 @@ static void process_tree_contents(struct traversal_context *ctx,process_gitlink (ctx, entry.oid->hash, base, entry.path); else { -struct blob *b =lookup_blob (the_repository, entry.oid); +struct blob *b =lookup_blob (ctx->revs->repo, entry.oid); b->object.flags |=NOT_USER_GIVEN ;process_blob (ctx, b, base, entry.path); }
Signature · 1 line
2.19.1.1231.g84aef82467
PATCH v2 5/22 notes-merge.c: remove implicit dependency on the_index
In reply to Nguyễn Thái Ngọc Duy--- builtin/notes.c | 2 +- notes-merge.c | 12 +++++++----- notes-merge.h | 5 ++++- 3 files changed, 12 insertions(+), 7 deletions(-)
builtin/notes.c +1 -1
@@ -808,7 +808,7 @@ static int merge(int argc, const char **argv, const char *prefix)usage_with_options (git_notes_merge_usage, options); } -init_notes_merge_options (&o); +init_notes_merge_options (the_repository, &o); o.verbosity = verbosity +NOTES_MERGE_VERBOSITY_DEFAULT ;if (do_abort)
notes-merge.c +7 -5
@@ -18,11 +18,13 @@ struct notes_merge_pair {struct object_id obj, base, local, remote; }; -void init_notes_merge_options (struct notes_merge_options *o) +void init_notes_merge_options (struct repository *r, +struct notes_merge_options *o) {memset (o,0 ,sizeof (struct notes_merge_options ));strbuf_init (&(o->commit_msg),0 ); o->verbosity =NOTES_MERGE_VERBOSITY_DEFAULT ; + o->repo = r; }static int path_to_oid (const char *path,struct object_id *oid)
@@ -127,7 +129,7 @@ static struct notes_merge_pair *diff_tree_remote(struct notes_merge_options *o,trace_printf ("\tdiff_tree_remote(base = %.7s, remote = %.7s)\n" ,oid_to_hex (base),oid_to_hex (remote)); -repo_diff_setup (the_repository, &opt); +repo_diff_setup (o->repo, &opt); opt.flags.recursive =1 ; opt.output_format =DIFF_FORMAT_NO_OUTPUT ;diff_setup_done (&opt);
@@ -190,7 +192,7 @@ static void diff_tree_local(struct notes_merge_options *o,trace_printf ("\tdiff_tree_local(len = %i, base = %.7s, local = %.7s)\n" , len,oid_to_hex (base),oid_to_hex (local)); -repo_diff_setup (the_repository, &opt); +repo_diff_setup (o->repo, &opt); opt.flags.recursive =1 ; opt.output_format =DIFF_FORMAT_NO_OUTPUT ;diff_setup_done (&opt);
@@ -350,7 +352,7 @@ static int ll_merge_in_worktree(struct notes_merge_options *o, status =ll_merge (&result_buf,oid_to_hex (&p->obj), &base,NULL , &local, o->local_ref, &remote, o->remote_ref, - &the_index,NULL ); + o->repo->index,NULL );free (base.ptr);free (local.ptr);
@@ -711,7 +713,7 @@ int notes_merge_commit(struct notes_merge_options *o,/* write file as blob, and add to partial_tree */ if (stat (path.buf, &st))die_errno ("Failed to stat '%s'" , path.buf); -if (index_path (&the_index, &blob_oid, path.buf, &st,HASH_WRITE_OBJECT )) +if (index_path (o->repo->index, &blob_oid, path.buf, &st,HASH_WRITE_OBJECT ))die ("Failed to write blob object from '%s'" , path.buf);if (add_note (partial_tree, &obj_oid, &blob_oid,NULL )) die("Failed to add resolved note '%s' to notes tree",
notes-merge.h +4 -1
@@ -6,6 +6,7 @@struct commit ;struct object_id ; +struct repository ;#define NOTES_MERGE_WORKTREE "NOTES_MERGE_WORKTREE"
@@ -15,6 +16,7 @@ enum notes_merge_verbosity { };struct notes_merge_options { +struct repository *repo;const char *local_ref;const char *remote_ref;struct strbuf commit_msg;
@@ -23,7 +25,8 @@ struct notes_merge_options { unsigned has_worktree:1; }; -void init_notes_merge_options (struct notes_merge_options *o); +void init_notes_merge_options (struct repository *r, +struct notes_merge_options *o);/* * Merge notes from o->remote_ref into o->local_ref
Signature · 1 line
2.19.1.1231.g84aef82467
PATCH v2 6/22 notes-merge.c: remove implicit dependency the_repository
In reply to Nguyễn Thái Ngọc Duy--- notes-merge.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
notes-merge.c +2 -2
@@ -558,7 +558,7 @@ int notes_merge(struct notes_merge_options *o,else if (!check_refname_format (o->local_ref,0 ) &&is_null_oid (&local_oid)) local =NULL ;/* local_oid == null_oid indicates unborn ref */ -else if (!(local =lookup_commit_reference (the_repository, &local_oid))) +else if (!(local =lookup_commit_reference (o->repo, &local_oid)))die ("Could not parse local commit %s (%s)" ,oid_to_hex (&local_oid), o->local_ref);trace_printf ("\tlocal commit: %.7s\n" ,oid_to_hex (&local_oid));
@@ -576,7 +576,7 @@ int notes_merge(struct notes_merge_options *o,die ("Failed to resolve remote notes ref '%s'" , o->remote_ref); } - }else if (!(remote =lookup_commit_reference (the_repository, &remote_oid))) { + }else if (!(remote =lookup_commit_reference (o->repo, &remote_oid))) {die ("Could not parse remote commit %s (%s)" ,oid_to_hex (&remote_oid), o->remote_ref); }
Signature · 1 line
2.19.1.1231.g84aef82467
PATCH v2 7/22 transport.c: remove implicit dependency on the_index
In reply to Nguyễn Thái Ngọc Duynote, there's still another hidden dependency related to this: even though we pass a repo to transport_push() we still use is_bare_repository() which pretty much assumes the_repository (and some other global state).
--- builtin/push.c | 3 ++- transport.c | 7 ++++--- transport.h | 3 ++- 3 files changed, 8 insertions(+), 5 deletions(-)
builtin/push.c +2 -1
@@ -355,7 +355,8 @@ static int push_with_options(struct transport *transport, struct refspec *rs,if (verbosity >0 )fprintf (stderr,_ ("Pushing to %s\n" ), transport->url); - err =transport_push (transport, rs, flags, &reject_reasons); + err =transport_push (the_repository, transport, + rs, flags, &reject_reasons);if (err !=0 ) {fprintf (stderr,"%s" ,push_get_color (PUSH_COLOR_ERROR ));error (_ ("failed to push some refs to '%s'" ), transport->url);
transport.c +4 -3
@@ -1105,7 +1105,8 @@ static int run_pre_push_hook(struct transport *transport,return ret; } -int transport_push (struct transport *transport, +int transport_push (struct repository *r, +struct transport *transport,struct refspec *rs,int flags,unsigned int *reject_reasons) {
@@ -1172,7 +1173,7 @@ int transport_push(struct transport *transport,oid_array_append (&commits, &ref->new_oid); - if (!push_unpushed_submodules(the_repository, + if (!push_unpushed_submodules(r, &commits, transport->remote, rs,
@@ -1197,7 +1198,7 @@ int transport_push(struct transport *transport,oid_array_append (&commits, &ref->new_oid); -if (find_unpushed_submodules (the_repository, +if (find_unpushed_submodules (r, &commits, transport->remote->name, &needs_pushing)) {
transport.h +2 -1
@@ -223,7 +223,8 @@ void transport_set_verbosity(struct transport *transport, int verbosity,#define REJECT_FETCH_FIRST 0x08#define REJECT_NEEDS_FORCE 0x10 -int transport_push (struct transport *connection, +int transport_push (struct repository *repo, +struct transport *connection,struct refspec *rs,int flags,unsigned int * reject_reasons);
Signature · 1 line
2.19.1.1231.g84aef82467
PATCH v2 8/22 sequencer.c: remove implicit dependency on the_index
In reply to Nguyễn Thái Ngọc DuySince we're going to pass 'struct repository *' around most of the time instead of 'struct index_state *' because most sequencer.c operations need more than just the index, the_repository is replaced as well in the functions that now take 'struct repository *'. the_repository is still present in this file, but total clean up will be done later. It's not the main focus of this patch.
--- builtin/commit.c | 3 +- builtin/merge.c | 2 +- builtin/rebase--interactive.c | 4 +- builtin/revert.c | 4 +- sequencer.c | 321 +++++++++++++++++++--------------- sequencer.h | 15 +- 6 files changed, 197 insertions(+), 152 deletions(-)
builtin/commit.c +2 -1
@@ -1679,7 +1679,8 @@ int cmd_commit(int argc, const char **argv, const char *prefix) flags |=SUMMARY_INITIAL_COMMIT ;if (author_date_is_interesting ()) flags |=SUMMARY_SHOW_AUTHOR_DATE ; -print_commit_summary (prefix, &oid, flags); +print_commit_summary (the_repository, prefix, + &oid, flags); }UNLEAK (err);
builtin/merge.c +1 -1
@@ -896,7 +896,7 @@ static int suggest_conflicts(void) filename =git_path_merge_msg (the_repository); fp =xfopen (filename,"a" ); -append_conflicts_hint (&msgbuf); +append_conflicts_hint (&the_index, &msgbuf);fputs (msgbuf.buf, fp);strbuf_release (&msgbuf);fclose (fp);
builtin/rebase--interactive.c +2 -2
@@ -105,7 +105,7 @@ static int do_interactive_rebase(struct replay_opts *opts, unsigned flags,if (restrict_revision)argv_array_push (&make_script_args, restrict_revision); - ret =sequencer_make_script (todo_list, + ret =sequencer_make_script (the_repository, todo_list, make_script_args.argc, make_script_args.argv, flags);fclose (todo_list);
@@ -235,7 +235,7 @@ int cmd_rebase__interactive(int argc, const char **argv, const char *prefix)rerere_clear (&merge_rr);/* fallthrough */ case CONTINUE : - ret =sequencer_continue (&opts); + ret =sequencer_continue (the_repository, &opts);break ; }case EDIT_TODO :
builtin/revert.c +2 -2
@@ -199,10 +199,10 @@ static int run_sequencer(int argc, const char **argv, struct replay_opts *opts)return ret; }if (cmd =='c' ) -return sequencer_continue (opts); +return sequencer_continue (the_repository, opts);if (cmd =='a' )return sequencer_rollback (opts); -return sequencer_pick_revisions (opts); +return sequencer_pick_revisions (the_repository, opts); }int cmd_revert (int argc,const char **argv,const char *prefix)
sequencer.c +180 -141
909 lines not on this page · raw message
sequencer.h +10 -5
@@ -5,6 +5,7 @@#include "strbuf.h" struct commit ; +struct repository ;const char *git_path_commit_editmsg (void );const char *git_path_seq_dir (void );
@@ -74,8 +75,9 @@ int write_message(const void *buf, size_t len, const char *filename,/* Call this to setup defaults before parsing command line options */ void sequencer_init_config (struct replay_opts *opts); -int sequencer_pick_revisions (struct replay_opts *opts); -int sequencer_continue (struct replay_opts *opts); +int sequencer_pick_revisions (struct repository *repo, +struct replay_opts *opts); +int sequencer_continue (struct repository *repo,struct replay_opts *opts);int sequencer_rollback (struct replay_opts *opts);int sequencer_remove_state (struct replay_opts *opts);
@@ -89,7 +91,8 @@ int sequencer_remove_state(struct replay_opts *opts);* commits should be rebased onto the new base, this flag needs to be passed. */ #define TODO_LIST_REBASE_COUSINS (1U << 4) -int sequencer_make_script (FILE *out,int argc,const char **argv, +int sequencer_make_script (struct repository *repo,FILE *out, +int argc,const char **argv,unsigned flags);int sequencer_add_exec_commands (const char *command);
@@ -112,7 +115,7 @@ extern const char sign_off_header[];*/ void append_signoff (struct strbuf *msgbuf,size_t ignore_footer,unsigned flag); -void append_conflicts_hint (struct strbuf *msgbuf); +void append_conflicts_hint (struct index_state *istate,struct strbuf *msgbuf);int message_is_empty (const struct strbuf *sb,enum commit_msg_cleanup_mode cleanup_mode); int template_untouched(const struct strbuf *sb, const char *template_file,
@@ -128,7 +131,9 @@ int prepare_branch_to_be_rebased(struct replay_opts *opts, const char *commit);#define SUMMARY_INITIAL_COMMIT (1 << 0)#define SUMMARY_SHOW_AUTHOR_DATE (1 << 1) -void print_commit_summary (const char *prefix,const struct object_id *oid, +void print_commit_summary (struct repository *repo, +const char *prefix, +const struct object_id *oid,unsigned int flags);#endif
Signature · 1 line
2.19.1.1231.g84aef82467
PATCH v2 9/22 sequencer.c: remove implicit dependency on the_repository
In reply to Nguyễn Thái Ngọc DuyNote that the_hash_algo stays, even if we can easily replace it with repo->hash_algo. My reason is I still believe tying hash_algo to a struct repository is a wrong move. But if I'm wrong, we can always go for another round of conversion.
--- builtin/rebase--interactive.c | 11 +-- builtin/revert.c | 2 +- rebase-interactive.c | 4 +- sequencer.c | 134 ++++++++++++++++++---------------- sequencer.h | 12 +-- 5 files changed, 86 insertions(+), 77 deletions(-)
builtin/rebase--interactive.c +6 -5
@@ -114,7 +114,8 @@ static int do_interactive_rebase(struct replay_opts *opts, unsigned flags,error (_ ("could not generate todo list" )); else {discard_cache (); - ret =complete_action (opts, flags, shortrevisions, onto_name, onto, + ret =complete_action (the_repository, opts, flags, + shortrevisions, onto_name, onto, head_hash, cmd, autosquash); }
@@ -252,16 +253,16 @@ int cmd_rebase__interactive(int argc, const char **argv, const char *prefix) }case SHORTEN_OIDS :case EXPAND_OIDS : - ret =transform_todos (flags); + ret =transform_todos (the_repository, flags);break ;case CHECK_TODO_LIST : - ret =check_todo_list (); + ret =check_todo_list (the_repository);break ;case REARRANGE_SQUASH : - ret =rearrange_squash (); + ret =rearrange_squash (the_repository);break ;case ADD_EXEC : - ret =sequencer_add_exec_commands (cmd); + ret =sequencer_add_exec_commands (the_repository, cmd);break ;default :BUG ("invalid command '%d'" , command);
builtin/revert.c +1 -1
@@ -201,7 +201,7 @@ static int run_sequencer(int argc, const char **argv, struct replay_opts *opts)if (cmd =='c' )return sequencer_continue (the_repository, opts);if (cmd =='a' ) -return sequencer_rollback (opts); +return sequencer_rollback (the_repository, opts);return sequencer_pick_revisions (the_repository, opts); }
rebase-interactive.c +2 -2
@@ -69,7 +69,7 @@ int edit_todo_list(unsigned flags)strbuf_release (&buf); -transform_todos (flags |TODO_LIST_SHORTEN_IDS ); +transform_todos (the_repository, flags |TODO_LIST_SHORTEN_IDS );if (strbuf_read_file (&buf, todo_file,0 ) <0 )return error_errno (_ ("could not read '%s'." ), todo_file);
@@ -85,7 +85,7 @@ int edit_todo_list(unsigned flags)if (launch_sequence_editor (todo_file,NULL ,NULL ))return -1 ; -transform_todos (flags & ~(TODO_LIST_SHORTEN_IDS )); +transform_todos (the_repository, flags & ~(TODO_LIST_SHORTEN_IDS ));return 0 ; }
sequencer.c +71 -63
445 lines not on this page · raw message
sequencer.h +6 -6
@@ -78,7 +78,7 @@ void sequencer_init_config(struct replay_opts *opts);int sequencer_pick_revisions (struct repository *repo,struct replay_opts *opts);int sequencer_continue (struct repository *repo,struct replay_opts *opts); -int sequencer_rollback (struct replay_opts *opts); +int sequencer_rollback (struct repository *repo,struct replay_opts *opts);int sequencer_remove_state (struct replay_opts *opts);#define TODO_LIST_KEEP_EMPTY (1U << 0)
@@ -95,15 +95,15 @@ int sequencer_make_script(struct repository *repo, FILE *out, int argc, const char **argv, unsigned flags); -int sequencer_add_exec_commands (const char *command); -int transform_todos (unsigned flags); +int sequencer_add_exec_commands (struct repository *r,const char *command); +int transform_todos (struct repository *r,unsigned flags);enum missing_commit_check_level get_missing_commit_check_level (void ); -int check_todo_list (void ); -int complete_action (struct replay_opts *opts,unsigned flags, +int check_todo_list (struct repository *r); +int complete_action (struct repository *r,struct replay_opts *opts,unsigned flags,const char *shortrevisions,const char *onto_name,const char *onto,const char *orig_head,const char *cmd,unsigned autosquash); -int rearrange_squash (void ); +int rearrange_squash (struct repository *r);extern const char sign_off_header[];
Signature · 1 line
2.19.1.1231.g84aef82467
PATCH v2 10/22 blame.c: remove implicit dependency the_repository
In reply to Nguyễn Thái Ngọc Duy--- blame.c | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-)
blame.c +22 -17
@@ -116,35 +116,38 @@ static void verify_working_tree_path(struct repository *r,die ("no such path '%s' in HEAD" , path); } -static struct commit_list **append_parent (struct commit_list **tail,const struct object_id *oid) +static struct commit_list **append_parent (struct repository *r, +struct commit_list **tail, +const struct object_id *oid) {struct commit *parent; - parent =lookup_commit_reference (the_repository, oid); + parent =lookup_commit_reference (r, oid);if (!parent)die ("no such commit %s" ,oid_to_hex (oid));return &commit_list_insert (parent, tail)->next; } -static void append_merge_parents (struct commit_list **tail) +static void append_merge_parents (struct repository *r, +struct commit_list **tail) {int merge_head;struct strbuf line =STRBUF_INIT ; - merge_head =open (git_path_merge_head (the_repository),O_RDONLY ); + merge_head =open (git_path_merge_head (r),O_RDONLY );if (merge_head <0 ) {if (errno ==ENOENT )return ;die ("cannot open '%s' for reading" , -git_path_merge_head (the_repository)); +git_path_merge_head (r)); }while (!strbuf_getwholeline_fd (&line, merge_head,'\n' )) {struct object_id oid;if (line.len <GIT_SHA1_HEXSZ ||get_oid_hex (line.buf, &oid))die ("unknown line in '%s': %s" , -git_path_merge_head (the_repository), line.buf); - tail =append_parent (tail, &oid); +git_path_merge_head (r), line.buf); + tail =append_parent (r, tail, &oid); }close (merge_head);strbuf_release (&line);
@@ -155,11 +158,13 @@ static void append_merge_parents(struct commit_list **tail)* want to transfer ownership of the buffer to the commit (so we * must use detach). */ -static void set_commit_buffer_from_strbuf (struct commit *c,struct strbuf *sb) +static void set_commit_buffer_from_strbuf (struct repository *r, +struct commit *c, +struct strbuf *sb) {size_t len;void *buf =strbuf_detach (sb, &len); -set_commit_buffer (the_repository, c, buf, len); +set_commit_buffer (r, c, buf, len); }/*
@@ -185,7 +190,7 @@ static struct commit *fake_working_tree_commit(struct repository *r,read_index (r->index);time (&now); - commit =alloc_commit_node (the_repository); + commit =alloc_commit_node (r); commit->object.parsed =1 ; commit->date = now; parent_tail = &commit->parents;
@@ -193,8 +198,8 @@ static struct commit *fake_working_tree_commit(struct repository *r,if (!resolve_ref_unsafe ("HEAD" ,RESOLVE_REF_READING , &head_oid,NULL ))die ("no such ref: HEAD" ); - parent_tail =append_parent (parent_tail, &head_oid); -append_merge_parents (parent_tail); + parent_tail =append_parent (r, parent_tail, &head_oid); +append_merge_parents (r, parent_tail);verify_working_tree_path (r, commit, path); origin =make_origin (commit, path);
@@ -211,7 +216,7 @@ static struct commit *fake_working_tree_commit(struct repository *r, ident, ident, path, (!contents_from ? path : (!strcmp(contents_from, "-") ? "standard input" : contents_from))); -set_commit_buffer_from_strbuf (commit, &msg); +set_commit_buffer_from_strbuf (r, commit, &msg);if (!contents_from ||strcmp ("-" , contents_from)) {struct stat st;
@@ -1678,7 +1683,7 @@ static struct commit *find_single_final(struct rev_info *revs,struct object *obj = revs->pending.objects[i].item;if (obj->flags &UNINTERESTING )continue ; - obj =deref_tag (the_repository, obj,NULL ,0 ); + obj =deref_tag (revs->repo, obj,NULL ,0 );if (obj->type !=OBJ_COMMIT )die ("Non commit %s?" , revs->pending.objects[i].name);if (found)
@@ -1709,14 +1714,14 @@ static struct commit *dwim_reverse_initial(struct rev_info *revs,/* Is that sole rev a committish? */ obj = revs->pending.objects[0 ].item; - obj =deref_tag (the_repository, obj,NULL ,0 ); + obj =deref_tag (revs->repo, obj,NULL ,0 );if (obj->type !=OBJ_COMMIT )return NULL ;/* Do we have HEAD? */ if (!resolve_ref_unsafe ("HEAD" ,RESOLVE_REF_READING , &head_oid,NULL ))return NULL ; - head_commit =lookup_commit_reference_gently (the_repository, + head_commit =lookup_commit_reference_gently (revs->repo, &head_oid,1 );if (!head_commit)return NULL ;
@@ -1745,7 +1750,7 @@ static struct commit *find_single_initial(struct rev_info *revs,struct object *obj = revs->pending.objects[i].item;if (!(obj->flags &UNINTERESTING ))continue ; - obj =deref_tag (the_repository, obj,NULL ,0 ); + obj =deref_tag (revs->repo, obj,NULL ,0 );if (obj->type !=OBJ_COMMIT )die ("Non commit %s?" , revs->pending.objects[i].name);if (found)
Signature · 1 line
2.19.1.1231.g84aef82467
PATCH v2 11/22 bisect.c: remove the_repository reference
In reply to Nguyễn Thái Ngọc Duy--- bisect.c | 48 +++++++++++++++++++++++----------------- bisect.h | 5 ++++- builtin/bisect--helper.c | 2 +- 3 files changed, 33 insertions(+), 22 deletions(-)
bisect.c +28 -20
@@ -626,14 +626,15 @@ static struct commit_list *managed_skipped(struct commit_list *list,return skip_away (list, count); } -static void bisect_rev_setup (struct rev_info *revs,const char *prefix, +static void bisect_rev_setup (struct repository *r,struct rev_info *revs, +const char *prefix,const char *bad_format,const char *good_format,int read_paths) {struct argv_array rev_argv =ARGV_ARRAY_INIT ;int i; -repo_init_revisions (the_repository, revs, prefix); +repo_init_revisions (r, revs, prefix); revs->abbrev =0 ; revs->commit_format =CMIT_FMT_UNSPECIFIED ;
@@ -723,23 +724,25 @@ static int bisect_checkout(const struct object_id *bisect_rev, int no_checkout)return run_command_v_opt (argv_show_branch,RUN_GIT_CMD ); } -static struct commit *get_commit_reference (const struct object_id *oid) +static struct commit *get_commit_reference (struct repository *r, +const struct object_id *oid) { -struct commit *r =lookup_commit_reference (the_repository, oid); -if (!r) +struct commit *c =lookup_commit_reference (r, oid); +if (!c)die (_ ("Not a valid commit name %s" ),oid_to_hex (oid)); -return r; +return c; } -static struct commit **get_bad_and_good_commits (int *rev_nr) +static struct commit **get_bad_and_good_commits (struct repository *r, +int *rev_nr) {struct commit **rev;int i, n =0 ;ALLOC_ARRAY (rev,1 + good_revs.nr); - rev[n++] =get_commit_reference (current_bad_oid); + rev[n++] =get_commit_reference (r, current_bad_oid);for (i =0 ; i < good_revs.nr; i++) - rev[n++] =get_commit_reference (good_revs.oid + i); + rev[n++] =get_commit_reference (r, good_revs.oid + i); *rev_nr = n;return rev;
@@ -823,12 +826,13 @@ static void check_merge_bases(int rev_nr, struct commit **rev, int no_checkout)free_commit_list (result); } -static int check_ancestors (int rev_nr,struct commit **rev,const char *prefix) +static int check_ancestors (struct repository *r,int rev_nr, +struct commit **rev,const char *prefix) {struct rev_info revs;int res; -bisect_rev_setup (&revs, prefix,"^%s" ,"%s" ,0 ); +bisect_rev_setup (r, &revs, prefix,"^%s" ,"%s" ,0 );bisect_common (&revs); res = (revs.commits !=NULL );
@@ -847,7 +851,9 @@ static int check_ancestors(int rev_nr, struct commit **rev, const char *prefix)* If a merge base must be tested by the user, its source code will be * checked out to be tested by the user and we will exit. */ -static void check_good_are_ancestors_of_bad (const char *prefix,int no_checkout) +static void check_good_are_ancestors_of_bad (struct repository *r, +const char *prefix, +int no_checkout) {char *filename =git_pathdup ("BISECT_ANCESTORS_OK" );struct stat st;
@@ -866,8 +872,8 @@ static void check_good_are_ancestors_of_bad(const char *prefix, int no_checkout) goto done;/* Check if all good revs are ancestor of the bad rev. */ - rev =get_bad_and_good_commits (&rev_nr); -if (check_ancestors (rev_nr, rev, prefix)) + rev =get_bad_and_good_commits (r, &rev_nr); +if (check_ancestors (r, rev_nr, rev, prefix))check_merge_bases (rev_nr, rev, no_checkout);free (rev);
@@ -885,12 +891,14 @@ static void check_good_are_ancestors_of_bad(const char *prefix, int no_checkout)/* * This does "git diff-tree --pretty COMMIT" without one fork+exec. */ -static void show_diff_tree (const char *prefix,struct commit *commit) +static void show_diff_tree (struct repository *r, +const char *prefix, +struct commit *commit) {struct rev_info opt;/* diff-tree init */ -repo_init_revisions (the_repository, &opt, prefix); +repo_init_revisions (r, &opt, prefix);git_config (git_diff_basic_config,NULL );/* no "diff" UI options */ opt.abbrev =0 ; opt.diff =1 ;
@@ -945,7 +953,7 @@ void read_bisect_terms(const char **read_bad, const char **read_good)* If no_checkout is non-zero, the bisection process does not * checkout the trial commit but instead simply updates BISECT_HEAD. */ -int bisect_next_all (const char *prefix,int no_checkout) +int bisect_next_all (struct repository *r,const char *prefix,int no_checkout) {struct rev_info revs;struct commit_list *tried;
@@ -957,9 +965,9 @@ int bisect_next_all(const char *prefix, int no_checkout)if (read_bisect_refs ())die (_ ("reading bisect refs failed" )); -check_good_are_ancestors_of_bad (prefix, no_checkout); +check_good_are_ancestors_of_bad (r, prefix, no_checkout); -bisect_rev_setup (&revs, prefix,"%s" ,"^%s" ,1 ); +bisect_rev_setup (r, &revs, prefix,"%s" ,"^%s" ,1 ); revs.limited =1 ;bisect_common (&revs);
@@ -993,7 +1001,7 @@ int bisect_next_all(const char *prefix, int no_checkout)exit_if_skipped_commits (tried, current_bad_oid);printf ("%s is the first %s commit\n" ,oid_to_hex (bisect_rev), term_bad); -show_diff_tree (prefix, revs.commits->item); +show_diff_tree (r, prefix, revs.commits->item);/* This means the bisection process succeeded. */ exit (10 ); }
bisect.h +4 -1
@@ -2,6 +2,7 @@#define BISECT_H struct commit_list ; +struct repository ;/* * Find bisection. If something is found, `reaches` will be the number of
@@ -30,7 +31,9 @@ struct rev_list_info {const char *header_prefix; }; -extern int bisect_next_all (const char *prefix,int no_checkout); +extern int bisect_next_all (struct repository *r, +const char *prefix, +int no_checkout);extern int estimate_bisect_steps (int all);
builtin/bisect--helper.c +1 -1
@@ -137,7 +137,7 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)switch (cmdmode) {case NEXT_ALL : -return bisect_next_all (prefix, no_checkout); +return bisect_next_all (the_repository, prefix, no_checkout);case WRITE_TERMS :if (argc !=2 )return error (_ ("--write-terms requires two arguments" ));
Signature · 1 line
2.19.1.1231.g84aef82467
PATCH v2 12/22 branch.c: remove the_repository reference
In reply to Nguyễn Thái Ngọc Duy--- branch.c | 21 +++++++++++---------- branch.h | 8 ++++++-- builtin/am.c | 2 +- builtin/branch.c | 6 ++++-- builtin/checkout.c | 5 +++-- builtin/reset.c | 2 +- builtin/revert.c | 2 +- 7 files changed, 27 insertions(+), 19 deletions(-)
branch.c +11 -10
@@ -242,7 +242,8 @@ N_("\n""will track its remote counterpart, you may want to use\n" "\"git push -u\" to set the upstream config as you push."); -void create_branch (const char *name,const char *start_name, +void create_branch (struct repository *r, +const char *name,const char *start_name,int force,int clobber_head_ok,int reflog,int quiet,enum branch_track track) {
@@ -300,7 +301,7 @@ void create_branch(const char *name, const char *start_name,break ; } -if ((commit =lookup_commit_reference (the_repository, &oid)) ==NULL ) +if ((commit =lookup_commit_reference (r, &oid)) ==NULL )die (_ ("Not a valid branch point: '%s'." ), start_name);oidcpy (&oid, &commit->object.oid);
@@ -336,15 +337,15 @@ void create_branch(const char *name, const char *start_name,free (real_ref); } -void remove_branch_state (void ) +void remove_branch_state (struct repository *r) { -unlink (git_path_cherry_pick_head (the_repository)); -unlink (git_path_revert_head (the_repository)); -unlink (git_path_merge_head (the_repository)); -unlink (git_path_merge_rr (the_repository)); -unlink (git_path_merge_msg (the_repository)); -unlink (git_path_merge_mode (the_repository)); -unlink (git_path_squash_msg (the_repository)); +unlink (git_path_cherry_pick_head (r)); +unlink (git_path_revert_head (r)); +unlink (git_path_merge_head (r)); +unlink (git_path_merge_rr (r)); +unlink (git_path_merge_msg (r)); +unlink (git_path_merge_mode (r)); +unlink (git_path_squash_msg (r)); }void die_if_checked_out (const char *branch,int ignore_current_worktree)
branch.h +6 -2
@@ -1,6 +1,7 @@#ifndef BRANCH_H #define BRANCH_H +struct repository ;struct strbuf ; enum branch_track {
@@ -19,6 +20,8 @@ extern enum branch_track git_branch_track;/* * Creates a new branch, where: * +* - r is the repository to add a branch to +* * - name is the new branch name * * - start_name is the name of the existing branch that the new branch should
@@ -37,7 +40,8 @@ extern enum branch_track git_branch_track;* that start_name is a tracking branch for (if any). * */ -void create_branch (const char *name,const char *start_name, +void create_branch (struct repository *r, +const char *name,const char *start_name,int force,int clobber_head_ok,int reflog,int quiet,enum branch_track track);
@@ -60,7 +64,7 @@ extern int validate_new_branchname(const char *name, struct strbuf *ref, int for* Remove information about the state of working on the current * branch. (E.g., MERGE_HEAD) */ -void remove_branch_state (void ); +void remove_branch_state (struct repository *r);/* * Configure local branch "local" as downstream to branch "remote"
builtin/am.c +1 -1
@@ -2022,7 +2022,7 @@ static int clean_index(const struct object_id *head, const struct object_id *remif (merge_tree (remote_tree))return -1 ; -remove_branch_state (); +remove_branch_state (the_repository);return 0 ; }
builtin/branch.c +4 -2
@@ -783,7 +783,8 @@ int cmd_branch(int argc, const char **argv, const char *prefix)* create_branch takes care of setting up the tracking * info and making sure new_upstream is correct */ -create_branch (branch->name, new_upstream,0 ,0 ,0 , quiet,BRANCH_TRACK_OVERRIDE ); +create_branch (the_repository, branch->name, new_upstream, +0 ,0 ,0 , quiet,BRANCH_TRACK_OVERRIDE ); }else if (unset_upstream) {struct branch *branch =branch_get (argv[0 ]);struct strbuf buf =STRBUF_INIT ;
@@ -814,7 +815,8 @@ int cmd_branch(int argc, const char **argv, const char *prefix)if (track ==BRANCH_TRACK_OVERRIDE )die (_ ("the '--set-upstream' option is no longer supported. Please use '--track' or '--set-upstream-to' instead." )); -create_branch (argv[0 ], (argc ==2 ) ? argv[1 ] : head, +create_branch (the_repository, + argv[0 ], (argc ==2 ) ? argv[1 ] : head, force,0 , reflog, quiet, track); }else
builtin/checkout.c +3 -2
@@ -753,7 +753,8 @@ static void update_refs_for_switch(const struct checkout_opts *opts,free (refname); }else - create_branch(opts->new_branch, new_branch_info->name, + create_branch(the_repository, + opts->new_branch, new_branch_info->name, opts->new_branch_force ? 1 : 0, opts->new_branch_force ? 1 : 0, opts->new_branch_log,
@@ -811,7 +812,7 @@ static void update_refs_for_switch(const struct checkout_opts *opts,delete_reflog (old_branch_info->path); } } -remove_branch_state (); +remove_branch_state (the_repository);strbuf_release (&msg);if (!opts->quiet && (new_branch_info->path || (!opts->force_detach && !strcmp (new_branch_info->name,"HEAD" ))))
builtin/reset.c +1 -1
@@ -400,7 +400,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)print_new_head_line (lookup_commit_reference (the_repository, &oid)); }if (!pathspec.nr) -remove_branch_state (); +remove_branch_state (the_repository);return update_ref_status; }
builtin/revert.c +1 -1
@@ -195,7 +195,7 @@ static int run_sequencer(int argc, const char **argv, struct replay_opts *opts)if (cmd =='q' ) {int ret =sequencer_remove_state (opts);if (!ret) -remove_branch_state (); +remove_branch_state (the_repository);return ret; }if (cmd =='c' )
Signature · 1 line
2.19.1.1231.g84aef82467
PATCH v2 13/22 bundle.c: remove the_repository references
In reply to Nguyễn Thái Ngọc Duy--- builtin/bundle.c | 7 ++++--- bundle.c | 26 ++++++++++++++------------ bundle.h | 9 +++++---- transport.c | 2 +- 4 files changed, 24 insertions(+), 20 deletions(-)
builtin/bundle.c +4 -3
@@ -40,7 +40,7 @@ int cmd_bundle(int argc, const char **argv, const char *prefix)usage (builtin_bundle_usage);return 1 ; } -if (verify_bundle (&header,1 )) +if (verify_bundle (the_repository, &header,1 ))return 1 ;fprintf (stderr,_ ("%s is okay\n" ), bundle_file);return 0 ;
@@ -56,11 +56,12 @@ int cmd_bundle(int argc, const char **argv, const char *prefix) }if (!startup_info->have_repository)die (_ ("Need a repository to create a bundle." )); -return !!create_bundle (&header, bundle_file, argc, argv); +return !!create_bundle (the_repository, &header, + bundle_file, argc, argv); }else if (!strcmp (cmd,"unbundle" )) {if (!startup_info->have_repository)die (_ ("Need a repository to unbundle." )); -return !!unbundle (&header, bundle_fd,0 ) || +return !!unbundle (the_repository, &header, bundle_fd,0 ) ||list_bundle_refs (&header, argc, argv); }else usage (builtin_bundle_usage);
bundle.c +14 -12
@@ -127,7 +127,9 @@ static int list_refs(struct ref_list *r, int argc, const char **argv)/* Remember to update object flag allocation in object.h */ #define PREREQ_MARK (1u<<16) -int verify_bundle (struct bundle_header *header,int verbose) +int verify_bundle (struct repository *r, +struct bundle_header *header, +int verbose) {/* * Do fast check, then if any prereqs are missing then go line by line
@@ -140,10 +142,10 @@ int verify_bundle(struct bundle_header *header, int verbose)int i, ret =0 , req_nr;const char *message =_ ("Repository lacks these prerequisite commits:" ); -repo_init_revisions (the_repository, &revs,NULL ); +repo_init_revisions (r, &revs,NULL );for (i =0 ; i < p->nr; i++) {struct ref_list_entry *e = p->list + i; -struct object *o =parse_object (the_repository, &e->oid); +struct object *o =parse_object (r, &e->oid);if (o) { o->flags |=PREREQ_MARK ;add_pending_object (&revs, o, e->name);
@@ -168,7 +170,7 @@ int verify_bundle(struct bundle_header *header, int verbose)for (i =0 ; i < p->nr; i++) {struct ref_list_entry *e = p->list + i; -struct object *o =parse_object (the_repository, &e->oid); +struct object *o =parse_object (r, &e->oid);assert (o);/* otherwise we'd have returned early */ if (o->flags &SHOWN )continue ;
@@ -180,7 +182,7 @@ int verify_bundle(struct bundle_header *header, int verbose)/* Clean up objects used, as they will be reused. */ for (i =0 ; i < p->nr; i++) {struct ref_list_entry *e = p->list + i; - commit =lookup_commit_reference_gently (the_repository, &e->oid,1 ); + commit =lookup_commit_reference_gently (r, &e->oid,1 );if (commit)clear_commit_marks (commit,ALL_REV_FLAGS ); }
@@ -375,8 +377,7 @@ static int write_bundle_refs(int bundle_fd, struct rev_info *revs)* in terms of a tag (e.g. v2.0 from the range * "v1.0..v2.0")? */ -struct commit *one =lookup_commit_reference (the_repository, - &oid); +struct commit *one =lookup_commit_reference (revs->repo, &oid);struct object *obj;if (e->item == &(one->object)) {
@@ -409,8 +410,8 @@ static int write_bundle_refs(int bundle_fd, struct rev_info *revs)return ref_count; } -int create_bundle (struct bundle_header *header,const char *path, -int argc,const char **argv) +int create_bundle (struct repository *r,struct bundle_header *header, +const char *path,int argc,const char **argv) {struct lock_file lock =LOCK_INIT ;int bundle_fd =-1 ;
@@ -441,7 +442,7 @@ int create_bundle(struct bundle_header *header, const char *path,/* init revs to list objects for pack-objects later */ save_commit_buffer =0 ; -repo_init_revisions (the_repository, &revs,NULL ); +repo_init_revisions (r, &revs,NULL );/* write prerequisites */ if (compute_and_write_prerequisites (bundle_fd, &revs, argc, argv))
@@ -482,7 +483,8 @@ int create_bundle(struct bundle_header *header, const char *path,return -1 ; } -int unbundle (struct bundle_header *header,int bundle_fd,int flags) +int unbundle (struct repository *r,struct bundle_header *header, +int bundle_fd,int flags) {const char *argv_index_pack[] = {"index-pack" ,"--fix-thin" ,"--stdin" ,NULL ,NULL };
@@ -491,7 +493,7 @@ int unbundle(struct bundle_header *header, int bundle_fd, int flags)if (flags &BUNDLE_VERBOSE ) argv_index_pack[3 ] ="-v" ; -if (verify_bundle (header,0 )) +if (verify_bundle (r, header,0 ))return -1 ; ip.argv = argv_index_pack; ip.in = bundle_fd;
bundle.h +5 -4
@@ -18,11 +18,12 @@ struct bundle_header {int is_bundle (const char *path,int quiet);int read_bundle_header (const char *path,struct bundle_header *header); -int create_bundle (struct bundle_header *header,const char *path, -int argc,const char **argv); -int verify_bundle (struct bundle_header *header,int verbose); +int create_bundle (struct repository *r,struct bundle_header *header, +const char *path,int argc,const char **argv); +int verify_bundle (struct repository *r,struct bundle_header *header,int verbose);#define BUNDLE_VERBOSE 1 -int unbundle (struct bundle_header *header,int bundle_fd,int flags); +int unbundle (struct repository *r,struct bundle_header *header, +int bundle_fd,int flags);int list_bundle_refs (struct bundle_header *header,int argc,const char **argv);
transport.c +1 -1
@@ -154,7 +154,7 @@ static int fetch_refs_from_bundle(struct transport *transport, int nr_heads, struct ref **to_fetch) { struct bundle_transport_data *data = transport->data; -return unbundle (&data->header, data->fd, +return unbundle (the_repository, &data->header, data->fd, transport->progress ?BUNDLE_VERBOSE :0 ); }
Signature · 1 line
2.19.1.1231.g84aef82467
PATCH v2 14/22 cache-tree.c: remove the_repository references
In reply to Nguyễn Thái Ngọc DuyThis case is more interesting than other boring "remove the_repo" commits because while we need access to the object database, we cannot simply use r->index because unpack-trees.c can operate on a temporary index, not $GIT_DIR/index. Ideally we should be able to pass an object database to lookup_tree() but that ship has sailed.
--- builtin/read-tree.c | 4 +++- builtin/rebase.c | 2 +- builtin/reset.c | 2 +- cache-tree.c | 26 +++++++++++++++----------- cache-tree.h | 4 ++-- read-cache.c | 2 +- sequencer.c | 2 +- unpack-trees.c | 2 +- 8 files changed, 25 insertions(+), 19 deletions(-)
builtin/read-tree.c +3 -1
@@ -255,7 +255,9 @@ int cmd_read_tree(int argc, const char **argv, const char *unused_prefix)* what came from the tree. */ if (nr_trees ==1 && !opts.prefix) -prime_cache_tree (&the_index, trees[0 ]); +prime_cache_tree (the_repository, + the_repository->index, + trees[0 ]);if (write_locked_index (&the_index, &lock_file,COMMIT_LOCK ))die ("unable to write new index file" );
builtin/rebase.c +1 -1
@@ -582,7 +582,7 @@ static int reset_head(struct object_id *oid, const char *action, } tree =parse_tree_indirect (oid); -prime_cache_tree (the_repository->index, tree); +prime_cache_tree (the_repository, the_repository->index, tree);if (write_locked_index (the_repository->index, &lock,COMMIT_LOCK ) <0 ) ret =error (_ ("could not write index" ));
builtin/reset.c +1 -1
@@ -93,7 +93,7 @@ static int reset_index(const struct object_id *oid, int reset_type, int quiet)if (reset_type ==MIXED || reset_type ==HARD ) { tree =parse_tree_indirect (oid); -prime_cache_tree (&the_index, tree); +prime_cache_tree (the_repository, the_repository->index, tree); } ret =0 ;
cache-tree.c +15 -11
@@ -659,7 +659,9 @@ int write_index_as_tree(struct object_id *oid, struct index_state *index_state,return ret; } -static void prime_cache_tree_rec (struct cache_tree *it,struct tree *tree) +static void prime_cache_tree_rec (struct repository *r, +struct cache_tree *it, +struct tree *tree) {struct tree_desc desc;struct name_entry entry;
@@ -673,24 +675,25 @@ static void prime_cache_tree_rec(struct cache_tree *it, struct tree *tree) cnt++; else {struct cache_tree_sub *sub; -struct tree *subtree =lookup_tree (the_repository, - entry.oid); +struct tree *subtree =lookup_tree (r, entry.oid);if (!subtree->object.parsed)parse_tree (subtree); sub =cache_tree_sub (it, entry.path); sub->cache_tree =cache_tree (); -prime_cache_tree_rec (sub->cache_tree, subtree); +prime_cache_tree_rec (r, sub->cache_tree, subtree); cnt += sub->cache_tree->entry_count; } } it->entry_count = cnt; } -void prime_cache_tree (struct index_state *istate,struct tree *tree) +void prime_cache_tree (struct repository *r, +struct index_state *istate, +struct tree *tree) {cache_tree_free (&istate->cache_tree); istate->cache_tree =cache_tree (); -prime_cache_tree_rec (istate->cache_tree, tree); +prime_cache_tree_rec (r, istate->cache_tree, tree); istate->cache_changed |=CACHE_TREE_CHANGED ; }
@@ -726,7 +729,8 @@ int cache_tree_matches_traversal(struct cache_tree *root,return 0 ; } -static void verify_one (struct index_state *istate, +static void verify_one (struct repository *r, +struct index_state *istate,struct cache_tree *it,struct strbuf *path) {
@@ -736,13 +740,13 @@ static void verify_one(struct index_state *istate,for (i =0 ; i < it->subtree_nr; i++) {strbuf_addf (path,"%s/" , it->down[i]->name); -verify_one (istate, it->down[i]->cache_tree, path); +verify_one (r, istate, it->down[i]->cache_tree, path);strbuf_setlen (path, len); }if (it->entry_count <0 ||/* no verification on tests (t7003) that replace trees */ -lookup_replace_object (the_repository, &it->oid) != &it->oid) +lookup_replace_object (r, &it->oid) != &it->oid)return ;if (path->len) {
@@ -793,12 +797,12 @@ static void verify_one(struct index_state *istate,strbuf_release (&tree_buf); } -void cache_tree_verify (struct index_state *istate) +void cache_tree_verify (struct repository *r,struct index_state *istate) {struct strbuf path =STRBUF_INIT ;if (!istate->cache_tree)return ; -verify_one (istate, istate->cache_tree, &path); +verify_one (r, istate, istate->cache_tree, &path);strbuf_release (&path); }
cache-tree.h +2 -2
@@ -32,7 +32,7 @@ struct cache_tree *cache_tree_read(const char *buffer, unsigned long size);int cache_tree_fully_valid (struct cache_tree *);int cache_tree_update (struct index_state *,int ); -void cache_tree_verify (struct index_state *); +void cache_tree_verify (struct repository *,struct index_state *);/* bitmasks to write_cache_as_tree flags */ #define WRITE_TREE_MISSING_OK 1
@@ -47,7 +47,7 @@ void cache_tree_verify(struct index_state *);#define WRITE_TREE_PREFIX_ERROR (-3)int write_index_as_tree (struct object_id *oid,struct index_state *index_state,const char *index_path,int flags,const char *prefix); -void prime_cache_tree (struct index_state *,struct tree *); +void prime_cache_tree (struct repository *,struct index_state *,struct tree *);int cache_tree_matches_traversal (struct cache_tree *,struct name_entry *ent,struct traverse_info *info);
read-cache.c +1 -1
@@ -3126,7 +3126,7 @@ int write_locked_index(struct index_state *istate, struct lock_file *lock,struct split_index *si = istate->split_index;if (git_env_bool ("GIT_TEST_CHECK_CACHE_TREE" ,0 )) -cache_tree_verify (istate); +cache_tree_verify (the_repository, istate);if ((flags &SKIP_IF_UNCHANGED ) && !istate->cache_changed) {if (flags &COMMIT_LOCK )
sequencer.c +1 -1
@@ -2991,7 +2991,7 @@ static int do_reset(struct repository *r, } tree =parse_tree_indirect (&oid); -prime_cache_tree (r->index, tree); +prime_cache_tree (r, r->index, tree);if (write_locked_index (r->index, &lock,COMMIT_LOCK ) <0 ) ret =error (_ ("could not write index" ));
unpack-trees.c +1 -1
@@ -1630,7 +1630,7 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_optionsmove_index_extensions (&o->result, o->src_index);if (!ret) {if (git_env_bool ("GIT_TEST_CHECK_CACHE_TREE" ,0 )) -cache_tree_verify (&o->result); +cache_tree_verify (the_repository, &o->result);if (!o->result.cache_tree) o->result.cache_tree =cache_tree ();if (!cache_tree_fully_valid (o->result.cache_tree))
Signature · 1 line
2.19.1.1231.g84aef82467
PATCH v2 15/22 delta-islands.c: remove the_repository references
In reply to Nguyễn Thái Ngọc Duy--- builtin/pack-objects.c | 4 ++-- delta-islands.c | 24 ++++++++++++++---------- delta-islands.h | 9 ++++++--- 3 files changed, 22 insertions(+), 15 deletions(-)
builtin/pack-objects.c +2 -2
@@ -2628,7 +2628,7 @@ static void prepare_pack(int window, int depth)unsigned n;if (use_delta_islands) -resolve_tree_islands (progress, &to_pack); +resolve_tree_islands (the_repository, progress, &to_pack);get_object_details ();
@@ -3143,7 +3143,7 @@ static void get_object_list(int ac, const char **av)return ;if (use_delta_islands) -load_delta_islands (); +load_delta_islands (the_repository);if (prepare_revision_walk (&revs))die (_ ("revision walk setup failed" ));
delta-islands.c +14 -10
@@ -190,13 +190,15 @@ static void set_island_marks(struct object *obj, struct island_bitmap *marks)island_bitmap_or (b, marks); } -static void mark_remote_island_1 (struct remote_island *rl,int is_core_island) +static void mark_remote_island_1 (struct repository *r, +struct remote_island *rl, +int is_core_island) {uint32_t i;for (i =0 ; i < rl->oids.nr; ++i) {struct island_bitmap *marks; -struct object *obj =parse_object (the_repository, &rl->oids.oid[i]); +struct object *obj =parse_object (r, &rl->oids.oid[i]);if (!obj)continue ;
@@ -211,7 +213,7 @@ static void mark_remote_island_1(struct remote_island *rl, int is_core_island)while (obj && obj->type ==OBJ_TAG ) { obj = ((struct tag *)obj)->tagged;if (obj) { -parse_object (the_repository, &obj->oid); +parse_object (r, &obj->oid); marks =create_or_get_island_marks (obj);island_bitmap_set (marks, island_counter); }
@@ -237,7 +239,9 @@ static int tree_depth_compare(const void *a, const void *b)return todo_a->depth - todo_b->depth; } -void resolve_tree_islands (int progress,struct packing_data *to_pack) +void resolve_tree_islands (struct repository *r, +int progress, +struct packing_data *to_pack) {struct progress *progress_state =NULL ;struct tree_islands_todo *todo;
@@ -281,7 +285,7 @@ void resolve_tree_islands(int progress, struct packing_data *to_pack) root_marks =kh_value (island_marks, pos); - tree =lookup_tree (the_repository, &ent->idx.oid); + tree =lookup_tree (r, &ent->idx.oid);if (!tree ||parse_tree (tree) <0 )die (_ ("bad tree object %s" ),oid_to_hex (&ent->idx.oid));
@@ -292,7 +296,7 @@ void resolve_tree_islands(int progress, struct packing_data *to_pack)if (S_ISGITLINK (entry.mode))continue ; - obj =lookup_object (the_repository, entry.oid->hash); + obj =lookup_object (r, entry.oid->hash);if (!obj)continue ;
@@ -415,7 +419,7 @@ static struct remote_island *get_core_island(void)return NULL ; } -static void deduplicate_islands (void ) +static void deduplicate_islands (struct repository *r) {struct remote_island *island, *core =NULL , **list;unsigned int island_count, dst, src, ref, i =0 ;
@@ -444,20 +448,20 @@ static void deduplicate_islands(void) core =get_core_island ();for (i =0 ; i < island_count; ++i) { -mark_remote_island_1 (list[i], core && list[i]->hash == core->hash); +mark_remote_island_1 (r, list[i], core && list[i]->hash == core->hash); }free (list); } -void load_delta_islands (void ) +void load_delta_islands (struct repository *r) { island_marks =kh_init_sha1 (); remote_islands =kh_init_str ();git_config (island_config_callback,NULL );for_each_ref (find_island_for_ref,NULL ); -deduplicate_islands (); +deduplicate_islands (r);fprintf (stderr,_ ("Marked %d islands, done.\n" ), island_counter); }
delta-islands.h +6 -3
@@ -1,14 +1,17 @@#ifndef DELTA_ISLANDS_H #define DELTA_ISLANDS_H +struct commit ;struct object_id ;struct packing_data ; -struct commit ; +struct repository ;int island_delta_cmp (const struct object_id *a,const struct object_id *b);int in_same_island (const struct object_id *,const struct object_id *); -void resolve_tree_islands (int progress,struct packing_data *to_pack); -void load_delta_islands (void ); +void resolve_tree_islands (struct repository *r, +int progress, +struct packing_data *to_pack); +void load_delta_islands (struct repository *r);void propagate_island_marks (struct commit *commit);int compute_pack_layers (struct packing_data *to_pack);
Signature · 1 line
2.19.1.1231.g84aef82467
PATCH v2 16/22 diff-lib.c: remove the_repository references
In reply to Nguyễn Thái Ngọc Duy--- builtin/commit.c | 3 ++- builtin/merge-ours.c | 2 +- diff-lib.c | 7 ++++--- diff.h | 3 ++- sequencer.c | 4 ++-- 5 files changed, 11 insertions(+), 8 deletions(-)
builtin/commit.c +2 -1
@@ -908,7 +908,8 @@ static int prepare_to_commit(const char *index_file, const char *prefix,if (ignore_submodule_arg && !strcmp (ignore_submodule_arg,"all" )) flags.ignore_submodules =1 ; - committable =index_differs_from (parent, &flags,1 ); + committable =index_differs_from (the_repository, + parent, &flags,1 ); } }strbuf_release (&committer_ident);
builtin/merge-ours.c +1 -1
@@ -26,7 +26,7 @@ int cmd_merge_ours(int argc, const char **argv, const char *prefix)*/ if (read_cache () <0 )die_errno ("read_cache failed" ); -if (index_differs_from ("HEAD" ,NULL ,0 )) +if (index_differs_from (the_repository,"HEAD" ,NULL ,0 ))exit (2 );exit (0 ); }
diff-lib.c +4 -3
@@ -542,7 +542,7 @@ int do_diff_cache(const struct object_id *tree_oid, struct diff_options *opt) {struct rev_info revs; -repo_init_revisions (the_repository, &revs,NULL ); +repo_init_revisions (opt->repo, &revs,NULL );copy_pathspec (&revs.prune_data, &opt->pathspec); revs.diffopt = *opt;
@@ -551,13 +551,14 @@ int do_diff_cache(const struct object_id *tree_oid, struct diff_options *opt)return 0 ; } -int index_differs_from (const char *def,const struct diff_flags *flags, +int index_differs_from (struct repository *r, +const char *def,const struct diff_flags *flags,int ita_invisible_in_index) {struct rev_info rev;struct setup_revision_opt opt; -repo_init_revisions (the_repository, &rev,NULL ); +repo_init_revisions (r, &rev,NULL );memset (&opt,0 ,sizeof (opt)); opt.def = def;setup_revisions (0 ,NULL , &rev, &opt);
diff.h +2 -1
@@ -436,7 +436,8 @@ int diff_result_code(struct diff_options *, int);void diff_no_index (struct repository *,struct rev_info *,int ,const char **); -int index_differs_from (const char *def,const struct diff_flags *flags, +int index_differs_from (struct repository *r,const char *def, +const struct diff_flags *flags,int ita_invisible_in_index);/*
sequencer.c +2 -2
@@ -1713,7 +1713,7 @@ static int do_pick_commit(struct repository *r, unborn =1 ; }else if (unborn)oidcpy (&head, the_hash_algo->empty_tree); -if (index_differs_from (unborn ?empty_tree_oid_hex () :"HEAD" , +if (index_differs_from (r, unborn ?empty_tree_oid_hex () :"HEAD" ,NULL ,0 ))return error_dirty_index (r->index, opts); }
@@ -3915,7 +3915,7 @@ int sequencer_continue(struct repository *r, struct replay_opts *opts)if (res) goto release_todo_list; } -if (index_differs_from ("HEAD" ,NULL ,0 )) { +if (index_differs_from (r,"HEAD" ,NULL ,0 )) { res =error_dirty_index (r->index, opts); goto release_todo_list; }
Signature · 1 line
2.19.1.1231.g84aef82467
PATCH v2 17/22 line-log.c: remove the_repository reference
In reply to Nguyễn Thái Ngọc Duy--- line-log.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
line-log.c +1 -1
@@ -479,7 +479,7 @@ static struct commit *check_single_commit(struct rev_info *revs)struct object *obj = revs->pending.objects[i].item;if (obj->flags &UNINTERESTING )continue ; - obj =deref_tag (the_repository, obj,NULL ,0 ); + obj =deref_tag (revs->repo, obj,NULL ,0 );if (obj->type !=OBJ_COMMIT )die ("Non commit %s?" , revs->pending.objects[i].name);if (commit)
Signature · 1 line
2.19.1.1231.g84aef82467
PATCH v2 18/22 notes-cache.c: remove the_repository references
In reply to Nguyễn Thái Ngọc Duy--- combine-diff.c | 2 +- diff.c | 12 ++++++------ diff.h | 2 +- diffcore-pickaxe.c | 4 ++-- grep.c | 2 +- notes-cache.c | 12 +++++++----- notes-cache.h | 6 ++++-- userdiff.c | 5 +++-- userdiff.h | 4 +++- 9 files changed, 28 insertions(+), 21 deletions(-)
combine-diff.c +1 -1
@@ -991,7 +991,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,if (!userdiff) userdiff =userdiff_find_by_name ("default" );if (opt->flags.allow_textconv) - textconv =userdiff_get_textconv (userdiff); + textconv =userdiff_get_textconv (opt->repo, userdiff);/* Read the result of merge first */ if (!working_tree_file)
diff.c +6 -6
@@ -3312,14 +3312,14 @@ void diff_set_mnemonic_prefix(struct diff_options *options, const char *a, const options->b_prefix = b; } -struct userdiff_driver *get_textconv (struct index_state *istate, +struct userdiff_driver *get_textconv (struct repository *r,struct diff_filespec *one) {if (!DIFF_FILE_VALID (one))return NULL ; -diff_filespec_load_driver (one, istate); -return userdiff_get_textconv (one->driver); +diff_filespec_load_driver (one, r->index); +return userdiff_get_textconv (r, one->driver); } static void builtin_diff(const char *name_a,
@@ -3368,8 +3368,8 @@ static void builtin_diff(const char *name_a, }if (o->flags.allow_textconv) { - textconv_one =get_textconv (o->repo->index, one); - textconv_two =get_textconv (o->repo->index, two); + textconv_one =get_textconv (o->repo, one); + textconv_two =get_textconv (o->repo, two); }/* Never use a non-valid filename anywhere if at all possible */
@@ -6436,7 +6436,7 @@ int textconv_object(struct repository *r, df =alloc_filespec (path);fill_filespec (df, oid, oid_valid, mode); - textconv =get_textconv (r->index, df); + textconv =get_textconv (r, df);if (!textconv) {free_filespec (df);return 0 ;
diff.h +1 -1
@@ -461,7 +461,7 @@ size_t fill_textconv(struct repository *r,* and only if it has textconv enabled (otherwise return NULL). The result * can be passed to fill_textconv(). */ -struct userdiff_driver *get_textconv (struct index_state *istate, +struct userdiff_driver *get_textconv (struct repository *r,struct diff_filespec *one);/*
diffcore-pickaxe.c +2 -2
@@ -139,8 +139,8 @@ static int pickaxe_match(struct diff_filepair *p, struct diff_options *o,return 0 ;if (o->flags.allow_textconv) { - textconv_one =get_textconv (o->repo->index, p->one); - textconv_two =get_textconv (o->repo->index, p->two); + textconv_one =get_textconv (o->repo, p->one); + textconv_two =get_textconv (o->repo, p->two); }/*
grep.c +1 -1
@@ -1811,7 +1811,7 @@ static int grep_source_1(struct grep_opt *opt, struct grep_source *gs, int colle* is not thread-safe. */ grep_attr_lock (); - textconv =userdiff_get_textconv (gs->driver); + textconv =userdiff_get_textconv (opt->repo, gs->driver);grep_attr_unlock (); }
notes-cache.c +7 -5
@@ -5,7 +5,9 @@#include "commit.h" #include "refs.h" -static int notes_cache_match_validity (const char *ref,const char *validity) +static int notes_cache_match_validity (struct repository *r, +const char *ref, +const char *validity) {struct object_id oid;struct commit *commit;
@@ -16,7 +18,7 @@ static int notes_cache_match_validity(const char *ref, const char *validity)if (read_ref (ref, &oid) <0 )return 0 ; - commit =lookup_commit_reference_gently (the_repository, &oid,1 ); + commit =lookup_commit_reference_gently (r, &oid,1 );if (!commit)return 0 ;
@@ -30,8 +32,8 @@ static int notes_cache_match_validity(const char *ref, const char *validity)return ret; } -void notes_cache_init (struct notes_cache *c,const char *name, -const char *validity) +void notes_cache_init (struct repository *r,struct notes_cache *c, +const char *name,const char *validity) {struct strbuf ref =STRBUF_INIT ;int flags =NOTES_INIT_WRITABLE ;
@@ -40,7 +42,7 @@ void notes_cache_init(struct notes_cache *c, const char *name, c->validity =xstrdup (validity);strbuf_addf (&ref,"refs/notes/%s" , name); -if (!notes_cache_match_validity (ref.buf, validity)) +if (!notes_cache_match_validity (r, ref.buf, validity)) flags |=NOTES_INIT_EMPTY ;init_notes (&c->tree, ref.buf, combine_notes_overwrite, flags);strbuf_release (&ref);
notes-cache.h +4 -2
@@ -3,13 +3,15 @@#include "notes.h" +struct repository ; +struct notes_cache {struct notes_tree tree;char *validity; }; -void notes_cache_init (struct notes_cache *c,const char *name, -const char *validity); +void notes_cache_init (struct repository *r,struct notes_cache *c, +const char *name,const char *validity);int notes_cache_write (struct notes_cache *c); char *notes_cache_get(struct notes_cache *c, struct object_id *oid, size_t
userdiff.c +3 -2
@@ -290,7 +290,8 @@ struct userdiff_driver *userdiff_find_by_path(struct index_state *istate,return userdiff_find_by_name (check->items[0 ].value); } -struct userdiff_driver *userdiff_get_textconv (struct userdiff_driver *driver) +struct userdiff_driver *userdiff_get_textconv (struct repository *r, +struct userdiff_driver *driver) {if (!driver->textconv)return NULL ;
@@ -300,7 +301,7 @@ struct userdiff_driver *userdiff_get_textconv(struct userdiff_driver *driver)struct strbuf name =STRBUF_INIT ;strbuf_addf (&name,"textconv/%s" , driver->name); -notes_cache_init (c, name.buf, driver->textconv); +notes_cache_init (r, c, name.buf, driver->textconv); driver->textconv_cache = c;strbuf_release (&name); }
userdiff.h +3 -1
@@ -4,6 +4,7 @@#include "notes-cache.h" struct index_state ; +struct repository ;struct userdiff_funcname {const char *pattern;
@@ -30,6 +31,7 @@ struct userdiff_driver *userdiff_find_by_path(struct index_state *istate,* Initialize any textconv-related fields in the driver and return it, or NULL * if it does not have textconv enabled at all. */ -struct userdiff_driver *userdiff_get_textconv (struct userdiff_driver *driver); +struct userdiff_driver *userdiff_get_textconv (struct repository *r, +struct userdiff_driver *driver);#endif /* USERDIFF */
Signature · 1 line
2.19.1.1231.g84aef82467
PATCH v2 19/22 pack-check.c: remove the_repository references
In reply to Nguyễn Thái Ngọc Duy--- builtin/fsck.c | 3 ++- pack-check.c | 9 +++++---- pack.h | 4 +++- 3 files changed, 10 insertions(+), 6 deletions(-)
builtin/fsck.c +2 -1
@@ -752,7 +752,8 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)for (p =get_all_packs (the_repository); p; p = p->next) {/* verify gives error messages itself */ -if (verify_pack (p, fsck_obj_buffer, +if (verify_pack (the_repository, + p, fsck_obj_buffer, progress, count)) errors_found |=ERROR_PACK ; count += p->num_objects;
pack-check.c +5 -4
@@ -48,7 +48,8 @@ int check_pack_crc(struct packed_git *p, struct pack_window **w_curs,return data_crc !=ntohl (*index_crc); } -static int verify_packfile (struct packed_git *p, +static int verify_packfile (struct repository *r, +struct packed_git *p,struct pack_window **w_curs,verify_fn fn,struct progress *progress,uint32_t base_count)
@@ -135,7 +136,7 @@ static int verify_packfile(struct packed_git *p, data =NULL ; data_valid =0 ; }else { - data =unpack_entry (the_repository, p, entries[i].offset, &type, &size); + data =unpack_entry (r, p, entries[i].offset, &type, &size); data_valid =1 ; }
@@ -186,7 +187,7 @@ int verify_pack_index(struct packed_git *p)return err; } -int verify_pack (struct packed_git *p,verify_fn fn, +int verify_pack (struct repository *r,struct packed_git *p,verify_fn fn,struct progress *progress,uint32_t base_count) {int err =0 ;
@@ -196,7 +197,7 @@ int verify_pack(struct packed_git *p, verify_fn fn,if (!p->index_data)return -1 ; - err |=verify_packfile (p, &w_curs, fn, progress, base_count); + err |=verify_packfile (r, p, &w_curs, fn, progress, base_count);unuse_pack (&w_curs);return err;
pack.h +3 -1
@@ -4,6 +4,8 @@#include "object.h" #include "csum-file.h" +struct repository ; +/* * Packed object header */
@@ -80,7 +82,7 @@ typedef int (*verify_fn)(const struct object_id *, enum object_type, unsigned loextern const char *write_idx_file (const char *index_name,struct pack_idx_entry **objects,int nr_objects,const struct pack_idx_option *,const unsigned char *sha1);extern int check_pack_crc (struct packed_git *p,struct pack_window **w_curs,off_t offset,off_t len,unsigned int nr);extern int verify_pack_index (struct packed_git *); -extern int verify_pack (struct packed_git *,verify_fn fn,struct progress *,uint32_t ); +extern int verify_pack (struct repository *,struct packed_git *,verify_fn fn,struct progress *,uint32_t );extern off_t write_pack_header (struct hashfile *f,uint32_t );extern void fixup_pack_header_footer (int ,unsigned char *,const char *,uint32_t ,unsigned char *,off_t );extern char *index_pack_lockfile (int fd);
Signature · 1 line
2.19.1.1231.g84aef82467
PATCH v2 20/22 pack-*.c: remove the_repository references
In reply to Nguyễn Thái Ngọc Duy--- builtin/pack-objects.c | 2 +- pack-bitmap-write.c | 6 +++--- pack-bitmap.c | 13 +++++++------ pack-bitmap.h | 3 ++- pack-objects.c | 6 ++++-- pack-objects.h | 5 ++++- 6 files changed, 21 insertions(+), 14 deletions(-)
builtin/pack-objects.c +1 -1
@@ -3481,7 +3481,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix) } } -prepare_packing_data (&to_pack); +prepare_packing_data (the_repository, &to_pack);if (progress) progress_state =start_progress (_ ("Enumerating objects" ),0 );
pack-bitmap-write.c +3 -3
@@ -77,7 +77,7 @@ void bitmap_writer_build_type_index(struct packing_data *to_pack,break ;default : - real_type =oid_object_info (the_repository, + real_type =oid_object_info (to_pack->repo, &entry->idx.oid,NULL );break ; }
@@ -262,7 +262,7 @@ void bitmap_writer_build(struct packing_data *to_pack)if (writer.show_progress) writer.progress =start_progress ("Building bitmaps" , writer.selected_nr); -repo_init_revisions (the_repository, &revs,NULL ); +repo_init_revisions (to_pack->repo, &revs,NULL ); revs.tag_objects =1 ; revs.tree_objects =1 ; revs.blob_objects =1 ;
@@ -363,7 +363,7 @@ static int date_compare(const void *_a, const void *_b)void bitmap_writer_reuse_bitmaps (struct packing_data *to_pack) {struct bitmap_index *bitmap_git; -if (!(bitmap_git =prepare_bitmap_git ())) +if (!(bitmap_git =prepare_bitmap_git (to_pack->repo)))return ; writer.reused =kh_init_sha1 ();
pack-bitmap.c +7 -6
@@ -328,14 +328,15 @@ static int load_pack_bitmap(struct bitmap_index *bitmap_git)return -1 ; } -static int open_pack_bitmap (struct bitmap_index *bitmap_git) +static int open_pack_bitmap (struct repository *r, +struct bitmap_index *bitmap_git) {struct packed_git *p;int ret =-1 ;assert (!bitmap_git->map); -for (p =get_all_packs (the_repository); p; p = p->next) { +for (p =get_all_packs (r); p; p = p->next) {if (open_pack_bitmap_1 (bitmap_git, p) ==0 ) ret =0 ; }
@@ -343,11 +344,11 @@ static int open_pack_bitmap(struct bitmap_index *bitmap_git)return ret; } -struct bitmap_index *prepare_bitmap_git (void ) +struct bitmap_index *prepare_bitmap_git (struct repository *r) {struct bitmap_index *bitmap_git =xcalloc (1 ,sizeof (*bitmap_git)); -if (!open_pack_bitmap (bitmap_git) && !load_pack_bitmap (bitmap_git)) +if (!open_pack_bitmap (r, bitmap_git) && !load_pack_bitmap (bitmap_git))return bitmap_git;free_bitmap_index (bitmap_git);
@@ -690,7 +691,7 @@ struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs)struct bitmap_index *bitmap_git =xcalloc (1 ,sizeof (*bitmap_git));/* try to open a bitmapped pack, but don't parse it yet * because we may not need to use it */ -if (open_pack_bitmap (bitmap_git) <0 ) +if (open_pack_bitmap (revs->repo, bitmap_git) <0 ) goto cleanup;for (i =0 ; i < revs->pending.nr; ++i) {
@@ -955,7 +956,7 @@ void test_bitmap_walk(struct rev_info *revs)struct bitmap_test_data tdata;struct bitmap_index *bitmap_git; -if (!(bitmap_git =prepare_bitmap_git ())) +if (!(bitmap_git =prepare_bitmap_git (revs->repo)))die ("failed to load bitmap indexes" );if (revs->pending.nr !=1 )
pack-bitmap.h +2 -1
@@ -6,6 +6,7 @@#include "pack-objects.h" struct commit ; +struct repository ;struct rev_info ;struct bitmap_disk_header {
@@ -39,7 +40,7 @@ typedef int (*show_reachable_fn)(struct bitmap_index ; -struct bitmap_index *prepare_bitmap_git (void ); +struct bitmap_index *prepare_bitmap_git (struct repository *r);void count_bitmap_commit_list (struct bitmap_index *,uint32_t *commits,uint32_t *trees,uint32_t *blobs,uint32_t *tags); void traverse_bitmap_commit_list(struct bitmap_index *,
pack-objects.c +4 -2
@@ -99,7 +99,7 @@ static void prepare_in_pack_by_idx(struct packing_data *pdata)* (i.e. in_pack_idx also zero) should return NULL. */ mapping[cnt++] =NULL ; -for (p =get_all_packs (the_repository); p; p = p->next, cnt++) { +for (p =get_all_packs (pdata->repo); p; p = p->next, cnt++) {if (cnt == nr) {free (mapping);return ;
@@ -133,8 +133,10 @@ void oe_map_new_pack(struct packing_data *pack, }/* assume pdata is already zero'd by caller */ -void prepare_packing_data (struct packing_data *pdata) +void prepare_packing_data (struct repository *r,struct packing_data *pdata) { + pdata->repo = r; +if (git_env_bool ("GIT_TEST_FULL_IN_PACK_ARRAY" ,0 )) {/* * do not initialize in_pack_by_idx[] to force the
pack-objects.h +4 -1
@@ -5,6 +5,8 @@#include "thread-utils.h" #include "pack.h" +struct repository ; +#define DEFAULT_DELTA_CACHE_SIZE (256 * 1024 * 1024)#define OE_DFS_STATE_BITS 2
@@ -127,6 +129,7 @@ struct object_entry { };struct packing_data { +struct repository *repo;struct object_entry *objects;uint32_t nr_objects, nr_alloc;
@@ -165,7 +168,7 @@ struct packing_data {unsigned char *layer; }; -void prepare_packing_data (struct packing_data *pdata); +void prepare_packing_data (struct repository *r,struct packing_data *pdata);static inline void packing_data_lock (struct packing_data *pdata) {
Signature · 1 line
2.19.1.1231.g84aef82467
PATCH v2 21/22 rerere.c: remove the_repository references
In reply to Nguyễn Thái Ngọc Duy--- builtin/am.c | 2 +- builtin/rebase--interactive.c | 2 +- builtin/rebase.c | 4 ++-- builtin/rerere.c | 10 ++++++---- rerere.c | 26 +++++++++++++------------- rerere.h | 6 +++--- 6 files changed, 26 insertions(+), 24 deletions(-)
builtin/am.c +1 -1
@@ -2033,7 +2033,7 @@ static int clean_index(const struct object_id *head, const struct object_id *remstatic void am_rerere_clear (void ) {struct string_list merge_rr =STRING_LIST_INIT_DUP ; -rerere_clear (&merge_rr); +rerere_clear (the_repository, &merge_rr);string_list_clear (&merge_rr,1 ); }
builtin/rebase--interactive.c +1 -1
@@ -233,7 +233,7 @@ int cmd_rebase__interactive(int argc, const char **argv, const char *prefix)case SKIP : {struct string_list merge_rr =STRING_LIST_INIT_DUP ; -rerere_clear (&merge_rr); +rerere_clear (the_repository, &merge_rr);/* fallthrough */ case CONTINUE : ret =sequencer_continue (the_repository, &opts);
builtin/rebase.c +2 -2
@@ -997,7 +997,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) options.action ="skip" ; -rerere_clear (&merge_rr); +rerere_clear (the_repository, &merge_rr);string_list_clear (&merge_rr,1 );if (reset_head (NULL ,"reset" ,NULL ,0 ,NULL ,NULL ) <0 )
@@ -1010,7 +1010,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)struct string_list merge_rr =STRING_LIST_INIT_DUP ; options.action ="abort" ; -rerere_clear (&merge_rr); +rerere_clear (the_repository, &merge_rr);string_list_clear (&merge_rr,1 );if (read_basic_state (&options))
builtin/rerere.c +6 -4
@@ -82,11 +82,12 @@ int cmd_rerere(int argc, const char **argv, const char *prefix) }if (!strcmp (argv[0 ],"clear" )) { -rerere_clear (&merge_rr); +rerere_clear (the_repository, &merge_rr); }else if (!strcmp (argv[0 ],"gc" )) -rerere_gc (&merge_rr); +rerere_gc (the_repository, &merge_rr);else if (!strcmp (argv[0 ],"status" )) { -if (setup_rerere (&merge_rr, flags |RERERE_READONLY ) <0 ) +if (setup_rerere (the_repository, &merge_rr, + flags |RERERE_READONLY ) <0 )return 0 ;for (i =0 ; i < merge_rr.nr; i++)printf ("%s\n" , merge_rr.items[i].string);
@@ -101,7 +102,8 @@ int cmd_rerere(int argc, const char **argv, const char *prefix) merge_rr.items[i].util =NULL ; } }else if (!strcmp (argv[0 ],"diff" )) { -if (setup_rerere (&merge_rr, flags |RERERE_READONLY ) <0 ) +if (setup_rerere (the_repository, &merge_rr, + flags |RERERE_READONLY ) <0 )return 0 ;for (i =0 ; i < merge_rr.nr; i++) {const char *path = merge_rr.items[i].string;
rerere.c +13 -13
@@ -198,10 +198,10 @@ static struct rerere_id *new_rerere_id(unsigned char *sha1)* work on (i.e. what is left by the previous invocation of "git * rerere" during the current conflict resolution session). */ -static void read_rr (struct string_list *rr) +static void read_rr (struct repository *r,struct string_list *rr) {struct strbuf buf =STRBUF_INIT ; -FILE *in =fopen_or_warn (git_path_merge_rr (the_repository),"r" ); +FILE *in =fopen_or_warn (git_path_merge_rr (r),"r" );if (!in)return ;
@@ -593,7 +593,7 @@ int rerere_remaining(struct repository *r, struct string_list *merge_rr) {int i; -if (setup_rerere (merge_rr,RERERE_READONLY )) +if (setup_rerere (r, merge_rr,RERERE_READONLY ))return 0 ;if (read_index (r->index) <0 )return error (_ ("index file corrupt" ));
@@ -882,7 +882,7 @@ static int is_rerere_enabled(void)return 1 ; } -int setup_rerere (struct string_list *merge_rr,int flags) +int setup_rerere (struct repository *r,struct string_list *merge_rr,int flags) {int fd;
@@ -896,9 +896,9 @@ int setup_rerere(struct string_list *merge_rr, int flags) fd =0 ; else fd =hold_lock_file_for_update (&write_lock, -git_path_merge_rr (the_repository), +git_path_merge_rr (r),LOCK_DIE_ON_ERROR ); -read_rr (merge_rr); +read_rr (r, merge_rr);return fd; }
@@ -912,7 +912,7 @@ int repo_rerere(struct repository *r, int flags)struct string_list merge_rr =STRING_LIST_INIT_DUP ;int fd, status; - fd =setup_rerere (&merge_rr, flags); + fd =setup_rerere (r, &merge_rr, flags);if (fd <0 )return 0 ; status =do_plain_rerere (r, &merge_rr, fd);
@@ -1110,7 +1110,7 @@ int rerere_forget(struct repository *r, struct pathspec *pathspec)if (read_index (r->index) <0 )return error (_ ("index file corrupt" )); - fd =setup_rerere (&merge_rr,RERERE_NOAUTOUPDATE ); + fd =setup_rerere (r, &merge_rr,RERERE_NOAUTOUPDATE );if (fd <0 )return 0 ;
@@ -1178,7 +1178,7 @@ static void prune_one(struct rerere_id *id,unlink_rr_item (id); } -void rerere_gc (struct string_list *rr) +void rerere_gc (struct repository *r,struct string_list *rr) {struct string_list to_remove =STRING_LIST_INIT_DUP ;DIR *dir;
@@ -1188,7 +1188,7 @@ void rerere_gc(struct string_list *rr)timestamp_t cutoff_noresolve = now -15 *86400 ;timestamp_t cutoff_resolve = now -60 *86400 ; -if (setup_rerere (rr,0 ) <0 ) +if (setup_rerere (r, rr,0 ) <0 )return ;git_config_get_expiry_in_days ("gc.rerereresolved" , &cutoff_resolve, now);
@@ -1236,11 +1236,11 @@ void rerere_gc(struct string_list *rr)* * NEEDSWORK: shouldn't we be calling this from "reset --hard"? */ -void rerere_clear (struct string_list *merge_rr) +void rerere_clear (struct repository *r,struct string_list *merge_rr) {int i; -if (setup_rerere (merge_rr,0 ) <0 ) +if (setup_rerere (r, merge_rr,0 ) <0 )return ;for (i =0 ; i < merge_rr->nr; i++) {
@@ -1250,6 +1250,6 @@ void rerere_clear(struct string_list *merge_rr)rmdir (rerere_path (id,NULL )); } } -unlink_or_warn (git_path_merge_rr (the_repository)); +unlink_or_warn (git_path_merge_rr (r));rollback_lock_file (&write_lock); }
rerere.h +3 -3
@@ -23,7 +23,7 @@ struct rerere_id {int variant; }; -int setup_rerere (struct string_list *,int ); +int setup_rerere (struct repository *,struct string_list *,int );#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS #define rerere (flags) repo_rerere(the_repository, flags)#endif
@@ -37,8 +37,8 @@ int repo_rerere(struct repository *, int);const char *rerere_path (const struct rerere_id *,const char *file);int rerere_forget (struct repository *,struct pathspec *);int rerere_remaining (struct repository *,struct string_list *); -void rerere_clear (struct string_list *); -void rerere_gc (struct string_list *); +void rerere_clear (struct repository *,struct string_list *); +void rerere_gc (struct repository *,struct string_list *);#define OPT_RERERE_AUTOUPDATE (v) OPT_UYN(0, "rerere-autoupdate", (v), \ N_("update the index with reused conflict resolution if possible"))
Signature · 1 line
2.19.1.1231.g84aef82467
PATCH v2 22/22 rebase-interactive.c: remove the_repository references
In reply to Nguyễn Thái Ngọc DuyWhile at there add a forward declaration for struct strbuf.
--- builtin/rebase--interactive.c | 2 +- rebase-interactive.c | 6 +++--- rebase-interactive.h | 5 ++++- 3 files changed, 8 insertions(+), 5 deletions(-)
builtin/rebase--interactive.c +1 -1
@@ -240,7 +240,7 @@ int cmd_rebase__interactive(int argc, const char **argv, const char *prefix)break ; }case EDIT_TODO : - ret =edit_todo_list (flags); + ret =edit_todo_list (the_repository, flags);break ;case SHOW_CURRENT_PATCH : {struct child_process cmd =CHILD_PROCESS_INIT ;
rebase-interactive.c +3 -3
@@ -53,7 +53,7 @@ void append_todo_help(unsigned edit_todo, unsigned keep_empty, } } -int edit_todo_list (unsigned flags) +int edit_todo_list (struct repository *r,unsigned flags) {struct strbuf buf =STRBUF_INIT ;const char *todo_file =rebase_path_todo ();
@@ -69,7 +69,7 @@ int edit_todo_list(unsigned flags)strbuf_release (&buf); -transform_todos (the_repository, flags |TODO_LIST_SHORTEN_IDS ); +transform_todos (r, flags |TODO_LIST_SHORTEN_IDS );if (strbuf_read_file (&buf, todo_file,0 ) <0 )return error_errno (_ ("could not read '%s'." ), todo_file);
@@ -85,7 +85,7 @@ int edit_todo_list(unsigned flags)if (launch_sequence_editor (todo_file,NULL ,NULL ))return -1 ; -transform_todos (the_repository, flags & ~(TODO_LIST_SHORTEN_IDS )); +transform_todos (r, flags & ~(TODO_LIST_SHORTEN_IDS ));return 0 ; }
rebase-interactive.h +4 -1
@@ -1,8 +1,11 @@#ifndef REBASE_INTERACTIVE_H #define REBASE_INTERACTIVE_H +struct strbuf ; +struct repository ; +void append_todo_help (unsigned edit_todo,unsigned keep_empty,struct strbuf *buf); -int edit_todo_list (unsigned flags); +int edit_todo_list (struct repository *r,unsigned flags);#endif
Signature · 1 line
2.19.1.1231.g84aef82467
Quoted 5 lines · Nguyễn Thái Ngọc Duy
I did start pushing
the_repositoryout of library code [1] in the bottom half of this series. There aren't big surprises except that cache-tree API now take _both_ struct repository and structindex_state. The reason is cache-tree can work on temporary indexes andrepo->indexis about $GIT_DIR/index.
Yes, this is very sensible, and I expect many more functions would (and probably should) follow suit, as we'd want to be able to work with temporary index (not in the sense that we'll write out on-disk temporary index, but multiple in-core instances of istate that is not necessarily tied to the current or the next state of $GIT_DIR/index) from more places.