Skip to content

fix(merge-repo): keep dotfiles and older stashes when merging into . - #1291

Open
jayhemnani9910 wants to merge 1 commit into
tj:mainfrom
jayhemnani9910:fix/merge-repo-flat-dotfiles
Open

jayhemnani9910 wants to merge 1 commit into
tj:mainfrom
jayhemnani9910:fix/merge-repo-flat-dotfiles

Conversation

@jayhemnani9910

Copy link
Copy Markdown
Contributor

git merge-repo <repo> <branch> . (merge into the current folder) loses the merged repo's dotfiles. mv "$prefix"/* ./ doesn't match names starting with a dot, so .gitignore, .github/ and the like stay in the temporary git-merge-repo.XXXXXXX folder, get committed there, and are then deleted from disk by rm -drf "$prefix"; the work tree shows them as deleted.

It also runs git stash apply whether or not git stash -u saved anything, so with a clean tree and an older entry in the stash list, that older stash is applied to the work tree.

The move now uses dotglob, and git stash apply only runs when git stash -u created a new entry.

Added tests/git-merge-repo.bats; both tests fail without the change. bats ./tests passes and shellcheck --severity=error bin/git-merge-repo is clean. Also checked by hand with a nested .github/workflows/ci.yml and an untracked file in the target repo: the merge commit has .github/ and .gitignore at the root, and the untracked file stays untracked.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant