Skip to content
  • Stan Hu's avatar
    Fix squash when target repository has a renamed file · e9fc43bd
    Stan Hu authored
    If a file were renamed on the target branch but the source branch still
    contained the original file, previously squash would fail with `error:
    Sparse checkout leaves no entry on working directory`. This happens
    because of the way a worktree is created with squash:
    
    1. `git diff --name-only <START_SHA>...<END_SHA>`, where START_SHA and
    END_SHA are from the source branch.
    2. This will populate `info/sparse-checkout` with the files changed on
    the source branch.
    3. We then checkout the target branch, which fails if all of the changed
    files from the source branch do not exist on it.
    
    A squash should not be confused with a squash and rebase. Squash should
    simply take the existing commits on the branch and collapse them into
    one. The target branch is irrelevant, and so we should ignore the branch
    parameter entirely.
    
    Closes #2395
    e9fc43bd