33#include "refs.h"
44
55static const char git_symbolic_ref_usage [] =
6- "git-symbolic-ref [-q] name [ref]" ;
6+ "git-symbolic-ref [-q] [-m <reason>] name [ref]" ;
77
88static void check_symref (const char * HEAD , int quiet )
99{
@@ -25,6 +25,7 @@ static void check_symref(const char *HEAD, int quiet)
2525int cmd_symbolic_ref (int argc , const char * * argv , const char * prefix )
2626{
2727 int quiet = 0 ;
28+ const char * msg = NULL ;
2829
2930 git_config (git_default_config );
3031
@@ -34,6 +35,17 @@ int cmd_symbolic_ref(int argc, const char **argv, const char *prefix)
3435 break ;
3536 else if (!strcmp ("-q" , arg ))
3637 quiet = 1 ;
38+ else if (!strcmp ("-m" , arg )) {
39+ argc -- ;
40+ argv ++ ;
41+ if (argc <= 1 )
42+ break ;
43+ msg = argv [1 ];
44+ if (!* msg )
45+ die ("Refusing to perform update with empty message" );
46+ if (strchr (msg , '\n' ))
47+ die ("Refusing to perform update with \\n in message" );
48+ }
3749 else if (!strcmp ("--" , arg )) {
3850 argc -- ;
3951 argv ++ ;
@@ -50,7 +62,7 @@ int cmd_symbolic_ref(int argc, const char **argv, const char *prefix)
5062 check_symref (argv [1 ], quiet );
5163 break ;
5264 case 3 :
53- create_symref (argv [1 ], argv [2 ]);
65+ create_symref (argv [1 ], argv [2 ], msg );
5466 break ;
5567 default :
5668 usage (git_symbolic_ref_usage );
0 commit comments