Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix rebase -r of a parent of a merge commit #538

Merged
merged 1 commit into from
Sep 12, 2022

Commits on Sep 12, 2022

  1. Fix rebase -r of a parent of a merge commit

    Previously, using `rebase -r` on the parent of a merge commit
    turned it into a non-merge commit. In other words, starting
    with
    
    ```
        o   d
        |\
        o | c
        o | b
        | o a
        |/  
        o 
    ```
    
    and doing `rebase -r c -d a` resulted in
    
    ```
        o d
        o b
        | o c
        | o a
        |/  
        o 
    ```
    
    where `d` is no longer a merge commit.
    
    For reference, here's a complete test that passed before this commit (but should NOT pass; see the diff for a test that should pass):
    
    ```
    #[test]
    fn test_rebase_single_revision_merge_parent() {
        let test_env = TestEnvironment::default();
        test_env.jj_cmd_success(test_env.env_root(), &["init", "repo", "--git"]);
        let repo_path = test_env.env_root().join("repo");
    
        create_commit(&test_env, &repo_path, "a", &[]);
        create_commit(&test_env, &repo_path, "b", &[]);
        create_commit(&test_env, &repo_path, "c", &["b"]);
        create_commit(&test_env, &repo_path, "d", &["a", "c"]);
        // Test the setup
        insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
        @
        o   d
        |\
        o | c
        o | b
        | o a
        |/
        o
        "###);
    
        let stdout = test_env.jj_cmd_success(&repo_path, &["rebase", "-r", "c", "-d", "a"]);
        insta::assert_snapshot!(stdout, @r###"
        Also rebased 2 descendant commits onto parent of rebased commit
        Working copy now at: 3e176b54d680 (no description set)
        Added 0 files, modified 0 files, removed 2 files
        "###);
        insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
        @
        o d
        | o c
        o | b
        | o a
        |/
        o
        "###);
    }
    ```
    ilyagr committed Sep 12, 2022
    Configuration menu
    Copy the full SHA
    67738a8 View commit details
    Browse the repository at this point in the history