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

av stack reorder it's too easy to get into a bad state and loose commits #315

Open
Brookke opened this issue Jun 6, 2024 · 1 comment
Open

Comments

@Brookke
Copy link
Contributor

Brookke commented Jun 6, 2024

Reproduction

  1. Create a branch with several commits

    av stack branch demo
    git commit -m "feature a" --allow-empty
    git commit -m "feature b" --allow-empty
    git commit -m "feature c" --allow-empty
    
  2. run av stack reorder

  3. edit the file to:

    stack-branch demo --trunk master@b91a233a59c7f8a92ab3ef721237b463cebddb86
    pick 5399908  # feature a
    stack-branch feature/b # note I have forgotten the --parent flag here
    pick 0eb9dbf  # feature b
    stack-branch feature/c # note I have forgotten the --parent here
    pick 89b8117  # feature c
    
  4. save and exit

Result

The command correctly errors. However, the feature b and feature c commits are now lost.

$ av stack reorder 
Starting branch demo at b91a233
  - applied commit 5399908 without conflict (HEAD is now at 5399908)
error: invalid stack-branch command: --parent=<branch> or --trunk=<branch> must be specified when creating the first branch

Expected result

because the command errors it should revert back to the prior state

Additional notes

Some of this could also be alleviated with a av stack split command that cut up a branch into a branch per commit (use the commit name as the branch name)

@draftcode
Copy link
Contributor

Aside from this, we can save something similar to reflog so that we can record the ref updates as a safety. Save something like:

{
  operations: [
    {
      command: "av stack sync",
      refUpdates: [
        {
          ref: "refs/heads/feature1",
          before: "b91a233a59c7f8a92ab3ef721237b463cebddb86",
          after: "0000000000000000000000000000000000000000",
        }
      ]
    }
  ]
}

Technically, similar data should be stored in reflog, but a bit more explicit in terms of what we've done.

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

No branches or pull requests

2 participants