common: simplify logic to find git
From chroot-git 2.33.1, we always have an executable named git for other build infrastructure and lints. Let's remove the shenanegan to find which git to be used, prepend the path to chroot-git's git into $PATH, and let's the shell call the correct git for us instead.
This commit is contained in:
parent
77db514078
commit
7510b96218
5 changed files with 20 additions and 34 deletions
|
@ -13,20 +13,18 @@ if ! [ "$base_rev" ]; then
|
|||
die "usage: $0 TEMPLATE BASE-REVISION [TIP-REVISION]"
|
||||
fi
|
||||
|
||||
if command -v chroot-git >/dev/null 2>&1; then
|
||||
GIT_CMD=$(command -v chroot-git)
|
||||
elif command -v git >/dev/null 2>&1; then
|
||||
GIT_CMD=$(command -v git)
|
||||
else
|
||||
PATH="/usr/libexec/chroot-git:$PATH"
|
||||
if ! command -v git >/dev/null 2>&1; then
|
||||
die "neither chroot-git nor git could be found"
|
||||
fi
|
||||
|
||||
scan() {
|
||||
rx="$1" msg="$2"
|
||||
template_path=$template
|
||||
maybe_git=
|
||||
if [ "$tip_rev" ]; then
|
||||
template_path="${tip_rev}:${template}"
|
||||
maybe_git="$GIT_CMD"
|
||||
maybe_git="git"
|
||||
revspec="[^:]*:"
|
||||
fi
|
||||
$maybe_git grep -P -Hn -e "$rx" "$template_path" |
|
||||
|
@ -37,7 +35,7 @@ scan() {
|
|||
show_template() {
|
||||
rev="$1"
|
||||
if [ "$rev" ]; then
|
||||
$GIT_CMD cat-file blob "${rev}:${template}" 2>/dev/null
|
||||
git cat-file blob "${rev}:${template}" 2>/dev/null
|
||||
else
|
||||
cat "${template}" 2>/dev/null
|
||||
fi
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue