Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions bin/git-missing
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,15 @@ fi
declare -a git_log_args=()
declare -a branches=()
declare -a pathspec=()
declare parse_path=false

for arg in "$@" ; do

if [[ $parse_path == true ]]; then
pathspec+=("$@")
break
fi
while [ "${#}" -gt 0 ]; do
arg="$1"
shift

case "$arg" in
--)
parse_path=true
pathspec+=("$@")
break
;;
--*)
git_log_args+=( "$arg" )
Expand Down
44 changes: 44 additions & 0 deletions tests/git-missing.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# shellcheck shell=bash

source "$BATS_TEST_DIRNAME/test_util.sh"

setup_file() {
test_util.setup_file
test_util.install_command missing
}

setup() {
test_util.cd_test

test_util.git_init
git commit --allow-empty -m "Initial commit"
git switch -c feature
mkdir feature src
printf '%s\n' 'a' > feature/file
git add feature/file
git commit -m "Change feature dir"
printf '%s\n' 'b' > src/file
git add src/file
git commit -m "Change src dir"
git switch main
}

@test "lists commits missing from either branch" {
run git missing main feature
assert_success
assert_line -p "Change feature dir"
assert_line -p "Change src dir"
}

@test "limits commits to the given pathspec" {
run git missing main feature -- src
assert_success
assert_line -p "Change src dir"
refute_line -p "Change feature dir"
}

@test "does not treat branch names as pathspec" {
run git missing main feature -- does-not-exist
assert_success
assert_output ""
}
Loading