@@ -52,7 +52,7 @@ cd "${BRANCH}"
5252
5353# datalad clone the input ria:
5454echo '# Clone the data from input RIA:'
55- datalad clone "${dssource}" ds -- --no-checkout
55+ datalad clone "${dssource}" ds -- --no-checkout --shared
5656cd ds
5757
5858# set up the result deposition:
@@ -87,16 +87,32 @@ git checkout -f
8787
8888# Input datasets: ``datalad clone --no-checkout``, sparse paths, ``git checkout -f``.
8989#
90- # ensure_input_submodule: if $1 is nonempty and not already a Git repo, clone it as a
91- # DataLad subdataset using .gitmodules (prefer datalad-url, else url). Plain absolute
92- # paths are converted to file:// URLs. Uses --no-checkout. No-op if already present;
90+ # is_installed_repo_root: true only when $1 is the root of an installed Git repo
91+ is_installed_repo_root() {
92+ local mount="$1"
93+ local mount_abs top
94+
95+ [ -n "${mount}" ] || return 1
96+ [ -d "${mount}" ] || return 1
97+
98+ mount_abs="$(cd "${mount}" 2>/dev/null && pwd -P)" || return 1
99+ top="$(git -C "${mount}" rev-parse --show-toplevel 2>/dev/null)" || return 1
100+
101+ [ "${top}" = "${mount_abs}" ]
102+ }
103+
104+ # ensure_input_submodule: if $1 is nonempty and not already an installed Git repo root,
105+ # clone it as a DataLad subdataset using .gitmodules (prefer datalad-url, else url). Plain
106+ # absolute paths are converted to file:// URLs. Uses --no-checkout. No-op if already present;
93107# exits if no URL is configured.
94108ensure_input_submodule() {
95109 local mount="$1"
96110 [ -n "${mount}" ] || return 0
97- if git -C "${mount}" rev-parse --git-dir >/dev/null 2>&1 ; then
111+
112+ if is_installed_repo_root "${mount}"; then
98113 return 0
99114 fi
115+
100116 local src
101117 src="$(git config -f .gitmodules --get "submodule.${mount}.datalad-url" 2>/dev/null)" \
102118 || src="$(git config -f .gitmodules --get "submodule.${mount}.url" 2>/dev/null)" \
@@ -105,22 +121,24 @@ ensure_input_submodule() {
105121 case "${src}" in
106122 /*) src="file://${src}" ;;
107123 esac
108- datalad clone -d . "${src}" "${mount}" -- --no-checkout
124+ datalad clone --reckless ephemeral - d . "${src}" "${mount}" -- --no-checkout --shared
109125 else
110126 echo "ERROR: no submodule URL in .gitmodules for ${mount}" 1>&2
111127 exit 1
112128 fi
113129}
114130
115- # sparse_checkout_input: if $1 is nonempty and points to a Git repo (e.g. a submodule path
116- # from .gitmodules such as inputs/data/BIDS), initialize sparse-checkout in non-cone mode,
117- # set patterns from remaining args (one path per line via --stdin), and checkout -f.
118- # Uses git -C so cwd stays the job superdataset. No-op if $1 is empty or not a Git repo.
131+ # sparse_checkout_input: if $1 is nonempty and is the root of an installed Git repo
132+ # (for example, a submodule path from .gitmodules such as inputs/data/BIDS), initialize
133+ # sparse-checkout in non-cone mode, set patterns from remaining args (one path per line
134+ # via --stdin), and checkout -f. Uses git -C to not change working directory.
135+ # No-op if $1 is empty or not an installed
136+ # Git repo root.
119137sparse_checkout_input() {
120138 local mount="$1"
121139 shift
122140 [ -n "${mount}" ] || return 0
123- git -C "${mount}" rev-parse --git-dir >/dev/null 2>&1 || return 0
141+ is_installed_repo_root "${mount}" || return 0
124142
125143 git -C "${mount}" sparse-checkout init --no-cone
126144 printf '%s\n' "$@" | git -C "${mount}" sparse-checkout set --stdin
0 commit comments