From b5fa4d80fb3f18150b132df3069472683a0ea7a7 Mon Sep 17 00:00:00 2001 From: Jerome Reybert Date: Mon, 26 Oct 2015 12:16:46 +0100 Subject: [PATCH 01/20] plugin/magit.vim: replace s:set() by get() --- plugin/magit.vim | 60 +++++++++++++++++++----------------------------- 1 file changed, 23 insertions(+), 37 deletions(-) diff --git a/plugin/magit.vim b/plugin/magit.vim index 4b5ee38..5a5e170 100644 --- a/plugin/magit.vim +++ b/plugin/magit.vim @@ -20,49 +20,35 @@ let g:magit_buffer_name = "magit-playground" let s:state = deepcopy(magit#state#state) -" s:set: helper function to set user definable variable -" param[in] var: variable to set -" param[in] default: default value if not already set by the user -" return: no -function! s:set(var, default) - if !exists(a:var) - if type(a:default) - execute 'let' a:var '=' string(a:default) - else - execute 'let' a:var '=' a:default - endif - endif -endfunction - " these mappings are broadly applied, for all vim buffers -call s:set('g:magit_show_magit_mapping', 'M' ) +let g:magit_show_magit_mapping = get(g:, 'magit_show_magit_mapping', 'M' ) " these mapping are applied locally, for magit buffer only -call s:set('g:magit_stage_file_mapping', 'F' ) -call s:set('g:magit_stage_hunk_mapping', 'S' ) -call s:set('g:magit_stage_line_mapping', 'L' ) -call s:set('g:magit_mark_line_mapping', 'M' ) -call s:set('g:magit_discard_hunk_mapping', 'DDD' ) -call s:set('g:magit_commit_mapping_command', 'w' ) -call s:set('g:magit_commit_mapping', 'CC' ) -call s:set('g:magit_commit_amend_mapping', 'CA' ) -call s:set('g:magit_commit_fixup_mapping', 'CF' ) -call s:set('g:magit_reload_mapping', 'R' ) -call s:set('g:magit_ignore_mapping', 'I' ) -call s:set('g:magit_close_mapping', 'q' ) -call s:set('g:magit_toggle_help_mapping', 'h' ) - -call s:set('g:magit_folding_toggle_mapping', [ '' ]) -call s:set('g:magit_folding_open_mapping', [ 'zo', 'zO' ]) -call s:set('g:magit_folding_close_mapping', [ 'zc', 'zC' ]) +let g:magit_stage_file_mapping = get(g:, 'magit_stage_file_mapping', 'F' ) +let g:magit_stage_hunk_mapping = get(g:, 'magit_stage_hunk_mapping', 'S' ) +let g:magit_stage_line_mapping = get(g:, 'magit_stage_line_mapping', 'L' ) +let g:magit_mark_line_mapping = get(g:, 'magit_mark_line_mapping', 'M' ) +let g:magit_discard_hunk_mapping = get(g:, 'magit_discard_hunk_mapping', 'DDD' ) +let g:magit_commit_mapping_command = get(g:, 'magit_commit_mapping_command', 'w' ) +let g:magit_commit_mapping = get(g:, 'magit_commit_mapping', 'CC' ) +let g:magit_commit_amend_mapping = get(g:, 'magit_commit_amend_mapping', 'CA' ) +let g:magit_commit_fixup_mapping = get(g:, 'magit_commit_fixup_mapping', 'CF' ) +let g:magit_reload_mapping = get(g:, 'magit_reload_mapping', 'R' ) +let g:magit_ignore_mapping = get(g:, 'magit_ignore_mapping', 'I' ) +let g:magit_close_mapping = get(g:, 'magit_close_mapping', 'q' ) +let g:magit_toggle_help_mapping = get(g:, 'magit_toggle_help_mapping', 'h' ) + +let g:magit_folding_toggle_mapping = get(g:, 'magit_folding_toggle_mapping', [ '' ]) +let g:magit_folding_open_mapping = get(g:, 'magit_folding_open_mapping', [ 'zo', 'zO' ]) +let g:magit_folding_close_mapping = get(g:, 'magit_folding_close_mapping', [ 'zc', 'zC' ]) " user options -call s:set('g:magit_enabled', 1) -call s:set('g:magit_show_help', 1) -call s:set('g:magit_default_show_all_files', 0) -call s:set('g:magit_default_fold_level', 1) +let g:magit_enabled = get(g:, 'magit_enabled', 1) +let g:magit_show_help = get(g:, 'magit_show_help', 1) +let g:magit_default_show_all_files = get(g:, 'magit_default_show_all_files', 0) +let g:magit_default_fold_level = get(g:, 'magit_default_fold_level', 1) -call s:set('g:magit_warning_max_lines', 10000) +let g:magit_warning_max_lines = get(g:, 'magit_warning_max_lines', 10000) execute "nnoremap " . g:magit_show_magit_mapping . " :call magit#show_magit('v')" " }}} From bedafeb3537d59e7dbc42016a155a6d0f881f9a2 Mon Sep 17 00:00:00 2001 From: Jerome Reybert Date: Mon, 26 Oct 2015 14:02:48 +0100 Subject: [PATCH 02/20] plugin/magit.vim: remove useless window restore commands add Do not move the cursor option to a search function call --- plugin/magit.vim | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/plugin/magit.vim b/plugin/magit.vim index 5a5e170..1d4dbdb 100644 --- a/plugin/magit.vim +++ b/plugin/magit.vim @@ -274,20 +274,17 @@ endfunction " inferior to upper_limit line, block is discarded " return: [startline, endline] function! s:mg_search_block(start_pattern, end_pattern, upper_limit_pattern) - let l:winview = winsaveview() let upper_limit=0 if ( a:upper_limit_pattern != "" ) let upper_limit=search(a:upper_limit_pattern, "cbnW") endif - let start=search(a:start_pattern[0], "cbW") + let start=search(a:start_pattern[0], "cbnW") if ( start == 0 ) - call winrestview(l:winview) throw "out_of_block" endif if ( start < upper_limit ) - call winrestview(l:winview) throw "out_of_block" endif let start+=a:start_pattern[1] @@ -302,12 +299,9 @@ function! s:mg_search_block(start_pattern, end_pattern, upper_limit_pattern) endif endfor if ( end == 0 ) - call winrestview(l:winview) throw "out_of_block" endif - call winrestview(l:winview) - return [start,end] endfunction From 5904932cc8283de97b745406727a9b8146123afc Mon Sep 17 00:00:00 2001 From: Jerome Reybert Date: Mon, 26 Oct 2015 14:19:49 +0100 Subject: [PATCH 03/20] plugin/magit.vim: factorize some if statements in s:mg_search_block() function --- plugin/magit.vim | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/plugin/magit.vim b/plugin/magit.vim index 1d4dbdb..cac6260 100644 --- a/plugin/magit.vim +++ b/plugin/magit.vim @@ -281,10 +281,7 @@ function! s:mg_search_block(start_pattern, end_pattern, upper_limit_pattern) endif let start=search(a:start_pattern[0], "cbnW") - if ( start == 0 ) - throw "out_of_block" - endif - if ( start < upper_limit ) + if ( start == 0 || start < upper_limit ) throw "out_of_block" endif let start+=a:start_pattern[1] From d2cb923592c2f632ece4c098db4edd9ea60e300d Mon Sep 17 00:00:00 2001 From: Jerome Reybert Date: Mon, 26 Oct 2015 14:20:18 +0100 Subject: [PATCH 04/20] plugin/magit.vim, autoload/magit/state.vim: add some comments --- autoload/magit/state.vim | 27 +++++++++++++++++++++++---- plugin/magit.vim | 7 +++++++ 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/autoload/magit/state.vim b/autoload/magit/state.vim index 8781329..d6557ac 100644 --- a/autoload/magit/state.vim +++ b/autoload/magit/state.vim @@ -1,23 +1,31 @@ +" magit#state#is_file_visible: file getter function +" return if file is visible function! magit#state#is_file_visible() dict return self.visible endfunction +" magit#state#set_file_visible: file setter function +" param[in] val: visible state to set to file function! magit#state#set_file_visible(val) dict let self.visible = a:val endfunction +" magit#state#toggle_file_visible: file setter function, toggle file visible +" state function! magit#state#toggle_file_visible() dict let self.visible = ( self.visible == 0 ) ? 1 : 0 endfunction +" magit#state#is_file_dir: file getter function +" return 1 if current file is a directory, 0 otherwise function! magit#state#is_file_dir() dict return self.dir != 0 endfunction -function! magit#state#get_files(mode) dict - return self.dict[a:mode] -endfunction - +" magit#state#must_be_added: file helper function +" there are some conditions where files must be widely added (git add), not +" 'diff applied' (git apply) +" return 1 if file must function! magit#state#must_be_added() dict return ( self.empty == 1 || \ self.symlink != '' || @@ -236,6 +244,9 @@ function! magit#state#update() dict endfor endfunction +" magit#state#set_files_visible: global dict setter function +" update all files visible state +" param[in] is_visible: boolean value to set to files function! magit#state#set_files_visible(is_visible) dict for diff_dict_mode in values(self.dict) for file in values(diff_dict_mode) @@ -244,6 +255,14 @@ function! magit#state#set_files_visible(is_visible) dict endfor endfunction +" magit#state#get_files: global dict getter function +" param[in] mode: mode to select, can be 'staged' or 'unstaged' +" return all files belonging to mode +function! magit#state#get_files(mode) dict + return self.dict[a:mode] +endfunction + + " dict: structure containing all diffs " It is formatted as follow " { diff --git a/plugin/magit.vim b/plugin/magit.vim index cac6260..12b18da 100644 --- a/plugin/magit.vim +++ b/plugin/magit.vim @@ -130,6 +130,13 @@ function! s:mg_get_info() silent put ='' endfunction +" s:mg_display_files: display in current buffer files, filtered by some +" parameters +" param[in] mode: files mode, can be 'staged' or 'unstaged' +" param[in] curdir: directory containing files (only needed for untracked +" directory) +" param[in] depth: current directory depth (only needed for untracked +" directory) function! s:mg_display_files(mode, curdir, depth) " FIXME: ouch, must store subdirs in more efficient way From a9c785bababb5fa4a11cc98748e0abf14311e3f1 Mon Sep 17 00:00:00 2001 From: Jerome Reybert Date: Mon, 26 Oct 2015 14:28:44 +0100 Subject: [PATCH 05/20] README.md: add asciinema example (fix #3) --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index aca7781..4382746 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,9 @@ From a very single vim buffer, you can perform all basic git operations. To name * Stage files/hunks/parts of hunks with single key S. * Write or amend your commit message and commit. +See a usage example: +[![asciicast](https://asciinema.org/a/28761.png)](https://asciinema.org/a/28761) + This workflow is 100% inspired from magnificent emacs [Magit](https://github.com/magit/magit) plugin. Take a look at [TL;DR](#tldr) to start using it immediatly. From 87cbc4f57ff819601ef49c00ccb5af395772a571 Mon Sep 17 00:00:00 2001 From: Jerome Reybert Date: Wed, 28 Oct 2015 09:39:32 +0100 Subject: [PATCH 06/20] syntax,plugin: fix end of diff display (section title may be non highlighed) change end of diff regex, search for first blank line. --- common/magit_common.vim | 1 + plugin/magit.vim | 4 +++- syntax/magit.vim | 5 ++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/common/magit_common.vim b/common/magit_common.vim index 47d488b..7773b0d 100644 --- a/common/magit_common.vim +++ b/common/magit_common.vim @@ -39,6 +39,7 @@ endfor let g:magit_section_re .= 'unknown section\)$' let g:magit_diff_re = '^diff --git' +let g:magit_end_diff_re = '^$' let g:magit_stash_re = '^stash@{\d\+}:' let g:magit_hunk_re = '^@@ -\(\d\+\),\?\(\d*\) +\(\d\+\),\?\(\d*\) @@' let g:magit_bin_re = '^Binary files ' diff --git a/plugin/magit.vim b/plugin/magit.vim index 12b18da..6f87613 100644 --- a/plugin/magit.vim +++ b/plugin/magit.vim @@ -351,7 +351,8 @@ endfunction function! s:mg_select_file_block() return mg_search_block( \ [g:magit_file_re, 1], - \ [ [g:magit_file_re, -1], + \ [ [g:magit_end_diff_re, 0], + \ [g:magit_file_re, -1], \ [g:magit_stash_re, -1], \ [g:magit_section_re, -2], \ [g:magit_bin_re, 0], @@ -370,6 +371,7 @@ function! s:mg_select_hunk_block() return mg_search_block( \ [g:magit_hunk_re, 0], \ [ [g:magit_hunk_re, -1], + \ [g:magit_end_diff_re, 0], \ [g:magit_file_re, -1], \ [g:magit_stash_re, -1], \ [g:magit_section_re, -2], diff --git a/syntax/magit.vim b/syntax/magit.vim index 5d2c8c5..e33e322 100644 --- a/syntax/magit.vim +++ b/syntax/magit.vim @@ -30,11 +30,10 @@ execute 'syn region gitStash start=/' . g:magit_stash_re . '/ end=/\%(' . \ g:magit_stash_re . '\)\@=/ contains=stashEntry fold' execute 'syn region gitFile start=/' . g:magit_file_re . '/ end=/\%(' . - \ g:magit_file_re . '\|' . g:magit_section_re '\)\@=/ contains=gitHunk,fileEntry fold' + \ g:magit_end_diff_re . '\)\@=/ contains=gitHunk,fileEntry fold' execute 'syn region gitHunk start=/' . - \ g:magit_hunk_re . '/ end=/\%(' . - \ g:magit_diff_re . '\|' . g:magit_hunk_re . '\|' . g:magit_section_re. '\|' . g:magit_stash_re . '\|' . g:magit_file_re . + \ g:magit_hunk_re . '/ end=/\%(' . g:magit_end_diff_re . '\|' . g:magit_hunk_re \ '\)\@=/ contains=@diff fold' let b:current_syntax = "magit" From c10c9cadc60d5728b60076db6e06f47d514b2dad Mon Sep 17 00:00:00 2001 From: Jerome Reybert Date: Fri, 30 Oct 2015 11:25:39 +0100 Subject: [PATCH 07/20] plugin/magit.vim: move git_(un)apply helper functions to utils.vim --- autoload/magit/utils.vim | 48 +++++++++++++++++++++++++++++++++++++ plugin/magit.vim | 52 +++------------------------------------- 2 files changed, 51 insertions(+), 49 deletions(-) diff --git a/autoload/magit/utils.vim b/autoload/magit/utils.vim index a8ec6ef..0b1c8a4 100644 --- a/autoload/magit/utils.vim +++ b/autoload/magit/utils.vim @@ -33,6 +33,54 @@ function! magit#utils#git_dir() return s:magit_git_dir endfunction + +" magit#utils#git_apply: helper function to stage a selection +" nota: when git fail (due to misformated patch for example), an error +" message is raised. +" param[in] selection: the text to stage. It must be a patch, i.e. a diff +" header plus one or more hunks +" return: no +function! magit#utils#git_apply(header, selection) + let selection = magit#utils#flatten(a:header + a:selection) + if ( selection[-1] !~ '^$' ) + let selection += [ '' ] + endif + let git_cmd="git apply --recount --no-index --cached -" + silent let git_result=magit#utils#system(git_cmd, selection) + if ( v:shell_error != 0 ) + echoerr "Git error: " . git_result + echoerr "Git cmd: " . git_cmd + echoerr "Tried to aply this" + echoerr string(selection) + endif +endfunction + +" magit#utils#git_unapply: helper function to unstage a selection +" nota: when git fail (due to misformated patch for example), an error +" message is raised. +" param[in] selection: the text to stage. It must be a patch, i.e. a diff +" header plus one or more hunks +" return: no +function! magit#utils#git_unapply(header, selection, mode) + let cached_flag='' + if ( a:mode == 'staged' ) + let cached_flag=' --cached ' + endif + let selection = magit#utils#flatten(a:header + a:selection) + if ( selection[-1] !~ '^$' ) + let selection += [ '' ] + endif + silent let git_result=magit#utils#system( + \ "git apply --recount --no-index " . cached_flag . " --reverse - ", + \ selection) + if ( v:shell_error != 0 ) + echoerr "Git error: " . git_result + echoerr "Tried to unaply this" + echoerr string(selection) + endif +endfunction + + " s:magit#utils#is_binary: check if file is a binary file " param[in] filename: the file path. it must quoted if it contains spaces function! magit#utils#is_binary(filename) diff --git a/plugin/magit.vim b/plugin/magit.vim index 6f87613..3461bf0 100644 --- a/plugin/magit.vim +++ b/plugin/magit.vim @@ -380,52 +380,6 @@ function! s:mg_select_hunk_block() \ g:magit_file_re) endfunction -" s:mg_git_apply: helper function to stage a selection -" nota: when git fail (due to misformated patch for example), an error -" message is raised. -" param[in] selection: the text to stage. It must be a patch, i.e. a diff -" header plus one or more hunks -" return: no -function! s:mg_git_apply(header, selection) - let selection = magit#utils#flatten(a:header + a:selection) - if ( selection[-1] !~ '^$' ) - let selection += [ '' ] - endif - let git_cmd="git apply --recount --no-index --cached -" - silent let git_result=magit#utils#system(git_cmd, selection) - if ( v:shell_error != 0 ) - echoerr "Git error: " . git_result - echoerr "Git cmd: " . git_cmd - echoerr "Tried to aply this" - echoerr string(selection) - endif -endfunction - -" s:mg_git_unapply: helper function to unstage a selection -" nota: when git fail (due to misformated patch for example), an error -" message is raised. -" param[in] selection: the text to stage. It must be a patch, i.e. a diff -" header plus one or more hunks -" return: no -function! s:mg_git_unapply(header, selection, mode) - let cached_flag='' - if ( a:mode == 'staged' ) - let cached_flag=' --cached ' - endif - let selection = magit#utils#flatten(a:header + a:selection) - if ( selection[-1] !~ '^$' ) - let selection += [ '' ] - endif - silent let git_result=magit#utils#system( - \ "git apply --recount --no-index " . cached_flag . " --reverse - ", - \ selection) - if ( v:shell_error != 0 ) - echoerr "Git error: " . git_result - echoerr "Tried to unaply this" - echoerr string(selection) - endif -endfunction - " s:mg_create_diff_from_select: craft the diff to apply from a selection " in a chunk " remarks: it works with full lines, and can not span over multiple chunks @@ -726,14 +680,14 @@ function! magit#stage_block(selection, discard) abort call magit#utils#system('git add ' . \ magit#utils#add_quotes(filename)) else - call mg_git_apply(header, a:selection) + call magit#utils#git_apply(header, a:selection) endif elseif ( section == 'staged' ) if ( file.must_be_added() ) call magit#utils#system('git reset ' . \ magit#utils#add_quotes(filename)) else - call mg_git_unapply(header, a:selection, 'staged') + call magit#utils#git_unapply(header, a:selection, 'staged') endif else echoerr "Must be in \"" . @@ -745,7 +699,7 @@ function! magit#stage_block(selection, discard) abort if ( file.must_be_added() ) call delete(filename) else - call mg_git_unapply(header, a:selection, 'unstaged') + call magit#utils#git_unapply(header, a:selection, 'unstaged') endif else echoerr "Must be in \"" . From d77693b6fbad61da14ffaa2a34cf2afef39f9f18 Mon Sep 17 00:00:00 2001 From: Jerome Reybert Date: Fri, 30 Oct 2015 11:50:46 +0100 Subject: [PATCH 08/20] autoload/magit/utils.vim: add git_add and git_reset helper functions --- autoload/magit/utils.vim | 25 +++++++++++++++++++++++++ plugin/magit.vim | 6 ++---- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/autoload/magit/utils.vim b/autoload/magit/utils.vim index 0b1c8a4..767aef8 100644 --- a/autoload/magit/utils.vim +++ b/autoload/magit/utils.vim @@ -33,6 +33,31 @@ function! magit#utils#git_dir() return s:magit_git_dir endfunction +" magit#utils#git_add: helper function to add a whole file +" nota: when git fail (due to misformated patch for example), an error +" message is raised. +" param[in] filemane: it must be quoted if it contains spaces +function! magit#utils#git_add(filename) + let git_cmd="git add -- " . a:filename + silent let git_result=magit#utils#system(git_cmd) + if ( v:shell_error != 0 ) + echoerr "Git error: " . git_result + echoerr "Git cmd: " . git_cmd + endif +endfunction + +" magit#utils#git_reset: helper function to add a whole file +" nota: when git fail (due to misformated patch for example), an error +" message is raised. +" param[in] filemane: it must be quoted if it contains spaces +function! magit#utils#git_reset(filename) + let git_cmd="git reset -- " . a:filename + silent let git_result=magit#utils#system(git_cmd) + if ( v:shell_error != 0 ) + echoerr "Git error: " . git_result + echoerr "Git cmd: " . git_cmd + endif +endfunction " magit#utils#git_apply: helper function to stage a selection " nota: when git fail (due to misformated patch for example), an error diff --git a/plugin/magit.vim b/plugin/magit.vim index 3461bf0..44fc02b 100644 --- a/plugin/magit.vim +++ b/plugin/magit.vim @@ -677,15 +677,13 @@ function! magit#stage_block(selection, discard) abort if ( a:discard == 0 ) if ( section == 'unstaged' ) if ( file.must_be_added() ) - call magit#utils#system('git add ' . - \ magit#utils#add_quotes(filename)) + call magit#utils#git_add(magit#utils#add_quotes(filename)) else call magit#utils#git_apply(header, a:selection) endif elseif ( section == 'staged' ) if ( file.must_be_added() ) - call magit#utils#system('git reset ' . - \ magit#utils#add_quotes(filename)) + call magit#utils#git_reset(magit#utils#add_quotes(filename)) else call magit#utils#git_unapply(header, a:selection, 'staged') endif From e9679192f3da1fd14aa1cb01bb55d9d33007d4ee Mon Sep 17 00:00:00 2001 From: Jerome Reybert Date: Fri, 30 Oct 2015 17:17:48 +0100 Subject: [PATCH 09/20] autoload/magit/git.vim: move all git related functions to git.vim --- autoload/magit/git.vim | 114 ++++++++++++++++++++++++++++++++++++++- autoload/magit/state.vim | 2 +- autoload/magit/utils.vim | 113 ++------------------------------------ plugin/magit.vim | 14 ++--- 4 files changed, 124 insertions(+), 119 deletions(-) diff --git a/autoload/magit/git.vim b/autoload/magit/git.vim index 0389b90..563a055 100644 --- a/autoload/magit/git.vim +++ b/autoload/magit/git.vim @@ -1,3 +1,5 @@ +let s:git_cmd="git" + " magit#git#get_status: this function returns the git status output formated " into a List of Dict as " [ {staged', 'unstaged', 'filename'}, ... ] @@ -8,7 +10,7 @@ function! magit#git#get_status() " we can't use git status -z here, because system doesn't make the " difference between NUL and NL. -status z terminate entries with NUL, " instead of NF - let status_list=magit#utils#systemlist("git status --porcelain") + let status_list=magit#utils#systemlist(s:git_cmd . " status --porcelain") for file_status_line in status_list let line_match = matchlist(file_status_line, '\(.\)\(.\) \%(.\{-\} -> \)\?"\?\(.\{-\}\)"\?$') let filename = line_match[3] @@ -17,3 +19,113 @@ function! magit#git#get_status() return file_list endfunction +" s:magit_top_dir: top directory of git tree +" it is evaluated only once +" FIXME: it won't work when playing with multiple git directories wihtin one +" vim session +let s:magit_top_dir='' +" magit#git#top_dir: return the absolute path of current git worktree +" return top directory +function! magit#git#top_dir() + if ( s:magit_top_dir == '' ) + let s:magit_top_dir=magit#utils#strip( + \ system(s:git_cmd . " rev-parse --show-toplevel")) . "/" + if ( v:shell_error != 0 ) + echoerr "Git error: " . s:magit_top_dir + endif + endif + return s:magit_top_dir +endfunction + +" s:magit_git_dir: git directory +" it is evaluated only once +" FIXME: it won't work when playing with multiple git directories wihtin one +" vim session +let s:magit_git_dir='' +" magit#git#git_dir: return the absolute path of current git worktree +" return git directory +function! magit#git#git_dir() + if ( s:magit_git_dir == '' ) + let s:magit_git_dir=magit#utils#strip(system(s:git_cmd . " rev-parse --git-dir")) . "/" + if ( v:shell_error != 0 ) + echoerr "Git error: " . s:magit_git_dir + endif + endif + return s:magit_git_dir +endfunction + +" magit#git#git_add: helper function to add a whole file +" nota: when git fail (due to misformated patch for example), an error +" message is raised. +" param[in] filemane: it must be quoted if it contains spaces +function! magit#git#git_add(filename) + let git_cmd=s:git_cmd . " add -- " . a:filename + silent let git_result=magit#utils#system(git_cmd) + if ( v:shell_error != 0 ) + echoerr "Git error: " . git_result + echoerr "Git cmd: " . git_cmd + endif +endfunction + +" magit#git#git_reset: helper function to add a whole file +" nota: when git fail (due to misformated patch for example), an error +" message is raised. +" param[in] filemane: it must be quoted if it contains spaces +function! magit#git#git_reset(filename) + let git_cmd=s:git_cmd . " reset -- " . a:filename + silent let git_result=magit#utils#system(git_cmd) + if ( v:shell_error != 0 ) + echoerr "Git error: " . git_result + echoerr "Git cmd: " . git_cmd + endif +endfunction + +" magit#git#git_apply: helper function to stage a selection +" nota: when git fail (due to misformated patch for example), an error +" message is raised. +" param[in] selection: the text to stage. It must be a patch, i.e. a diff +" header plus one or more hunks +" return: no +function! magit#git#git_apply(header, selection) + let selection = magit#utils#flatten(a:header + a:selection) + if ( selection[-1] !~ '^$' ) + let selection += [ '' ] + endif + let git_cmd=s:git_cmd . " apply --recount --no-index --cached -" + silent let git_result=magit#utils#system(git_cmd, selection) + if ( v:shell_error != 0 ) + echoerr "Git error: " . git_result + echoerr "Git cmd: " . git_cmd + echoerr "Tried to aply this" + echoerr string(selection) + endif +endfunction + +" magit#git#git_unapply: helper function to unstage a selection +" nota: when git fail (due to misformated patch for example), an error +" message is raised. +" param[in] selection: the text to stage. It must be a patch, i.e. a diff +" header plus one or more hunks +" return: no +function! magit#git#git_unapply(header, selection, mode) + let cached_flag='' + if ( a:mode == 'staged' ) + let cached_flag=' --cached ' + endif + let selection = magit#utils#flatten(a:header + a:selection) + if ( selection[-1] !~ '^$' ) + let selection += [ '' ] + endif + silent let git_result=magit#utils#system( + \ s:git_cmd . " apply --recount --no-index " . cached_flag . " --reverse - ", + \ selection) + if ( v:shell_error != 0 ) + echoerr "Git error: " . git_result + echoerr "Tried to unaply this" + echoerr string(selection) + endif +endfunction + +function! magit#git#submodule_status() + return system(s:git_cmd . " submodule status") +endfunction diff --git a/autoload/magit/state.vim b/autoload/magit/state.vim index d6557ac..032416e 100644 --- a/autoload/magit/state.vim +++ b/autoload/magit/state.vim @@ -216,7 +216,7 @@ function! magit#state#update() dict let dir = getcwd() try - call magit#utils#lcd(magit#utils#top_dir()) + call magit#utils#lcd(magit#git#top_dir()) call magit#utils#refresh_submodule_list() for [mode, diff_dict_mode] in items(self.dict) let status_list = magit#git#get_status() diff --git a/autoload/magit/utils.vim b/autoload/magit/utils.vim index 767aef8..87c4da6 100644 --- a/autoload/magit/utils.vim +++ b/autoload/magit/utils.vim @@ -1,110 +1,3 @@ -" s:magit_top_dir: top directory of git tree -" it is evaluated only once -" FIXME: it won't work when playing with multiple git directories wihtin one -" vim session -let s:magit_top_dir='' -" magit#utils#top_dir: return the absolute path of current git worktree -" return top directory -function! magit#utils#top_dir() - if ( s:magit_top_dir == '' ) - let s:magit_top_dir=magit#utils#strip( - \ system("git rev-parse --show-toplevel")) . "/" - if ( v:shell_error != 0 ) - echoerr "Git error: " . s:magit_top_dir - endif - endif - return s:magit_top_dir -endfunction - -" s:magit_git_dir: git directory -" it is evaluated only once -" FIXME: it won't work when playing with multiple git directories wihtin one -" vim session -let s:magit_git_dir='' -" magit#utils#git_dir: return the absolute path of current git worktree -" return git directory -function! magit#utils#git_dir() - if ( s:magit_git_dir == '' ) - let s:magit_git_dir=magit#utils#strip(system("git rev-parse --git-dir")) . "/" - if ( v:shell_error != 0 ) - echoerr "Git error: " . s:magit_git_dir - endif - endif - return s:magit_git_dir -endfunction - -" magit#utils#git_add: helper function to add a whole file -" nota: when git fail (due to misformated patch for example), an error -" message is raised. -" param[in] filemane: it must be quoted if it contains spaces -function! magit#utils#git_add(filename) - let git_cmd="git add -- " . a:filename - silent let git_result=magit#utils#system(git_cmd) - if ( v:shell_error != 0 ) - echoerr "Git error: " . git_result - echoerr "Git cmd: " . git_cmd - endif -endfunction - -" magit#utils#git_reset: helper function to add a whole file -" nota: when git fail (due to misformated patch for example), an error -" message is raised. -" param[in] filemane: it must be quoted if it contains spaces -function! magit#utils#git_reset(filename) - let git_cmd="git reset -- " . a:filename - silent let git_result=magit#utils#system(git_cmd) - if ( v:shell_error != 0 ) - echoerr "Git error: " . git_result - echoerr "Git cmd: " . git_cmd - endif -endfunction - -" magit#utils#git_apply: helper function to stage a selection -" nota: when git fail (due to misformated patch for example), an error -" message is raised. -" param[in] selection: the text to stage. It must be a patch, i.e. a diff -" header plus one or more hunks -" return: no -function! magit#utils#git_apply(header, selection) - let selection = magit#utils#flatten(a:header + a:selection) - if ( selection[-1] !~ '^$' ) - let selection += [ '' ] - endif - let git_cmd="git apply --recount --no-index --cached -" - silent let git_result=magit#utils#system(git_cmd, selection) - if ( v:shell_error != 0 ) - echoerr "Git error: " . git_result - echoerr "Git cmd: " . git_cmd - echoerr "Tried to aply this" - echoerr string(selection) - endif -endfunction - -" magit#utils#git_unapply: helper function to unstage a selection -" nota: when git fail (due to misformated patch for example), an error -" message is raised. -" param[in] selection: the text to stage. It must be a patch, i.e. a diff -" header plus one or more hunks -" return: no -function! magit#utils#git_unapply(header, selection, mode) - let cached_flag='' - if ( a:mode == 'staged' ) - let cached_flag=' --cached ' - endif - let selection = magit#utils#flatten(a:header + a:selection) - if ( selection[-1] !~ '^$' ) - let selection += [ '' ] - endif - silent let git_result=magit#utils#system( - \ "git apply --recount --no-index " . cached_flag . " --reverse - ", - \ selection) - if ( v:shell_error != 0 ) - echoerr "Git error: " . git_result - echoerr "Tried to unaply this" - echoerr string(selection) - endif -endfunction - " s:magit#utils#is_binary: check if file is a binary file " param[in] filename: the file path. it must quoted if it contains spaces @@ -124,7 +17,7 @@ let s:submodule_list = [] " magit#utils#refresh_submodule_list: this function refresh the List s:submodule_list " magit#utils#is_submodule() is using s:submodule_list function! magit#utils#refresh_submodule_list() - let s:submodule_list = map(split(system("git submodule status"), "\n"), 'split(v:val)[1]') + let s:submodule_list = map(split(magit#git#submodule_status(), "\n"), 'split(v:val)[1]') endfunction " magit#utils#is_submodule search if dirname is in s:submodule_list @@ -151,7 +44,7 @@ endfunction function! magit#utils#system(...) let dir = getcwd() try - execute s:magit_cd_cmd . magit#utils#top_dir() + execute s:magit_cd_cmd . magit#git#top_dir() " List as system() input is since v7.4.247, it is safe to check " systemlist, which is sine v7.4.248 if exists('*systemlist') @@ -184,7 +77,7 @@ endfunction function! magit#utils#systemlist(...) let dir = getcwd() try - execute s:magit_cd_cmd . magit#utils#top_dir() + execute s:magit_cd_cmd . magit#git#top_dir() " systemlist since v7.4.248 if exists('*systemlist') return call('systemlist', a:000) diff --git a/plugin/magit.vim b/plugin/magit.vim index 44fc02b..773bf59 100644 --- a/plugin/magit.vim +++ b/plugin/magit.vim @@ -240,7 +240,7 @@ function! s:mg_get_commit_section() silent put =magit#utils#underline(g:magit_sections.commit_start) silent put ='' - let git_dir=magit#utils#git_dir() + let git_dir=magit#git#git_dir() " refresh the COMMIT_EDITMSG file if ( s:magit_commit_mode == 'CC' ) silent! call magit#utils#system("GIT_EDITOR=/bin/false git commit -e 2> /dev/null") @@ -677,15 +677,15 @@ function! magit#stage_block(selection, discard) abort if ( a:discard == 0 ) if ( section == 'unstaged' ) if ( file.must_be_added() ) - call magit#utils#git_add(magit#utils#add_quotes(filename)) + call magit#git#git_add(magit#utils#add_quotes(filename)) else - call magit#utils#git_apply(header, a:selection) + call magit#git#git_apply(header, a:selection) endif elseif ( section == 'staged' ) if ( file.must_be_added() ) - call magit#utils#git_reset(magit#utils#add_quotes(filename)) + call magit#git#git_resetmagit#utils#add_quotes(filename)) else - call magit#utils#git_unapply(header, a:selection, 'staged') + call magit#git#git_unapply(header, a:selection, 'staged') endif else echoerr "Must be in \"" . @@ -697,7 +697,7 @@ function! magit#stage_block(selection, discard) abort if ( file.must_be_added() ) call delete(filename) else - call magit#utils#git_unapply(header, a:selection, 'unstaged') + call magit#git#git_unapply(header, a:selection, 'unstaged') endif else echoerr "Must be in \"" . @@ -780,7 +780,7 @@ endfunction " FIXME: git diff adds some strange characters to end of line function! magit#ignore_file() abort let ignore_file=mg_get_filename() - call magit#utils#append_file(magit#utils#top_dir() . ".gitignore", + call magit#utils#append_file(magit#git#top_dir() . ".gitignore", \ [ ignore_file ] ) call magit#update_buffer() endfunction From 32819f0c2ac21c4d0ffafa0a670f76d1d2ec276c Mon Sep 17 00:00:00 2001 From: Jerome Reybert Date: Fri, 30 Oct 2015 17:18:57 +0100 Subject: [PATCH 10/20] autoload/magit/git.vim: git works in a clean environment (no config) --- autoload/magit/git.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/magit/git.vim b/autoload/magit/git.vim index 563a055..0d4e55e 100644 --- a/autoload/magit/git.vim +++ b/autoload/magit/git.vim @@ -1,4 +1,4 @@ -let s:git_cmd="git" +let s:git_cmd="GIT_CONFIG=/dev/null GIT_CONFIG_NOSYSTEM=1 XDG_CONFIG_HOME=/ git" " magit#git#get_status: this function returns the git status output formated " into a List of Dict as From 7387303ced622869c7de8bfcea1438b732409e16 Mon Sep 17 00:00:00 2001 From: Jerome Reybert Date: Fri, 30 Oct 2015 18:46:49 +0100 Subject: [PATCH 11/20] plugin/magit.vim: fix big :%s --- plugin/magit.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/magit.vim b/plugin/magit.vim index 773bf59..e8a4ab0 100644 --- a/plugin/magit.vim +++ b/plugin/magit.vim @@ -683,7 +683,7 @@ function! magit#stage_block(selection, discard) abort endif elseif ( section == 'staged' ) if ( file.must_be_added() ) - call magit#git#git_resetmagit#utils#add_quotes(filename)) + call magit#git#git_reset(magit#utils#add_quotes(filename)) else call magit#git#git_unapply(header, a:selection, 'staged') endif From d758175454e9d33ec04b809c2a80860ece26cf5c Mon Sep 17 00:00:00 2001 From: Jerome Reybert Date: Fri, 30 Oct 2015 18:47:10 +0100 Subject: [PATCH 12/20] plugin/magit.vim: add mg_stage_closed_file function --- plugin/magit.vim | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/plugin/magit.vim b/plugin/magit.vim index e8a4ab0..4b78ead 100644 --- a/plugin/magit.vim +++ b/plugin/magit.vim @@ -646,6 +646,44 @@ function! magit#show_magit(display, ...) execute "normal! gg" endfunction +function! s:mg_stage_closed_file(discard) + if ( getline(".") =~ g:magit_file_re ) + let list = matchlist(getline("."), g:magit_file_re) + let filename = list[2] + let section=mg_get_section() + + let file = s:state.get_file(section, filename) + if ( file.is_visible() == 0 || + \ file.is_dir() == 1 ) + if ( a:discard == 0 ) + if ( section == 'unstaged' ) + call magit#git#git_add(magit#utils#add_quotes(filename)) + elseif ( section == 'staged' ) + call magit#git#git_reset(magit#utils#add_quotes(filename)) + else + echoerr "Must be in \"" . + \ g:magit_sections.staged . "\" or \"" . + \ g:magit_sections.unstaged . "\" section" + endif + else + if ( section == 'unstaged' ) + if ( file.must_be_added() ) + call delete(filename) + else + call magit#git#git_reset(filename) + endif + else + echoerr "Must be in \"" . + \ g:magit_sections.unstaged . "\" section" + endif + endif + call magit#update_buffer() + return + endif + endif + throw "out_of_block" +endfunction + function! s:mg_select_closed_file() if ( getline(".") =~ g:magit_file_re ) let list = matchlist(getline("."), g:magit_file_re) From d148915bd302a81ec5870e042c410d80fa03bc66 Mon Sep 17 00:00:00 2001 From: Jerome Reybert Date: Fri, 30 Oct 2015 23:47:56 +0100 Subject: [PATCH 13/20] autoload/magit/git.vim: add git_checkout(), fix git_add() and git_reset() --- autoload/magit/git.vim | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/autoload/magit/git.vim b/autoload/magit/git.vim index 0d4e55e..66b0181 100644 --- a/autoload/magit/git.vim +++ b/autoload/magit/git.vim @@ -59,7 +59,20 @@ endfunction " message is raised. " param[in] filemane: it must be quoted if it contains spaces function! magit#git#git_add(filename) - let git_cmd=s:git_cmd . " add -- " . a:filename + let git_cmd=s:git_cmd . " add --no-ignore-removal -- " . a:filename + silent let git_result=magit#utils#system(git_cmd) + if ( v:shell_error != 0 ) + echoerr "Git error: " . git_result + echoerr "Git cmd: " . git_cmd + endif +endfunction + +" magit#git#git_checkout: helper function to add a whole file +" nota: when git fail (due to misformated patch for example), an error +" message is raised. +" param[in] filemane: it must be quoted if it contains spaces +function! magit#git#git_checkout(filename) + let git_cmd=s:git_cmd . " checkout -- " . a:filename silent let git_result=magit#utils#system(git_cmd) if ( v:shell_error != 0 ) echoerr "Git error: " . git_result @@ -72,7 +85,7 @@ endfunction " message is raised. " param[in] filemane: it must be quoted if it contains spaces function! magit#git#git_reset(filename) - let git_cmd=s:git_cmd . " reset -- " . a:filename + let git_cmd=s:git_cmd . " reset HEAD -- " . a:filename silent let git_result=magit#utils#system(git_cmd) if ( v:shell_error != 0 ) echoerr "Git error: " . git_result From 45cc6262315eae78a0396e6e227da748f42f5b91 Mon Sep 17 00:00:00 2001 From: Jerome Reybert Date: Fri, 30 Oct 2015 23:54:01 +0100 Subject: [PATCH 14/20] plugin/magit.vim: stage file when closed (do not need vimagit cached data) --- plugin/magit.vim | 34 ++++++++-------------------------- 1 file changed, 8 insertions(+), 26 deletions(-) diff --git a/plugin/magit.vim b/plugin/magit.vim index 4b78ead..43e0c21 100644 --- a/plugin/magit.vim +++ b/plugin/magit.vim @@ -661,19 +661,15 @@ function! s:mg_stage_closed_file(discard) elseif ( section == 'staged' ) call magit#git#git_reset(magit#utils#add_quotes(filename)) else - echoerr "Must be in \"" . - \ g:magit_sections.staged . "\" or \"" . + echoerr "Must be in \"" . + \ g:magit_sections.staged . "\" or \"" . \ g:magit_sections.unstaged . "\" section" endif else if ( section == 'unstaged' ) - if ( file.must_be_added() ) - call delete(filename) - else - call magit#git#git_reset(filename) - endif + call magit#git#git_checkout(magit#utils#add_quotes(filename)) else - echoerr "Must be in \"" . + echoerr "Must be in \"" . \ g:magit_sections.unstaged . "\" section" endif endif @@ -684,22 +680,6 @@ function! s:mg_stage_closed_file(discard) throw "out_of_block" endfunction -function! s:mg_select_closed_file() - if ( getline(".") =~ g:magit_file_re ) - let list = matchlist(getline("."), g:magit_file_re) - let filename = list[2] - let section=mg_get_section() - - let file = s:state.get_file(section, filename) - if ( file.is_visible() == 0 || - \ file.is_dir() == 1 ) - let selection = s:state.get_file(section, filename).get_flat_hunks() - return selection - endif - endif - throw "out_of_block" -endfunction - " magit#stage_block: this function (un)stage a block, according to parameter " INFO: in unstaged section, it stages the hunk, and in staged section, it " unstages the hunk @@ -753,7 +733,8 @@ endfunction " return: no function! magit#stage_file() try - let selection = mg_select_closed_file() + call mg_stage_closed_file(0) + return catch 'out_of_block' let [start, end] = mg_select_file_block() let selection = getline(start, end) @@ -771,7 +752,8 @@ endfunction " return: no function! magit#stage_hunk(discard) try - let selection = mg_select_closed_file() + call mg_stage_closed_file(a:discard) + return catch 'out_of_block' try let [start,end] = mg_select_hunk_block() From d7c85b1c0156672ebb6810e99631e8ae1652cd62 Mon Sep 17 00:00:00 2001 From: Jerome Reybert Date: Fri, 30 Oct 2015 23:54:50 +0100 Subject: [PATCH 15/20] plugin/magit.vim: fix stage_block discard --- plugin/magit.vim | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugin/magit.vim b/plugin/magit.vim index 43e0c21..8607817 100644 --- a/plugin/magit.vim +++ b/plugin/magit.vim @@ -706,19 +706,19 @@ function! magit#stage_block(selection, discard) abort call magit#git#git_unapply(header, a:selection, 'staged') endif else - echoerr "Must be in \"" . - \ g:magit_sections.staged . "\" or \"" . + echoerr "Must be in \"" . + \ g:magit_sections.staged . "\" or \"" . \ g:magit_sections.unstaged . "\" section" endif else if ( section == 'unstaged' ) if ( file.must_be_added() ) - call delete(filename) + call magit#git#git_checkout(magit#utils#add_quotes(filename)) else call magit#git#git_unapply(header, a:selection, 'unstaged') endif else - echoerr "Must be in \"" . + echoerr "Must be in \"" . \ g:magit_sections.unstaged . "\" section" endif endif From e12d661031d5028fccb9cc383f8e654c441e751b Mon Sep 17 00:00:00 2001 From: Jerome Reybert Date: Sat, 31 Oct 2015 00:13:06 +0100 Subject: [PATCH 16/20] test/: add new tests with new and modified binary files --- test/run.sh | 2 +- test/test.config | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/run.sh b/test/run.sh index ded972c..b8b732b 100755 --- a/test/run.sh +++ b/test/run.sh @@ -26,7 +26,7 @@ fi pushd $TEST_PATH git config --local user.email 'tester@vimagit.org' git config --local user.name 'vimagit tester' -export TEST_HEAD_SHA1='origin/vimagit_test-1.4' +export TEST_HEAD_SHA1='origin/vimagit_test-1.4.1' git submodule update git show $TEST_HEAD_SHA1 --stat git reset $TEST_HEAD_SHA1~1 && git status --porcelain && git reset --hard $TEST_HEAD_SHA1 diff --git a/test/test.config b/test/test.config index e137682..3b5b21a 100644 --- a/test/test.config +++ b/test/test.config @@ -1,6 +1,6 @@ declare -a test_paths=(./ ./books/templates/) declare -A test_scripts=( - [addFile.vader]='bootstrap;books/models.py;bootstrap.lnk;empty_file;bootstrap\ with\ spaces;bootstrap\ with\ spaces.lnk;empty_file\ with\ spaces' + [addFile.vader]='bootstrap;books/models.py;bootstrap.lnk;empty_file;bootstrap\ with\ spaces;bootstrap\ with\ spaces.lnk;empty_file\ with\ spaces;nanopdf.png;modnano.png' [addHunk.vader]='bootstrap;books/models.py' [addSelect.vader]='books/models.py' [renameFile.vader]='manage.py|manage\ with\ spaces.py;djooks/settings\ with\ spaces.py|djooks/settings_without_spaces.py' From 46ce3d700ad4f1862f7e8d29c827744a7ffadc7a Mon Sep 17 00:00:00 2001 From: Jerome Reybert Date: Sun, 1 Nov 2015 00:30:17 +0100 Subject: [PATCH 17/20] .travis.yml: enable travis for all dev/* branches --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 184293b..0cab22d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ branches: only: - master - next - - dev + - /^dev\/.*$/ os: - linux From 381b06a01cb41304ef32f918aadcca2d62150599 Mon Sep 17 00:00:00 2001 From: Jerome Reybert Date: Sun, 1 Nov 2015 01:05:01 +0100 Subject: [PATCH 18/20] autoload/magit/utils.vim: fix is_binary function (fixes #27) --- autoload/magit/utils.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/magit/utils.vim b/autoload/magit/utils.vim index 87c4da6..6be7df1 100644 --- a/autoload/magit/utils.vim +++ b/autoload/magit/utils.vim @@ -3,7 +3,7 @@ " param[in] filename: the file path. it must quoted if it contains spaces function! magit#utils#is_binary(filename) return ( match(system("file --mime " . a:filename ), - \ a:filename . ".*charset=binary") != -1 ) + \ ".*charset=binary") != -1 ) endfunction " magit#utils#ls_all: list all files (including hidden ones) in a given path From 06600b324dcc354873508d17292f99b90040d298 Mon Sep 17 00:00:00 2001 From: Jerome Reybert Date: Sun, 1 Nov 2015 01:08:52 +0100 Subject: [PATCH 19/20] test/addFile/: add golden files for binary tests --- test/addFile/addFile_modnano_png_commit.expect | 10 ++++++++++ test/addFile/addFile_modnano_png_file_diff.expect | 2 ++ .../addFile_modnano_png_unstaged_status.expect | 1 + test/addFile/addFile_nanopdf_png_commit.expect | 11 +++++++++++ test/addFile/addFile_nanopdf_png_file_diff.expect | 3 +++ .../addFile_nanopdf_png_unstaged_status.expect | 1 + 6 files changed, 28 insertions(+) create mode 100644 test/addFile/addFile_modnano_png_commit.expect create mode 100644 test/addFile/addFile_modnano_png_file_diff.expect create mode 100644 test/addFile/addFile_modnano_png_unstaged_status.expect create mode 100644 test/addFile/addFile_nanopdf_png_commit.expect create mode 100644 test/addFile/addFile_nanopdf_png_file_diff.expect create mode 100644 test/addFile/addFile_nanopdf_png_unstaged_status.expect diff --git a/test/addFile/addFile_modnano_png_commit.expect b/test/addFile/addFile_modnano_png_commit.expect new file mode 100644 index 0000000..44cda0f --- /dev/null +++ b/test/addFile/addFile_modnano_png_commit.expect @@ -0,0 +1,10 @@ +Add bootstrap fileAdd bootstrap file + +Some description text +On multiple lines + +With blanks + + +diff --git modnano.png modnano.png +Binary files modnano.png and modnano.png differ diff --git a/test/addFile/addFile_modnano_png_file_diff.expect b/test/addFile/addFile_modnano_png_file_diff.expect new file mode 100644 index 0000000..f92b334 --- /dev/null +++ b/test/addFile/addFile_modnano_png_file_diff.expect @@ -0,0 +1,2 @@ +diff --git modnano.png modnano.png +Binary files modnano.png and modnano.png differ diff --git a/test/addFile/addFile_modnano_png_unstaged_status.expect b/test/addFile/addFile_modnano_png_unstaged_status.expect new file mode 100644 index 0000000..c93827b --- /dev/null +++ b/test/addFile/addFile_modnano_png_unstaged_status.expect @@ -0,0 +1 @@ + M modnano.png diff --git a/test/addFile/addFile_nanopdf_png_commit.expect b/test/addFile/addFile_nanopdf_png_commit.expect new file mode 100644 index 0000000..a79399b --- /dev/null +++ b/test/addFile/addFile_nanopdf_png_commit.expect @@ -0,0 +1,11 @@ +Add bootstrap fileAdd bootstrap file + +Some description text +On multiple lines + +With blanks + + +diff --git nanopdf.png nanopdf.png +new file mode 100644 +Binary files /dev/null and nanopdf.png differ diff --git a/test/addFile/addFile_nanopdf_png_file_diff.expect b/test/addFile/addFile_nanopdf_png_file_diff.expect new file mode 100644 index 0000000..b9902b2 --- /dev/null +++ b/test/addFile/addFile_nanopdf_png_file_diff.expect @@ -0,0 +1,3 @@ +diff --git nanopdf.png nanopdf.png +new file mode 100644 +Binary files /dev/null and nanopdf.png differ diff --git a/test/addFile/addFile_nanopdf_png_unstaged_status.expect b/test/addFile/addFile_nanopdf_png_unstaged_status.expect new file mode 100644 index 0000000..b8ee5f5 --- /dev/null +++ b/test/addFile/addFile_nanopdf_png_unstaged_status.expect @@ -0,0 +1 @@ +?? nanopdf.png From a874be69f9c0cacbddb3efdc1fab9d19ba56dcca Mon Sep 17 00:00:00 2001 From: Jerome Reybert Date: Sun, 1 Nov 2015 01:27:01 +0100 Subject: [PATCH 20/20] travis: reuse disable vader vim version output --- .travis.yml | 2 +- test/run.sh | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0cab22d..0288e9b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -62,7 +62,7 @@ install: before_script: - git clone https://github.com/jreybert/djooks - - git clone https://github.com/junegunn/vader.vim + - git clone https://github.com/jreybert/vader.vim script: - ./test/run.sh . vader.vim djooks $VIM_VERSION diff --git a/test/run.sh b/test/run.sh index b8b732b..8a4e374 100755 --- a/test/run.sh +++ b/test/run.sh @@ -76,6 +76,7 @@ for script in ${!test_scripts[@]}; do set rtp-=~/.vim/after set rtp+=$VIMAGIT_PATH set rtp+=$VADER_PATH + let g:vader_show_version=0 filetype plugin indent on syntax enable EOF) -c "Vader! $VIMAGIT_PATH/test/$script 2> >(sed -n '/^Starting Vader/,$p')"