Skip to content

Commit 204893c

Browse files
committed
Increased performance by avoiding checkout. Thanks to doener on #git.
1 parent 3c301e7 commit 204893c

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

git-diff-directory

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@ if [[ "$1" == "-p" ]]; then
66
shift 1
77
fi
88

9-
if [[ $# == 2 ]]; then
10-
git checkout $2
11-
echo ======================================================================
12-
fi
9+
HERE=$(pwd)
1310

14-
if [[ $stat == true ]]; then
15-
diff -w -U3 -r -x .git . "$1" | diffstat | grep -v only$
16-
else
17-
diff -w -U3 -r -x .git . "$1"
18-
fi
11+
(cd "$1" && git --git-dir=$HERE/.git diff ${2:-HEAD}) | \
12+
if [[ $stat == true ]]; then \
13+
diffstat | grep -v only$; \
14+
else \
15+
cat; \
16+
fi

0 commit comments

Comments
 (0)