[PATCH] fixup! diff: do not show submodule with untracked files as "-dirty"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Simplify checking if we've already set the flags for ignoring submodules
---
 builtin/checkout.c |  1 -
 diff.c             | 12 +++++-------
 diff.h             |  7 +------
 submodule.c        |  5 ++---
 wt-status.c        |  3 ---
 5 files changed, 8 insertions(+), 20 deletions(-)

diff --git a/builtin/checkout.c b/builtin/checkout.c
index 428201380e..0951f8fee5 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -1095,7 +1095,6 @@ static int git_checkout_config(const char *var, const char *value, void *cb)
 {
 	if (!strcmp(var, "diff.ignoresubmodules")) {
 		struct checkout_opts *opts = cb;
-		diff_ignore_submodule_config =1;
 		handle_ignore_submodules_arg(&opts->diff_options, value);
 		return 0;
 	}
diff --git a/diff.c b/diff.c
index 6c9d28d363..93bbb57f88 100644
--- a/diff.c
+++ b/diff.c
@@ -51,7 +51,6 @@ static int diff_no_prefix;
 static int diff_relative;
 static int diff_stat_graph_width;
 static int diff_dirstat_permille_default = 30;
-int diff_ignore_submodule_config = 0;
 static struct diff_options default_diff_options;
 static long diff_algorithm;
 static unsigned ws_error_highlight_default = WSEH_NEW;
@@ -403,10 +402,8 @@ int git_diff_ui_config(const char *var, const char *value, void *cb)
 	if (!strcmp(var, "diff.orderfile"))
 		return git_config_pathname(&diff_order_file_cfg, var, value);
 
-	if (!strcmp(var, "diff.ignoresubmodules")) {
-		diff_ignore_submodule_config =1;
+	if (!strcmp(var, "diff.ignoresubmodules"))
 		handle_ignore_submodules_arg(&default_diff_options, value);
-	}
 
 	if (!strcmp(var, "diff.submodule")) {
 		if (parse_submodule_params(&default_diff_options, value))
@@ -4598,8 +4595,10 @@ void repo_diff_setup(struct repository *r, struct diff_options *options)
 
 	options->color_moved = diff_color_moved_default;
 	options->color_moved_ws_handling = diff_color_moved_ws_default;
-	if(!diff_ignore_submodule_config)
-		handle_ignore_submodules_arg(options, "untracked");
+
+	if(!options->flags.ignore_submodule_set)
+		options->flags.ignore_untracked_in_submodules = 1;
+
 	prep_parse_options(options);
 }
 
@@ -5142,7 +5141,6 @@ static int diff_opt_ignore_submodules(const struct option *opt,
 	if (!arg)
 		arg = "all";
 	options->flags.override_submodule_config = 1;
-	diff_ignore_submodule_config =1;
 	handle_ignore_submodules_arg(options, arg);
 	return 0;
 }
diff --git a/diff.h b/diff.h
index 9bfce084d8..2f5612ff7d 100644
--- a/diff.h
+++ b/diff.h
@@ -180,6 +180,7 @@ struct diff_flags {
 	unsigned ignore_untracked_in_submodules;
 	unsigned ignore_dirty_submodules;
 	unsigned override_submodule_config;
+	unsigned ignore_submodule_set;
 	unsigned dirstat_by_line;
 	unsigned funccontext;
 	unsigned default_follow_renames;
@@ -556,12 +557,6 @@ int diff_queue_is_empty(void);
 void diff_flush(struct diff_options*);
 void diff_warn_rename_limit(const char *varname, int needed, int degraded_cc);
 
-/* 
- * This is for keeping a track whether ignoreSubmodules
- * is  present in user defined config or not.
- */
-extern int diff_ignore_submodule_config;
-
 /* diff-raw status letters */
 #define DIFF_STATUS_ADDED		'A'
 #define DIFF_STATUS_COPIED		'C'
diff --git a/submodule.c b/submodule.c
index a526c96ce2..8f6227c993 100644
--- a/submodule.c
+++ b/submodule.c
@@ -198,10 +198,8 @@ void set_diffopt_flags_from_submodule_config(struct diff_options *diffopt,
 			ignore = submodule->ignore;
 		free(key);
 
-		if (ignore){
-			diff_ignore_submodule_config =1;
+		if (ignore)
 			handle_ignore_submodules_arg(diffopt, ignore);
-		}
 		else if (is_gitmodules_unmerged(the_repository->index))
 			diffopt->flags.ignore_submodules = 1;
 	}
@@ -422,6 +420,7 @@ const char *submodule_strategy_to_string(const struct submodule_update_strategy
 void handle_ignore_submodules_arg(struct diff_options *diffopt,
 				  const char *arg)
 {
+	diffopt->flags.ignore_submodule_set = 1;
 	diffopt->flags.ignore_submodules = 0;
 	diffopt->flags.ignore_untracked_in_submodules = 0;
 	diffopt->flags.ignore_dirty_submodules = 0;
diff --git a/wt-status.c b/wt-status.c
index 791af9321a..7074bbdd53 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -605,7 +605,6 @@ static void wt_status_collect_changes_worktree(struct wt_status *s)
 		rev.diffopt.flags.ignore_untracked_in_submodules = 1;
 	if (s->ignore_submodule_arg) {
 		rev.diffopt.flags.override_submodule_config = 1;
-		diff_ignore_submodule_config =1;
 		handle_ignore_submodules_arg(&rev.diffopt, s->ignore_submodule_arg);
 	}
 	rev.diffopt.format_callback = wt_status_collect_changed_cb;
@@ -630,7 +629,6 @@ static void wt_status_collect_changes_index(struct wt_status *s)
 	rev.diffopt.flags.override_submodule_config = 1;
 	rev.diffopt.ita_invisible_in_index = 1;
 	if (s->ignore_submodule_arg) {
-		diff_ignore_submodule_config =1;
 		handle_ignore_submodules_arg(&rev.diffopt, s->ignore_submodule_arg);
 	} else {
 		/*
@@ -641,7 +639,6 @@ static void wt_status_collect_changes_index(struct wt_status *s)
 		 * shown any submodules she manually added (and which are
 		 * staged to be committed), which would be really confusing.
 		 */
-		diff_ignore_submodule_config =1;
 		handle_ignore_submodules_arg(&rev.diffopt, "dirty");
 	}
 
-- 
2.25.1.551.gd3318bf0d3.dirty




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux