@@ -123,6 +123,17 @@ static int parse_dirstat_params(struct diff_options *options, const char *params
123123 return ret ;
124124}
125125
126+ static int parse_submodule_params (struct diff_options * options , const char * value )
127+ {
128+ if (!strcmp (value , "log" ))
129+ DIFF_OPT_SET (options , SUBMODULE_LOG );
130+ else if (!strcmp (value , "short" ))
131+ DIFF_OPT_CLR (options , SUBMODULE_LOG );
132+ else
133+ return -1 ;
134+ return 0 ;
135+ }
136+
126137static int git_config_rename (const char * var , const char * value )
127138{
128139 if (!value )
@@ -178,6 +189,13 @@ int git_diff_ui_config(const char *var, const char *value, void *cb)
178189 if (!strcmp (var , "diff.ignoresubmodules" ))
179190 handle_ignore_submodules_arg (& default_diff_options , value );
180191
192+ if (!strcmp (var , "diff.submodule" )) {
193+ if (parse_submodule_params (& default_diff_options , value ))
194+ warning (_ ("Unknown value for 'diff.submodule' config variable: '%s'" ),
195+ value );
196+ return 0 ;
197+ }
198+
181199 if (git_color_config (var , value , cb ) < 0 )
182200 return -1 ;
183201
@@ -2223,7 +2241,7 @@ static void builtin_diff(const char *name_a,
22232241 mmfile_t mf1 , mf2 ;
22242242 const char * lbl [2 ];
22252243 char * a_one , * b_two ;
2226- const char * set = diff_get_color_opt (o , DIFF_METAINFO );
2244+ const char * meta = diff_get_color_opt (o , DIFF_METAINFO );
22272245 const char * reset = diff_get_color_opt (o , DIFF_RESET );
22282246 const char * a_prefix , * b_prefix ;
22292247 struct userdiff_driver * textconv_one = NULL ;
@@ -2244,7 +2262,7 @@ static void builtin_diff(const char *name_a,
22442262 const char * add = diff_get_color_opt (o , DIFF_FILE_NEW );
22452263 show_submodule_summary (o -> file , one ? one -> path : two -> path ,
22462264 one -> sha1 , two -> sha1 , two -> dirty_submodule ,
2247- del , add , reset );
2265+ meta , del , add , reset );
22482266 return ;
22492267 }
22502268
@@ -2270,24 +2288,24 @@ static void builtin_diff(const char *name_a,
22702288 b_two = quote_two (b_prefix , name_b + (* name_b == '/' ));
22712289 lbl [0 ] = DIFF_FILE_VALID (one ) ? a_one : "/dev/null" ;
22722290 lbl [1 ] = DIFF_FILE_VALID (two ) ? b_two : "/dev/null" ;
2273- strbuf_addf (& header , "%s%sdiff --git %s %s%s\n" , line_prefix , set , a_one , b_two , reset );
2291+ strbuf_addf (& header , "%s%sdiff --git %s %s%s\n" , line_prefix , meta , a_one , b_two , reset );
22742292 if (lbl [0 ][0 ] == '/' ) {
22752293 /* /dev/null */
2276- strbuf_addf (& header , "%s%snew file mode %06o%s\n" , line_prefix , set , two -> mode , reset );
2294+ strbuf_addf (& header , "%s%snew file mode %06o%s\n" , line_prefix , meta , two -> mode , reset );
22772295 if (xfrm_msg )
22782296 strbuf_addstr (& header , xfrm_msg );
22792297 must_show_header = 1 ;
22802298 }
22812299 else if (lbl [1 ][0 ] == '/' ) {
2282- strbuf_addf (& header , "%s%sdeleted file mode %06o%s\n" , line_prefix , set , one -> mode , reset );
2300+ strbuf_addf (& header , "%s%sdeleted file mode %06o%s\n" , line_prefix , meta , one -> mode , reset );
22832301 if (xfrm_msg )
22842302 strbuf_addstr (& header , xfrm_msg );
22852303 must_show_header = 1 ;
22862304 }
22872305 else {
22882306 if (one -> mode != two -> mode ) {
2289- strbuf_addf (& header , "%s%sold mode %06o%s\n" , line_prefix , set , one -> mode , reset );
2290- strbuf_addf (& header , "%s%snew mode %06o%s\n" , line_prefix , set , two -> mode , reset );
2307+ strbuf_addf (& header , "%s%sold mode %06o%s\n" , line_prefix , meta , one -> mode , reset );
2308+ strbuf_addf (& header , "%s%snew mode %06o%s\n" , line_prefix , meta , two -> mode , reset );
22912309 must_show_header = 1 ;
22922310 }
22932311 if (xfrm_msg )
@@ -3480,6 +3498,14 @@ static int parse_dirstat_opt(struct diff_options *options, const char *params)
34803498 return 1 ;
34813499}
34823500
3501+ static int parse_submodule_opt (struct diff_options * options , const char * value )
3502+ {
3503+ if (parse_submodule_params (options , value ))
3504+ die (_ ("Failed to parse --submodule option parameter: '%s'" ),
3505+ value );
3506+ return 1 ;
3507+ }
3508+
34833509int diff_opt_parse (struct diff_options * options , const char * * av , int ac )
34843510{
34853511 const char * arg = av [0 ];
@@ -3660,10 +3686,8 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
36603686 handle_ignore_submodules_arg (options , arg + 20 );
36613687 } else if (!strcmp (arg , "--submodule" ))
36623688 DIFF_OPT_SET (options , SUBMODULE_LOG );
3663- else if (!prefixcmp (arg , "--submodule=" )) {
3664- if (!strcmp (arg + 12 , "log" ))
3665- DIFF_OPT_SET (options , SUBMODULE_LOG );
3666- }
3689+ else if (!prefixcmp (arg , "--submodule=" ))
3690+ return parse_submodule_opt (options , arg + 12 );
36673691
36683692 /* misc options */
36693693 else if (!strcmp (arg , "-z" ))
0 commit comments