From: Junio C Hamano Date: Wed, 15 Nov 2017 03:14:30 +0000 (+0900) Subject: Merge branch 'bw/rebase-i-ignored-submodule-fix' X-Git-Tag: v2.16.0-rc0~131 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/b50d82b00a8fc9d24e41ae7dc30185555f8fb0a0?hp=-c Merge branch 'bw/rebase-i-ignored-submodule-fix' "git rebase -i" recently started misbehaving when a submodule that is configured with 'submodule..ignore' is dirty; this has been corrected. * bw/rebase-i-ignored-submodule-fix: wt-status: actually ignore submodules when requested --- b50d82b00a8fc9d24e41ae7dc30185555f8fb0a0 diff --combined wt-status.c index 937a87bbd5,7346a89ef2..ef26f07446 --- a/wt-status.c +++ b/wt-status.c @@@ -121,13 -121,15 +121,13 @@@ static void status_printf_more(struct w void wt_status_prepare(struct wt_status *s) { - struct object_id oid; - memset(s, 0, sizeof(*s)); memcpy(s->color_palette, default_wt_status_colors, sizeof(default_wt_status_colors)); s->show_untracked_files = SHOW_NORMAL_UNTRACKED_FILES; s->use_color = -1; s->relative_paths = 1; - s->branch = resolve_refdup("HEAD", 0, oid.hash, NULL); + s->branch = resolve_refdup("HEAD", 0, NULL, NULL); s->reference = "HEAD"; s->fp = stdout; s->index_file = get_index_file(); @@@ -559,12 -561,12 +559,12 @@@ static void wt_status_collect_changes_w init_revisions(&rev, NULL); setup_revisions(0, NULL, &rev, NULL); rev.diffopt.output_format |= DIFF_FORMAT_CALLBACK; - DIFF_OPT_SET(&rev.diffopt, DIRTY_SUBMODULES); + rev.diffopt.flags.dirty_submodules = 1; rev.diffopt.ita_invisible_in_index = 1; if (!s->show_untracked_files) - DIFF_OPT_SET(&rev.diffopt, IGNORE_UNTRACKED_IN_SUBMODULES); + rev.diffopt.flags.ignore_untracked_in_submodules = 1; if (s->ignore_submodule_arg) { - DIFF_OPT_SET(&rev.diffopt, OVERRIDE_SUBMODULE_CONFIG); + rev.diffopt.flags.override_submodule_config = 1; handle_ignore_submodules_arg(&rev.diffopt, s->ignore_submodule_arg); } rev.diffopt.format_callback = wt_status_collect_changed_cb; @@@ -583,7 -585,7 +583,7 @@@ static void wt_status_collect_changes_i opt.def = s->is_initial ? EMPTY_TREE_SHA1_HEX : s->reference; setup_revisions(0, NULL, &rev, &opt); - DIFF_OPT_SET(&rev.diffopt, OVERRIDE_SUBMODULE_CONFIG); + rev.diffopt.flags.override_submodule_config = 1; rev.diffopt.ita_invisible_in_index = 1; if (s->ignore_submodule_arg) { handle_ignore_submodules_arg(&rev.diffopt, s->ignore_submodule_arg); @@@ -658,15 -660,10 +658,15 @@@ static void wt_status_collect_untracked if (s->show_untracked_files != SHOW_ALL_UNTRACKED_FILES) dir.flags |= DIR_SHOW_OTHER_DIRECTORIES | DIR_HIDE_EMPTY_DIRECTORIES; - if (s->show_ignored_files) + if (s->show_ignored_mode) { dir.flags |= DIR_SHOW_IGNORED_TOO; - else + + if (s->show_ignored_mode == SHOW_MATCHING_IGNORED) + dir.flags |= DIR_SHOW_IGNORED_TOO_MODE_MATCHING; + } else { dir.untracked = the_index.untracked; + } + setup_standard_excludes(&dir); fill_directory(&dir, &the_index, &s->pathspec); @@@ -937,7 -934,7 +937,7 @@@ size_t wt_status_locate_end(const char void wt_status_add_cut_line(FILE *fp) { - const char *explanation = _("Do not touch the line above.\nEverything below will be removed."); + const char *explanation = _("Do not modify or remove the line above.\nEverything below it will be ignored."); struct strbuf buf = STRBUF_INIT; fprintf(fp, "%c %s", comment_line_char, cut_line); @@@ -954,7 -951,7 +954,7 @@@ static void wt_longstatus_print_verbose const char *c = color(WT_STATUS_HEADER, s); init_revisions(&rev, NULL); - DIFF_OPT_SET(&rev.diffopt, ALLOW_TEXTCONV); + rev.diffopt.flags.allow_textconv = 1; rev.diffopt.ita_invisible_in_index = 1; memset(&opt, 0, sizeof(opt)); @@@ -1029,7 -1026,6 +1029,7 @@@ static void wt_longstatus_print_trackin comment_line_char); else fputs("\n", s->fp); + strbuf_release(&sb); } static int has_unmerged(struct wt_status *s) @@@ -1197,7 -1193,6 +1197,7 @@@ static int read_rebase_todolist(const c string_list_append(lines, line.buf); } fclose(f); + strbuf_release(&line); return 0; } @@@ -1454,7 -1449,7 +1454,7 @@@ static void wt_status_get_detached_from return; } - if (dwim_ref(cb.buf.buf, cb.buf.len, oid.hash, &ref) == 1 && + if (dwim_ref(cb.buf.buf, cb.buf.len, &oid, &ref) == 1 && /* sha1 is a commit? match without further lookup */ (!oidcmp(&cb.noid, &oid) || /* perhaps sha1 is a tag, try to dereference to a commit */ @@@ -1624,7 -1619,7 +1624,7 @@@ static void wt_longstatus_print(struct } if (s->show_untracked_files) { wt_longstatus_print_other(s, &s->untracked, _("Untracked files"), "add"); - if (s->show_ignored_files) + if (s->show_ignored_mode) wt_longstatus_print_other(s, &s->ignored, _("Ignored files"), "add -f"); if (advice_status_u_option && 2000 < s->untracked_in_ms) { status_printf_ln(s, GIT_COLOR_NORMAL, "%s", ""); @@@ -2267,9 -2262,11 +2267,11 @@@ int has_unstaged_changes(int ignore_sub int result; init_revisions(&rev_info, NULL); - if (ignore_submodules) + if (ignore_submodules) { - DIFF_OPT_SET(&rev_info.diffopt, IGNORE_SUBMODULES); - DIFF_OPT_SET(&rev_info.diffopt, OVERRIDE_SUBMODULE_CONFIG); + rev_info.diffopt.flags.ignore_submodules = 1; ++ rev_info.diffopt.flags.override_submodule_config = 1; + } - DIFF_OPT_SET(&rev_info.diffopt, QUICK); + rev_info.diffopt.flags.quick = 1; diff_setup_done(&rev_info.diffopt); result = run_diff_files(&rev_info, 0); return diff_result_code(&rev_info.diffopt, result); @@@ -2288,8 -2285,8 +2290,8 @@@ int has_uncommitted_changes(int ignore_ init_revisions(&rev_info, NULL); if (ignore_submodules) - DIFF_OPT_SET(&rev_info.diffopt, IGNORE_SUBMODULES); - DIFF_OPT_SET(&rev_info.diffopt, QUICK); + rev_info.diffopt.flags.ignore_submodules = 1; + rev_info.diffopt.flags.quick = 1; add_head_to_pending(&rev_info); diff_setup_done(&rev_info.diffopt); result = run_diff_index(&rev_info, 1); @@@ -2302,14 -2299,14 +2304,14 @@@ */ int require_clean_work_tree(const char *action, const char *hint, int ignore_submodules, int gently) { - struct lock_file *lock_file = xcalloc(1, sizeof(*lock_file)); + struct lock_file lock_file = LOCK_INIT; int err = 0, fd; - fd = hold_locked_index(lock_file, 0); + fd = hold_locked_index(&lock_file, 0); refresh_cache(REFRESH_QUIET); if (0 <= fd) - update_index_if_able(&the_index, lock_file); - rollback_lock_file(lock_file); + update_index_if_able(&the_index, &lock_file); + rollback_lock_file(&lock_file); if (has_unstaged_changes(ignore_submodules)) { /* TRANSLATORS: the action is e.g. "pull with rebase" */