Lackm
Lackm

Reputation: 1

Jgit Fixup, Squash Interactive Rebase is not working properly

Jgit Fixup Interactive Rebase is not work properly

What I want

before

after

In Git Cli

git rebase -i commitA

pick 70b72153 A
fixup 96e62976 B
fixup 02282c93 C
fixup d3f25efb D
pick 456cd8d2 E
pick 00e1cf08 F

If I fixup B, C, and D, the commit message of A remains the same and the commit contents are combined to A.

I Implemented the CLI command above through Jgit.

JGit (JAVA)

public void rebase(Ref branch) {
    try (Repository repository = JgitHelper.openJGitCookbookRepository()) {
      try (Git git = new Git(repository)) {
        RebaseCommand.InteractiveHandler handler = new RebaseCommand.InteractiveHandler() {
          @Override
          public void prepareSteps(List<RebaseTodoLine> steps) {
            try {
              steps.get(1).setAction(RebaseTodoLine.Action.FIXUP); // Index 0 is not available because there is no previous commit.
            } catch (IllegalTodoFileModification e) {
              throw new RuntimeException(e);
            }
          }

          @Override
          public String modifyCommitMessage(String oldMessage) {
            return oldMessage;
          }
        };

        RebaseResult result = git.rebase()
            .runInteractively(handler)
            .setUpstream("{ FIRST_COMMIT_HASH_CODE }")
            .call();
        }

I wanted to perform the GIT CLI described above through this code. However, this code has an "A(+B+C+D+E+F)" result

I don't know why everything is fixed up in commit A. Squash works the same way.

Is there another way to get A(+B+C+D) - E - F results with JGit?

Upvotes: 0

Views: 32

Answers (0)

Related Questions