summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--file/git-hist.c17
-rw-r--r--file/git-hist.h2
-rw-r--r--gui/gui.c4
3 files changed, 13 insertions, 10 deletions
diff --git a/file/git-hist.c b/file/git-hist.c
index 6b01bb5..0359673 100644
--- a/file/git-hist.c
+++ b/file/git-hist.c
@@ -157,7 +157,7 @@ static struct vcs_hist *find_commit(struct vcs_history *history,
static void recurse(struct vcs_history *history, struct vcs_hist *h,
- unsigned n_branches)
+ unsigned n_branches, unsigned depth)
{
unsigned n, i;
@@ -190,7 +190,9 @@ static void recurse(struct vcs_history *history, struct vcs_hist *h,
h->older[i] = new;
n_branches++;
uplink(new, h);
- recurse(history, new, n_branches);
+ if (depth != 1)
+ recurse(history, new, n_branches,
+ depth ? depth - 1 : 0);
}
}
}
@@ -231,7 +233,8 @@ static void add_head(struct vcs_history *history, struct vcs_hist *head)
}
-static void merge_head(struct vcs_history *history, git_commit *commit)
+static void merge_head(struct vcs_history *history, git_commit *commit,
+ unsigned depth)
{
struct vcs_hist *new;
@@ -241,12 +244,12 @@ static void merge_head(struct vcs_history *history, git_commit *commit)
new->commit = commit;
new->branches = matching_branches(history, new->commit,
&new->n_branches);
- recurse(history, new, 1);
+ recurse(history, new, 1, depth);
add_head(history, new);
}
-struct vcs_history *vcs_git_history(const char *path)
+struct vcs_history *vcs_git_history(const char *path, unsigned depth)
{
struct vcs_history *history;
struct vcs_hist *head, *dirty;
@@ -278,7 +281,7 @@ struct vcs_history *vcs_git_history(const char *path)
head->branches = matching_branches(history, head->commit,
&head->n_branches);
- recurse(history, head, 1);
+ recurse(history, head, 1, depth);
if (git_repo_is_dirty(history->repo)) {
dirty = new_commit(history, 0);
@@ -292,7 +295,7 @@ struct vcs_history *vcs_git_history(const char *path)
}
for (i = 0; i != history->n_branches; i++)
- merge_head(history, history->branches[i].commit);
+ merge_head(history, history->branches[i].commit, depth);
return history;
}
diff --git a/file/git-hist.h b/file/git-hist.h
index 58cb7eb..5e2aa56 100644
--- a/file/git-hist.h
+++ b/file/git-hist.h
@@ -52,7 +52,7 @@ struct vcs_history;
bool vcs_git_try(const char *path);
-struct vcs_history *vcs_git_history(const char *path);
+struct vcs_history *vcs_git_history(const char *path, unsigned depth);
char *vcs_git_get_rev(struct vcs_hist *h);
bool vcs_is_empty(const struct vcs_history *history);
diff --git a/gui/gui.c b/gui/gui.c
index f218283..8f9e25a 100644
--- a/gui/gui.c
+++ b/gui/gui.c
@@ -418,10 +418,10 @@ static void get_history(struct gui *gui, const char *name, int limit)
return;
}
- gui->vcs_history = vcs_git_history(name);
- hist_iterate(gui->vcs_history, count_history, gui);
if (limit < 0)
limit = -limit;
+ gui->vcs_history = vcs_git_history(name, limit);
+ hist_iterate(gui->vcs_history, count_history, gui);
if (limit && gui->hist_size > limit)
gui->hist_size = limit;
}