Skip to content

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

Merged
spacewander merged 1 commit into
tj:mainfrom
jayhemnani9910:fix/merge-repo-flat-dotfiles
Nov 26, 2026
Merged

spacewander merged 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.

@hyperupcall hyperupcall left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@spacewander
spacewander merged commit 5e53d50 into tj:main Nov 26, 2026
5 checks passed
@spacewander

Copy link
Copy Markdown
Collaborator

@jayhemnani9910
Merged. Thank you!

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.

3 participants