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
3 changes: 2 additions & 1 deletion bin/git-merge-into
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ usage() {
cur_branch=$(current_branch)

stashed=0
if [ -n "$(git status --porcelain)" ];
# git stash saves no untracked files; stashing then would pop an older stash.
if [ -n "$(git status --porcelain --untracked-files=no)" ];
then
echo "Local modifications detected, stashing"
stashed=1
Expand Down
32 changes: 32 additions & 0 deletions tests/git-merge-into.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# shellcheck shell=bash

source "$BATS_TEST_DIRNAME/test_util.sh"

setup_file() {
test_util.setup_file
test_util.install_command merge-into
}

setup() {
test_util.cd_test

test_util.git_init
printf '%s\n' 'a' > file
git add .
git commit -m "Initial commit"
git branch dest
}

@test "merging with only untracked files leaves an older stash alone" {
printf '%s\n' 'old work' >> file
git stash
printf '%s\n' 'new' > untracked

run git merge-into dest
assert_success

run git stash list
assert_output --partial 'WIP on main'
run cat file
assert_output 'a'
}
Loading