Skip to content

Commit 6b61eb5

Browse files
committed
Add '--version' option for printing script version
1 parent eb406e4 commit 6b61eb5

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ options:
4545
--fmtprg-stderr show stderr from formatter programs
4646
--warn-risky-stderr redirects warning about potential unsolicited changes in suggestions to stderr;
4747
option not recommended as the warning blocks dangerous 'git apply'
48+
--version print version of git-fmt-diff script
4849
```
4950

5051
## Installation

git-fmt-diff

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# globals {{{
77

88
gc_prog_name="fmt-diff"
9+
gc_version="0.1.5-3-geb406e4"
910

1011
g_cached_opt=
1112

@@ -456,14 +457,14 @@ EOL
456457
wait
457458

458459
if [ -s "$risky" ]; then
459-
cat > "$risky".temp << EOW
460+
cat > "$risky".temp << EOF
460461
$(sgr 33 '@ WARNING!')
461462
$(sgr 33 '@ Suggestions for the following files might smuggle unsolicited changes:')
462463
$(sort "$risky" | sed 's/^/- /')
463464
$(sgr 33 "@ Review them thoroughly before applying.")
464465
465466
466-
EOW
467+
EOF
467468
mv "$risky".temp "$risky"
468469

469470
if [ "$gf_warn_risky_stderr" -eq 1 ]; then
@@ -480,7 +481,7 @@ EOW
480481
# }}}1
481482

482483
usage () {
483-
cat << EOU
484+
cat << EOF
484485
usage: git fmt-diff [<options>] [<commit>] [--] [<path>...]
485486
or: git fmt-diff [<options>] --cached [<commit>] [--] [<path>...]
486487
or: git fmt-diff [<options>] <commit>...<commit> [--] [<path>...]
@@ -496,7 +497,8 @@ options:
496497
--fmtprg-stderr show stderr from formatter programs
497498
--warn-risky-stderr redirects warning about potential unsolicited changes in suggestions to stderr;
498499
option not recommended as the warning blocks dangerous 'git apply'
499-
EOU
500+
--version print version of git-$gc_prog_name script
501+
EOF
500502
}
501503

502504
# parse options {{{2
@@ -536,6 +538,10 @@ while :; do
536538
--warn-risky-stderr)
537539
gf_warn_risky_stderr=1
538540
;;
541+
--version)
542+
echo "$gc_version"
543+
exit
544+
;;
539545
--)
540546
shift
541547
break

0 commit comments

Comments
 (0)