Skip to content

Commit 011b7ed

Browse files
committed
Fix: Ignore git security error caused by being run by root
1 parent 06b8ec0 commit 011b7ed

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

build.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,16 @@ echo_blank(){ yes " " 2> /dev/null | head -n "${1}" | tr -d "\n"; }
7777
# cpコマンドのラッパー
7878
_cp(){ cp -af --no-preserve=ownership,mode -- "${@}"; }
7979

80+
# gitコマンドのラッパー
81+
# https://stackoverflow.com/questions/71901632/fatal-unsafe-repository-home-repon-is-owned-by-someone-else
82+
# https://qiita.com/megane42/items/5375b54ea3570506e296
83+
git(){
84+
command git config --global safe.directory "$script_path"
85+
command git "$@"
86+
command git config --global --unset safe.directory
87+
}
88+
89+
8090
_usage () {
8191
cat "${script_path}/docs/build.sh/help.1"
8292
local blank="29" _arch _dirname _type _output _first
@@ -1155,7 +1165,8 @@ else
11551165
fi
11561166

11571167
# Set vars
1158-
build_dir="${work_dir}/build/${arch}" cache_dir="${work_dir}/cache/${arch}" airootfs_dir="${build_dir}/airootfs" isofs_dir="${build_dir}/iso" lockfile_dir="${build_dir}/lockfile" gitrev="$(cd "${script_path}"; git rev-parse --short HEAD)" preset_dir="${script_path}/presets"
1168+
build_dir="${work_dir}/build/${arch}" cache_dir="${work_dir}/cache/${arch}" airootfs_dir="${build_dir}/airootfs" isofs_dir="${build_dir}/iso" lockfile_dir="${build_dir}/lockfile" preset_dir="${script_path}/presets"
1169+
gitrev="$(cd "${script_path}"; git rev-parse --short HEAD)"
11591170

11601171
# Create dir
11611172
for _dir in build_dir cache_dir airootfs_dir isofs_dir lockfile_dir out_dir; do

0 commit comments

Comments
 (0)