We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f3d3248 commit 1545b2cCopy full SHA for 1545b2c
1 file changed
libexec/plugins/pipe
@@ -2,12 +2,20 @@
2
# The plugin which allows running a given functions through different types
3
# (aka pre- and post-conditions).
4
5
+has-changes() {
6
+ # Check if a current index (HEAD) has staged or non-staged changes
7
+ if git diff-index --quiet HEAD && git diff-index --cached --quiet HEAD; then
8
+ return 1
9
+ fi
10
+ return 0
11
+}
12
+
13
stash-pipe() {
14
# Makes automatic stash and unstash if possible
15
# usage: stash-pipe <command> [args]...
16
17
git update-index -q --really-refresh
- if ! git diff-index --quiet HEAD --; then
18
+ if has-changes; then
19
local message="Elegant Git auto-stash: "
20
message+="WIP in '$(git rev-parse --abbrev-ref HEAD)' branch "
21
message+="on $(date "+%Y-%m-%dT%H:%M:%S")"
0 commit comments