aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkst <[email protected]>2020-08-05 22:11:18 +0000
committerHiltjo Posthuma <[email protected]>2020-08-06 18:25:27 +0200
commit174a763058f9a90831ab5a2aeb1c9bfbecdabf48 (patch)
tree641e9989acb9afb379a1dc872593d745faaeff3f
parentf05e6b0fcb3b874180970d06ebcde05fb5aea470 (diff)
downloadstagit-174a763058f9a90831ab5a2aeb1c9bfbecdabf48.tar.gz
stagit-174a763058f9a90831ab5a2aeb1c9bfbecdabf48.zip
fix submodule lookup in bare repos
git_submodule_lookup does not work without a working tree [1], so the current approach fails to recognize any submodules in bare repos. Instead, notice that $ git ls-tree HEAD lists any submodules as commit objects regardless of a working tree. This is the only instance commit object is used in a tree, so we will use this to check for submodules. [1]: https://github.com/libgit2/libgit2/pull/4305/files
-rw-r--r--stagit.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/stagit.c b/stagit.c
index 0377ad8..d5c6015 100644
--- a/stagit.c
+++ b/stagit.c
@@ -976,7 +976,6 @@ int
writefilestree(FILE *fp, git_tree *tree, const char *path)
{
const git_tree_entry *entry = NULL;
- git_submodule *module = NULL;
git_object *obj = NULL;
git_off_t filesize;
const char *entryname;
@@ -1029,11 +1028,11 @@ writefilestree(FILE *fp, git_tree *tree, const char *path)
fprintf(fp, "%juB", (uintmax_t)filesize);
fputs("</td></tr>\n", fp);
git_object_free(obj);
- } else if (!git_submodule_lookup(&module, repo, entryname)) {
+ } else if (git_tree_entry_type(entry) == GIT_OBJ_COMMIT) {
+ /* commit object in tree is a submodule */
fprintf(fp, "<tr><td>m---------</td><td><a href=\"%sfile/.gitmodules.html\">",
relpath);
xmlencode(fp, entrypath, strlen(entrypath));
- git_submodule_free(module);
fputs("</a></td><td class=\"num\" align=\"right\"></td></tr>\n", fp);
}
}