summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f55675e)
raw | patch | inline | side by side (parent: f55675e)
author | Jonas Fonseca <fonseca@diku.dk> | |
Tue, 15 Mar 2011 01:35:53 +0000 (21:35 -0400) | ||
committer | Jonas Fonseca <fonseca@diku.dk> | |
Wed, 16 Mar 2011 01:02:20 +0000 (21:02 -0400) |
... which provide the argv to begin_update
tig.c | patch | blob | history |
index 4a42cf7bbb7656d7c67b9bc57b366e58425156cf..c971ff754476630cbb858e6f9659ebf081cd9a19 100644 (file)
--- a/tig.c
+++ b/tig.c
struct view_ops {
/* What type of content being displayed. Used in the title bar. */
const char *type;
- /* Default command arguments. */
- const char **argv;
/* Open and reads in all view content. */
bool (*open)(struct view *view, enum open_flags flags);
/* Read one line; updates view->line. */
}
static bool
-begin_update(struct view *view, const char *dir, enum open_flags flags)
+begin_update(struct view *view, const char *dir, const char **argv, enum open_flags flags)
{
bool reload = !!(flags & (OPEN_RELOAD | OPEN_REFRESH | OPEN_PREPARED));
bool refresh = flags & (OPEN_REFRESH | OPEN_PREPARED);
end_update(view, TRUE);
if (!refresh) {
- if (!prepare_io(view, dir, view->ops->argv, TRUE))
+ if (!prepare_io(view, dir, argv, TRUE))
return FALSE;
/* Put the current ref_* value to the view title ref
static bool
view_open(struct view *view, enum open_flags flags)
{
- return begin_update(view, NULL, flags);
+ return begin_update(view, NULL, NULL, flags);
}
static bool
static struct view_ops pager_ops = {
"line",
- NULL,
view_open,
pager_read,
pager_draw,
pager_select,
};
-static const char *log_argv[SIZEOF_ARG] = {
- "git", "log", "--no-color", "--cc", "--stat", "-n100", "%(head)", NULL
-};
+static bool
+log_open(struct view *view, enum open_flags flags)
+{
+ static const char *log_argv[] = {
+ "git", "log", "--no-color", "--cc", "--stat", "-n100", "%(head)", NULL
+ };
+
+ return begin_update(view, NULL, log_argv, flags);
+}
static enum request
log_request(struct view *view, enum request request, struct line *line)
static struct view_ops log_ops = {
"line",
- log_argv,
- view_open,
+ log_open,
pager_read,
pager_draw,
log_request,
pager_select,
};
-static const char *diff_argv[SIZEOF_ARG] = {
- "git", "show", "--pretty=fuller", "--no-color", "--root",
- "--patch-with-stat", "--find-copies-harder", "-C",
- "%(diffargs)", "%(commit)", "--", "%(fileargs)", NULL
-};
+static bool
+diff_open(struct view *view, enum open_flags flags)
+{
+ static const char *diff_argv[] = {
+ "git", "show", "--pretty=fuller", "--no-color", "--root",
+ "--patch-with-stat", "--find-copies-harder", "-C",
+ "%(diffargs)", "%(commit)", "--", "%(fileargs)", NULL
+ };
+
+ return begin_update(view, NULL, diff_argv, flags);
+}
static bool
diff_read(struct view *view, char *data)
static struct view_ops diff_ops = {
"line",
- diff_argv,
- view_open,
+ diff_open,
diff_read,
pager_draw,
pager_request,
static struct view_ops help_ops = {
"line",
- NULL,
help_open,
NULL,
pager_draw,
static bool
tree_open(struct view *view, enum open_flags flags)
{
+ static const char *tree_argv[] = {
+ "git", "ls-tree", "%(commit)", "%(directory)", NULL
+ };
+
if (view->lines == 0 && opt_prefix[0]) {
char *pos = opt_prefix;
opt_path[0] = 0;
}
- return begin_update(view, opt_cdup, flags);
+ return begin_update(view, opt_cdup, tree_argv, flags);
}
-static const char *tree_argv[SIZEOF_ARG] = {
- "git", "ls-tree", "%(commit)", "%(directory)", NULL
-};
-
static struct view_ops tree_ops = {
"file",
- tree_argv,
tree_open,
tree_read,
tree_draw,
tree_select,
};
+static bool
+blob_open(struct view *view, enum open_flags flags)
+{
+ static const char *blob_argv[] = {
+ "git", "cat-file", "blob", "%(blob)", NULL
+ };
+
+ return begin_update(view, NULL, blob_argv, flags);
+}
+
static bool
blob_read(struct view *view, char *line)
{
}
}
-static const char *blob_argv[SIZEOF_ARG] = {
- "git", "cat-file", "blob", "%(blob)", NULL
-};
-
static struct view_ops blob_ops = {
"line",
- blob_argv,
- view_open,
+ blob_open,
blob_read,
pager_draw,
blob_request,
static struct view_ops blame_ops = {
"line",
- NULL,
blame_open,
blame_read,
blame_draw,
static struct view_ops branch_ops = {
"branch",
- NULL,
branch_open,
branch_read,
branch_draw,
static struct view_ops status_ops = {
"file",
- NULL,
status_open,
NULL,
status_draw,
static struct view_ops stage_ops = {
"line",
- NULL,
view_open,
pager_read,
pager_draw,
struct graph_canvas graph; /* Ancestry chain graphics. */
};
-static const char *main_argv[SIZEOF_ARG] = {
- "git", "log", "--no-color", "--pretty=raw", "--parents",
- "--topo-order", "%(diffargs)", "%(revargs)",
- "--", "%(fileargs)", NULL
-};
+static bool
+main_open(struct view *view, enum open_flags flags)
+{
+ static const char *main_argv[] = {
+ "git", "log", "--no-color", "--pretty=raw", "--parents",
+ "--topo-order", "%(diffargs)", "%(revargs)",
+ "--", "%(fileargs)", NULL
+ };
+
+ return begin_update(view, NULL, main_argv, flags);
+}
static bool
main_draw(struct view *view, struct line *line, unsigned int lineno)
static struct view_ops main_ops = {
"commit",
- main_argv,
- view_open,
+ main_open,
main_read,
main_draw,
main_request,