From: Oleg Broytman Date: Thu, 28 Feb 2019 00:53:03 +0000 (+0300) Subject: Feat: Split scripts into 3: run in one repo, recursive, in all X-Git-Url: https://git.phdru.name/?p=git-scripts.git;a=commitdiff_plain;h=bde260ddb033606e9c70830cca48c94962c08021 Feat: Split scripts into 3: run in one repo, recursive, in all --- diff --git a/edit-description b/edit-description index 3311bb9..1e7605e 100755 --- a/edit-description +++ b/edit-description @@ -1,5 +1,8 @@ #! /bin/sh -exec "`dirname \"$0\"`"/do-all \ - 'test "`cat $g/description`" = "Unnamed repository; edit this file '"'"description"'"' to name the repository." && - `git var GIT_EDITOR` "$g"/description < /dev/tty' +g="`git rev-parse --git-dir`" && + +if [ "`cat $g/description`" = "Unnamed repository; edit this file 'description' to name the repository." ] +then + exec `git var GIT_EDITOR` "$g"/description < /dev/tty +fi diff --git a/edit-description-recursive b/edit-description-recursive new file mode 100755 index 0000000..d9e57f3 --- /dev/null +++ b/edit-description-recursive @@ -0,0 +1,4 @@ +#! /bin/sh + +prog_dir="`dirname \"$0\"`" && +exec "$prog_dir"/run-recursive "$prog_dir"/edit-description diff --git a/edit-description-repos b/edit-description-repos new file mode 100755 index 0000000..7c78af4 --- /dev/null +++ b/edit-description-repos @@ -0,0 +1,9 @@ +#! /bin/sh + +cd "`dirname \"$0\"`" && +prog_dir="`pwd`" && +export prog_dir + +exec "$prog_dir"/do-all \ + 'echo "----- $d -----" && cd "$d" &&' \ + '"$prog_dir"/edit-description-recursive || exit 1' diff --git a/fix-config b/fix-config index 9aa748a..f7d4cda 100755 --- a/fix-config +++ b/fix-config @@ -1,2 +1,4 @@ #! /bin/sh -exec "`dirname \"$0\"`"/do-all 'chmod a-x $g/config' + +g="`git rev-parse --git-dir`" && +exec chmod a-x "$g"/config diff --git a/fix-config-recursive b/fix-config-recursive new file mode 100755 index 0000000..afbe197 --- /dev/null +++ b/fix-config-recursive @@ -0,0 +1,4 @@ +#! /bin/sh + +prog_dir="`dirname \"$0\"`" && +exec "$prog_dir"/run-recursive "$prog_dir"/fix-config diff --git a/fix-config-repos b/fix-config-repos new file mode 100755 index 0000000..7a6d69f --- /dev/null +++ b/fix-config-repos @@ -0,0 +1,9 @@ +#! /bin/sh + +cd "`dirname \"$0\"`" && +prog_dir="`pwd`" && +export prog_dir + +exec "$prog_dir"/do-all \ + 'echo "----- $d -----" && cd "$d" &&' \ + '"$prog_dir"/fix-config-recursive || exit 1' diff --git a/ls-assumed b/ls-assumed index bfbfdc3..7f7a407 100755 --- a/ls-assumed +++ b/ls-assumed @@ -1,5 +1,8 @@ #! /bin/sh -exec "`dirname \"$0\"`"/do-all \ - 'test "$g" = "$d/.git" || continue; cd "$d" &&' \ - 'test -n "`git ls-files -v | grep ^[a-z]`" && echo "$d"' +d="`git rev-parse --show-toplevel`" && +g="`git rev-parse --git-dir`" && + +if [ -n "$d" ]; then + if [ -n "`git ls-files -v | grep ^[a-z]`" ]; then echo "$d"; fi +fi diff --git a/ls-assumed-recursive b/ls-assumed-recursive new file mode 100755 index 0000000..d9161dc --- /dev/null +++ b/ls-assumed-recursive @@ -0,0 +1,4 @@ +#! /bin/sh + +prog_dir="`dirname \"$0\"`" && +exec "$prog_dir"/run-recursive "$prog_dir"/ls-assumed diff --git a/ls-assumed-repos b/ls-assumed-repos new file mode 100755 index 0000000..c3d177f --- /dev/null +++ b/ls-assumed-repos @@ -0,0 +1,7 @@ +#! /bin/sh + +cd "`dirname \"$0\"`" && +prog_dir="`pwd`" && +export prog_dir + +exec "$prog_dir"/do-all 'cd "$d" && "$prog_dir"/ls-assumed-recursive || exit 1' diff --git a/ls-branches b/ls-branches index 1fa0ae5..80cdaef 100755 --- a/ls-branches +++ b/ls-branches @@ -1,10 +1,2 @@ #! /bin/sh - -if [ "$1" = "-v" ]; then - verbose="--verbose" -fi -export verbose - -exec "`dirname \"$0\"`"/do-all \ - 'test "$g" = "$d/.git" || continue; cd "$d" &&' \ - 'echo "----- $d -----"; git branch --all $verbose' +echo "----- `pwd` -----" && exec git branch --all $verbose diff --git a/ls-branches-recursive b/ls-branches-recursive new file mode 100755 index 0000000..7c6bab2 --- /dev/null +++ b/ls-branches-recursive @@ -0,0 +1,4 @@ +#! /bin/sh + +prog_dir="`dirname \"$0\"`" && +exec "$prog_dir"/run-recursive "$prog_dir"/ls-branches diff --git a/ls-branches-repos b/ls-branches-repos new file mode 100755 index 0000000..737a0a3 --- /dev/null +++ b/ls-branches-repos @@ -0,0 +1,12 @@ +#! /bin/sh + +cd "`dirname \"$0\"`" && +prog_dir="`pwd`" && +export prog_dir + +if [ "$1" = "-v" ]; then + verbose="--verbose" +fi +export verbose + +exec "$prog_dir"/do-all 'cd "$d" && "$prog_dir"/ls-branches-recursive || exit 1' diff --git a/ls-dirty b/ls-dirty index 109296e..77cad68 100755 --- a/ls-dirty +++ b/ls-dirty @@ -1,5 +1,10 @@ #! /bin/sh -exec "`dirname \"$0\"`"/do-all \ - 'test "$g" = "$d/.git" || continue; cd "$d" &&' \ - 'test -n "`git ls-files --deleted --modified --others --unmerged --killed --exclude-standard --directory --no-empty-directory`" && echo "$d"' +d="`git rev-parse --show-toplevel`" && + +if [ -n "$d" ]; then + if [ -n "`git ls-files --deleted --modified --others --unmerged --killed --exclude-standard --directory --no-empty-directory`" ] + then + echo "$d" + fi +fi diff --git a/ls-dirty-recursive b/ls-dirty-recursive new file mode 100755 index 0000000..b4f4931 --- /dev/null +++ b/ls-dirty-recursive @@ -0,0 +1,4 @@ +#! /bin/sh + +prog_dir="`dirname \"$0\"`" && +exec "$prog_dir"/run-recursive "$prog_dir"/ls-dirty diff --git a/ls-dirty-repos b/ls-dirty-repos new file mode 100755 index 0000000..fa9df2f --- /dev/null +++ b/ls-dirty-repos @@ -0,0 +1,7 @@ +#! /bin/sh + +cd "`dirname \"$0\"`" && +prog_dir="`pwd`" && +export prog_dir + +exec "$prog_dir"/do-all 'cd "$d" && "$prog_dir"/ls-dirty-recursive || exit 1' diff --git a/ls-no-description b/ls-no-description index 0966ffb..81ddb61 100755 --- a/ls-no-description +++ b/ls-no-description @@ -1,4 +1,8 @@ #! /bin/sh -exec "`dirname \"$0\"`"/do-all \ - 'test "`cat $g/description`" = "Unnamed repository; edit this file '"'"description"'"' to name the repository." && echo "$d"' +g="`git rev-parse --git-dir`" && + +if [ "`cat $g/description`" = "Unnamed repository; edit this file 'description' to name the repository." ] +then + echo "$g" +fi diff --git a/ls-no-description-recursive b/ls-no-description-recursive new file mode 100755 index 0000000..c1d11a6 --- /dev/null +++ b/ls-no-description-recursive @@ -0,0 +1,4 @@ +#! /bin/sh + +prog_dir="`dirname \"$0\"`" && +exec "$prog_dir"/run-recursive "$prog_dir"/ls-no-description diff --git a/ls-no-description-repos b/ls-no-description-repos new file mode 100755 index 0000000..76c689b --- /dev/null +++ b/ls-no-description-repos @@ -0,0 +1,7 @@ +#! /bin/sh + +cd "`dirname \"$0\"`" && +prog_dir="`pwd`" && +export prog_dir + +exec "$prog_dir"/do-all 'cd "$d" && "$prog_dir"/ls-no-description-recursive || exit 1' diff --git a/ls-remotes b/ls-remotes index 5371f6f..542306a 100755 --- a/ls-remotes +++ b/ls-remotes @@ -1,10 +1,2 @@ #! /bin/sh - -if [ "$1" = "-v" ]; then - verbose="--verbose" -fi -export verbose - -exec "`dirname \"$0\"`"/do-all \ - 'test "$g" = "$d/.git" || continue; cd "$d" &&' \ - 'echo "----- $d -----"; git remote $verbose' +echo "----- `pwd` -----"; exec git remote $verbose diff --git a/ls-remotes-recursive b/ls-remotes-recursive new file mode 100755 index 0000000..df3a199 --- /dev/null +++ b/ls-remotes-recursive @@ -0,0 +1,4 @@ +#! /bin/sh + +prog_dir="`dirname \"$0\"`" && +exec "$prog_dir"/run-recursive "$prog_dir"/ls-remotes diff --git a/ls-remotes-repos b/ls-remotes-repos new file mode 100755 index 0000000..966989f --- /dev/null +++ b/ls-remotes-repos @@ -0,0 +1,12 @@ +#! /bin/sh + +cd "`dirname \"$0\"`" && +prog_dir="`pwd`" && +export prog_dir + +if [ "$1" = "-v" ]; then + verbose="--verbose" +fi +export verbose + +exec "$prog_dir"/do-all 'cd "$d" && "$prog_dir"/ls-remotes-recursive || exit 1' diff --git a/ls-stash b/ls-stash index 93af80d..1933508 100755 --- a/ls-stash +++ b/ls-stash @@ -1,5 +1,7 @@ #! /bin/sh -exec "`dirname \"$0\"`"/do-all \ - 'test "$g" = "$d/.git" || continue; cd "$d" &&' \ - 'test -n "`git stash list`" && echo "$d"' +d="`git rev-parse --show-toplevel`" && + +if [ -n "$d" ]; then + if [ -n "`git stash list`" ]; then echo "$d"; fi +fi diff --git a/ls-stash-recursive b/ls-stash-recursive new file mode 100755 index 0000000..64984e8 --- /dev/null +++ b/ls-stash-recursive @@ -0,0 +1,4 @@ +#! /bin/sh + +prog_dir="`dirname \"$0\"`" && +exec "$prog_dir"/run-recursive "$prog_dir"/ls-stash diff --git a/ls-stash-repos b/ls-stash-repos new file mode 100755 index 0000000..9e057ba --- /dev/null +++ b/ls-stash-repos @@ -0,0 +1,7 @@ +#! /bin/sh + +cd "`dirname \"$0\"`" && +prog_dir="`pwd`" && +export prog_dir + +exec "$prog_dir"/do-all 'cd "$d" && "$prog_dir"/ls-stash-recursive || exit 1' diff --git a/ls-status b/ls-status index 6892f2b..5d38083 100755 --- a/ls-status +++ b/ls-status @@ -1,9 +1,12 @@ #! /bin/sh -cd "`dirname \"$0\"`" && -prog_dir="`pwd`" && -export prog_dir +d="`git rev-parse --show-toplevel`" && -exec "$prog_dir"/do-all \ - 'test "$g" = "$d/.git" || continue; cd "$d" &&' \ - 'test -n "`"$prog_dir"/git-status.sh --short`" && echo "$d"' +if [ -n "$d" ]; then + cd "`dirname \"$0\"`" && + prog_dir="`pwd`" && + export prog_dir && + cd "$d" && + + if [ -n "`"$prog_dir"/git-status.sh --short`" ]; then echo "$d"; fi +fi diff --git a/ls-status-recursive b/ls-status-recursive new file mode 100755 index 0000000..825d276 --- /dev/null +++ b/ls-status-recursive @@ -0,0 +1,4 @@ +#! /bin/sh + +prog_dir="`dirname \"$0\"`" && +exec "$prog_dir"/run-recursive "$prog_dir"/ls-status diff --git a/ls-status-repos b/ls-status-repos new file mode 100755 index 0000000..349cee7 --- /dev/null +++ b/ls-status-repos @@ -0,0 +1,7 @@ +#! /bin/sh + +cd "`dirname \"$0\"`" && +prog_dir="`pwd`" && +export prog_dir + +exec "$prog_dir"/do-all 'cd "$d" && "$prog_dir"/ls-status-recursive || exit 1' diff --git a/run-recursive b/run-recursive index 401ed27..3599293 100755 --- a/run-recursive +++ b/run-recursive @@ -3,5 +3,5 @@ "$@" && if [ -f .gitmodules ]; then - exec git submodule foreach "$@" + exec git submodule foreach --quiet --recursive "$@" fi