Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
vimagit
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GitHub Mirror
jreybert
vimagit
Commits
868dab5b
Commit
868dab5b
authored
9 years ago
by
Jerome Reybert
Browse files
Options
Downloads
Patches
Plain Diff
autoload/magit/utils.vim: new function magit#utils#is_binary to test file type
parent
a76323f4
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
autoload/magit/state.vim
+1
-3
1 addition, 3 deletions
autoload/magit/state.vim
autoload/magit/utils.vim
+7
-0
7 additions, 0 deletions
autoload/magit/utils.vim
with
8 additions
and
3 deletions
autoload/magit/state.vim
+
1
−
3
View file @
868dab5b
...
@@ -136,9 +136,7 @@ function! magit#state#add_file(mode, status, filename, depth) dict
...
@@ -136,9 +136,7 @@ function! magit#state#add_file(mode, status, filename, depth) dict
let
file
.
empty
=
1
let
file
.
empty
=
1
call
add
(
file
.
diff
.
header
,
'no header'
)
call
add
(
file
.
diff
.
header
,
'no header'
)
let
file
.
diff
.
hunks
[
0
].
header
=
'New empty file'
let
file
.
diff
.
hunks
[
0
].
header
=
'New empty file'
elseif
(
match
(
system
(
"file --mime "
.
elseif
(
magit#utils#is_binary
(
magit#utils#add_quotes
(
a:filename
)))
\
magit#utils#add_quotes
(
a:filename
)),
\
a:filename
.
".*charset=binary"
)
!=
-1
)
let
file
.
binary
=
1
let
file
.
binary
=
1
call
add
(
file
.
diff
.
header
,
'no header'
)
call
add
(
file
.
diff
.
header
,
'no header'
)
let
file
.
diff
.
hunks
[
0
].
header
=
'Binary file'
let
file
.
diff
.
hunks
[
0
].
header
=
'Binary file'
...
...
This diff is collapsed.
Click to expand it.
autoload/magit/utils.vim
+
7
−
0
View file @
868dab5b
...
@@ -33,6 +33,13 @@ function! magit#utils#git_dir()
...
@@ -33,6 +33,13 @@ function! magit#utils#git_dir()
return
s:magit_git_dir
return
s:magit_git_dir
endfunction
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
)
return
(
match
(
system
(
"file --mime "
.
a:filename
),
\
a:filename
.
".*charset=binary"
)
!=
-1
)
endfunction
" s:magit_cd_cmd: plugin variable to choose lcd/cd command, 'lcd' if exists,
" s:magit_cd_cmd: plugin variable to choose lcd/cd command, 'lcd' if exists,
" 'cd' otherwise
" 'cd' otherwise
let
s:magit_cd_cmd
=
exists
(
'*haslocaldir'
)
&&
haslocaldir
()
?
'lcd '
:
'cd '
let
s:magit_cd_cmd
=
exists
(
'*haslocaldir'
)
&&
haslocaldir
()
?
'lcd '
:
'cd '
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment