From 1dca8510a2e815c95293c1ebaacf2a286a9c6e1d Mon Sep 17 00:00:00 2001 From: Sascha Cunz Date: Fri, 5 Oct 2012 13:44:18 +0200 Subject: [PATCH] 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)); --- src/diff.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/diff.c b/src/diff.c index 375520e04..7a0051ae3 100644 --- a/src/diff.c +++ b/src/diff.c @@ -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");