Diff: Do not try to calculate an oid for a GITLINK.

We don't have anything useful that we could do with that oid anyway (We
need to query the submodule for the HEAD commit instead).

Without this, the following code creates the error "Failed to read
descriptor: Is a directory" when run against the submod2 test-case:

    const char* oidstr = "873585b94bdeabccea991ea5e3ec1a277895b698";
    git_tree* tree = resolve_commit_oid_to_tree(g_repo, oidstr);
    git_diff_list* diff = NULL;
    cl_assert(tree);
    cl_git_pass(git_diff_workdir_to_tree(g_repo, NULL, tree, &diff));
This commit is contained in:
Sascha Cunz 2012-10-05 13:44:18 +02:00
parent 1686641f18
commit 1dca8510a2

View File

@ -448,7 +448,11 @@ static int oid_for_workdir_item(
return -1;
/* calculate OID for file if possible*/
if (S_ISLNK(item->mode))
if (S_ISGITLINK(item->mode)) {
/* Don't bother to figure out an oid for a submodule. We won't use it anyway. */
memset(oid, 0, sizeof(*oid));
result = 0;
} else if (S_ISLNK(item->mode))
result = git_odb__hashlink(oid, full_path.ptr);
else if (!git__is_sizet(item->file_size)) {
giterr_set(GITERR_OS, "File size overflow for 32-bit systems");