Kill the_index part 5
cover Kill the_index part 5
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/1 format-patch: respect --stat in cover letter's diffstat
Commit 43662b23ab (format-patch: keep cover-letter diffstat wrapped in 72 columns - 2018-01-24) uncondtionally sets stat width to 72 when generating diffstat for the cover letter, ignoring --stat from command line. But it should only do so when stat width is still default (i.e. stat_width == 0).
In order to fix this, we should only set stat_width if stat_width is zero. But it will never be. Commit 071dd0ba43 (format-patch: reduce patch diffstat width to 72 - 2018-02-01) makes sure that default stat width will be 72 (ignoring $COLUMNS, but could still be overriden by --stat). So all we need to do here is drop the assignment.
--- builtin/log.c | 2 -- t/t4052-stat-output.sh | 48 +++++++++++++++++++++++++++++------------- 2 files changed, 33 insertions(+), 17 deletions(-)
builtin/log.c +0 -2
@@ -1009,8 +1009,6 @@ static void show_diffstat(struct rev_info *rev,memcpy (&opts, &rev->diffopt,sizeof (opts)); opts.output_format =DIFF_FORMAT_SUMMARY |DIFF_FORMAT_DIFFSTAT ; - opts.stat_width =MAIL_DEFAULT_WRAP ; -diff_setup_done (&opts); diff_tree_oid(get_commit_tree_oid(origin),
t/t4052-stat-output.sh +33 -15
81 lines not on this page · raw message
Signature · 1 line
2.19.1.1005.gac84295441
PATCH 1/22 wt-status.c: remove implicit dependency on the_index
In reply to Nguyễn Thái Ngọc Duy--- 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 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 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
Re: [PATCH v2] format-patch: respect --stat in cover letter's diffstat
In reply to Nguyễn Thái Ngọc DuyQuoted 12 lines · Nguyễn Thái Ngọc Duy
Commit
43662b23ab(format-patch: keep cover-letter diffstat wrapped in 72 columns - 2018-01-24) uncondtionally sets stat width to 72 when generating diffstat for the cover letter, ignoring --stat from command line. But it should only do so when stat width is still default (i.e.stat_width== 0).In order to fix this, we should only set
stat_widthifstat_widthis zero. But it will never be. Commit071dd0ba43(format-patch: reduce patch diffstat width to 72 - 2018-02-01) makes sure that default stat width will be 72 (ignoring $COLUMNS, but could still be overriden by --stat). So all we need to do here is drop the assignment.
Quoted 7 lines
Reported-by Laszlo Ersek <[email protected]>Helped-by Leif Lindholm <[email protected]>Signed-off-by Nguyễn Thái Ngọc Duy <[email protected]>--- builtin/log.c | 2 -- t/t4052-stat-output.sh | 48 +++++++++++++++++++++++++++++------------- 2 files changed, 33 insertions(+), 17 deletions(-)
* This submission should have been posted as v3, not v2. V2 was posted at
https://public-inbox.org/git/[email protected]/
* Comparing the patch emails, the only difference is that this version renames "expect.40" to "expect.60". This should have been mentioned in a cover letter, or in the Notes section of the current submission.
* In my response to the (original) v2 posting, at
https://public-inbox.org/git/[email protected]/
I stated that I didn't try to run the test suite, and gave my T-b (under the circumstances described there). Given that the change in v3 (= this submission) is limited to the test case, I think my T-b should have been carried forward.
Thanks
Laszlo
Quoted 101 lines
builtin/log.c +0
-2@@ -1009,8 +1009,6 @@ static void show_diffstat(struct rev_info *rev,memcpy (&opts, &rev->diffopt,sizeof (opts)); opts.output_format =DIFF_FORMAT_SUMMARY |DIFF_FORMAT_DIFFSTAT ; - opts.stat_width =MAIL_DEFAULT_WRAP ; -diff_setup_done (&opts); diff_tree_oid(get_commit_tree_oid(origin),t/t4052-stat-output.sh +33
-15@@ -44,42 +44,50 @@ show --stat log -1 --stat EOF -while read cmd args +cat >expect.60 <<-'EOF' + ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1 + +EOF +cat >expect.6030 <<-'EOF' + ...aaaaaaaaaaaaaaaaaaaaaaaaaaa | 1 + +EOF +cat >expect2.60 <<-'EOF' + ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1 + + ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1 + +EOF +cat >expect2.6030 <<-'EOF' + ...aaaaaaaaaaaaaaaaaaaaaaaaaaa | 1 + + ...aaaaaaaaaaaaaaaaaaaaaaaaaaa | 1 + +EOF +while read expect cmd args do - cat >expect <<-'EOF' - ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaa | 1 + - EOF test_expect_success "$cmd --stat=width: a long name is given more room when the bar is short" ' git $cmd $args --stat=40 >output && grep " | " output >actual && - test_cmp expect actual + test_cmp $expect.60 actual ' test_expect_success "$cmd --stat-width=width with long name" ' git $cmd $args --stat-width=40 >output && grep " | " output >actual && - test_cmp expect actual + test_cmp $expect.60 actual ' - cat >expect <<-'EOF' - ...aaaaaaaaaaaaaaaaaaaaaaaaaaa | 1 + - EOF test_expect_success "$cmd --stat=...,name-width with long name" ' git $cmd $args --stat=60,30 >output && grep " | " output >actual && - test_cmp expect actual + test_cmp $expect.6030 actual ' test_expect_success "$cmd --stat-name-width with long name" ' git $cmd $args --stat-name-width=30 >output && grep " | " output >actual && - test_cmp expect actual + test_cmp $expect.6030 actual ' done <<\EOF -format-patch -1 --stdout -diff HEAD^ HEAD --stat -show --stat -log -1 --stat +expect2 format-patch --cover-letter -1 --stdout +expect diff HEAD^ HEAD --stat +expect show --stat +expect log -1 --stat EOF@@ -95,6 +103,16 @@ test_expect_success 'preparation for big change tests' ' git commit -m message abcd ' +cat >expect72 <<'EOF' + abcd | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + abcd | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +EOF +test_expect_success "format-patch --cover-letter ignores COLUMNS (big change)" ' + COLUMNS=200 git format-patch -1 --stdout --cover-letter >output && + grep " | " output >actual && + test_cmp expect72 actual +' + cat >expect72 <<'EOF' abcd | 1000 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ EOF