Skip to content

Commit

Permalink
Change the signature of get_object_entry for future use from Rust
Browse files Browse the repository at this point in the history
  • Loading branch information
glandium committed Nov 11, 2023
1 parent 7a24706 commit 8a6fa69
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
13 changes: 7 additions & 6 deletions src/cinnabar-fast-import.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,20 +113,21 @@ off_t real_find_pack_entry_one(const unsigned char *sha1,
off_t find_pack_entry_one(const unsigned char *sha1, struct packed_git *p)
{
if (p == pack_data) {
struct object_entry *oe = get_object_entry(sha1);
struct object_id oid;
struct object_entry *oe;
hashcpy(oid.hash, sha1);
oid.algo = GIT_HASH_SHA1;
oe = get_object_entry(&oid);
if (oe && oe->idx.offset > 1 && oe->pack_id == pack_id)
return oe->idx.offset;
return 0;
}
return real_find_pack_entry_one(sha1, p);
}

void *get_object_entry(const unsigned char *sha1)
struct object_entry *get_object_entry(const struct object_id *oid)
{
struct object_id oid;
hashcpy(oid.hash, sha1);
oid.algo = GIT_HASH_SHA1;
return find_object(&oid);
return find_object((struct object_id*)oid);
}

/* Mostly copied from fast-import.c's cmd_main() */
Expand Down
3 changes: 2 additions & 1 deletion src/cinnabar-fast-import.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ struct object_id;
struct hg_object_id;
struct cinnabar_notes_tree;
struct rev_chunk;
struct object_entry;

int maybe_handle_command(struct reader *helper_input, int helper_output,
const char *command, struct string_list *args);

void *get_object_entry(const unsigned char *sha1);
struct object_entry *get_object_entry(const struct object_id *oid);

void store_git_tree(struct strbuf *tree_buf,
const struct object_id *reference,
Expand Down
2 changes: 1 addition & 1 deletion src/hg-data.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void hg_file_load(struct hg_file *result, const struct hg_object_id *oid)
free(content);

// Note this duplicates work read_object_file already did.
result->content_oe = get_object_entry(note->hash);
result->content_oe = get_object_entry(note);

_hg_file_split(result, metadata_len);
}
Expand Down

0 comments on commit 8a6fa69

Please sign in to comment.