Michael Haggerty wrote:
> It's bad manners. Especially since there could be a signal during the
> call to unlink_or_warn(), in which case the signal handler will see
> the wrong filename and delete the reference file, leaving the lockfile
> behind.
>
> So make our own copy to work with.
Nice. Could this be a helper, to help others avoid a PATH_MAX
sized buffer too?
[...]
> --- a/refs.c
> +++ b/refs.c
> @@ -2551,12 +2551,15 @@ int repack_without_refs(const char **refnames, int n,
> struct strbuf *err)
> static int delete_ref_loose(struct ref_lock *lock, int flag)
[...]
> + /*
> + * loose. The loose file name is the same as the
> + * lockfile name, minus ".lock":
> + */
> + char *loose_filename = xmemdupz(
> + lock->lk->filename,
> + strlen(lock->lk->filename) - LOCK_SUFFIX_LEN);
Ronnie mentioned that this would misbehave in the
!lock->lk->filename[0] case, which shouldn't come up because
lock_ref_sha1_basic dies on error but seems worth futureproofing
against. Maybe something like
assert(lock->lk->filename[0]);
would be enough to make the assumption obvious for people reading.
Otherwise looks good.
Thanks,
Jonathan
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html