diff options
| author | tv <tv@krebsco.de> | 2026-11-13 20:27:48 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-13 21:58:36 +0100 |
| commit | ef581c93f391919b35b903b93af45f33d90de15d (patch) | |
| tree | 13ab36537f805dcba0534c8f3e1b3f4d6b8e13b4 /pkgs/populate/src/sh.rs | |
| parent | e9256952f16eb33f9b7e49777ec76878489a5053 (diff) | |
populate: keep URLs, refs, and names from being taken for options
A git source's url and ref are strings, and git clone, git remote, and
git fetch took ones starting with - for options, e.g. --upload-pack,
which runs a command where the repository is local. They come after
-- now, and so does a pass source's name for git log and pass show.
git-ref-option gives a ref that git fetch would take for
--upload-pack.
Diffstat (limited to 'pkgs/populate/src/sh.rs')
| -rw-r--r-- | pkgs/populate/src/sh.rs | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/pkgs/populate/src/sh.rs b/pkgs/populate/src/sh.rs index 8282370..ce42e12 100644 --- a/pkgs/populate/src/sh.rs +++ b/pkgs/populate/src/sh.rs @@ -352,24 +352,25 @@ if ! test -e "$path"; then if test -n "$shallow"; then git init "$path" else - git clone --recurse-submodules "$url" "$path" + git clone --recurse-submodules -- "$url" "$path" fi fi cd "$path" if ! origin=$(git config remote.origin.url); then - git remote add origin "$url" + git remote add -- origin "$url" elif test "$origin" != "$url"; then - git remote set-url origin "$url" + git remote set-url -- origin "$url" fi # A commit, given by its hash or a prefix thereof, gets fetched only if the -# work tree lacks it, unless fetchAlways is set. A branch or tag gets +# work tree lacks it, unless fetchAlways is set. After --, a ref can't be +# taken for an option. A branch or tag gets # fetched on every run, so the work tree follows it: resetting to its name # would reset to a local branch, which fetching doesn't move. fetch() { if test -n "$shallow"; then - git fetch --depth=1 origin "$1" + git fetch --depth=1 origin -- "$1" else - git fetch origin "$1" + git fetch origin -- "$1" fi } fetch_commit() { @@ -418,7 +419,7 @@ pub mod local { dir=$1 name=$2 if test -e "$dir"/.git; then printf '%s %s\n' "$name" "$( - git -C "$dir" log -1 --format=%H "$name" + git -C "$dir" log -1 --format=%H -- "$name" find "$dir"/"$name" -type l -exec realpath {} + | sort | xargs -r -n 1 git -C "$dir" log -1 --format=%H @@ -446,7 +447,7 @@ while read -r gpg_path; do pass_name=$name/$rel_name pass_out=$PWD/$rel_name mkdir -p "$(dirname "$pass_out")" - PASSWORD_STORE_DIR=$dir pass show "$pass_name" > "$pass_out" + PASSWORD_STORE_DIR=$dir pass show -- "$pass_name" > "$pass_out" if [ -n "$pass_date" ]; then touch -d "$pass_date" "$pass_out" fi |
