@@ -199,6 +199,7 @@ static const char *lock_repo_for_gc(int force, pid_t* ret_pid)
199
199
uintmax_t pid ;
200
200
FILE * fp ;
201
201
int fd ;
202
+ char * pidfile_path ;
202
203
203
204
if (pidfile )
204
205
/* already locked */
@@ -207,12 +208,13 @@ static const char *lock_repo_for_gc(int force, pid_t* ret_pid)
207
208
if (gethostname (my_host , sizeof (my_host )))
208
209
strcpy (my_host , "unknown" );
209
210
210
- fd = hold_lock_file_for_update (& lock , git_path ("gc.pid" ),
211
+ pidfile_path = git_pathdup ("gc.pid" );
212
+ fd = hold_lock_file_for_update (& lock , pidfile_path ,
211
213
LOCK_DIE_ON_ERROR );
212
214
if (!force ) {
213
215
static char locking_host [128 ];
214
216
int should_exit ;
215
- fp = fopen (git_path ( "gc.pid" ) , "r" );
217
+ fp = fopen (pidfile_path , "r" );
216
218
memset (locking_host , 0 , sizeof (locking_host ));
217
219
should_exit =
218
220
fp != NULL &&
@@ -236,6 +238,7 @@ static const char *lock_repo_for_gc(int force, pid_t* ret_pid)
236
238
if (fd >= 0 )
237
239
rollback_lock_file (& lock );
238
240
* ret_pid = pid ;
241
+ free (pidfile_path );
239
242
return locking_host ;
240
243
}
241
244
}
@@ -246,7 +249,7 @@ static const char *lock_repo_for_gc(int force, pid_t* ret_pid)
246
249
strbuf_release (& sb );
247
250
commit_lock_file (& lock );
248
251
249
- pidfile = git_pathdup ( "gc.pid" ) ;
252
+ pidfile = pidfile_path ;
250
253
sigchain_push_common (remove_pidfile_on_signal );
251
254
atexit (remove_pidfile );
252
255
0 commit comments