1 /* Copyright (c) 2006-2015 Jonas Fonseca <jonas.fonseca@gmail.com>
3 * This program is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU General Public License as
5 * published by the Free Software Foundation; either version 2 of
6 * the License, or (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
14 #include "tig/display.h"
20 stash_open(struct view
*view
, enum open_flags flags
)
22 static const char *stash_argv
[] = { "git", "stash", "list",
23 encoding_arg
, "--no-color", "--pretty=raw", NULL
};
24 struct main_state
*state
= view
->private;
26 state
->with_graph
= false;
27 watch_register(&view
->watch
, WATCH_STASH
);
28 return begin_update(view
, NULL
, stash_argv
, flags
| OPEN_RELOAD
);
32 stash_select(struct view
*view
, struct line
*line
)
34 main_select(view
, line
);
35 string_format(view
->env
->stash
, "stash@{%d}", line
->lineno
- 1);
36 string_copy(view
->ref
, view
->env
->stash
);
40 stash_request(struct view
*view
, enum request request
, struct line
*line
)
42 enum open_flags flags
= (view_is_displayed(view
) && request
!= REQ_VIEW_DIFF
)
43 ? OPEN_SPLIT
: OPEN_DEFAULT
;
44 struct view
*diff
= &diff_view
;
49 if (view_is_displayed(view
) && display
[0] != view
)
50 maximize_view(view
, true);
52 if (!view_is_displayed(diff
) ||
53 strcmp(view
->env
->stash
, diff
->ref
)) {
54 const char *diff_argv
[] = {
55 "git", "stash", "show", encoding_arg
, "--pretty=fuller",
56 "--root", "--patch-with-stat", use_mailmap_arg(),
57 show_notes_arg(), diff_context_arg(),
58 ignore_space_arg(), "%(diffargs)",
59 "--no-color", "%(stash)", NULL
62 if (!argv_format(diff_view
.env
, &diff_view
.argv
, diff_argv
, false, false))
63 report("Failed to format argument");
65 open_view(view
, &diff_view
, flags
| OPEN_PREPARED
);
70 return main_request(view
, request
, line
);
74 static struct view_ops stash_ops
= {
77 VIEW_SEND_CHILD_ENTER
| VIEW_REFRESH
,
78 sizeof(struct main_state
),
86 view_column_bit(AUTHOR
) | view_column_bit(COMMIT_TITLE
) |
87 view_column_bit(DATE
) | view_column_bit(ID
) |
88 view_column_bit(LINE_NUMBER
),
94 /* vim: set ts=8 sw=8 noexpandtab: */