├── .github
└── ISSUE_TEMPLATE.md
├── .gitignore
├── CONTRIBUTING.md
├── README.md
├── ROADMAP.md
├── TESTING.md
├── addon-info.json
├── autoload
└── gitv
│ └── util
│ └── line.vim
├── doc
├── gitv.txt
└── tags
├── ftplugin
└── gitv.vim
├── img
├── gitv-bisecting.png
├── gitv-commit.png
├── gitv-diffsplit.png
├── gitv-diffstat.png
└── gitv-rebasing.png
├── plugin
└── gitv.vim
└── syntax
└── gitv.vim
/.github/ISSUE_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | Hi there!
2 |
3 | If you're submitting a bug, please run `:call Gitv_GetDebugInfo()` and paste your clipboard here.
4 |
5 | Otherwise, please disregard this message.
6 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | tags
2 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | gitv is not heavily active.
4 | No real guidelines are currently in place outside of bug submissions.
5 |
6 | ## Bugs
7 |
8 | Please make sure you are running the latest version of gitv.
9 |
10 | gitv interacts with a lot of technologies, and there is a lot of needed
11 | information for bugs.
12 |
13 | Please open gitv and run `:call Gitv_GetDebugInfo()` and paste the contents of
14 | your clipboard into the pull request.
15 |
16 | ## Testing
17 |
18 | We are in need of testers across various platforms, especially OSX and Windows.
19 |
20 | If you are interested in testing, please [email][5] or get in touch via
21 | [matrix][2].
22 |
23 | ## Questions, Feature Requests
24 |
25 | Questions and feature requests are highly encouraged.
26 |
27 | Please submit questions and feature requests to the [issue tracker][1] or ask
28 | them on [matrix.org][2].
29 |
30 | ## Pull Requests
31 |
32 | [Pull requests and patches][3] are encouraged.
33 |
34 | You may want to check [the roadmap][4] to see the currently planned features
35 | before contributing, or to get an idea of what to help out with.
36 |
37 | [1]: https://github.com/gregsexton/gitv/issues
38 | [2]: https://riot.im/app/#/room/#gitv:matrix.org
39 | [3]: https://github.com/gregsexton/gitv/pulls
40 | [4]: https://github.com/gregsexton/gitv/blob/master/ROADMAP.md
41 | [5]: mailto:r.l.bongers@gmail.com
42 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Maintainers Needed
2 |
3 | I am no longer maintaining this project as I no longer use Gitv.
4 | If you would like to maintain this project, please email gregsexton.
5 |
6 | # Readme
7 |
8 | gitv is a repository viewer similar to gitk. It is an extension of the
9 | [fugitive git plugin][5] for vim. It is essentially a wrapper around
10 | `git log --graph`, allowing you to see your branching history. It allows you to
11 | view commits, diffstats, inline diffs, and file or folder specific history, and
12 | more. It allows you to perform operations on the commit tree interactively,
13 | such as merges, cherry picks, reversions, resets, deletions, checkouts,
14 | bisections, and rebase operations.
15 |
16 | This repo has the most bleeding edge version of gitv. Stable versions are
17 | available at [the vim.org page][1].
18 |
19 | [Bugs, suggestions,][2] [pull requests and patches][3] are all very welcome.
20 |
21 | We are currently actively looking for feature requests and bugs regarding the
22 | latest [pre-release][4].
23 |
24 | ## Basic usage
25 |
26 | Start the plugin by running :Gitv in Vim when viewing a file in a git repository.
27 |
28 | This plugin is an extension of the [fugitive git plugin][5] by Tim Pope.
29 |
30 | I hope you like it!
31 |
32 | ## Installation
33 |
34 | You will need the [tpope/fugitive][5] plugin installed and working for gitv to work.
35 |
36 | For Windows, use the `~\vimfiles` directory instead of `~/.vim`
37 |
38 |
39 | | Method | Instalation instructions |
40 | | -------------- | -------------------------------------------------------------------------------------------------------------- |
41 | | Manual | Merge the `autoload`, `doc`, `ftplugin`, `plugin`, and `syntax` folders into their respective `~/.vim` folders |
42 | | [NeoBundle][6] | Add `NeoBundle 'gregsexton/gitv'` to `.vimrc` |
43 | | [Pathogen][7] | Run `git clone https://github.com/gregsexton/gitv ~/.vim/bundle/gitv` |
44 | | [Plug][8] | Add `Plug 'gregsexton/gitv', {'on': ['Gitv']}` to `.vimrc` |
45 | | [Vundle][9] | Add `Plugin 'gregsexton/gitv'` to `.vimrc` |
46 |
47 | ### Compatibility
48 |
49 | gitv was developed against Vim 7.3 and later 8.0 but earlier versions of Vim
50 | should work. Vim 7.2+ is recommended as it ships with syntax highlighting for
51 | many Git file types. Vim 7.3+ is recommended for UTF-8 support.
52 |
53 | gitv now has basic neovim support.
54 |
55 | ## Purpose
56 |
57 | gitv is a 'gitk clone' plugin for the text editor Vim. The goal is to give you
58 | a similar set of functionality as a repository viewer. Using this plugin you
59 | can view a repository's history including branching and merging, you can see
60 | which commits refs point to. You can quickly and easily view what changed to
61 | which files and when. You can perform arbitrary diffs (using Vim's excellent
62 | built in diff functionality) and you can easily check out whole commits and
63 | branches or just individual files if need be.
64 |
65 | Throw in the fact that it is running in Vim and you get for free: the ability
66 | to move over repository history quickly and precisely using Vim's built in
67 | movement operators. You get excellent code syntax highlighting due to Vim's
68 | built in ability. You can open up all sorts of repository views in multiple
69 | windows and position them exactly how you like. You can take advantage of Vim's
70 | registers to copy multiple fragments of code from previous commits. The list
71 | goes on.
72 |
73 | ## Links
74 |
75 | Click [here][10] for help on our official [matrix.org][11] server.
76 |
77 | Future changes are viewable in [the roadmap][12].
78 |
79 | A tentative release schedule is available in [the milestone view][13].
80 |
81 | You can download stable release versions (and vote for gitv!) at
82 | [gitv’s page][1] on `vim.org`.
83 |
84 | ## Screenshots
85 |
86 | ### commit preview
87 |
88 | 
89 |
90 | ### diff splitting
91 |
92 | 
93 |
94 | ### diff stat-ing
95 |
96 | 
97 |
98 | ### interactive bisecting
99 |
100 | 
101 |
102 | ### interactive rebasing
103 |
104 | 
105 |
106 | [1]: http://www.vim.org/scripts/script.php?script_id=3574
107 | [2]: https://github.com/gregsexton/gitv/issues
108 | [3]: https://github.com/gregsexton/gitv/pulls
109 | [4]: https://github.com/gregsexton/gitv/releases/tag/v1.3.1
110 | [5]: https://github.com/tpope/vim-fugitive
111 | [6]: https://github.com/Shougo/neobundle.vim
112 | [7]: https://github.com/tpope/vim-pathogen
113 | [8]: https://github.com/junegunn/vim-plug
114 | [9]: https://github.com/gmarik/vundle
115 | [10]: https://riot.im/app/#/room/#gitv:matrix.org
116 | [11]: http://matrix.org/
117 | [12]: https://github.com/gregsexton/gitv/blob/master/ROADMAP.md
118 | [13]: https://github.com/gregsexton/gitv/milestones
119 | [15]: http://www.vim.org/scripts/script.php?script_id=3574
120 |
--------------------------------------------------------------------------------
/ROADMAP.md:
--------------------------------------------------------------------------------
1 | # Roadmap
2 |
3 | This document describes upcoming releases and planned features/enhancements.
4 | I no longer maintain this project, so this roadmap will probably not reflect the plan of future maintainers.
5 |
6 |
7 |
8 |
9 | Version |
10 | Goals |
11 | Features |
12 |
13 |
14 | 1.3.1 (complete) |
15 | Incorporate new features present in other branch viewers and fix long standing bugs |
16 |
17 |
18 | - Implement bisecting directly inside the plugin
19 | - Implement rebasing directly inside the plugin
20 | - Add robust key remapping
21 |
22 | |
23 |
24 |
25 | 1.4 (stable, pending testing) |
26 | Improve stability of new features and incorporate community feedback |
27 |
28 |
29 | - Fixes for broken/duplicate bindings
30 | - More binding name consistency
31 | - Better rebasing/bisecting documentation
32 | - Better bisecting UX ("next" only targets cursor on visual selection)
33 | - Fixed custom split directions breaking certain functions (split direction is hardcoded until 1.4.1 or later) - thanks to @synic
34 | - Added helper to get debugging information
35 | - Added rudamentary neovim support - thanks to the Neovim team
36 |
37 | |
38 |
39 |
40 | 1.4.1 |
41 | Improve window system |
42 |
43 |
44 | - Reworked window creation and switching system
45 | - Configurable window layout
46 | - Reduced layout mangling in browser mode
47 | - Stable preview window functionality
48 |
49 | |
50 |
51 |
52 | 1.4.2 |
53 | Improve command running and output |
54 |
55 |
56 | - Reworked git command running system
57 | - Improved error output
58 | - New informational output system
59 | - Better compatibility with neovim's new command running system
60 |
61 | |
62 |
63 |
64 | 1.5 (stable) |
65 | Improve stability of the reworked features and incorporate community feedback |
66 | Pending community feedback |
67 |
68 |
69 | 1.5.1 |
70 | Improve customizability and function of the preview window |
71 |
72 |
73 | - Reworked preview window creation system
74 | - Customizable preview formatting
75 | - More kinds of preview window output
76 | - Preview window binding and settings system
77 |
78 | |
79 |
80 |
81 | 1.5.2 |
82 | Improve customizability of log formatting |
83 |
84 |
85 | - Reworked ref/commit retrieval system
86 | - Reworked log format parsing system
87 |
88 | |
89 |
90 |
91 | 1.6 (stable) |
92 | Improve stability of new customizable systems and incorporate community feedback |
93 | Pending community feedback |
94 |
95 |
96 |
97 |
--------------------------------------------------------------------------------
/TESTING.md:
--------------------------------------------------------------------------------
1 | - [ ] File browser mode
2 | - [ ] Rebasing mode
3 | - [ ] Bisecting mode
4 | - [ ] With custom bindings
5 |
--------------------------------------------------------------------------------
/addon-info.json:
--------------------------------------------------------------------------------
1 | {
2 | "dependencies": {
3 | "fugitive": {}
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/autoload/gitv/util/line.vim:
--------------------------------------------------------------------------------
1 | "AUTHOR: Greg Sexton
2 | "MAINTAINER: Roger Bongers
3 | "WEBSITE: http://www.gregsexton.org/portfolio/gitv/
4 | "LICENSE: Same terms as Vim itself (see :help license).
5 | " Gitv line-related utility functions
6 |
7 | if exists('g:autoloaded_gitv_util_line')
8 | finish
9 | endif
10 | let g:autoloaded_gitv_util_line = 1
11 |
12 | fu! gitv#util#line#sha(lineNumber) "{{{
13 | let l = getline(a:lineNumber)
14 | let sha = matchstr(l, "\\[\\zs[0-9a-f]\\{7,40}\\ze\\]$")
15 | return sha
16 | endf "}}}
17 |
18 | fu! gitv#util#line#refs(line) "{{{
19 | let l = getline(a:line)
20 | let refstr = matchstr(l, "^\\(\\(|\\|\\/\\|\\\\\\|\\*\\)\\s\\?\\)*\\s\\+(\\zs.\\{-}\\ze)")
21 | let refs = split(refstr, ', \| -> ')
22 | return refs
23 | endf "}}}
24 |
25 | " vim:set et sw=4 ts=4 fdm=marker:
26 |
--------------------------------------------------------------------------------
/doc/gitv.txt:
--------------------------------------------------------------------------------
1 | gitv -- gitk for vim.
2 |
3 | AUTHOR: Greg Sexton *gitv-author*
4 | MAINTAINER: Roger Bongers
5 | WEBSITE: http://www.gregsexton.org/portfolio/gitv/
6 | LICENSE: Same terms as Vim itself (see :help license).
7 | NOTES: Much of the credit for gitv goes to Tim Pope and the fugitive plugin
8 | where this plugin either uses functionality directly or was inspired
9 | heavily.
10 |
11 | gitv *gitv*
12 |
13 | 1. Introduction |gitv-introduction|
14 | 2. Installation |gitv-installation|
15 | 3. Usage |gitv-usage|
16 | 4. Configuration Options |gitv-config-options|
17 | 5. Changelog |gitv-changelog|
18 | 6. Misc |gitv-misc|
19 |
20 | ==============================================================================
21 | 1. Introduction *gitv-introduction*
22 |
23 | |gitv| is a 'gitk clone' plugin for the text editor Vim. The goal is to give
24 | you a similar set of functionality as a repository viewer. Using this plugin
25 | you can view a repository's history including branching and merging, you can
26 | see which commits refs point to. You can quickly and easily view what changed
27 | to which files and when. You can perform arbitrary diffs (using Vim's
28 | excellent built in diff functionality) and you can easily check out whole
29 | commits and branches or just individual files if need be.
30 |
31 | Throw in the fact that it is running in Vim and you get for free: the ability
32 | to move over repository history quickly and precisely using Vim's built in
33 | movement operators. You get excellent code syntax highlighting due to Vim's
34 | built in ability. You can open up all sorts of repository views in multiple
35 | windows and position them exactly how you like. You can take advantage of
36 | Vim's registers to copy multiple fragments of code from previous commits. The
37 | list goes on.
38 |
39 | This plugin is an extension of the |fugitive| plugin.
40 |
41 | I hope you like it!
42 |
43 | ==============================================================================
44 | 2. Installation *gitv-installation*
45 |
46 | Install in ~/.vim, or in ~\vimfiles if you're on Windows. This plugin should
47 | be fully pathogen compatible if you want to install it this way.
48 |
49 | |gitv| was developed against Vim 7.3 but earlier versions of Vim should work.
50 | Vim 7.2+ is recommended as it ships with syntax highlighting for many Git file
51 | types. You will also need the |fugitive| plugin installed and working for
52 | |gitv| to work.
53 |
54 | ==============================================================================
55 | 3. Usage *gitv-usage*
56 |
57 | |gitv| defines the following command.
58 |
59 | :[range]Gitv[!] [args]
60 |
61 | Invoking this command on a buffer that belongs to a git
62 | repository causes the gitv browser to open. '!' causes gitv
63 | to open in file mode rather than browser mode. Any [args]
64 | supplied are passed on to the gitv viewer and can be used to
65 | narrow the commits that are shown. If this command is run
66 | on a buffer not belonging to a git repository a message
67 | stating 'Not a git repository.' is displayed.
68 |
69 | When used with a [range] this has no effect in browser mode.
70 | In file mode it narrows the commits shown to only those
71 | affecting lines in the range. See section 3.8 for more
72 | details.
73 |
74 | The following abbreviation is also defined so that you can type :gitv without
75 | capitalisation. The abbreviation is defined in such a way that this
76 | substitution is only performed when 'gitv' is the first word on the command
77 | line.
78 | >
79 | cabbrev gitv Gitv
80 | <
81 |
82 | 3.1 Browser mode
83 |
84 | |gitv| has two distinct modes. Browser mode and file mode. The browser mode is
85 | opened in a new tab and allows the repository history to be viewed for all
86 | files. This is activated by running :Gitv without a '!'.
87 |
88 | In this mode you can view the entire repository history and see which files
89 | were changed with each commit. This mode tries to closely resemble gitk.
90 |
91 | 3.2 File mode
92 |
93 | File mode is opened in a |preview-window| above the buffer you are currently in.
94 | This view is tailored to act on the buffer that :Gitv! was run from, the
95 | "focused" file. Whilst in this mode all actions performed are specific to the
96 | single focused file. The browser only shows commits where the focused file
97 | changed. Selecting a commit, views the focused file as it was in that commit.
98 | Performing a check out only checks the focused file out as it was in the
99 | commit. And so on. See 3.4 for the differences.
100 |
101 | 3.3 Arguments
102 |
103 | You can pass arguments to the :Gitv command. These allow you to filter and
104 | narrow the commits shown. Essentially, gitv is a glorified 'git log' wrapper
105 | and so any flag that 'git log' accepts so will gitv. gitv does not inspect the
106 | arguments passed on to 'git log' and so may not work if they don't make sense.
107 |
108 | Without any arguments gitv behaves just like gitk and git log without
109 | arguments. It will display the commit history for the currently checked out
110 | branch.
111 |
112 | Gitv will also accept and autocomplete filenames. Only filenames at the end of
113 | the command are supported, as in 'git log'.
114 |
115 | Here are some particularly useful examples of arguments that could be
116 | passed to :Gitv. For more info see 'git help log' and in particular the
117 | section: "Commit Limiting".
118 |
119 | Flag Description ~
120 |
121 | --all View repository history for all refs.
122 |
123 | --bisect If a bisect is started, show only the remaining commits.
124 |
125 | .. Show only commits between the named two commits. When
126 | either or is omitted, it defaults to
127 | HEAD, i.e. the tip of the current branch. For a more
128 | complete list of ways to spell and ,
129 | see gitrevisions(7).
130 |
131 | --merges View only merge commits.
132 |
133 | -S Look for differences that introduce or remove an
134 | instance of . Note that this is different than
135 | the string simply appearing in diff output; see the
136 | pickaxe entry in gitdiffcore(7) for more details.
137 |
138 | -G Look for differences whose added or removed line
139 | matches the given .
140 |
141 | 3.4 Key mappings. *gitv-browser-mappings*
142 |
143 | This is a list of key mappings that will work only in the gitv browser window.
144 | Where appropriate the differences in action is described for the two gitv
145 | modes.
146 |
147 | Mode Map Description~
148 |
149 | normal Opens a commit. In browser mode this will show the
150 | commit header information including the commit
151 | message. It will also display a full diff showing all the
152 | changes to files.
153 |
154 | Tip: if you press on anything sensible you can
155 | view the expected output. For example pressing on
156 | the line beginning a file diff, it will display the
157 | diff using Vim's built in diff viewing capability.
158 | Pressing on the tree sha will list all the files
159 | in the commit and pressing on one of these will
160 | show that file as it was in the commit. And so on.
161 |
162 | Pressing on the line "-- Load More --" will load
163 | |g:Gitv_CommitStep| more commits.
164 |
165 | In file mode this will open the focused file as it was
166 | in the currently selected diff. This allows you to
167 | easily go back in time and look at the focused file.
168 |
169 | Pressing on the top line in file mode opens the
170 | current working copy of the focused file.
171 |
172 | normal In either browser or file mode, this moves down to
173 | J the next commit and opens it. This allows you to
174 | quickly move from commit to commit and view either
175 | the commit details or the file itself, depending on
176 | the mode, in one action.
177 |
178 | normal The same as but move back a commit.
179 | K
180 |
181 | normal o The same as but opens in a new |split|.
182 |
183 |
184 | normal O The same as but opens in a new |tab|.
185 |
186 |
187 | normal s The same as but opens in a new |vsplit|.
188 |
189 |
190 | normal gw Switch between the preview window and browser.
191 |
192 | normal i This performs the same thing as in browser mode.
193 | In file mode it opens the commit details rather than
194 | the focused file. (NOTE: many terminal emulators do
195 | not support ).
196 |
197 | normal q Quits gitv. In browser mode this will close the entire
198 | tab. In file mode this closes only the |preview-window|.
199 | Note: in browser mode this will close the tab
200 | regardless of any windows you may have opened as well
201 | as the gitv windows.
202 |
203 | normal a Switches the '--all' argument and updates the browser
204 | window.
205 |
206 | normal u Forces an update of the content of the browser window.
207 |
208 | normal co Performs a 'git checkout' of the commit the cursor is
209 | on. In both modes this will present you with a choice
210 | of whether you would like to checkout the sha or any
211 | ref that might point to this commit.
212 |
213 | File mode differs in that it doesn't check out the
214 | entire commit but just the focused file in that
215 | commit.
216 |
217 | Tip: in gVim this will present you with a pop up dialog.
218 | You can make this a text choice by performing ':set
219 | guioptions+=c.'
220 |
221 | normal D Performs a diff using Vim's built in diff viewing
222 | capabilities. This does nothing in browser mode. In
223 | file mode it will diff the current file with the
224 | focused file in the commit under the cursor.
225 |
226 | visual D In visual mode this performs a diff against the file
227 | in the commit at the top of the selection against the
228 | file in the commit at the bottom of the selection. The
229 | newest file is always on the right.
230 |
231 | normal S Open a diffstat of everything that has changed since
232 | the commit under the cursor, in both browse and
233 | normal mode.
234 |
235 | visual S In visual mode this works in exactly the same way as
236 | normal mode. However, it only shows what has changed
237 | in the range of commits that are highlighted.
238 |
239 | visual m Merges the commit in either the top or bottom line of
240 | the selection into the commit specified by the other
241 | end of the selection. This uses prompts to guide you
242 | through the merge process and should be fairly
243 | intuitive. By default, it will also ask for
244 | confirmation if you wish to perform a fast-forward
245 | merge or not. If you have defined g:Gitv_MergeArgs,
246 | you will not be prompted to fast forward.
247 |
248 | gitv does not allow you to merge arbitrary commits.
249 | The lines at the top and bottom of the selection
250 | must contain refs in the form of tags, remotes or
251 | local branches.
252 |
253 | visual cp Cherry-Picks the selected commits to the active
254 | branch.
255 |
256 | normal cp Same as visual cp
257 |
258 | visual rb Reset (mixed) the active branch to the top of the
259 | selected commits.
260 |
261 | normal rb Same as visual rb
262 |
263 | visual rbs Reset (soft) the active branch to the top of the
264 | selected commits.
265 |
266 | normal rbs Same as visual rbs
267 |
268 | visual rbh Reset (hard) the active branch to the top of the
269 | selected commits.
270 |
271 | normal rbh Same as visual rbh
272 |
273 | normal rev Revert the commit. If the commit is a merge, selects
274 | the first parent for reverting to.
275 |
276 | visual rev Same as rev, but revert a range of commits. If a
277 | merge is within the range, fails by necessity.
278 |
279 | visual d Delete a branch or tag on the selected line. You will
280 | be asked which branch/tag to use.
281 |
282 | normal d Same as visual d
283 |
284 | normal m Merges the first ref found on the current line in to
285 | the branch currently pointed to by HEAD. By default,
286 | this will prompt you if you wish to use a fast-forward
287 | merge. If you have defined g:Gitv_MergeArgs, you
288 | will not be prompted to fast forward.
289 |
290 | normal git Enters command mode with ":Git " already typed for
291 | you. Just a convenient shortcut for executing git
292 | commands and watching them affect the repository.
293 |
294 | normal yc Copy the sha on the current line in either mode.
295 | This also copies it to the '+' register so that it
296 | can be pasted externally. If there is no commit on
297 | the current line the behaviour (although harmless)
298 | is undefined.
299 |
300 | Here is a list of extra key mappings that can be used to efficiently move
301 | around a repository history in the browser window.
302 |
303 | Mode Map Description~
304 |
305 | normal x Jumps the cursor forward to the next branching point
306 | in the history.
307 |
308 | normal X Jumps the cursor backward to the previous branching
309 | point in the history.
310 |
311 | normal r Jumps the cursor forward to the next ref in the
312 | history.
313 |
314 | normal R Jumps the cursor backward to the previous ref in the
315 | history.
316 |
317 | normal P Jumps the cursor to the commit referenced by HEAD.
318 |
319 | normal p Jumps the cursor to the commit which is the parent of
320 | current line. When on a merge commit, a |count|
321 | may be used to choose a parent other than the first.
322 |
323 | Here is a list of mappings for rebasing.
324 |
325 | Mode Map Description~
326 |
327 | normal grr Rebase the current HEAD onto the ref or commit under
328 | the cursor. A choice will be given of multiple refs.
329 |
330 | normal grR Mark the commit under the line for reword.
331 |
332 | normal grE Mark the commit under the line for edit.
333 |
334 | normal grS Mark the commit under the line for squash.
335 |
336 | normal grF Mark the commit under the line for fixup.
337 |
338 | normal grX Mark the commit under the line for exec. A command must
339 | be entered to be executed. The command will be
340 | executed after performing an instruction on the
341 | commit. By default, the commit will be picked.
342 |
343 | normal grD Mark the commit under the line for dropping.
344 |
345 | normal grP Mark the commit under the line for picking. Since this
346 | is the default instruction, if every commit is marked
347 | for picking, no commits will be considered marked.
348 | This also removes exec commands from marking commits
349 | with grX.
350 |
351 | normal grs Start or stop (disable) an interactive rebase.
352 | Interactive rebasing is only available in browser mode.
353 | Merge commits are preserved.
354 | If the rebase has already been started, merely enables
355 | rebase mode.
356 | If starting the rebase without instructions, it begins
357 | at the commit before the commit under the cursor in
358 | edit mode. This is a limitation of interactive
359 | rebasing.
360 | If any commits have been marked for an instruction,
361 | automatically runs the interactive rebase.
362 | If enabled in browser mode with files specified, will
363 | drop the file names while the rebase is in progress.
364 |
365 | normal gra Abort the current rebase.
366 |
367 | normal grn Go to the next commit in the current rebase (skip).
368 | Accepts a count.
369 |
370 | normal grc Continue through the rebase until input is needed.
371 |
372 | visual grR, Same as normal mode, but marks every commit.
373 | grE,
374 | grS,
375 | grF,
376 | grX,
377 | grD,
378 | grP
379 |
380 | visual grs, Same as normal mode, but will attempt to rebase from
381 | grr a ref at the top or bottom to the other end of the
382 | selection.
383 |
384 | Here is a list of mappings for bisecting.
385 |
386 | Mode Map Description~
387 |
388 | normal gbs Begin the bisecting process. If the bisecting process
389 | has been started elsewhere, merely enables bisect mode.
390 | If the bisecting process has already been enabled,
391 | disables bisecting mode.
392 | Works in both modes.
393 | If file names have been specified, only bisects the
394 | selected files.
395 | Mnemonic- git bisect start/git bisect stop.
396 |
397 | visual gbs Same as normal mode, but if the bisecting process has
398 | not yet been started, marks the first commit selected
399 | as bad and the last commit selected as good.
400 |
401 | normal gbg Mark the commit under the cursor as good.
402 |
403 | visual gbg Mark selected commits as good.
404 |
405 | normal gbb Mark the commit under the cursor as bad.
406 |
407 | visual gbb Mark selected commits as bad.
408 |
409 | normal gbn Skip the current commit. Accepts a count. If a count
410 | is given, skips the number of times specified.
411 | Mnemonic- git bisect next.
412 |
413 | visual gbn Skip the selected range of commits.
414 |
415 | normal gbr End the bisect process. Mnemonic- git bisect reset.
416 |
417 | normal gbl Save the current bisect history to a file. Edit the log
418 | file to correct mistakes and replay later.
419 | Mnemonic- git bisect log.
420 |
421 | normal gbp Replay a saved log file.
422 |
423 | 3.5 Commands
424 |
425 | Running the |:Git| command in the commit browser window, in either mode, will
426 | cause the |:Git| command to be run as expected but the commit history will
427 | automatically update to reflect any changes too.
428 |
429 | 3.6 Windows
430 |
431 | In browser mode, two windows are opened initially. The "browser window" that
432 | displays the commit history and the "preview window" that shows the currently
433 | selected commit.
434 |
435 | In file mode, a |preview-window| is opened above the current file. This is a
436 | browser window filtered to show commits only affecting the focused file. The
437 | window holding the focused file acts as the preview window in this mode.
438 |
439 | NOTE: In both modes the buffer in the preview window is wiped after replacing
440 | it. This is to stop the quick build up of fugitive buffers. A buffer will not
441 | be wiped if it contains unsaved changes. Buffers are not wiped when opening a
442 | commit in a split, vsplit or a new tab.
443 |
444 | When opening a commit, the window it will be opened in is determined by simple
445 | rules. If in browser mode and the layout is vertical it will open in the
446 | window to the immediate right (exactly as if you performed l). If in a
447 | horizontal layout, it will be opened in the window immediately below (exactly
448 | as if you performed j). If in file mode, it will open exactly like
449 | browser mode split horizontally. NOTE: It is for this reason that you should
450 | not move the browser window as it will cause commits to be opened in
451 | unexpected places.
452 |
453 | 3.7 Folding
454 |
455 | Folding of branches is supported in the browser window. Initially all folds
456 | are always open and will open on a reload. You can collapse any branch by
457 | using Vim's built in fold operators. See |folding| for more details.
458 |
459 | 3.8 Using with a range of lines
460 |
461 | If a range is passed to the :Gitv command it will have no effect in browser
462 | mode. In file mode however, only commits that affect at least one line in the
463 | range will be displayed. This is useful, for example, to view the commit
464 | history for a function and all of the changes made to it.
465 |
466 | If a range of less than two lines is used then gitv opens in regular file
467 | mode.
468 |
469 | Selecting a commit by pressing on it will show the file as it was in that
470 | commit with all lines not in the range folded away. This allows you to quickly
471 | and easily move from commit to commit viewing the evolution of the range of
472 | lines. Pressing will show you the commit details so that you can see
473 | any other changes it may have made. (NOTE: many terminal emulators do not
474 | support ).
475 |
476 | The range that Git looks at is specified by the first and last line in the
477 | range passed to :Gitv. These lines are escaped appropriately and passed to Git
478 | to use as a regular expression. If you wish to modify either regex delimiter
479 | this can be done by pressing on the appropriate line near the top of the
480 | file mode buffer. Vim will prompt you to modify the regex. If you press enter
481 | without modification, nothing happens. If you modify the regex (Git supports
482 | POSIX regular expressions) gitv will automatically update.
483 |
484 | You may also pass arguments to the :Gitv! command when using a range. This
485 | filters the commits that are to be compared for changes in the range. For
486 | example you could pass the name of a branch to only look at changes in commits
487 | on that branch.
488 |
489 | Note: This feature requires the bash shell to be installed on your system and
490 | in your path. This should already be the case for the majority of users.
491 |
492 | Note: Using a range searches back through the commit history looking at each
493 | section of lines for where changes occurred. It will only look at the last
494 | g:Gitv_CommitStep number, if you don't get any matches you could try pressing
495 | on the 'load more' line. This command may be slow if you choose a large
496 | range and have a large g:Gitv_CommitStep.
497 |
498 | 3.9 Bisecting *gitv-bisecting*
499 |
500 | gitv provides several bisecting instructions that essentially send it into a
501 | separate mode. It is intended that this mode can be enabled/disabled at will
502 | so as to use gitv as normal if desired. This also allows entering into the
503 | bisecting mode at any time. Since gitv is a visual branch manager, bisecting
504 | mode offers its most useful capabilities via visual selection.
505 |
506 | When gitv is in bisecting mode, only the range of commits being bisected is
507 | shown. This is why capabilities are given to disable bisecting mode and
508 | explore branches as normal while bisecting. This is a wrapper around the
509 | `git log --bisect` command.
510 |
511 | When the repository is not in bisecting mode, pressing `gbs` or the keybinding
512 | to `bisectStart` will start the bisecting process. It is recommended that for
513 | small ranges of commits, you start the bisecting process using visual mode.
514 |
515 | When the repository is in visual mode and gitv is not, pressing `gbs` will
516 | only put gitv into bisecting mode.
517 |
518 | However bisecting mode has been enabled, it can always be disabled again using
519 | `gbs` and enabled again in the same way. It does not keeep stateful
520 | information about the bisecting process.
521 |
522 | You should be able to see which commits have been marked as good, bad, or to
523 | skip via the output from the `--bisect` command. You should also see the
524 | current commit marked with `HEAD`. If you need to perform operations on the
525 | current head, you can jump to it via `P` key or the keybinding to `head`.
526 |
527 | `gbr` will call `git bisect --reset` and stop the bisecting process, as
528 | opposed to just disabling it.
529 |
530 | 3.10 Rebasing *gitv-rebasing*
531 |
532 | Similar to bisecting, rebasing in gitv provides a separate mode which can be
533 | easily toggled on and off as to jump into the rebasing process at any time. It
534 | also provides useful visual commands.
535 |
536 | There are three ways to start a rebase with gitv if rebasing is not already in
537 | process in the repository. The most simple, non interactive way, is to use
538 | `grr`. This is the same as calling `git rebase (ref)` or
539 | `git rebase (ref1) (ref2)` for a range.
540 |
541 | The rest of the ways to start rebasing are wrappers around the
542 | `git rebase --interactive` command, which allows performing special
543 | instructions on commits.
544 |
545 | The first way to interactively rebase is to call `gbs` when the cursor is on
546 | the desired ref or commit to rebase without doing anything else first. This
547 | opens up the file normally used for entering in `--interactive` instructions.
548 | After you enter in your instructions and save, rebasing does not continue
549 | automatically. This is to allow you to re-edit your instructions via
550 | selecting `Edit rebase todo` in the branch viewer. You must use `grc` or the
551 | keybinding to `rebaseContinue` to confirm you wish to proceed. You may re-edit
552 | instructions at any time during the rebasing procedure.
553 |
554 | In case it is useful to view the branch history structure while editing rebase
555 | instructions, a third method is provided for entering rebase mode. By staging
556 | instructions using the `grR`, `grE`, `grS`, `grF`, `grX`, `grD`, and `grP`
557 | commands or custom bindings, you can skip editing the initial todo file.
558 | However, you must still press `grs` on the ref or commit you wish to begin
559 | rebasing on. Be advised that after you press `grs`, you will not get another
560 | chance to confirm with `grc`. However, you can still edit the todo at any time
561 | during the rebasing process. Staged instructions can be cleared using `grP`.
562 |
563 | If you are already in the process of an interactive rebase and you enter gitv,
564 | `grs` will enable rebasing mode instead of starting it.
565 |
566 | Once rebasing mode is enabled, `grc` may do one of several things. If the
567 | rebasing instruction would normally trigger a commit, the fugitive commit
568 | window will automatically open. If you are not sure why the window has opened,
569 | please view the comments in the commit window. If the window is closed, it can
570 | always be reopened with `Gcommit`. gitv may also do nothing. This indicates
571 | that you have a chance to edit the commit.
572 |
573 | You can continue with the rebase process at any interactive instruction with
574 | `grc` whenever you are ready. When the rebasing ends, gitv will automatically
575 | return to normal mode.
576 |
577 | You may cancel the rebasing process at any time with `gra` or the
578 | `git rebase --abort` command.
579 |
580 | If you git into an undesirable state after rebasing, you may use `git reflog`
581 | to recover.
582 |
583 | ==============================================================================
584 | 4. Configuration Options *gitv-config-options*
585 |
586 | You can set the following options in your .vimrc to override the values used
587 | by |gitv|. The defaults are shown.
588 |
589 | 4.1 Commit Step
590 |
591 | This is the number of commits to show each time. When pressing on
592 | "-- Load More --", the number of extra commits loaded is g:Gitv_CommitStep.
593 | The default is a screen's worth of lines. This should be set to an integer
594 | number. Setting this to a value _really_ high will load the entire repo in one
595 | go.
596 | >
597 | g:Gitv_CommitStep = &lines
598 | <
599 |
600 | 4.2 Open Horizontal
601 |
602 | This is the default layout to use in browser mode. If set to 0 then browser
603 | mode will open in a vertical split. If set to 1 then browser mode will open in
604 | a horizontal split. If set to 'auto' then browser mode will open in a vertical
605 | split unless the content fits better in a horizontal split, in which case it
606 | will open horizontally.
607 |
608 | The commit browser width and height is automatically sized to best fit the
609 | content in all modes and settings.
610 | >
611 | g:Gitv_OpenHorizontal = 0
612 | <
613 |
614 | 4.3 Git Executable
615 |
616 | Gitv uses the same executable as fugitive.
617 |
618 | 4.4 Wipe All on Close
619 |
620 | This option should be set to either 0 (to disable) or 1 (to enable). If set to
621 | 1 then on closing the browser mode by using the q key all buffers displayed in
622 | a window in the tab will be wiped before the tab is closed. This option allows
623 | you to limit the number of fugitive buffers that accumulate in the use of gitv.
624 |
625 | NOTE: This will not wipe any buffer with unsaved content. It will however
626 | mercilessly wipe all buffers in the tab regardless of the file they hold.
627 | >
628 | g:Gitv_WipeAllOnClose = 0
629 | <
630 |
631 | 4.5 Wrap Lines
632 |
633 | If set to 1 then line wrapping is enabled. This is useful if you have
634 | occasional very long commit messages.
635 | >
636 | g:Gitv_WrapLines = 0
637 | <
638 |
639 | 4.6 Truncate Commit Subjects
640 |
641 | If set to 1 then commit subject truncation is enabled. This will truncate
642 | commit subjects, where necessary, so that the whole line will fit in one
643 | screen width. If this is set, then automatically switching to a horizontal
644 | layout will no longer work as commits will be truncated to always fit in a
645 | vertical split. NOTE: It is possible that this can truncate any refs pointing
646 | at a commit. In this situation it will not be possible to check out any of
647 | these refs. This is due to gitv being unable to recognise that they are refs.
648 | >
649 | g:Gitv_TruncateCommitSubjects = 0
650 | <
651 |
652 | 4.7 Open Preview On Launch
653 |
654 | If set to 1 then the preview window is displayed when launching gitv in
655 | browser mode. If set to 0 then no preview window is displayed until a commit
656 | is opened. This option has no effect in file mode.
657 | >
658 | g:Gitv_OpenPreviewOnLaunch = 1
659 | <
660 |
661 | 4.8 Prompt to Delete Merge Branch
662 |
663 | If set to 1 then, when performing a merge using gitv, you will be prompted if
664 | you wish to delete the topic branch. If you often merge a branch into another
665 | and rarely wish to delete branches, set this to 0. The default is 0.
666 | >
667 | let g:Gitv_PromptToDeleteMergeBranch = 0
668 | <
669 | 4.9 Custom merge arguments
670 |
671 | The purpose of this option is to customize the merging behaviour. To use the
672 | default merge behaviour, unset this variable. To not confirm for fast forward,
673 | set this to an empty string. By default, this is undefined.
674 | >
675 | unset! g:Gitv_MergeArgs
676 | <
677 |
678 | Example: if you wish to use a different merge strategy, you can use this.
679 | >
680 | fu! MergeOurs()
681 | let g:Gitv_MergeArgs = '--strategy=ours'
682 | " Escape put in because of :normal quirks with space
683 | execute "normal \ m"
684 | " Put whatever your default is here
685 | unlet! g:Gitv_MergeArgs
686 | enfu
687 | autocmd FileType gitv nno Mo :call MergeOurs()
688 | <
689 | 4.10 Do not map the control key
690 |
691 | If this is set then no mappings that use the control key will be created. The
692 | control key mappings are all alternatives and so can be disabled without
693 | losing functionality. The default is to create the mappings.
694 | >
695 | let g:Gitv_DoNotMapCtrlKey = 1
696 | >
697 |
698 | 4.11 Do not log bisect actions
699 |
700 | If this is set then no bisect mappings will log their actions. This will
701 | prevent the need to press enter after every bisect action, but could cause
702 | confusion. Errors will still be shown.
703 | >
704 | let g:Gitv_QuietBisect = 1
705 |
706 | 4.12 Custom key mappings *gitv-custom-browser-mappings*
707 |
708 | Set custom key mappings which will overwrite the defaults. The following would
709 | result in bindings equivalent to the defaults.
710 | >
711 | let g:Gitv_CustomMappings = {
712 | \'quit': 'q',
713 | \'update': 'u',
714 | \'toggleAll': 'a',
715 | \'nextBranch': 'x',
716 | \'prevBranch': 'X',
717 | \'nextRef': 'r',
718 | \'prevRef': 'R',
719 | \'editCommit': [
720 | \'', { 'keys': '', 'prefix', '' }
721 | \],
722 | \'prevCommit': 'J',
723 | \'nextCommit': 'K',
724 | \'splitCommit': 'o',
725 | \'vertSplitCommit': 's',
726 | \'tabeCommit': 'O',
727 | \'editCommitDetails': 'i',
728 | \'diff': 'D',
729 | \'vdiff': 'D',
730 | \'stat': 'S',
731 | \'vstat': 'S',
732 | \'checkout': 'co',
733 | \'merge': 'm',
734 | \'vmerge': 'm',
735 | \'cherryPick': 'cp',
736 | \'vcherryPick': 'cp',
737 | \'reset': 'rb',
738 | \'vreset': 'rb',
739 | \'resetSoft': 'rbs',
740 | \'vresetSoft': 'rbs',
741 | \'resetHard': 'rbh',
742 | \'vresetHard': 'rbh',
743 | \'revert': 'rev',
744 | \'vrevert': 'rev',
745 | \'delete': 'd',
746 | \'vdelete': 'd',
747 | \'rebase': 'grr',
748 | \'vrebase': 'grr',
749 | \'rebasePick': 'grP',
750 | \'vrebasePick': 'grP',
751 | \'rebaseReword': 'grR',
752 | \'vrebaseReword': 'grR',
753 | \'rebaseMarkEdit': 'grF',
754 | \'vrebaseMarkEdit': 'grF',
755 | \'rebaseSquash': 'grF',
756 | \'vrebaseSquash': 'grF',
757 | \'rebaseFixup': 'grF',
758 | \'vrebaseFixup': 'grF',
759 | \'rebaseExec': 'grF',
760 | \'vrebaseExec': 'grF',
761 | \'rebaseDrop': 'grF',
762 | \'vrebaseDrop': 'grF',
763 | \'rebaseAbort': 'gra',
764 | \'rebaseToggle': 'grs',
765 | \'vrebaseToggle': 'grs',
766 | \'rebaseSkip': 'grn',
767 | \'rebaseContinue': 'grc',
768 | \'rebaseEdit': 'gre',
769 | \'bisectStart': 'gbs',
770 | \'vbisectStart': 'gbs',
771 | \'bisectGood': 'gbg',
772 | \'vbisectGood': 'gbg',
773 | \'bisectBad': 'gbb',
774 | \'vbisectBad': 'gbb',
775 | \'bisectSkip': 'gbn',
776 | \'vbisectSkip': 'gbn',
777 | \'bisectReset': 'gbr',
778 | \'bisectLog': 'gbl',
779 | \'bisectReplay': 'gbp',
780 | \'head': 'P',
781 | \'parent': 'p',
782 | \'toggleWindow': 'gw',
783 | \'git': 'git',
784 | \'yank': 'yc'
785 | \}
786 | <
787 |
788 | Bindings that use the ctrl modifier are kept internal and disabled when
789 | g:Gitv_DoNotMapCtrlKey is set.
790 |
791 | 4.13 Change The Behaviour Of The Preview Window
792 |
793 | Set custom options for the preview window. These options are passed directly
794 | to |git-show|.
795 | >
796 | let g:Gitv_PreviewOptions = '--name-only'
797 | <
798 |
799 | ==============================================================================
800 | 5. Changelog *gitv-changelog*
801 |
802 | 1.1 Nodes displaying local changes are inserted above HEAD ref.
803 | Added range feature.
804 | Merging branches is possible in gitv.
805 | strwidth bugfix (thanks Adam Reeve).
806 | Prevent bdelete errors (thanks pydave).
807 |
808 | 1.0 First release. I hope you enjoy gitv!
809 |
810 | ==============================================================================
811 | 6. Misc *gitv-misc*
812 |
813 | 6.1 Tips and tricks
814 |
815 | I use the following mappings to make working with |gitv| easier.
816 | >
817 | nmap gv :Gitv --all
818 | nmap gV :Gitv! --all
819 | vmap gV :Gitv! --all
820 | <
821 | The vmap equivalent for file mode is to make dealing with ranges easier. It
822 | allows you to visually select a range of lines to view the commit history for
823 | that section of the file.
824 |
825 | I highly recommend adding to your vimrc:
826 | >
827 | set lazyredraw
828 | <
829 |
830 | This stops Vim from redrawing the screen during complex operations and results
831 | in much smoother looking plugins.
832 |
833 | 6.2 API
834 |
835 | You can grab the current line's hash programatically with
836 | >
837 | gitv#util#line#sha(line('.'))
838 | <
839 | You can grab the ref with
840 | >
841 | gitv#util#line#refs('.')
842 | <
843 |
844 | The function: 'Gitv_OpenGitCommand(command, windowCmd)' is provided to allow
845 | the more advanced user to create their own commands. This function will
846 | execute the git command provided in the new window created using windowCmd.
847 |
848 | By using this function you get for free: the buffer set up for read only git
849 | output, including syntax highlighting and many other tailored options. You
850 | also get mappings for 'u' to update the output and 'q' to easily close the
851 | window.
852 |
853 | Here is an example of getting diff output both cached and not, in a vertical
854 | and horizontal split respectively.
855 | >
856 | call Gitv_OpenGitCommand("diff --no-color --cached", 'vnew')
857 | call Gitv_OpenGitCommand("diff --no-color", 'new')
858 |
859 | Use this command at your own risk. gitv currently makes certain assumptions
860 | about window layout, and custom layouts could break certain functions.
861 |
862 | 6.3 Bugs, issues, features and contributing.
863 |
864 | Bugs, suggestions, pull requests and patches are all very welcome. If you find
865 | issues with |gitv| please add them to the issues page on the github project.
866 | Anything else, feel free to email me at r.l.bongers@gmail.com
867 |
868 | Please run `Gitv_GetDebugInfo()` and post your clipboard output for bugs.
869 |
870 | vim:tw=78:ts=8:ft=help:norl:
871 |
--------------------------------------------------------------------------------
/doc/tags:
--------------------------------------------------------------------------------
1 | gitv gitv.txt /*gitv*
2 | gitv-author gitv.txt /*gitv-author*
3 | gitv-bisecting gitv.txt /*gitv-bisecting*
4 | gitv-browser-mappings gitv.txt /*gitv-browser-mappings*
5 | gitv-changelog gitv.txt /*gitv-changelog*
6 | gitv-config-options gitv.txt /*gitv-config-options*
7 | gitv-custom-browser-mappings gitv.txt /*gitv-custom-browser-mappings*
8 | gitv-installation gitv.txt /*gitv-installation*
9 | gitv-introduction gitv.txt /*gitv-introduction*
10 | gitv-misc gitv.txt /*gitv-misc*
11 | gitv-rebasing gitv.txt /*gitv-rebasing*
12 | gitv-usage gitv.txt /*gitv-usage*
13 |
--------------------------------------------------------------------------------
/ftplugin/gitv.vim:
--------------------------------------------------------------------------------
1 | "AUTHOR: Greg Sexton
2 | "MAINTAINER: Roger Bongers
3 | "WEBSITE: http://www.gregsexton.org/portfolio/gitv/
4 | "LICENSE: Same terms as Vim itself (see :help license).
5 | "NOTES: Much of the credit for gitv goes to Tim Pope and the fugitive plugin
6 | " where this plugin either uses functionality directly or was inspired heavily.
7 |
8 | "enabling these next lines breaks settings when reloading the buffer
9 | "if exists("b:did_ftplugin") | finish | endif
10 | "let b:did_ftplugin = 1
11 |
12 | let s:cpo_save = &cpo
13 | set cpo&vim
14 |
15 | setlocal fdm=expr
16 |
17 | fu! Foldlevelforbranch() "{{{
18 | let line = getline(v:lnum)
19 |
20 | if line == "-- Load More --"
21 | return 0
22 | endif
23 | if line =~ "^-- \\[.*\\] --$"
24 | return 0
25 | endif
26 |
27 | let line = substitute(line, "\\s", "", "g")
28 | let level = match(line, "*") + 1
29 | return level == 0 ? -1 : level
30 | endfu "}}}
31 | setlocal foldexpr=Foldlevelforbranch()
32 |
33 | fu! BranchFoldText() "{{{
34 | "get first non-blank line
35 | let fs = v:foldstart
36 | while getline(fs) =~ '^\s*$' | let fs = nextnonblank(fs + 1)
37 | endwhile
38 | if fs > v:foldend
39 | let line = getline(v:foldstart)
40 | else
41 | let line = getline(fs)
42 | endif
43 | return line
44 | endf "}}}
45 | setlocal foldtext=BranchFoldText()
46 | setlocal foldlevel=99
47 | setlocal nosplitbelow
48 | setlocal nosplitright
49 |
50 | let &cpo = s:cpo_save
51 | unlet s:cpo_save
52 |
--------------------------------------------------------------------------------
/img/gitv-bisecting.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gregsexton/gitv/a73599c34202709eaa7da78f4fe32b97c6ef83f8/img/gitv-bisecting.png
--------------------------------------------------------------------------------
/img/gitv-commit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gregsexton/gitv/a73599c34202709eaa7da78f4fe32b97c6ef83f8/img/gitv-commit.png
--------------------------------------------------------------------------------
/img/gitv-diffsplit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gregsexton/gitv/a73599c34202709eaa7da78f4fe32b97c6ef83f8/img/gitv-diffsplit.png
--------------------------------------------------------------------------------
/img/gitv-diffstat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gregsexton/gitv/a73599c34202709eaa7da78f4fe32b97c6ef83f8/img/gitv-diffstat.png
--------------------------------------------------------------------------------
/img/gitv-rebasing.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gregsexton/gitv/a73599c34202709eaa7da78f4fe32b97c6ef83f8/img/gitv-rebasing.png
--------------------------------------------------------------------------------
/plugin/gitv.vim:
--------------------------------------------------------------------------------
1 | "AUTHOR: Greg Sexton
2 | "MAINTAINER: Roger Bongers
3 | "WEBSITE: http://www.gregsexton.org/portfolio/gitv/
4 | "LICENSE: Same terms as Vim itself (see :help license).
5 | "NOTES: Much of the credit for gitv goes to Tim Pope and the fugitive plugin
6 | " where this plugin either uses functionality directly or was inspired heavily.
7 |
8 | if exists("g:loaded_gitv") || v:version < 700
9 | finish
10 | endif
11 | let g:loaded_gitv = 1
12 |
13 | let s:savecpo = &cpo
14 | set cpo&vim
15 |
16 | "configurable options:
17 | "g:Gitv_CommitStep - int
18 | "g:Gitv_OpenHorizontal - {0,1,'AUTO'}
19 | "g:Gitv_WipeAllOnClose - int
20 | "g:Gitv_WrapLines - {0,1}
21 | "g:Gitv_TruncateCommitSubjects - {0,1}
22 | "g:Gitv_OpenPreviewOnLaunch - {0,1}
23 | "g:Gitv_PromptToDeleteMergeBranch - {0,1}
24 |
25 | if !exists("g:Gitv_CommitStep")
26 | let g:Gitv_CommitStep = &lines
27 | endif
28 |
29 | if !exists('g:Gitv_WipeAllOnClose')
30 | let g:Gitv_WipeAllOnClose = 0 "default for safety
31 | endif
32 |
33 | if !exists('g:Gitv_WrapLines')
34 | let g:Gitv_WrapLines = 0
35 | endif
36 |
37 | if !exists('g:Gitv_TruncateCommitSubjects')
38 | let g:Gitv_TruncateCommitSubjects = 0
39 | endif
40 |
41 | if !exists('g:Gitv_OpenPreviewOnLaunch')
42 | let g:Gitv_OpenPreviewOnLaunch = 1
43 | endif
44 |
45 | if !exists('g:Gitv_PromptToDeleteMergeBranch')
46 | let g:Gitv_PromptToDeleteMergeBranch = 0
47 | endif
48 |
49 | if !exists('g:Gitv_CustomMappings')
50 | let g:Gitv_CustomMappings = {}
51 | endif
52 |
53 | if !exists('g:Gitv_DisableShellEscape')
54 | let g:Gitv_DisableShellEscape = 0
55 | endif
56 |
57 | if !exists('g:Gitv_DoNotMapCtrlKey')
58 | let g:Gitv_DoNotMapCtrlKey = 0
59 | endif
60 |
61 | if !exists('g:Gitv_PreviewOptions')
62 | let g:Gitv_PreviewOptions = ''
63 | endif
64 |
65 | if !exists('g:Gitv_QuietBisect')
66 | let g:Gitv_QuietBisect = 0
67 | endif
68 |
69 | " create a temporary file for working
70 | let s:workingFile = tempname()
71 |
72 | "this counts up each time gitv is opened to ensure a unique file name
73 | let g:Gitv_InstanceCounter = 0
74 |
75 | let s:localUncommitedMsg = 'Local uncommitted changes, not checked in to index.'
76 | let s:localCommitedMsg = 'Local changes checked in to index but not committed.'
77 |
78 | let s:pendingRebaseMsg = 'View pending rebase instructions'
79 | let s:rebaseMsg = 'Edit rebase todo'
80 |
81 | command! -nargs=* -range -bang -complete=custom,s:CompleteGitv Gitv call s:OpenGitv(s:EscapeGitvArgs(), 0, , )
82 | cabbrev gitv =(getcmdtype()==':' && getcmdpos()==1 ? 'Gitv' : 'gitv')
83 |
84 | "Public API:"{{{
85 | fu! Gitv_OpenGitCommand(command, windowCmd, ...) "{{{
86 | "returns 1 if command succeeded with output
87 | "optional arg is a flag, if present runs command verbatim
88 |
89 | "this function is not limited to script scope as is useful for running other commands.
90 | "e.g call Gitv_OpenGitCommand("diff --no-color", 'vnew') is useful for getting an overall git diff.
91 |
92 | let [result, finalCmd] = s:RunGitCommand(a:command, a:0)
93 |
94 | if type(result) == type(0)
95 | return 0
96 | endif
97 | if type(result) == type("") && result == ""
98 | echom "No output."
99 | return 0
100 | else
101 | if a:windowCmd == ''
102 | silent setlocal modifiable
103 | silent setlocal noreadonly
104 | 1,$ d _
105 | else
106 | let goBackTo = winnr()
107 | let dir = fugitive#repo().dir()
108 | let workingDir = fugitive#repo().tree()
109 | let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd ' : 'cd '
110 | let bufferDir = getcwd()
111 | let tempSplitBelow = &splitbelow
112 | let tempSplitRight = &splitright
113 | try
114 | set nosplitbelow
115 | set nosplitright
116 | execute cd.'`=workingDir`'
117 | exec a:windowCmd
118 | let newWindow = winnr()
119 | finally
120 | exec goBackTo . 'wincmd w'
121 | execute cd.'`=bufferDir`'
122 | if exists('newWindow')
123 | exec newWindow . 'wincmd w'
124 | endif
125 | exec 'set '. (tempSplitBelow ? '' : 'no') . 'splitbelow'
126 | exec 'set '. (tempSplitRight ? '' : 'no') . 'splitright'
127 | endtry
128 | endif
129 | if !(&modifiable)
130 | return 0
131 | endif
132 | let b:Git_Command = finalCmd
133 | silent setlocal ft=git
134 | silent setlocal buftype=nofile
135 | silent setlocal nobuflisted
136 | silent setlocal noswapfile
137 | silent setlocal bufhidden=wipe
138 | silent setlocal nonumber
139 | if exists('+relativenumber')
140 | silent setlocal norelativenumber
141 | endif
142 | if g:Gitv_WrapLines
143 | silent setlocal wrap
144 | else
145 | silent setlocal nowrap
146 | endif
147 | silent setlocal fdm=syntax
148 | nnoremap q :q!
149 | nnoremap u :if exists('b:Git_Command')call Gitv_OpenGitCommand(b:Git_Command, '', 1)endif
150 | call append(0, split(result, '\n')) "system converts eols to \n regardless of os.
151 | silent setlocal nomodifiable
152 | silent setlocal readonly
153 | 1
154 | return 1
155 | endif
156 | endf "}}}
157 | fu! Gitv_GetDebugInfo() "{{{
158 | if has('clipboard')
159 | redir @+
160 | endif
161 |
162 | echo '## Gitv debug output'
163 | echo ''
164 |
165 | echo '### Basic information'
166 | echo ''
167 | echo '```'
168 | echo 'Version: 1.3.1.22'
169 | echo ''
170 | echo strftime('%c')
171 | echo '```'
172 | echo ''
173 |
174 | echo '### Settings'
175 | echo ''
176 | echo '```'
177 | set
178 | echo '```'
179 | echo ''
180 |
181 | echo '### Vim version'
182 | echo ''
183 | echo '```'
184 | version
185 | echo '```'
186 | echo ''
187 |
188 | echo '### Git output'
189 | echo ''
190 | echo '```'
191 |
192 | try
193 | echo '$ git --version'
194 | echo s:RunCommandRelativeToGitRepo('git --version')[0]
195 | echo '$ git status'
196 | echo s:RunCommandRelativeToGitRepo('git status')[0]
197 | echo '$ git remote --verbose'
198 | echo s:RunCommandRelativeToGitRepo('git remote --verbose')[0]
199 | catch
200 | echo 'Gitv_GetDebugInfo exception:'
201 | echo v:exception
202 | endtry
203 |
204 | echo '```'
205 | echo ''
206 |
207 | echo '### Fugitive version'
208 | echo ''
209 | echo '```'
210 |
211 | try
212 | let filename = s:GetFugitiveInfo()[1]
213 | " Make sure redirection is still set up
214 | if has('clipboard')
215 | redir @+
216 | endif
217 | for line in readfile(filename)
218 | if line =~ 'Version:' || line =~ 'GetLatestVimScripts:'
219 | echo line
220 | endif
221 | endfor
222 | catch
223 | echo 'Gitv_GetDebugInfo exception:'
224 | echo v:exception
225 | endtry
226 |
227 | echo '```'
228 | echo ''
229 |
230 | redir END
231 |
232 | if has('clipboard')
233 | echo 'Debug information has been copied to your clipboard. Please attach this information to your submitted issue.'
234 | else
235 | echo 'Please copy the contents above and add them to your submitted issue.'
236 | endif
237 | endf "}}} }}}
238 | "General Git Functions: "{{{
239 | fu! s:RunGitCommand(command, verbatim) "{{{
240 | "if verbatim returns result of system command, else
241 | "switches to the buffer repository before running the command and switches back after.
242 | if !a:verbatim
243 | "switches to the buffer repository before running the command and switches back after.
244 | let cmd = fugitive#repo().git_command() .' '. a:command
245 | let [result, finalCmd] = s:RunCommandRelativeToGitRepo(cmd)
246 | else
247 | let result = system(a:command)
248 | let finalCmd = a:command
249 | endif
250 | return [result, finalCmd]
251 | endfu "}}}
252 | fu! s:RunCommandRelativeToGitRepo(command) abort "{{{
253 | " Runs the command verbatim but first changing to the root git dir.
254 | " Input commands should include a --git-dir argument to git (see
255 | " fugitive#repo().git_command()).
256 | let workingDir = fugitive#repo().tree()
257 |
258 | let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd ' : 'cd '
259 | let bufferDir = getcwd()
260 | try
261 | execute cd.'`=workingDir`'
262 | let result = system(a:command)
263 | finally
264 | execute cd.'`=bufferDir`'
265 | endtry
266 | return [result, a:command]
267 | endfu "}}} }}}
268 | "Open And Update Gitv:"{{{
269 | fu! s:SanitizeReservedArgs(extraArgs) "{{{
270 | let sanitizedArgs = a:extraArgs
271 | if sanitizedArgs[0] =~ "[\"']" && sanitizedArgs[:-1] =~ "[\"']"
272 | let sanitizedArgs = sanitizedArgs[1:-2]
273 | endif
274 | " store bisect
275 | if match(sanitizedArgs, ' --bisect') >= 0
276 | let sanitizedArgs = substitute(sanitizedArgs, ' --bisect', '', 'g')
277 | if s:BisectHasStarted()
278 | let b:Gitv_Bisecting = 1
279 | endif
280 | endif
281 | " store files
282 | let selectedFiles = []
283 | let splitArgs = split(sanitizedArgs, ' ')
284 | let index = len(splitArgs)
285 | let root = fugitive#repo().tree().'/'
286 | while index
287 | let index -= 1
288 | let path = splitArgs[index]
289 | if !empty(globpath('.', path))
290 | " transform the path relative to the git directory
291 | let path = fnamemodify(path, ':p')
292 | let splitPath = split(path, root)
293 | if splitPath[0] == path
294 | echoerr "Not in git repo:" path
295 | break
296 | endif
297 | " join the relroot back in case we split more than one off
298 | let path = join(splitPath, root)
299 | let selectedFiles += [path]
300 | else
301 | break
302 | endif
303 | endwhile
304 | let selectedFiles = sort(selectedFiles)
305 | return [join(splitArgs[0:-len(selectedFiles) - 1], ' '), join(selectedFiles, ' ')]
306 | endfu "}}}
307 | fu! s:ReapplyReservedArgs(extraArgs) "{{{
308 | let options = a:extraArgs[0]
309 | if s:RebaseIsEnabled()
310 | return [options, '']
311 | endif
312 | if s:BisectIsEnabled()
313 | if !s:IsBisectingCurrentFiles()
314 | echoerr "Not bisecting specified files."
315 | let b:Gitv_Bisecting = 0
316 | else
317 | let options .= " --bisect"
318 | let options = s:FilterArgs(options, ['--all', '--first-parent'])
319 | endif
320 | endif
321 | return [options, a:extraArgs[1]]
322 | endfu "}}}
323 | fu! s:EscapeGitvArgs(extraArgs) "{{{
324 | " TODO: test whether shellescape is really needed on windows.
325 | if g:Gitv_DisableShellEscape == 0
326 | return shellescape(a:extraArgs)
327 | else
328 | return a:extraArgs
329 | endif
330 | endfu "}}}
331 | fu! s:OpenGitv(extraArgs, fileMode, rangeStart, rangeEnd) "{{{
332 | if !exists('s:fugitiveSid')
333 | let s:fugitiveSid = s:GetFugitiveSid()
334 | endif
335 | let sanitizedArgs = s:SanitizeReservedArgs(a:extraArgs)
336 | let g:Gitv_InstanceCounter += 1
337 | if !s:IsCompatible() "this outputs specific errors
338 | return
339 | endif
340 | try
341 | if a:fileMode
342 | call s:OpenFileMode(sanitizedArgs, a:rangeStart, a:rangeEnd)
343 | else
344 | call s:OpenBrowserMode(sanitizedArgs)
345 | endif
346 | catch /not a git repository/
347 | echom 'Not a git repository.'
348 | return
349 | endtry
350 | endf "}}}
351 | fu! s:IsCompatible() "{{{
352 | if !exists('g:loaded_fugitive')
353 | echoerr "gitv requires the fugitive plugin to be installed."
354 | endif
355 | return exists('g:loaded_fugitive')
356 | endfu "}}}
357 | fu! s:CompleteGitv(arglead, cmdline, pos) "{{{
358 | if match( a:arglead, '^-' ) >= 0
359 | return "\n--after\n--all-match\n--ancestry-path\n--author-date-order"
360 | \ . "\n--author=\n--author=\n--before=\n--bisect\n--boundary"
361 | \ . "\n--branches\n--cherry-mark\n--cherry-pick\n--committer="
362 | \ . "\n--date-order\n--dense\n--exclude=\n--first-parent"
363 | \ . "\n--fixed-strings\n--follow\n--glob\n--grep-reflog"
364 | \ . "\n--grep=\n--max-age=\n--max-count=\n--merges\n--no-merges"
365 | \ . "\n--min-age=\n--min-parents=\n--not\n--pickaxe-all"
366 | \ . "\n--pickaxe-regex\n--regexp-ignore-case\n--remotes"
367 | \ . "\n--remove-empty\n--since=\n--skip\n--tags\n--topo-order"
368 | \ . "\n--until=\n--use-mailmap"
369 | else
370 | if match(a:arglead, '\/$') >= 0
371 | let paths = "\n".globpath(a:arglead, '*')
372 | else
373 | let paths = "\n".glob(a:arglead.'*')
374 | endif
375 |
376 | let refs = fugitive#repo().git_chomp('rev-parse', '--symbolic', '--branches', '--tags', '--remotes')
377 | let refs .= "\nHEAD\nFETCH_HEAD\nORIG_HEAD"
378 |
379 | " Complete ref names preceded by a ^ or anything followed by 2-3 dots
380 | let prefix = matchstr( a:arglead, '\v^(\^|.*\.\.\.?)' )
381 | if prefix == ''
382 | return refs.paths
383 | else
384 | return substitute( refs, "\\v(^|\n)\\zs", prefix, 'g' ).paths
385 | endif
386 | endf "}}}
387 | fu! s:OpenBrowserMode(extraArgs) "{{{
388 | "this throws an exception if not a git repo which is caught immediately
389 | silent Gtabedit HEAD:
390 |
391 | if s:IsHorizontal()
392 | let direction = 'new gitv'.'-'.g:Gitv_InstanceCounter
393 | else
394 | let direction = 'vnew gitv'.'-'.g:Gitv_InstanceCounter
395 | endif
396 | if !s:LoadGitv(direction, 0, g:Gitv_CommitStep, a:extraArgs, '', [])
397 | return 0
398 | endif
399 | call s:SetupBufferCommands(0)
400 | let b:Gitv_RebaseInstructions = {}
401 | "open the first commit
402 | if g:Gitv_OpenPreviewOnLaunch
403 | silent call s:OpenGitvCommit("Gedit", 0)
404 | else
405 | call s:MoveIntoPreviewAndExecute('bdelete', 0)
406 | endif
407 | endf "}}}
408 | fu! s:OpenFileMode(extraArgs, rangeStart, rangeEnd) "{{{
409 | let relPath = fugitive#Path(@%, a:0 ? a:1 : '')
410 | pclose!
411 | let range = a:rangeStart != a:rangeEnd ? s:GetRegexRange(a:rangeStart, a:rangeEnd) : []
412 | if !s:LoadGitv(&previewheight . "new gitv".'-'.g:Gitv_InstanceCounter, 0, g:Gitv_CommitStep, a:extraArgs, relPath, range)
413 | return 0
414 | endif
415 | set previewwindow
416 | set winfixheight
417 | let b:Gitv_FileMode = 1
418 | let b:Gitv_FileModeRelPath = relPath
419 | let b:Gitv_FileModeRange = range
420 | call s:SetupBufferCommands(1)
421 | endf "}}}
422 | fu! s:LoadGitv(direction, reload, commitCount, extraArgs, filePath, range) "{{{
423 | call s:RebaseUpdate()
424 | call s:BisectUpdate()
425 |
426 | if a:reload
427 | let jumpTo = line('.') "this is for repositioning the cursor after reload
428 | endif
429 |
430 | "precondition: a:range should be of the form [a, b] or []
431 | " where a,b are integers && a 0
573 | let extraArgs = s:ReapplyReservedArgs(['', ''])
574 | let git = fugitive#repo().git_command()
575 | let cmd = 'for hash in ' . join(a:hashes, " ") . '; '
576 | let cmd .= "do "
577 | let cmd .= git.' log'
578 | let cmd .= extraArgs[0]
579 | let cmd .=' --no-color --decorate=full --pretty=format:"%d__START__ %s__SEP__%ar__SEP__%an__SEP__[%h]%n" --graph -1 ${hash}; '
580 | let cmd .= 'done'
581 | let finalCmd = "bash -c " . shellescape(cmd)
582 |
583 | let [result, cmd] = s:RunCommandRelativeToGitRepo(finalCmd)
584 | return split(result, '\n')
585 | else
586 | return ""
587 | endif
588 | endfu "}}}
589 | fu! s:GetRegexRange(rangeStart, rangeEnd) "{{{
590 | let rangeS = getline(a:rangeStart)
591 | let rangeS = escape(rangeS, '.^$*\/[]')
592 | let rangeS = matchstr(rangeS, '\v^\s*\zs.{-}\ze\s*$') "trim whitespace
593 | let rangeE = getline(a:rangeEnd)
594 | let rangeE = escape(rangeE, '.^$*\/[]')
595 | let rangeE = matchstr(rangeE, '\v^\s*\zs.{-}\ze\s*$') "trim whitespace
596 | let rangeS = rangeS =~ '^\s*$' ? '^[:blank:]*$' : rangeS
597 | let rangeE = rangeE =~ '^\s*$' ? '^[:blank:]*$' : rangeE
598 | return ['/'.rangeS.'/', '/'.rangeE.'/']
599 | endfu "}}} }}}
600 | fu! s:SetupBuffer(commitCount, extraArgs, filePath, range) "{{{
601 | silent set filetype=gitv
602 | let b:Gitv_CommitCount = a:commitCount
603 | let b:Gitv_ExtraArgs = a:extraArgs
604 | silent setlocal modifiable
605 | silent setlocal noreadonly
606 | silent %s/refs\/tags\//t:/ge
607 | silent %s/refs\/remotes\//r:/ge
608 | silent %s/refs\/heads\///ge
609 | call s:AddLoadMore()
610 | call s:AddLocalNodes(a:filePath)
611 | call s:AddFileModeSpecific(a:filePath, a:range, a:commitCount)
612 | call s:AddRebaseMessage(a:filePath)
613 |
614 | " run any autocmds the user may have defined to hook in here
615 | silent doautocmd User GitvSetupBuffer
616 |
617 | silent call s:InsertRebaseInstructions()
618 | silent %call s:Align("__SEP__", a:filePath)
619 | silent %s/\s\+$//e
620 | silent setlocal nomodifiable
621 | silent setlocal readonly
622 | silent setlocal cursorline
623 | endf "}}}
624 | fu! s:InsertRebaseInstructions() "{{{
625 | if s:RebaseHasInstructions()
626 | for key in keys(b:Gitv_RebaseInstructions)
627 | let search = '__START__\ze.*\['.key.'\]$'
628 | let replace = ' ['.b:Gitv_RebaseInstructions[key].instruction
629 | if exists('b:Gitv_RebaseInstructions[key].cmd')
630 | let replace .= 'x'
631 | endif
632 | let replace .= ']'
633 | exec '%s/'.search.'/'.replace
634 | endfor
635 | endif
636 | %s/__START__//
637 | endf "}}}
638 | fu! s:CleanupRebasePreview() "{{{
639 | if &syntax == 'gitrebase'
640 | bdelete
641 | endif
642 | endf "}}}
643 | fu! s:AddRebaseMessage(filePath) "{{{
644 | if a:filePath != ''
645 | return
646 | endif
647 | if s:RebaseHasInstructions()
648 | call append(0, '= '.s:pendingRebaseMsg)
649 | elseif s:RebaseIsEnabled()
650 | call append(0, '= '.s:rebaseMsg)
651 | else
652 | " TODO: this will fail if there's no preview window
653 | call s:MoveIntoPreviewAndExecute('call s:CleanupRebasePreview()', 0)
654 | endif
655 | endf "}}}
656 | fu! s:AddLocalNodes(filePath) "{{{
657 | let suffix = a:filePath == '' ? '' : ' -- '.a:filePath
658 | let gitCmd = "diff --no-color" . suffix
659 | let [result, cmd] = s:RunGitCommand(gitCmd, 0)
660 | let headLine = search('^\(\(|\|\/\|\\\|\*\)\s\?\)*\s*([^)]*HEAD', 'cnw')
661 | let headLine = headLine == 0 ? 1 : headLine
662 | if result != ""
663 | let line = s:AlignWithRefs(headLine, s:localUncommitedMsg)
664 | call append(headLine-1, substitute(line, '*', '=', ''))
665 | let headLine += 1
666 | endif
667 | let gitCmd = "diff --no-color --cached" . suffix
668 | let [result, cmd] = s:RunGitCommand(gitCmd, 0)
669 | if result != ""
670 | let line = s:AlignWithRefs(headLine, s:localCommitedMsg)
671 | call append(headLine-1, substitute(line, '*', '+', ''))
672 | endif
673 | endfu
674 | fu! s:AlignWithRefs(targetLine, targetStr)
675 | "returns the targetStr prefixed with enough whitespace to align with
676 | "the first asterisk on targetLine
677 | if a:targetLine == 0
678 | return '* '.a:targetStr
679 | endif
680 | let line = getline(a:targetLine)
681 | let idx = stridx(line, '(')
682 | if idx == -1
683 | return '* '.a:targetStr
684 | endif
685 | return strpart(line, 0, idx) . a:targetStr
686 | endfu "}}}
687 | fu! s:AddLoadMore() "{{{
688 | call append(line('$'), '-- Load More --')
689 | endfu "}}}
690 | fu! s:AddFileModeSpecific(filePath, range, commitCount) "{{{
691 | if a:filePath != ''
692 | call append(0, '-- ['.a:filePath.'] --')
693 | if a:range != []
694 | call append(1, '-- Showing (up to '.a:commitCount.') commits affecting lines in the range:')
695 | call append(2, '-- ' . a:range[0])
696 | call append(3, '-- ' . a:range[1])
697 | endif
698 | endif
699 | endfu "}}}
700 | "Mapping: "{{{
701 | fu! s:SetDefaultMappings() "{{{
702 | " creates the script-scoped dictionary of mapping descriptors
703 | " the dictionary will optionally include ctrl based commands
704 | " sets s:defaultMappings to the dictionary
705 | let s:defaultMappings = {}
706 |
707 | " convenience
708 | let s:defaultMappings.quit = {
709 | \'cmd': ':call CloseGitv()', 'bindings': 'q'
710 | \}
711 | let s:defaultMappings.update = {
712 | \'cmd': ':call LoadGitv("", 1, b:Gitv_CommitCount, b:Gitv_ExtraArgs, GetRelativeFilePath(), GetRange())',
713 | \'bindings': 'u'
714 | \}
715 | let s:defaultMappings.toggleAll = {
716 | \'cmd': ':call LoadGitv("", 0, b:Gitv_CommitCount, ToggleArg(b:Gitv_ExtraArgs, "--all"), GetRelativeFilePath(), GetRange())',
717 | \'bindings': 'a'
718 | \}
719 |
720 | " movement
721 | let s:defaultMappings.nextBranch = {
722 | \'cmd': ':call JumpToBranch(0)',
723 | \'bindings': 'x'
724 | \}
725 | let s:defaultMappings.prevBranch = {
726 | \'cmd': ':call JumpToBranch(1)',
727 | \'bindings': 'X'
728 | \}
729 | let s:defaultMappings.nextRef = {
730 | \'cmd': ':call JumpToRef(0)',
731 | \'bindings': 'r'
732 | \}
733 | let s:defaultMappings.prevRef = {
734 | \'cmd': ':call JumpToRef(1)',
735 | \'bindings': 'R'
736 | \}
737 | let s:defaultMappings.head = {
738 | \'cmd': ':call JumpToHead()',
739 | \'bindings': 'P'
740 | \}
741 | let s:defaultMappings.parent = {
742 | \'cmd': ':call JumpToParent()',
743 | \'bindings': 'p'
744 | \}
745 | let s:defaultMappings.toggleWindow = {
746 | \'cmd': ':call SwitchBetweenWindows()',
747 | \'bindings': 'gw'
748 | \}
749 |
750 | " viewing commits
751 | let s:defaultMappings.editCommit = {
752 | \'cmd': ':call OpenGitvCommit("Gedit", 0)',
753 | \'bindings': [
754 | \'', { 'keys': '', 'prefix': '' }
755 | \],
756 | \}
757 | " (gitv-*) are fuzzyfinder style keymappings
758 | let s:defaultMappings.splitCommit = {
759 | \'cmd': ':call OpenGitvCommit("Gsplit", 0)',
760 | \'bindings': 'o',
761 | \'permanentBindings': '(gitv-split)'
762 | \}
763 | let s:defaultMappings.tabeCommit = {
764 | \'cmd': ':call OpenGitvCommit("Gtabedit", 0)',
765 | \'bindings': 'O' ,
766 | \'permanentBindings': '(gitv-tabedit)'
767 | \}
768 | let s:defaultMappings.vertSplitCommit = {
769 | \'cmd': ':call OpenGitvCommit("Gvsplit", 0)',
770 | \'bindings': 's',
771 | \'permanentBindings': '(gitv-vsplit)'
772 | \}
773 | let s:defaultMappings.prevCommit = {
774 | \'cmd': ':call JumpToCommit(0)',
775 | \'bindings': 'J',
776 | \'permanentBindings': '(gitv-previous-commit)'
777 | \}
778 | let s:defaultMappings.nextCommit = {
779 | \'cmd': ':call JumpToCommit(1)',
780 | \'bindings': 'K',
781 | \'permanentBindings': '(gitv-next-commit)'
782 | \}
783 | " force opening the fugitive buffer for the commit
784 | let s:defaultMappings.editCommitDetails = {
785 | \'cmd': ':call OpenGitvCommit("Gedit", 1)',
786 | \'bindings': 'i',
787 | \'permanentBindings': '(gitv-edit)'
788 | \}
789 | let s:defaultMappings.diff = {
790 | \'cmd': ':call DiffGitvCommit()',
791 | \'bindings': 'D'
792 | \}
793 | let s:defaultMappings.vdiff = {
794 | \'mapCmd': 'vnoremap',
795 | \'cmd': ':call DiffGitvCommit()',
796 | \'bindings': 'D'
797 | \}
798 | let s:defaultMappings.stat = {
799 | \'cmd': ':call StatGitvCommit()',
800 | \'bindings': 'S'
801 | \}
802 | let s:defaultMappings.vstat = {
803 | \'mapCmd': 'vnoremap',
804 | \'cmd': ':call StatGitvCommit()',
805 | \'bindings': 'S'
806 | \}
807 |
808 | " general git commands
809 | let s:defaultMappings.checkout = {
810 | \'cmd': ':call CheckOutGitvCommit()', 'bindings': 'co'
811 | \}
812 | let s:defaultMappings.merge = {
813 | \'cmd': ':call MergeToCurrent()', 'bindings': 'm'
814 | \}
815 | let s:defaultMappings.vmerge = {
816 | \'mapCmd': 'vnoremap',
817 | \'cmd': ':call MergeBranches()',
818 | \'bindings': 'm'
819 | \}
820 | let s:defaultMappings.cherryPick = {
821 | \'mapCmd': 'nmap',
822 | \'cmd': ':call CherryPick()',
823 | \'bindings': 'cp'
824 | \}
825 | let s:defaultMappings.vcherryPick = {
826 | \'mapCmd': 'vmap',
827 | \'cmd': ':call CherryPick()',
828 | \'bindings': 'cp'
829 | \}
830 | let s:defaultMappings.reset = {
831 | \'mapCmd': 'nmap',
832 | \'cmd': ':call ResetBranch("--mixed")',
833 | \'bindings': 'rb'
834 | \}
835 | let s:defaultMappings.vreset = {
836 | \'mapCmd': 'vmap',
837 | \'cmd': ':call ResetBranch("--mixed")',
838 | \'bindings': 'rb'
839 | \}
840 | let s:defaultMappings.resetSoft = {
841 | \'mapCmd': 'nmap',
842 | \'cmd': ':call ResetBranch("--soft")',
843 | \'bindings': 'rbs'
844 | \}
845 | let s:defaultMappings.vresetSoft = {
846 | \'mapCmd': 'vmap',
847 | \'cmd': ':call ResetBranch("--soft")',
848 | \'bindings': 'rbs'
849 | \}
850 | let s:defaultMappings.resetHard = {
851 | \'mapCmd': 'nmap',
852 | \'cmd': ':call ResetBranch("--hard")',
853 | \'bindings': 'rbh'
854 | \}
855 | let s:defaultMappings.vresetHard = {
856 | \'mapCmd': 'vmap',
857 | \'cmd': ':call ResetBranch("--hard")',
858 | \'bindings': 'rbh'
859 | \}
860 | let s:defaultMappings.revert = {
861 | \'mapCmd': 'nmap',
862 | \'cmd': ':call Revert()',
863 | \'bindings': 'rev'
864 | \}
865 | let s:defaultMappings.vrevert = {
866 | \'mapCmd': 'vmap',
867 | \'cmd': ':call Revert()',
868 | \'bindings': 'rev'
869 | \}
870 | let s:defaultMappings.delete = {
871 | \'mapCmd': 'nmap',
872 | \'cmd': ':call DeleteRef()',
873 | \'bindings': 'd'
874 | \}
875 | let s:defaultMappings.vdelete = {
876 | \'mapCmd': 'vmap',
877 | \'cmd': ':call DeleteRef()',
878 | \'bindings': 'd'
879 | \}
880 |
881 | " rebasing
882 | let s:defaultMappings.rebase = {
883 | \'cmd': ':call Rebase()',
884 | \'bindings': 'grr'
885 | \}
886 | let s:defaultMappings.vrebase = {
887 | \'mapCmd': 'vmap',
888 | \'cmd': ':call Rebase()',
889 | \'bindings': 'grr'
890 | \}
891 | let s:defaultMappings.rebasePick = {
892 | \'cmd': ':call RebaseSetInstruction("p")',
893 | \'bindings': 'grP'
894 | \}
895 | let s:defaultMappings.vrebasePick = {
896 | \'mapCmd': 'vmap',
897 | \'cmd': ':call RebaseSetInstruction("p")',
898 | \'bindings': 'grP'
899 | \}
900 | let s:defaultMappings.rebaseReword = {
901 | \'cmd': ':call RebaseSetInstruction("r")',
902 | \'bindings': 'grR'
903 | \}
904 | let s:defaultMappings.vrebaseReword = {
905 | \'mapCmd': 'vmap',
906 | \'cmd': ':call RebaseSetInstruction("r")',
907 | \'bindings': 'grR'
908 | \}
909 | let s:defaultMappings.rebaseMarkEdit = {
910 | \'cmd': ':call RebaseSetInstruction("e")',
911 | \'bindings': 'grE'
912 | \}
913 | let s:defaultMappings.vrebaseMarkEdit = {
914 | \'mapCmd': 'vmap',
915 | \'cmd': ':call RebaseSetInstruction("e")',
916 | \'bindings': 'grE'
917 | \}
918 | let s:defaultMappings.rebaseSquash = {
919 | \'cmd': ':call RebaseSetInstruction("s")',
920 | \'bindings': 'grS'
921 | \}
922 | let s:defaultMappings.vrebaseSquash = {
923 | \'mapCmd': 'vmap',
924 | \'cmd': ':call RebaseSetInstruction("s")',
925 | \'bindings': 'grS'
926 | \}
927 | let s:defaultMappings.rebaseFixup = {
928 | \'cmd': ':call RebaseSetInstruction("f")',
929 | \'bindings': 'grF'
930 | \}
931 | let s:defaultMappings.vrebaseFixup = {
932 | \'mapCmd': 'vmap',
933 | \'cmd': ':call RebaseSetInstruction("f")',
934 | \'bindings': 'grF'
935 | \}
936 | let s:defaultMappings.rebaseExec = {
937 | \'cmd': ':call RebaseSetInstruction("x")',
938 | \'bindings': 'grX'
939 | \}
940 | let s:defaultMappings.vrebaseExec = {
941 | \'mapCmd': 'vmap',
942 | \'cmd': ':call RebaseSetInstruction("x")',
943 | \'bindings': 'grX'
944 | \}
945 | let s:defaultMappings.rebaseDrop = {
946 | \'cmd': ':call RebaseSetInstruction("d")',
947 | \'bindings': 'grD'
948 | \}
949 | let s:defaultMappings.vrebaseDrop = {
950 | \'mapCmd': 'vmap',
951 | \'cmd': ':call RebaseSetInstruction("d")',
952 | \'bindings': 'grD'
953 | \}
954 | let s:defaultMappings.rebaseAbort = {
955 | \'cmd': ':call RebaseAbort()',
956 | \'bindings': 'gra'
957 | \}
958 | let s:defaultMappings.rebaseToggle = {
959 | \'cmd': ':call RebaseToggle()',
960 | \'bindings': 'grs'
961 | \}
962 | let s:defaultMappings.vrebaseToggle = {
963 | \'mapCmd': 'vmap',
964 | \'cmd': ':call RebaseToggle()',
965 | \'bindings': 'grs'
966 | \}
967 | let s:defaultMappings.rebaseSkip = {
968 | \'cmd': ':call RebaseSkip()',
969 | \'bindings': 'grn'
970 | \}
971 | let s:defaultMappings.rebaseContinue = {
972 | \'cmd': ':call RebaseContinue()',
973 | \'bindings': 'grc'
974 | \}
975 |
976 | " bisecting
977 | let s:defaultMappings.bisectStart = {
978 | \'mapCmd': 'nmap',
979 | \'cmd': ':call BisectStart("n")',
980 | \'bindings': 'gbs'
981 | \}
982 | let s:defaultMappings.vbisectStart = {
983 | \'mapCmd': 'vmap',
984 | \'cmd': ':call BisectStart("v")',
985 | \'bindings': 'gbs'
986 | \}
987 | let s:defaultMappings.bisectGood = {
988 | \'mapCmd': 'nmap',
989 | \'cmd': ':call BisectGoodBad("good")',
990 | \'bindings': 'gbg'
991 | \}
992 | let s:defaultMappings.vbisectGood = {
993 | \'mapCmd': 'vmap',
994 | \'cmd': ':call BisectGoodBad("good")',
995 | \'bindings': 'gbg'
996 | \}
997 | let s:defaultMappings.bisectBad = {
998 | \'mapCmd': 'nmap',
999 | \'cmd': ':call BisectGoodBad("bad")',
1000 | \'bindings': 'gbb'
1001 | \}
1002 | let s:defaultMappings.vbisectBad = {
1003 | \'mapCmd': 'vmap',
1004 | \'cmd': ':call BisectGoodBad("bad")',
1005 | \'bindings': 'gbb'
1006 | \}
1007 | let s:defaultMappings.bisectSkip = {
1008 | \'mapCmd': 'nmap',
1009 | \'cmd': ':call BisectSkip("n")',
1010 | \'bindings': 'gbn'
1011 | \}
1012 | let s:defaultMappings.vbisectSkip = {
1013 | \'mapCmd': 'vmap',
1014 | \'cmd': ':call