@@ -121,6 +121,17 @@ static int parse_dirstat_params(struct diff_options *options, const char *params
121121 return ret ;
122122}
123123
124+ static int parse_submodule_params (struct diff_options * options , const char * value )
125+ {
126+ if (!strcmp (value , "log" ))
127+ DIFF_OPT_SET (options , SUBMODULE_LOG );
128+ else if (!strcmp (value , "short" ))
129+ DIFF_OPT_CLR (options , SUBMODULE_LOG );
130+ else
131+ return -1 ;
132+ return 0 ;
133+ }
134+
124135static int git_config_rename (const char * var , const char * value )
125136{
126137 if (!value )
@@ -176,6 +187,13 @@ int git_diff_ui_config(const char *var, const char *value, void *cb)
176187 if (!strcmp (var , "diff.ignoresubmodules" ))
177188 handle_ignore_submodules_arg (& default_diff_options , value );
178189
190+ if (!strcmp (var , "diff.submodule" )) {
191+ if (parse_submodule_params (& default_diff_options , value ))
192+ warning (_ ("Unknown value for 'diff.submodule' config variable: '%s'" ),
193+ value );
194+ return 0 ;
195+ }
196+
179197 if (git_color_config (var , value , cb ) < 0 )
180198 return -1 ;
181199
@@ -3473,6 +3491,14 @@ static int parse_dirstat_opt(struct diff_options *options, const char *params)
34733491 return 1 ;
34743492}
34753493
3494+ static int parse_submodule_opt (struct diff_options * options , const char * value )
3495+ {
3496+ if (parse_submodule_params (options , value ))
3497+ die (_ ("Failed to parse --submodule option parameter: '%s'" ),
3498+ value );
3499+ return 1 ;
3500+ }
3501+
34763502int diff_opt_parse (struct diff_options * options , const char * * av , int ac )
34773503{
34783504 const char * arg = av [0 ];
@@ -3653,10 +3679,8 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
36533679 handle_ignore_submodules_arg (options , arg + 20 );
36543680 } else if (!strcmp (arg , "--submodule" ))
36553681 DIFF_OPT_SET (options , SUBMODULE_LOG );
3656- else if (!prefixcmp (arg , "--submodule=" )) {
3657- if (!strcmp (arg + 12 , "log" ))
3658- DIFF_OPT_SET (options , SUBMODULE_LOG );
3659- }
3682+ else if (!prefixcmp (arg , "--submodule=" ))
3683+ return parse_submodule_opt (options , arg + 12 );
36603684
36613685 /* misc options */
36623686 else if (!strcmp (arg , "-z" ))
0 commit comments