@@ -31,24 +31,19 @@ static void show_new(enum object_type type, unsigned char *sha1_new)
3131 find_unique_abbrev (sha1_new , DEFAULT_ABBREV ));
3232}
3333
34- static int update_ref (const char * action ,
34+ static int update_ref_env (const char * action ,
3535 const char * refname ,
3636 unsigned char * sha1 ,
3737 unsigned char * oldval )
3838{
3939 char msg [1024 ];
4040 char * rla = getenv ("GIT_REFLOG_ACTION" );
41- static struct ref_lock * lock ;
4241
4342 if (!rla )
4443 rla = "(reflog update)" ;
45- snprintf (msg , sizeof (msg ), "%s: %s" , rla , action );
46- lock = lock_any_ref_for_update (refname , oldval , 0 );
47- if (!lock )
48- return 1 ;
49- if (write_ref_sha1 (lock , sha1 , msg ) < 0 )
50- return 1 ;
51- return 0 ;
44+ if (snprintf (msg , sizeof (msg ), "%s: %s" , rla , action ) >= sizeof (msg ))
45+ warning ("reflog message too long: %.*s..." , 50 , msg );
46+ return update_ref (msg , refname , sha1 , oldval , 0 , QUIET_ON_ERR );
5247}
5348
5449static int update_local_ref (const char * name ,
@@ -88,7 +83,7 @@ static int update_local_ref(const char *name,
8883 fprintf (stderr , "* %s: storing %s\n" ,
8984 name , note );
9085 show_new (type , sha1_new );
91- return update_ref (msg , name , sha1_new , NULL );
86+ return update_ref_env (msg , name , sha1_new , NULL );
9287 }
9388
9489 if (!hashcmp (sha1_old , sha1_new )) {
@@ -102,7 +97,7 @@ static int update_local_ref(const char *name,
10297 if (!strncmp (name , "refs/tags/" , 10 )) {
10398 fprintf (stderr , "* %s: updating with %s\n" , name , note );
10499 show_new (type , sha1_new );
105- return update_ref ("updating tag" , name , sha1_new , NULL );
100+ return update_ref_env ("updating tag" , name , sha1_new , NULL );
106101 }
107102
108103 current = lookup_commit_reference (sha1_old );
@@ -117,7 +112,7 @@ static int update_local_ref(const char *name,
117112 fprintf (stderr , "* %s: fast forward to %s\n" ,
118113 name , note );
119114 fprintf (stderr , " old..new: %s..%s\n" , oldh , newh );
120- return update_ref ("fast forward" , name , sha1_new , sha1_old );
115+ return update_ref_env ("fast forward" , name , sha1_new , sha1_old );
121116 }
122117 if (!force ) {
123118 fprintf (stderr ,
@@ -131,7 +126,7 @@ static int update_local_ref(const char *name,
131126 "* %s: forcing update to non-fast forward %s\n" ,
132127 name , note );
133128 fprintf (stderr , " old...new: %s...%s\n" , oldh , newh );
134- return update_ref ("forced-update" , name , sha1_new , sha1_old );
129+ return update_ref_env ("forced-update" , name , sha1_new , sha1_old );
135130}
136131
137132static int append_fetch_head (FILE * fp ,
0 commit comments