From 21fc2decd741d3a18c88445e11de8860148060d0 Mon Sep 17 00:00:00 2001 From: David Adam Date: Wed, 18 May 2016 23:00:30 +0000 Subject: lint, style: use git plumbing commands Rather than using porcelain commands, try using plumbing for a more stable interface with less string munging. --- build_tools/lint.fish | 5 +++-- build_tools/style.fish | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'build_tools') diff --git a/build_tools/lint.fish b/build_tools/lint.fish index f40d4c35..2b21402c 100755 --- a/build_tools/lint.fish +++ b/build_tools/lint.fish @@ -48,10 +48,11 @@ if test $all = yes else # 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. - 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] # 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 # Extract just the C/C++ files that exist. diff --git a/build_tools/style.fish b/build_tools/style.fish index b5b3b871..27f89804 100755 --- a/build_tools/style.fish +++ b/build_tools/style.fish @@ -34,12 +34,13 @@ if test $all = yes else # 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. - 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] set git_clang_format yes else # 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 # Extract just the C/C++ files that exist. -- cgit v1.2.3