mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-09 18:22:16 +00:00
Diff: teach get_blob_content to show a submodule as text
diff_output.c:get_blob_content used to try to read the submodule commit as a blob in the superproject's odb. Of course it cannot find it and errors out with GIT_ENOTFOUND, implcitly terminating the whole diff output. This patch teaches it to create a text that describes the submodule instead. The text looks like: Subproject commit <SHA1>\n which is what git.git does, too.
This commit is contained in:
parent
1a5cd26b8c
commit
9ce44f1ae5
@ -212,6 +212,22 @@ static int get_blob_content(
|
||||
if (git_oid_iszero(&file->oid))
|
||||
return 0;
|
||||
|
||||
if (file->mode == GIT_FILEMODE_COMMIT)
|
||||
{
|
||||
char oidstr[GIT_OID_HEXSZ+1];
|
||||
git_buf content = GIT_BUF_INIT;
|
||||
|
||||
git_oid_fmt(oidstr, &file->oid);
|
||||
oidstr[GIT_OID_HEXSZ] = 0;
|
||||
git_buf_printf(&content, "Subproject commit %s\n", oidstr );
|
||||
|
||||
map->data = git_buf_detach(&content);
|
||||
map->len = strlen(map->data);
|
||||
|
||||
file->flags |= GIT_DIFF_FILE_FREE_DATA;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!file->size) {
|
||||
git_odb *odb;
|
||||
size_t len;
|
||||
|
Loading…
Reference in New Issue
Block a user