summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1cb715d)
raw | patch | inline | side by side (parent: 1cb715d)
author | Jonas Fonseca <fonseca@diku.dk> | |
Tue, 17 Nov 2009 04:56:00 +0000 (23:56 -0500) | ||
committer | Jonas Fonseca <fonseca@diku.dk> | |
Tue, 17 Nov 2009 05:00:00 +0000 (00:00 -0500) |
... and CWD is a subdirectory (Debian bug 540766). Also, improve the
tree view to allow entering the parent directory.
tree view to allow entering the parent directory.
NEWS | patch | blob | history | |
tig.c | patch | blob | history |
index dffb43d11b8411a898f465419610b7011a579e49..f2c45e44573e8f77ea44692a7d3c164a0fcf28d4 100644 (file)
--- a/NEWS
+++ b/NEWS
help messages.
- Add branch view for choosing which branch to display in the main
view. Bound to 'H' by default.
+ - Tree view: show entry to parent directory ('..') when running from
+ subdirectory.
- Tree view: sort entries by name, date or author. Toggling is bound to
'i' by default, with 'I' controlling whether or not to sort in
ascending order.
Bug fixes:
+ - Blame view: fix loading of blame data when cwd is not the repo root.
+ (Debian bug 540766)
- Tree view: fix searching.
tig-0.14.1
index 084fc0f362c2f69879127ee8021773128b0449b1..0f9ff04cbfe37e7564ffcb88405a134300a23d14 100644 (file)
--- a/tig.c
+++ b/tig.c
return init_io_rd(io, argv, NULL, flags) && start_io(io);
}
+static bool
+run_io_rd_dir(struct io *io, const char **argv, const char *dir, enum format_flags flags)
+{
+ return init_io_rd(io, argv, dir, flags) && start_io(io);
+}
+
static bool
io_eof(struct io *io)
{
bool (*grep)(struct view *view, struct line *line);
/* Select line */
void (*select)(struct view *view, struct line *line);
+ /* Prepare view for loading */
+ bool (*prepare)(struct view *view);
};
static struct view_ops blame_ops;
return FALSE;
} else {
- if (view == VIEW(REQ_VIEW_TREE) && strcmp(view->vid, view->id))
- opt_path[0] = 0;
-
- if (!run_io_rd(&view->io, view->ops->argv, FORMAT_ALL))
+ if (view->ops->prepare) {
+ if (!view->ops->prepare(view))
+ return FALSE;
+ } else if (!run_io_rd(&view->io, view->ops->argv, FORMAT_ALL)) {
return FALSE;
+ }
/* Put the current ref_* value to the view title ref
* member. This is needed by the blob view. Most other
display[current_view] = view;
}
+ /* No parent signals that this is the first loaded view. */
+ if (prev && view != prev) {
+ view->parent = prev;
+ }
+
/* Resize the view when switching between split- and full-screen,
* or when switching between two different full-screen views. */
if (nviews != displayed_views() ||
/* "Blur" the previous view. */
update_view_title(prev);
}
-
- view->parent = prev;
}
if (view->pipe && view->lines == 0) {
return TRUE;
}
- if (!run_io_rd(&io, log_file, FORMAT_NONE)) {
+ if (!run_io_rd_dir(&io, log_file, opt_cdup, FORMAT_NONE)) {
report("Failed to load tree data");
return TRUE;
}
if (!pos)
return TRUE;
text = pos + 1;
- if (*opt_prefix && !strncmp(text, opt_prefix, strlen(opt_prefix)))
- text += strlen(opt_prefix);
if (*opt_path && !strncmp(text, opt_path, strlen(opt_path)))
text += strlen(opt_path);
pos = strchr(text, '/');
string_copy_rev(view->ref, entry->id);
}
+static bool
+tree_prepare(struct view *view)
+{
+ if (view->lines == 0 && opt_prefix[0]) {
+ char *pos = opt_prefix;
+
+ while (pos && *pos) {
+ char *end = strchr(pos, '/');
+
+ if (end)
+ *end = 0;
+ push_tree_stack_entry(pos, 0);
+ pos = end;
+ if (end) {
+ *end = '/';
+ pos++;
+ }
+ }
+
+ } else if (strcmp(view->vid, view->id)) {
+ opt_path[0] = 0;
+ }
+
+ return run_io_rd_dir(&view->io, view->ops->argv, opt_cdup, FORMAT_ALL);
+}
+
static const char *tree_argv[SIZEOF_ARG] = {
"git", "ls-tree", "%(commit)", "%(directory)", NULL
};
tree_request,
tree_grep,
tree_select,
+ tree_prepare,
};
static bool
static bool
blame_open(struct view *view)
{
- if (*opt_ref || !io_open(&view->io, opt_file)) {
- if (!run_io_rd(&view->io, blame_cat_file_argv, FORMAT_ALL))
+ char path[SIZEOF_STR];
+
+ if (!view->parent && *opt_prefix) {
+ string_copy(path, opt_file);
+ if (!string_format(opt_file, "%s%s", opt_prefix, path))
+ return FALSE;
+ }
+
+ if (!string_format(path, "%s%s", opt_cdup, opt_file))
+ return FALSE;
+
+ if (*opt_ref || !io_open(&view->io, path)) {
+ if (!run_io_rd_dir(&view->io, blame_cat_file_argv, opt_cdup, FORMAT_ALL))
return FALSE;
}
if (view->lines == 0 && !view->parent)
die("No blame exist for %s", view->vid);
- if (view->lines == 0 || !run_io_rd(&io, argv, FORMAT_ALL)) {
+ if (view->lines == 0 || !run_io_rd_dir(&io, argv, opt_cdup, FORMAT_ALL)) {
report("Failed to load blame data");
return TRUE;
}