summaryrefslogtreecommitdiff
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
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.
-rw-r--r--file/file.c8
-rw-r--r--file/file.h1
-rw-r--r--file/git-hist.c16
3 files changed, 24 insertions, 1 deletions
diff --git a/file/file.c b/file/file.c
index 80c19a7..7b7ebca 100644
--- a/file/file.c
+++ b/file/file.c
@@ -166,6 +166,14 @@ static void file_init(struct file *file, const char *name,
}
+bool file_open_vcs(struct file *file, const char *name)
+{
+ file_init(file, name, NULL);
+ file->vcs = open_vcs(file);
+ return file->vcs;
+}
+
+
bool file_open(struct file *file, const char *name, const struct file *related)
{
file_init(file, name, related);
diff --git a/file/file.h b/file/file.h
index 15ebc1a..44d12cc 100644
--- a/file/file.h
+++ b/file/file.h
@@ -33,6 +33,7 @@ bool file_cat(const struct file *file, void *user, const char *line);
char *file_graft_relative(const char *base, const char *name);
+bool file_open_vcs(struct file *file, const char *name);
bool file_open(struct file *file, const char *name,
const struct file *related);
bool file_open_revision(struct file *file, const char *rev, const char *name,
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;
}