Skip to content

Commit cba1202

Browse files
rsahlberggitster
authored andcommitted
refs.c: remove lock_ref_sha1
lock_ref_sha1 was only called from one place in refs.c and only provided a check that the refname was sane before adding back the initial "refs/" part of the ref path name, the initial "refs/" that this caller had already stripped off before calling lock_ref_sha1. Signed-off-by: Ronnie Sahlberg <[email protected]> Reviewed-by: Michael Haggerty <[email protected]> Signed-off-by: Jonathan Nieder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 04ad622 commit cba1202

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

refs.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2173,15 +2173,6 @@ static struct ref_lock *lock_ref_sha1_basic(const char *refname,
21732173
return NULL;
21742174
}
21752175

2176-
static struct ref_lock *lock_ref_sha1(const char *refname, const unsigned char *old_sha1)
2177-
{
2178-
char refpath[PATH_MAX];
2179-
if (check_refname_format(refname, 0))
2180-
return NULL;
2181-
strcpy(refpath, mkpath("refs/%s", refname));
2182-
return lock_ref_sha1_basic(refpath, old_sha1, 0, NULL);
2183-
}
2184-
21852176
struct ref_lock *lock_any_ref_for_update(const char *refname,
21862177
const unsigned char *old_sha1,
21872178
int flags, int *type_p)
@@ -2391,8 +2382,12 @@ static void try_remove_empty_parents(char *name)
23912382
/* make sure nobody touched the ref, and unlink */
23922383
static void prune_ref(struct ref_to_prune *r)
23932384
{
2394-
struct ref_lock *lock = lock_ref_sha1(r->name + 5, r->sha1);
2385+
struct ref_lock *lock;
2386+
2387+
if (check_refname_format(r->name + 5, 0))
2388+
return;
23952389

2390+
lock = lock_ref_sha1_basic(r->name, r->sha1, 0, NULL);
23962391
if (lock) {
23972392
unlink_or_warn(git_path("%s", r->name));
23982393
unlock_ref(lock);

0 commit comments

Comments
 (0)