mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-13 13:39:02 +00:00
lint, style: use git plumbing commands
Rather than using porcelain commands, try using plumbing for a more stable interface with less string munging.
This commit is contained in:
parent
9192bf1db5
commit
21fc2decd7
2 changed files with 6 additions and 4 deletions
|
@ -48,10 +48,11 @@ if test $all = yes
|
||||||
else
|
else
|
||||||
# We haven't been asked to lint all the source. If there are uncommitted
|
# We haven't been asked to lint all the source. If there are uncommitted
|
||||||
# changes lint those, else lint the files in the most recent commit.
|
# changes lint those, else lint the files in the most recent commit.
|
||||||
set files (git status --porcelain --short --untracked-files=all | sed -e 's/^ *[^ ]* *//')
|
# Select (cached files) (modified but not cached, and untracked files)
|
||||||
|
set files (git diff-index --cached HEAD --name-only) (git ls-files --exclude-standard --others --modified)
|
||||||
if not set -q files[1]
|
if not set -q files[1]
|
||||||
# No pending changes so lint the files in the most recent commit.
|
# No pending changes so lint the files in the most recent commit.
|
||||||
set files (git show --word-diff=porcelain --name-only --pretty=oneline)[2..-1]
|
set files (git diff-tree --no-commit-id --name-only -r HEAD)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Extract just the C/C++ files that exist.
|
# Extract just the C/C++ files that exist.
|
||||||
|
|
|
@ -34,12 +34,13 @@ if test $all = yes
|
||||||
else
|
else
|
||||||
# We haven't been asked to reformat all the source. If there are uncommitted changes reformat
|
# We haven't been asked to reformat all the source. If there are uncommitted changes reformat
|
||||||
# those using `git clang-format`. Else reformat the files in the most recent commit.
|
# those using `git clang-format`. Else reformat the files in the most recent commit.
|
||||||
set files (git status --porcelain --short --untracked-files=all | sed -e 's/^ *[^ ]* *//')
|
# Select (cached files) (modified but not cached, and untracked files)
|
||||||
|
set files (git diff-index --cached HEAD --name-only) (git ls-files --exclude-standard --others --modified)
|
||||||
if set -q files[1]
|
if set -q files[1]
|
||||||
set git_clang_format yes
|
set git_clang_format yes
|
||||||
else
|
else
|
||||||
# No pending changes so lint the files in the most recent commit.
|
# No pending changes so lint the files in the most recent commit.
|
||||||
set files (git show --name-only --pretty=oneline | tail --lines=+2)
|
set files (git diff-tree --no-commit-id --name-only -r HEAD)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Extract just the C/C++ files that exist.
|
# Extract just the C/C++ files that exist.
|
||||||
|
|
Loading…
Reference in a new issue