commit - b74bd7ab16a541c7e40d2f73187e0455f5416bb2
commit + 95b631b25683415ef380e22998436c28ad3e34c0
blob - 53e99801ab01ad8804d048c5f59a94930e5ef10a
blob + 17dcc926d4cae7fa2f169eb003ed4aeebba92346
--- include/got_repository.h
+++ include/got_repository.h
/* Obtain the file descriptor of the repository's .git directory. */
int got_repo_get_fd(struct got_repository *);
+/* Obtain the object format */
+enum got_hash_algorithm got_repo_get_object_format(struct got_repository *);
+
/* Obtain the commit author name if parsed from gitconfig, else NULL. */
const char *got_repo_get_gitconfig_author_name(struct got_repository *);
blob - 83d718aa029bf9afded3debb15731d617de2169c
blob + 38259e224eecc4b0deaaaff9b35ca1c7e54810fb
--- lib/got_lib_repository.h
+++ lib/got_lib_repository.h
char *path;
char *path_git_dir;
int gitdir_fd;
+ enum got_hash_algorithm algo;
struct got_pathlist_head packidx_paths;
struct timespec pack_path_mtime;
blob - 822d23e36daa2ec8baf6ed8a425b1b3982747390
blob + 47ff224bf7a9abf8dc6dbf39d3b8c6eb7c173a02
--- lib/reference.c
+++ lib/reference.c
static const struct got_error *
parse_ref_line(struct got_reference **ref, const char *name, const char *line,
- time_t mtime)
+ time_t mtime, enum got_hash_algorithm algo)
{
- enum got_hash_algorithm algo = GOT_HASH_SHA1;
struct got_object_id id;
if (strncmp(line, "ref: ", 5) == 0) {
static const struct got_error *
parse_ref_file(struct got_reference **ref, const char *name,
- const char *absname, const char *abspath, int lock)
+ const char *absname, const char *abspath, int lock,
+ enum got_hash_algorithm algo)
{
const struct got_error *err = NULL;
FILE *f;
linelen--;
}
- err = parse_ref_line(ref, absname, line, sb.st_mtime);
+ err = parse_ref_line(ref, absname, line, sb.st_mtime, algo);
if (lock) {
if (err)
got_lockfile_unlock(lf, -1);
static const struct got_error *
parse_packed_ref_line(struct got_reference **ref, const char *abs_refname,
- const char *line, time_t mtime)
+ const char *line, time_t mtime, enum got_hash_algorithm algo)
{
- enum got_hash_algorithm algo = GOT_HASH_SHA1;
struct got_object_id id;
const char *name;
static const struct got_error *
open_packed_ref(struct got_reference **ref, FILE *f, const char **subdirs,
- int nsubdirs, const char *refname, time_t mtime)
+ int nsubdirs, const char *refname, time_t mtime,
+ enum got_hash_algorithm algo)
{
const struct got_error *err = NULL;
char *abs_refname;
refname) == -1)
return got_error_from_errno("asprintf");
err = parse_packed_ref_line(ref, abs_refname, line,
- mtime);
+ mtime, algo);
if (!ref_is_absolute)
free(abs_refname);
if (err || *ref != NULL)
static const struct got_error *
open_ref(struct got_reference **ref, const char *path_refs, const char *subdir,
- const char *name, int lock)
+ const char *name, int lock, enum got_hash_algorithm algo)
{
const struct got_error *err = NULL;
char *path = NULL;
}
}
- err = parse_ref_file(ref, name, absname, path, lock);
+ err = parse_ref_file(ref, name, absname, path, lock, algo);
done:
if (!ref_is_absolute && !ref_is_well_known)
free(absname);
}
if (well_known) {
- err = open_ref(ref, path_refs, "", refname, lock);
+ err = open_ref(ref, path_refs, "", refname, lock,
+ got_repo_get_object_format(repo));
} else {
FILE *f;
/* Search on-disk refs before packed refs! */
for (i = 0; i < nitems(subdirs); i++) {
err = open_ref(ref, path_refs, subdirs[i], refname,
- lock);
+ lock, got_repo_get_object_format(repo));
if ((err && err->code != GOT_ERR_NOT_REF) || *ref)
goto done;
}
goto done;
}
err = open_packed_ref(ref, f, subdirs, nitems(subdirs),
- refname, sb.st_mtime);
+ refname, sb.st_mtime,
+ got_repo_get_object_format(repo));
if (!err) {
if (fclose(f) == EOF) {
err = got_error_from_errno("fclose");
switch (type) {
case DT_REG:
err = open_ref(&ref, path_refs, subdir, dent->d_name,
- 0);
+ 0, got_repo_get_object_format(repo));
if (err)
goto done;
if (ref) {
err = got_error_from_errno("get_refs_dir_path");
goto done;
}
- err = open_ref(&ref, path_refs, "", GOT_REF_HEAD, 0);
+ err = open_ref(&ref, path_refs, "", GOT_REF_HEAD, 0,
+ got_repo_get_object_format(repo));
if (err)
goto done;
err = got_reflist_insert(&new, refs, ref, cmp_cb, cmp_arg);
err = got_error_from_errno("get_refs_dir_path");
goto done;
}
- err = open_ref(&ref, path_refs, "", refname, 0);
+ err = open_ref(&ref, path_refs, "", refname, 0,
+ got_repo_get_object_format(repo));
if (err) {
if (err->code != GOT_ERR_NOT_REF)
goto done;
if (linelen > 0 && line[linelen - 1] == '\n')
line[linelen - 1] = '\0';
err = parse_packed_ref_line(&ref, NULL, line,
- sb.st_mtime);
+ sb.st_mtime, got_repo_get_object_format(repo));
if (err)
goto done;
if (ref) {
}
if (linelen > 0 && line[linelen - 1] == '\n')
line[linelen - 1] = '\0';
- err = parse_packed_ref_line(&ref, NULL, line, 0);
+ err = parse_packed_ref_line(&ref, NULL, line, 0,
+ got_repo_get_object_format(repo));
if (err)
goto done;
if (ref == NULL)
blob - 7557fdbf38bd4ea36129a027cef620639766bd8d
blob + f6ac7c86bcf7794ce925c45451471441e0d4827c
--- lib/repository.c
+++ lib/repository.c
return repo->gitdir_fd;
}
+enum got_hash_algorithm
+got_repo_get_object_format(struct got_repository *repo)
+{
+ return repo->algo;
+}
+
const char *
got_repo_get_gitconfig_author_name(struct got_repository *repo)
{
}
while ((dent = readdir(dir)) != NULL) {
int cmp;
- enum got_hash_algorithm algo = GOT_HASH_SHA1;
free(id_str);
id_str = NULL;
goto done;
}
- if (!got_parse_hash_digest(id.sha1, id_str, algo))
+ if (!got_parse_hash_digest(id.sha1, id_str, repo->algo))
continue;
/*
char *id_str;
int fd;
struct stat sb;
- enum got_hash_algorithm algo = GOT_HASH_SHA1;
if (strcmp(dent->d_name, ".") == 0 ||
strcmp(dent->d_name, "..") == 0)
goto done;
}
- if (!got_parse_hash_digest(id.sha1, id_str, algo)) {
+ if (!got_parse_hash_digest(id.sha1, id_str,
+ repo->algo)) {
free(id_str);
continue;
}