]> git.armaanb.net Git - stagit.git/commitdiff
check if LICENSE, README and .gitmodules is a file blob
authorHiltjo Posthuma <hiltjo@codemadness.org>
Sun, 8 May 2016 18:35:49 +0000 (20:35 +0200)
committerHiltjo Posthuma <hiltjo@codemadness.org>
Sun, 8 May 2016 18:37:37 +0000 (20:37 +0200)
don't link to directory trees, etc. Thanks 600360 for reporting it!

stagit.c

index bb7cd738343b63541cc66c117d487aec9ab7f386..f97ade984f8a08cbd370f4d39e878f999e0e9d56 100644 (file)
--- a/stagit.c
+++ b/stagit.c
@@ -1085,12 +1085,17 @@ main(int argc, char *argv[])
        }
 
        /* check LICENSE */
-       haslicense = !git_revparse_single(&obj, repo, "HEAD:LICENSE");
+       haslicense = (!git_revparse_single(&obj, repo, "HEAD:LICENSE") &&
+               git_object_type(obj) == GIT_OBJ_BLOB);
        git_object_free(obj);
+
        /* check README */
-       hasreadme = !git_revparse_single(&obj, repo, "HEAD:README");
+       hasreadme = (!git_revparse_single(&obj, repo, "HEAD:README") &&
+               git_object_type(obj) == GIT_OBJ_BLOB);
        git_object_free(obj);
-       hassubmodules = !git_revparse_single(&obj, repo, "HEAD:.gitmodules");
+
+       hassubmodules = (!git_revparse_single(&obj, repo, "HEAD:.gitmodules") &&
+               git_object_type(obj) == GIT_OBJ_BLOB);
        git_object_free(obj);
 
        /* log for HEAD */