@@ -8,21 +8,25 @@ static const char * const git_symbolic_ref_usage[] = {
8
8
NULL
9
9
};
10
10
11
+ static int shorten ;
12
+
11
13
static void check_symref (const char * HEAD , int quiet )
12
14
{
13
15
unsigned char sha1 [20 ];
14
16
int flag ;
15
- const char * refs_heads_master = resolve_ref_unsafe (HEAD , sha1 , 0 , & flag );
17
+ const char * refname = resolve_ref_unsafe (HEAD , sha1 , 0 , & flag );
16
18
17
- if (!refs_heads_master )
19
+ if (!refname )
18
20
die ("No such ref: %s" , HEAD );
19
21
else if (!(flag & REF_ISSYMREF )) {
20
22
if (!quiet )
21
23
die ("ref %s is not a symbolic ref" , HEAD );
22
24
else
23
25
exit (1 );
24
26
}
25
- puts (refs_heads_master );
27
+ if (shorten )
28
+ refname = shorten_unambiguous_ref (refname , 0 );
29
+ puts (refname );
26
30
}
27
31
28
32
int cmd_symbolic_ref (int argc , const char * * argv , const char * prefix )
@@ -32,6 +36,7 @@ int cmd_symbolic_ref(int argc, const char **argv, const char *prefix)
32
36
struct option options [] = {
33
37
OPT__QUIET (& quiet ,
34
38
"suppress error message for non-symbolic (detached) refs" ),
39
+ OPT_BOOL (0 , "short" , & shorten , "shorten ref output" ),
35
40
OPT_STRING ('m' , NULL , & msg , "reason" , "reason of the update" ),
36
41
OPT_END (),
37
42
};
0 commit comments