summaryrefslogtreecommitdiff
path: root/file/git-hist.c
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-09-04 07:11:13 -0300
committerWerner Almesberger <werner@almesberger.net>2016-09-04 07:19:45 -0300
commitba7b2c25799e9615705e146f18a74a0389108e6c (patch)
tree6972000191be3e6fd8dbcac95eec01ee07cf5c7f /file/git-hist.c
parentce034adb60b431114abf49b4aceb39e96b48c682 (diff)
downloadeeshow-ba7b2c25799e9615705e146f18a74a0389108e6c.tar.gz
eeshow-ba7b2c25799e9615705e146f18a74a0389108e6c.tar.bz2
eeshow-ba7b2c25799e9615705e146f18a74a0389108e6c.zip
file/git-hist.c (vcs_git_try): check if the file really exists in the repo
Else, eeshow may load some huge revision history for an uncommitted file, just to report that it can't be found.
Diffstat (limited to 'file/git-hist.c')
-rw-r--r--file/git-hist.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/file/git-hist.c b/file/git-hist.c
index b536c22..4b81ce8 100644
--- a/file/git-hist.c
+++ b/file/git-hist.c
@@ -22,6 +22,7 @@
#include "misc/util.h"
#include "misc/diag.h"
+#include "file/file.h"
#include "file/git-util.h"
#include "file/git-file.h"
#include "file/git-hist.h"
@@ -199,13 +200,26 @@ static void recurse(struct vcs_history *history, struct vcs_hist *h,
bool vcs_git_try(const char *path)
{
git_repository *repo;
+ struct file file;
git_init_once();
+ /*
+ * We could just call file_open_vcs and let it check if the repo even
+ * exists, but then it would complain about the file not existing,
+ * which would be at best confusing.
+ */
if (git_repository_open_ext(&repo, path,
GIT_REPOSITORY_OPEN_CROSS_FS, NULL))
return 0;
- return !git_repository_is_empty(repo);
+ if (git_repository_is_empty(repo))
+ return 0;
+
+ /* check that the file is really in the repo */
+ if (!file_open_vcs(&file, path))
+ return 0;
+ file_close(&file);
+ return 1;
}