commit c7c91d04baae78ae88b314441674560c169f7556
parent a05a7b4b0182bb6e304f803b321e885e7ee231ab
Author: gearsix <gearsix@DESKTOP-TEKDS0R.Solagen.local>
Date: Mon, 3 Jul 2023 10:52:17 +0100
git-pradd -> git diffadd
- renamed from pradd to diffadd because it's more informative (bit more
to type though)
- fixed posix compatibility bugs
Diffstat:
2 files changed, 54 insertions(+), 54 deletions(-)
diff --git a/src/posix/git-diffadd.sh b/src/posix/git-diffadd.sh
@@ -0,0 +1,54 @@
+#!/usr/bin/env sh
+# DESCRIPTION: 'git diff', prompt y/n if 'git add'
+# ARGUMENTS: git-diffadd file1 file2 file3 ...
+# DEPENDENCIES: git
+
+if [ "$1" = "-h" ] || [ "$1" = "--help" ]
+then
+ echo "usage: git-diffadd FILE..."
+ echo ""
+ echo "Preview the 'git diff' of all specified paths (FILE...)"
+ echo "and prompt y/n if 'git add' should be run on the file."
+ echo "If no FILE... targets are provided, all un-added files"
+ echo "will be used"
+ exit
+fi
+
+pradd() {
+ git diff "$dir/$f"
+
+ yn=""
+ while [ "$yn" = "" ]; do
+ printf "git add '%s' (y/n)? " "$f"
+ read -r yn
+ if [ "$yn" = "y" ]
+ then git add "$f"
+ elif [ "$yn" != "n" ]
+ then yn=""; fi
+ done
+}
+
+dir="."
+if [ ! "$(git rev-parse --show-toplevel)" ]
+then
+ echo "'git rev-parse --show-toplevel' failed to return repo root dir at '$(pwd)'"
+ exit 1
+else
+ dir="$(pwd)"
+fi
+
+n=0
+for f in "$@"
+do
+ n=$((n+1))
+ pradd "$dir/$f"
+done
+
+if [ $n -eq 0 ]
+then
+ for f in $(git ls-files -m)
+ do
+ pradd "$f"
+ done
+fi
+
diff --git a/src/posix/git-pradd.sh b/src/posix/git-pradd.sh
@@ -1,54 +0,0 @@
-#!/usr/bin/env sh
-# DESCRIPTION: 'git diff', prompt y/n if 'git add'
-# ARGUMENTS: git-pradd file1 file2 file3 ...
-# DEPENDENCIES: git
-
-if [ "$1" = "-h" ] || [ "$1" = "--help" ]
-then
- echo "usage: git-pradd FILE..."
- echo ""
- echo "Preview the 'git diff' of all specified paths (FILE...)"
- echo "and prompt y/n if 'git add' should be run on the file."
- echo "If no FILE... targets are provided, all un-added files"
- echo "will be used"
- exit
-fi
-
-pradd() {
- git diff "$dir/$f"
-
- yn=""
- while [ "$yn" = "" ]; do
- printf "git add '%s' (y/n)? " "$f"
- read -r yn
- if [ "$yn" = "y" ]
- then git add "$f"
- elif [ "$yn" != "n" ]
- then yn=""; fi
- done
-}
-
-dir="."
-if [ ! "$(git rev-parse --show-toplevel)" ]
-then
- echo "'git rev-parse --show-toplevel' failed to return repo root dir at '$(pwd)'"
- exit 1
-else
- dir="$(pwd)"
-fi
-
-declare -i n=0
-for f in "$@"
-do
- n+=1
- pradd "$dir/$f"
-done
-
-if [ $n -eq 0 ]
-then
- for f in $(git ls-files -m)
- do
- pradd "$f"
- done
-fi
-