Skip to content

Commit 5434f9a

Browse files
committed
refs: remove function to read HEAD directly
With the last user of `git_reference__read_head` gone, let's remove it as it's been reading references without consulting the refdb backends.
1 parent 6589541 commit 5434f9a

File tree

2 files changed

+0
-52
lines changed

2 files changed

+0
-52
lines changed

src/refs.c

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -263,40 +263,6 @@ int git_reference_lookup_resolved(
263263
return 0;
264264
}
265265

266-
int git_reference__read_head(
267-
git_reference **out,
268-
git_repository *repo,
269-
const char *path)
270-
{
271-
git_buf reference = GIT_BUF_INIT;
272-
char *name = NULL;
273-
int error;
274-
275-
if ((error = git_futils_readbuffer(&reference, path)) < 0)
276-
goto out;
277-
git_buf_rtrim(&reference);
278-
279-
if (git__strncmp(reference.ptr, GIT_SYMREF, strlen(GIT_SYMREF)) == 0) {
280-
git_buf_consume(&reference, reference.ptr + strlen(GIT_SYMREF));
281-
282-
name = git_path_basename(path);
283-
284-
if ((*out = git_reference__alloc_symbolic(name, reference.ptr)) == NULL) {
285-
error = -1;
286-
goto out;
287-
}
288-
} else {
289-
if ((error = git_reference_lookup(out, repo, reference.ptr)) < 0)
290-
goto out;
291-
}
292-
293-
out:
294-
git__free(name);
295-
git_buf_dispose(&reference);
296-
297-
return error;
298-
}
299-
300266
int git_reference_dwim(git_reference **out, git_repository *repo, const char *refname)
301267
{
302268
int error = 0, i;

src/refs.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -116,24 +116,6 @@ int git_reference_lookup_resolved(
116116
const char *name,
117117
int max_deref);
118118

119-
/**
120-
* Read reference from a file.
121-
*
122-
* This function will read in the file at `path`. If it is a
123-
* symref, it will return a new unresolved symbolic reference
124-
* with the given name pointing to the reference pointed to by
125-
* the file. If it is not a symbolic reference, it will return
126-
* the resolved reference.
127-
*
128-
* Note that because the refdb is not involved for symbolic references, they
129-
* won't be owned, hence you should either not make the returned reference
130-
* 'externally visible', or perform the lookup before returning it to the user.
131-
*/
132-
int git_reference__read_head(
133-
git_reference **out,
134-
git_repository *repo,
135-
const char *path);
136-
137119
int git_reference__log_signature(git_signature **out, git_repository *repo);
138120

139121
/** Update a reference after a commit. */

0 commit comments

Comments
 (0)