Lines Matching +full:use +full:- +full:case
6 # version in the variable BR_FMT_VERSION_git, in package/pkg-download.mk.
9 set -E
14 # -q Be quiet.
15 # -r Clone and archive sub-modules.
16 # -o FILE Generate archive in FILE.
17 # -u URI Clone from repository at URI.
18 # -c CSET Use changeset CSET.
19 # -n NAME Use basename NAME.
26 # Save our path and options in case we need to call ourselves again
28 declare -a OPTS=("${@}")
31 # clone from scratch (only once!) in case the git tree is borked, or in
32 # case an unexpected and unsupported situation arises with submodules
39 if ${BR_GIT_BACKEND_FIRST_FAULT:-false}; then
48 rm -rf "${git_cache}"
56 case "${OPT}" in
57 q) quiet=-q; exec >/dev/null;;
69 shift $((OPTIND-1)) # Get rid of our options
73 mkdir -p "${git_cache}"
79 # Caller needs to single-quote its arguments to prevent them from
80 # being expanded a second time (in case there are spaces in them)
82 if [ -z "${quiet}" ]; then
92 # Create a warning file, that the user should not use the git cache.
94 cat <<-_EOF_ >"${dl_dir}/git.readme"
97 The git tree located in this directory is for the exclusive use
102 to use it. Buildroot may even remove it in case it detects the
106 lost. Do *not* even use it as a remote, or as the source for new
112 # case this magically restores it to working conditions. In the latter
113 # case, we might be missing blobs, but that's not a problem: we'll
116 # We can still go through the wrapper, because 'init' does not use the
121 # Ensure the repo has an origin (in case a previous run was killed).
122 if ! _plain_git remote |grep -q -E '^origin$'; then
126 _git remote set-url origin "'${uri}'"
130 _git fetch origin -t
132 # Try to get the special refs exposed by some forges (pull-requests for
143 # Check that the changeset does exist. If it does not, re-cloning from
146 if ! _git rev-parse --quiet --verify "'${cset}^{commit}'" >/dev/null 2>&1; then
152 # have sub-dirs converted to/from a submodule. So we would need to
155 # Using "git submodule deinit --all" would remove all the files for
157 # However, it was only introduced with git-1.8.3, which is too recent
158 # for some enterprise-grade distros.
160 # So, we fall-back to just removing all submodules directories. We do
161 # not need to be recursive, as removing a submodule will de-facto remove
174 cmd='printf "Deregistering submodule \"%s\"\n" "${path}" && cd .. && rm -rf "${path##*/}"'
175 _git submodule --quiet foreach "'${cmd}'"
179 _git checkout -f -q "'${cset}'"
181 # Get rid of now-untracked directories (in case a git operation was
184 _git clean -ffdx
188 date="$( _plain_git log -1 --pretty=format:%ci )"
191 if [ ${recurse} -eq 1 ]; then
192 _git submodule update --init --recursive
195 # in the .git of submodules, while newer versions just use relative
196 # paths. Detect and fix the older variants to use relative paths, so
201 for module_dir in $( _plain_git submodule --quiet foreach "'${cmd}'" ); do
202 [ -f "${module_dir}/.git" ] || continue
203 relative_dir="$( sed -r -e 's,/+,/,g; s,[^/]+/,../,g' <<<"${module_dir}" )"
204 sed -r -i -e "s:^gitdir\: $(pwd)/:gitdir\: "${relative_dir}":" "${module_dir}/.git"
211 # We do not want the .git dir; we keep other .git files, in case they are the