diff --git a/README.md b/README.md index 058c6c4..586ee32 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,43 @@ +# Fork note + +This is a fork from mikepqr/stowsh which adds a few functions and it adds +some functionality that the original might not wish to provide: + +1. A new `-a PACKAGE_DIR` option can be used to add files from a target into + the package directory. The full expected use of the `-a` option is + `-a PACKAGE_DIR -t TARGET_DIR SOURCEFILES...`, + where `SOURCEFILES...` are referenced from the current working directory in + the shell, but are seen as relative to `TARGET_DIR`. + +2. On installation of a package when a file in the TARGET is encountered that + is identical to the corresponding file in PACKAGE, the PACKAGE version will + be overwritten by the TARGET and the TARGET will be convert to a symlink as + it would when no file was encountered. + +3. The new `-l` option will print a simple report listing the files in + `SOURCEFILES...` and how each one matches to the files in the `TARGET_DIR`. + By swapping target and source one can also check if the target dir have files + that are missing in the source package. When given the `-l` option will exit + after printing the status information and no other action will be taken. + +4. The `-g` option will now test the git status of package files, and if the + repo is clean `-g` will: + + + For installations `-g` will overwrite safely revisioned package files with + what was found in the target folder. The benefit of this is if you install + a package somewhere and you want to see what the changes were you can + afterwards use git diff tools in the package directory to check this, + and determine if you want to revert it or stage & commit some of the changes. + + + When adding to packages with `-g -a PACKAGE_DIR -t TARGET_DIR SOURCEFILES...` + this will copy and overwrite git-revisioned files in PACKAGE_DIR with what + it found in the SOURCES. + + + When used with `-l`, `-g` will additionally print the status characters for + the source package files as output by `git status --porcelain`. + +--- + # stowsh A shell script to install and uninstall dotfiles using symlinks. @@ -134,7 +174,7 @@ $ tree -a -I '.dotfiles' # exclude ./.dotfiles from tree listing └── script2 -> ../.dotfiles/pkg2/bin/script2 ``` -Things to note here: +Things to note here: - `~/bin` was created by `stowsh`. It's a real directory, not a link. - both `pkg1` and `pkg2` install files into `~/bin` diff --git a/stowsh b/stowsh index ee3b7af..2552e90 100755 --- a/stowsh +++ b/stowsh @@ -51,33 +51,253 @@ stowsh_setpaths() { return 1 fi if [[ "${USEGIT}" -eq 1 ]]; then + dlist="list_git_dirs" flist="list_git_files" else + dlist="list_dirs" flist="list_files" fi + if [[ "$OSTYPE" == "darwin"* || "$OSTYPE" == "freebsd"* ]]; then + _cp_keep_symlink="-P" + _cp_deref_symlink="-L" + else + _cp_keep_symlink="-d" + _cp_deref_symlink="-L" + fi +} + +list_dirs() { + local path="${1-.}" + $findcmd "${path}" -mindepth 1 -type d -printf "%P\0" } list_files() { - if [[ "$1" == "-d" ]]; then - $findcmd . -mindepth 1 -type d -printf "%P\0" - else - $findcmd . -type f -printf "%P\0" -or -type l -printf "%P\0" - fi + local path="${1-.}" + $findcmd "${path}" -type f -printf "%P\0" -or -type l -printf "%P\0" +} + +list_git_dirs() { + local path="${1-.}" + gitfiles=($(git ls-files "$path")) + if [[ "${#gitfiles[@]}" == 0 ]]; then return; fi + printf "%s\n" "${gitfiles[@]}" | + xargs -n1 dirname | + sort | uniq | + sed '/^\.$/d' | + tr '\n' '\0' } list_git_files() { - gitfiles=($(git ls-files)) + # list_git_files can be inconvenient when working on a new package in a repo, + # unless it also lists tracked/untracked files. The stowsh -u option controls + # $LIST_UNTRACKED which resolves to -o to list the untracked files. + local path="${1-.}" + gitfiles=($(git ls-files -c $LIST_UNTRACKED "$path")) if [[ "${#gitfiles[@]}" == 0 ]]; then return; fi + printf "%s\0" "${gitfiles[@]}" +} - if [[ "$1" == "-d" ]]; then - printf "%s\n" "${gitfiles[@]}" | - xargs -n1 dirname | - sort | uniq | - sed '/^\.$/d' | - tr '\n' '\0' +git_writeable() { + # TODO: Consider if ignored files should be included here .. + local output + if output="$(git status --porcelain --ignored -u all ""$@"")" && [[ -z "$output" ]]; then + return 0 # Safe to write to repo + fi + echoerr Target "$@" already in the git-repo with uncomitted changes. Aborting... + echoerr Output of 'git status --ignored': + git status --ignored "$@" 1>&2 + return 1 +} + +git_is_path_inside_repo() { + local path="${1-.}" + local output + if output=$(cd "$path" && git rev-parse --show-toplevel 2>&1 >/dev/null); then + return 0 # Path is in a git repo + else + return 1 + fi +} + +git_clean() { + local path="${1-.}" + local output + if output=$(cd "$path" && git status --porcelain --untracked-files=no) && [ -z "$output" ]; then + return 0 # Clean git, but may still have untracked files else - printf "%s\0" "${gitfiles[@]}" + return 1 + fi +} + +stowsh_list_status() { + # Compares the files in the source package and displays + # 1) Missing files + # 2) Files with different content + # 3) TODO: Check if target symlink points to package + # + # Returns 1 if operation failed. + stowsh_setpaths || exit 1 + local pkg=$1 + local target=$("$rpcmd" "${2-$PWD}") + local commands=() + local messages=() + local relative + local branch + + if [[ -e "$pkg" && ! -d "$pkg" ]]; then + echoerr "The path '$pkg' exists and is not a directory! Aborting." + exit 1 + fi + if [[ ! -e "$pkg" ]]; then + echoerr "The path '$pkg' does not exist! Aborting." + exit 1 + fi + if [[ ! -d "$target" ]]; then + echoerr "The path '$target' is not a directory. Aborting." + exit 1 + fi + if [[ "$USEGIT" -eq 1 ]] && ! git_clean "$pkg"; then + echoerr "Uncommitted changes or no git repository at" "$pkg" + fi + + echo "Listing package status for $pkg/ at $($rpcmd "$target" -s --relative-to="$PWD")/" + local GS="" + [[ "${USEGIT}" -eq 1 ]] && GS="GS | " + messages+=("${GS}PACKAGE PATH | STATUS | TARGET PATH | TARGET TIMESTAMP") + while IFS= read -r -d '' f; do + local src_file + if [[ -z "$f" ]]; then + echoerr "ERROR 101 TODO" + exit 1 + else + src_file="$pkg/$f" + fi + + local relative=$($rpcmd "$src_file" -s --relative-to="$pkg") + local pkg_target="$target/$relative" + local tgt=$($rpcmd "$pkg_target" -s --relative-to="$target/..") + #echo pkg="$pkg" target="$target" f="$f" relative="$relative" + if [[ "${USEGIT}" -eq 1 ]]; then + gitstatus=$(cd "$pkg" && git status --porcelain "$f") + if [[ ! -z "${gitstatus}" ]]; then + gitstatus="${gitstatus:0:2} | " + else + gitstatus=' | ' + fi + else + gitstatus="" + fi + local tgt_type="" + local src_type="" + [[ -L "${pkg_target}" ]] && tgt_type="(link)" + [[ -L "${src_file}" ]] && src_type="(link)" + if [[ ! -e "$pkg_target" ]]; then + messages+=("${gitstatus}""$src_file $src_type"" | missing | $tgt | ") + else + local newer="" + [[ "$src_file" -ot "$pkg_target" ]] && newer="newer" + local older="" + [[ "$src_file" -nt "$pkg_target" ]] && older="older" + local timeinfo="${newer}${older}" + if diff_result=$(diff -q "$src_file" "$pkg_target"); then + messages+=("${gitstatus}""$src_file"" | match | ""$tgt $tgt_type | ") + else + messages+=("${gitstatus}""$src_file"" | diff | ""$tgt $tgt_type | $timeinfo ") + fi + fi + done < <(list_files "$pkg") + for cmd in "${commands[@]}"; do + echo _runcommands "$cmd" + done + printf '%s\n' "${messages[@]}" | column -t -s '|' -o '|' +} + +stowsh_add_to_pkg() { + # This function copies to package $1 the source file(s) at path $3 + # The path $3 is given relative to $2 given by the -t TARGET option + # Returns 1 if operation failed. + # + stowsh_setpaths || exit 1 + local pkg=$1 + local target=$("$rpcmd" "${2-$PWD}") + local pkg_src="${3-.}" + local commands=() + local messages=() + local relative + local branch + + if [[ -e "$pkg" && ! -d "$pkg" ]]; then + echoerr "The path '$pkg' exists and is not a directory! Aborting ..." + exit 1 fi + [[ ! -e "$pkg" ]] && mkdir -p "$pkg" && messages+=("Created new package main directory: '$pkg'") + + while IFS= read -r -d '' f; do + local src_file + if [[ -z "$f" ]]; then + src_file="$pkg_src" + else + src_file="$pkg_src/$f" + fi + relative=$($rpcmd "$src_file" -s --relative-to="$target") + local pkg_target="$pkg/$relative" + local pkg_target_dir="$(dirname ""${pkg_target}"")" + if [[ -e "$pkg_target_dir" && ! -d "$pkg_target_dir" ]]; then + echoerr "The path '$pkg_target_dir' exists and is not a directory! Aborting ..." + # TODO : No clean-up of directories made so far + exit 1 + fi + if [[ ! -e "$pkg_target_dir" ]]; then + mkdir -p "${pkg_target_dir}" || ( + echoerr "Error creating directory" "${pkg_target_dir}" + exit 1 + ) + messages+=("Created new package sub-directory: '$pkg_target_dir'") + fi + if [[ ! -f "$pkg_target" ]]; then + if [[ "$ADD_PKG_COPY_LINKS" -eq 1 ]]; then + commands+=("cp $_cp_keep_symlink '$src_file' '$pkg_target'") + else + commands+=("cp $_cp_deref_symlink '$src_file' '$pkg_target'") + fi + [[ "${USEGIT}" -eq 1 ]] && commands+=("git add '$pkg_target'") + else + local diff=1 + [[ -f "$pkg_target" ]] && diff=$(diff -q "$pkg_target" "$src_file") + if [[ -z "$diff" ]]; then + messages+=("File '$pkg_target' already matches '$src_file'.") + else + if [[ "${USEGIT}" -eq 1 ]]; then + git_writeable "$pkg_target" || exit 1 + if [[ "$ADD_PKG_COPY_LINKS" -eq 1 ]]; then + commands+=("cp $_cp_keep_symlink -f '$src_file' '$pkg_target'") + else + commands+=("cp $_cp_deref_symlink -f '$src_file' '$pkg_target'") + fi + commands+=("git add '$pkg_target'") + messages+=("Git-versioned file '$pkg_target' in has been staged with NEW CONTENTS from '$src_file'.") + messages+=("Please review the diff and commit or revert any changes.") + else + echoerr "$pkg_target already exists." + if [[ ! $SKIP -eq 1 ]]; then + $( + cd $pkg + git status >/dev/null 2>&1 + ) || git_suggestion=" or -g for a more git-aware mode." + echoerr "Aborting. Rerun with the -s flag to skip errors${git_suggestion}." + return 1 + fi + fi + fi + fi + done < <(list_files "$pkg_src") + + for cmd in "${commands[@]}"; do + _runcommands "$cmd" + done + for msg in "${messages[@]}"; do + echo stowsh: "$msg" + done } stowsh_install() { @@ -86,27 +306,42 @@ stowsh_install() { local target target=$("$rpcmd" "${2-$PWD}") local commands=() + local messages=() cd "$pkg" || return 1 mkdir -p "$target" while IFS= read -r -d '' d; do commands+=("mkdir -p '$target/$d'") - done < <($flist -d) - + done < <($dlist) while IFS= read -r -d '' f; do local targetf="$target/$f" local thisdir thisdir=$(dirname "$targetf") local relative relative=$($rpcmd "$f" --relative-to="$thisdir" --canonicalize-missing) - if [[ ! -f "$targetf" ]]; then + + if [[ ! -e "$targetf" ]]; then commands+=("ln -s '$relative' '$targetf'") else - echoerr "$targetf already exists." - if [[ ! $SKIP -eq 1 ]]; then - echoerr "Aborting. Rerun with the -s flag to skip errors." - return 1 + local diff=1 + [[ "${LINK_REPLACES_EQUALS}" -eq 1 && -f $targetf ]] && diff=$(diff -q "$f" "$targetf") + if [[ -z "$diff" ]]; then + commands+=("ln -s -f '$relative' '$targetf'") + else + if [[ "${USEGIT}" -eq 1 ]]; then + git_writeable "$f" || exit 1 + commands+=("mv -f '$targetf' '$f'") + commands+=("ln -s '$relative' '$targetf'") + messages+=("Git-versioned file '$f' in '$pkg' has been replaced with the contents of '$targetf'.") + messages+=("Please review the diff and commit or revert any changes.") + else + echoerr "$targetf already exists." + if [[ ! $SKIP -eq 1 ]]; then + echoerr "Aborting. Rerun with the -s flag to skip errors." + return 1 + fi + fi fi fi done < <($flist) @@ -114,6 +349,9 @@ stowsh_install() { for cmd in "${commands[@]}"; do _runcommands "$cmd" done + for msg in "${messages[@]}"; do + echo "stowsh:" "$msg" + done } stowsh_uninstall() { @@ -146,7 +384,7 @@ stowsh_uninstall() { while IFS= read -r -d '' d; do commands+=("[[ -d '$target/$d' ]] && $findcmd '$target/$d' -type d -empty -delete") - done < <($flist -d) + done < <($dlist) for cmd in "${commands[@]}"; do _runcommands "$cmd" @@ -154,20 +392,26 @@ stowsh_uninstall() { } stowsh_help() { - echo "Usage: $0 [-D] [-n] [-s] [-g] [-v[v]] [-t TARGET] PACKAGES..." + echo "Usage: $0 [-D] [-n] [-s] [-g] [-u] [-r] [-v[v]] [-l] [-t TARGET] PACKAGES..." + echo " $0 [-d] [-n] [-s] [-g] [-c] [-u] [-r] [-v[v]] [-t TARGET] -a PACKAGE FILES..." } if [ "$0" = "$BASH_SOURCE" ]; then UNINSTALL=0 DRYRUN=0 SKIP=0 + LINK_REPLACES_EQUALS=0 + ADD_TO_PACKAGE= + ADD_PKG_COPY_LINKS=1 USEGIT=0 + LIST_UNTRACKED= + CONTINUE_COMMIT=0 TARGET="$PWD" - PACKAGES=() + SOURCES=() while [[ "$@" ]]; do if [[ $1 =~ ^- ]]; then OPTIND=1 - while getopts ":vhDsngt:" opt; do + while getopts ":vhDsnrdgcult:a:" opt; do case $opt in h) stowsh_help @@ -175,10 +419,17 @@ if [ "$0" = "$BASH_SOURCE" ]; then ;; D) UNINSTALL=1 + [[ ! -z "$ADD_TO_PACKAGE" ]] && echoerr "Options -a and -D may not be given together. Aborting..." && exit 1 ;; n) DRYRUN=1 ;; + r) + LINK_REPLACES_EQUALS=1 + ;; + d) # --dereference + ADD_PKG_COPY_LINKS=0 + ;; s) SKIP=1 ;; @@ -188,9 +439,23 @@ if [ "$0" = "$BASH_SOURCE" ]; then g) USEGIT=1 ;; + c) + CONTINUE_COMMIT=1 + ;; + u) + LIST_UNTRACKED="--others --exclude-standard" + ;; + l) + LIST_PKG_STATUS=1 + ;; t) TARGET="$OPTARG" ;; + a) + [[ ! -z "${ADD_TO_PACKAGE}" ]] && echoerr Only one -a add-package option may be supplied && exit 1 + ADD_TO_PACKAGE="$OPTARG" + [[ "$UNINSTALL" -eq 1 ]] && echoerr "Options -a and -D may not be given together. Aborting..." && exit 1 + ;; *) echo "'$OPTARG' is an invalid option/flag" exit 1 @@ -199,18 +464,41 @@ if [ "$0" = "$BASH_SOURCE" ]; then done shift $((OPTIND - 1)) else - PACKAGES+=("$1") + SOURCES+=("$1") shift fi done - if [[ ${#PACKAGES[@]} -eq 0 ]]; then + if [[ ${#SOURCES[@]} -eq 0 ]]; then stowsh_help exit 1 fi - - for i in ${!PACKAGES[*]}; do - pkg=${PACKAGES[$i]} + if [[ ! -z "${LIST_PKG_STATUS}" ]]; then + for i in ${!SOURCES[*]}; do + pkg=${SOURCES[$i]} + stowsh_list_status "$pkg" "$TARGET" + done + exit 0 + fi + if [[ ! -z "${ADD_TO_PACKAGE}" ]]; then + if [[ "$USEGIT" -eq 1 ]]; then + if ! git_is_path_inside_repo "${ADD_TO_PACKAGE}"; then + echoerr "No git repository at \'${ADD_TO_PACKAGE}\'. Aborting." + exit 1 + fi + if ! git_clean "${ADD_TO_PACKAGE}" && ! [[ $CONTINUE_COMMIT -eq 1 ]]; then + echoerr "Unclean git repository at \'${ADD_TO_PACKAGE}\', without continue-commit (-c). Aborting ..." + exit 1 + fi + fi + for i in ${!SOURCES[*]}; do + if [[ $VERBOSE -gt 0 ]]; then echoerr "Adding to ${ADD_TO_PACKAGE}: '${TARGET}' '${SOURCES[$i]}'"; fi + stowsh_add_to_pkg "${ADD_TO_PACKAGE}" "${TARGET}" "${SOURCES[$i]}" + done + exit 0 + fi + for i in ${!SOURCES[*]}; do + pkg=${SOURCES[$i]} if [[ $UNINSTALL -eq 1 ]]; then if [[ $VERBOSE -gt 0 ]]; then echoerr "Uninstalling $pkg from $TARGET"; fi stowsh_uninstall "$pkg" "$TARGET" @@ -220,3 +508,4 @@ if [ "$0" = "$BASH_SOURCE" ]; then fi done fi +# vim: ts=4 sts=4 sw=4 diff --git a/tests/add_to_pkg/git_pkg/file b/tests/add_to_pkg/git_pkg/file new file mode 100644 index 0000000..0cfbf08 --- /dev/null +++ b/tests/add_to_pkg/git_pkg/file @@ -0,0 +1 @@ +2 diff --git a/tests/add_to_pkg/git_pkg/link b/tests/add_to_pkg/git_pkg/link new file mode 120000 index 0000000..1a010b1 --- /dev/null +++ b/tests/add_to_pkg/git_pkg/link @@ -0,0 +1 @@ +file \ No newline at end of file diff --git a/tests/add_to_pkg/git_pkg/path/file b/tests/add_to_pkg/git_pkg/path/file new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/tests/add_to_pkg/git_pkg/path/file @@ -0,0 +1 @@ +1 diff --git a/tests/add_to_pkg/run b/tests/add_to_pkg/run new file mode 100755 index 0000000..5b31417 --- /dev/null +++ b/tests/add_to_pkg/run @@ -0,0 +1,98 @@ +#!/bin/bash + +stowsh=../../stowsh + +fail=0 +fails=0 + +red=""; green=""; normal=""; +[[ $(type -P tput) ]] && + [[ "$(tput colors)" -ge 8 ]] && + normal="$(tput sgr0)" && + red="$(tput setaf 1)" && + green="$(tput setaf 2)" && + yellow="$(tput setaf 3)" + +FAIL="${red}FAIL${normal}" +PASS="${green}PASS${normal}" + +echo +echo \#\# Test that we can grab the tree in src +rm -rf "pkg" +$stowsh -vv -t "src" -a "pkg" "src" || fail=1 +diff -qr "pkg" "src" || fail=1 +echo \#\# Report +echo ${yellow}Listing src${normal} +tree src +echo ${yellow}Listing pkg${normal} +tree pkg +if [[ $fail == 1 ]] ; then + echo $FAIL +else + echo $PASS +fi +fails=$(( $fails + $fail )) + +echo +echo \#\# Test that we don\'t overwrite a file with a directory +rm -rf "pkg" +mkdir -p pkg +touch pkg/path +$stowsh -vv -t "src" -a "pkg" "src" && fail=1 +echo \#\# Report +echo ${yellow}Listing src${normal} +tree src +echo ${yellow}Listing pkg${normal} +tree pkg +if [[ $fail == 1 ]] ; then + echo $FAIL +else + echo $PASS +fi +fails=$(( $fails + $fail )) +rm -rf "pkg" + +echo +echo \#\# Test that we overwrite a versioned file with a new +$stowsh -vv -t "src" -g -a "git_pkg" "src/file" || fail=1 +echo \#\# Report +echo ${yellow}Listing src${normal} +tree src +echo ${yellow}Listing git_pkg${normal} +tree git_pkg +if [[ $fail == 1 ]] ; then + echo $FAIL +else + echo $PASS +fi +fails=$(( $fails + $fail )) +git restore --staged git_pkg + +echo +echo \#\# Test that we don\'t overwrite a modified versioned file +echo 3 > git_pkg/file +$stowsh -vv -t "src" -g -a "git_pkg" "src" && fail=1 +echo \#\# Report +echo ${yellow}Listing src${normal} +tree src +echo ${yellow}Listing git_pkg${normal} +tree git_pkg +if [[ $fail == 1 ]] ; then + echo $FAIL +else + echo $PASS +fi +fails=$(( $fails + $fail )) +git restore git_pkg +git restore --staged git_pkg + + + +echo \#\# add_to_pkg result +if [[ $fails -ge 1 ]] ; then + echo $FAIL + exit 1 +else + echo $PASS + exit 0 +fi diff --git a/tests/add_to_pkg/src/file b/tests/add_to_pkg/src/file new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/tests/add_to_pkg/src/file @@ -0,0 +1 @@ +1 diff --git a/tests/add_to_pkg/src/link b/tests/add_to_pkg/src/link new file mode 120000 index 0000000..3ce78d3 --- /dev/null +++ b/tests/add_to_pkg/src/link @@ -0,0 +1 @@ +path/file \ No newline at end of file diff --git a/tests/add_to_pkg/src/path/file b/tests/add_to_pkg/src/path/file new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/tests/add_to_pkg/src/path/file @@ -0,0 +1 @@ +1 diff --git a/tests/git/run b/tests/git/run index 1e6c435..43646ee 100755 --- a/tests/git/run +++ b/tests/git/run @@ -2,24 +2,82 @@ stowsh=../../stowsh +fail=0 +fails=0 + +red=""; green=""; normal=""; +[[ $(type -P tput) ]] && + [[ "$(tput colors)" -ge 8 ]] && + normal="$(tput sgr0)" && + red="$(tput setaf 1)" && + green="$(tput setaf 2)" && + yellow="$(tput setaf 3)" + +FAIL="${red}FAIL${normal}" +PASS="${green}PASS${normal}" + +_fail_report() { + if [[ $fail == 1 ]] ; then + echo $FAIL + else + echo $PASS + fi + fails=$(( $fails + $fail )) + fail=0 +} + +### + +# Test that files not in git won't be installed / uninstalled +# (unless the -u option is applied = TODO) notingit=( 'pkg/not_in_git' 'pkg/also_not_in git' ) fail=0 +rm -rf "uninstalled" mkdir -p "uninstalled" rm -rf "dest" cp -r "uninstalled" "dest" touch "${notingit[@]}" + $stowsh -vv -g -t "dest" "pkg" diff -qr "dest" "installed" || fail=1 +_fail_report + $stowsh -vv -D -g -t "dest" "pkg" diff -qr "dest" "uninstalled" || fail=1 +_fail_report rm "${notingit[@]}" -if [[ $fail == 1 ]] ; then - echo "FAIL" +# Test that different files won't be overwritten +echo 1 > pkg/file +echo 2 > dest/file + +$stowsh -vv -D -g -t "dest" "pkg" && fail=1 +_fail_report + +diff -qr "dest" "pkg" && fail=1 +_fail_report + +# Test that different file will be moved and symlinked +# if versioned by git +git restore pkg/file + +$stowsh -vv -g -t "dest" "pkg" || fail=1 +_fail_report + +diff -qr "dest" "pkg" || fail=1 +_fail_report + +if [[ $fails -ge 1 ]] ; then + echo $FAIL exit 1 else - echo "OK" + ls -l pkg + ls -l dest rm -rf "dest" + cat pkg/file + git restore pkg/file + echo $PASS exit 0 fi + diff --git a/tests/overwrites/pkg/.bash_profile b/tests/overwrites/pkg/.bash_profile index e69de29..792d600 100644 --- a/tests/overwrites/pkg/.bash_profile +++ b/tests/overwrites/pkg/.bash_profile @@ -0,0 +1 @@ +# diff --git a/tests/overwrites/run b/tests/overwrites/run index ec2db3e..36591e7 100755 --- a/tests/overwrites/run +++ b/tests/overwrites/run @@ -6,10 +6,11 @@ fail=0 rm -rf "dest" cp -r "uninstalled" "dest" -# This block verifies the claim "When installing a package stowsh will never -# overwrite existing files." +# This block verifies that "When installing a package stowsh will not +# overwrite existing files (unless they are equal or the contents can be +# safely be kept for both files using git with the -g option)." # -# This should fail because .bash_profile already exists at dest +# This should fail because .bash_profile already exists at dest and the files differ $stowsh -vv -t "dest" "pkg" && fail=1 # This file should not exist because the previous command should not have set up # any links