Skip to content

git gc (garbage collection) should reset commit indices #1233

@ohadschn

Description

@ohadschn

Issue

Suppose I start with:
c0 <- c1(main)

I do git reset c0 and git gc so now I have:
c0(main)

Finally I do git commit and get:
c0 <- c2(main)

Where I would have expected:
c0 <- c1(main)

Impact

Beyond the matter of general consistency, this "current commit index" hidden state behavior interferes with level building.
Suppose I want the student to simply do git commit on a trivial graph (with only init commit). So starting from c0(main) I do:

  • define start
  • git commit
  • define goal

But then when I share the level and the student does git commit they will get c0 <- c1(main) (and not c0 <- c2(main)) so the exercise won't succeed...

This is especially troublesome considering how build level seems to always start with c0 <- c1(main) (where reset just brings it back to that position)

Workaround

Reset the state to a "clean" trivial tree with:
importTreeNow {"branches":{"main":{"target":"C0","id":"main"}},"commits":{"C0":{"parents":[],"id":"C0","rootCommit":true}},"HEAD":{"target":"main","id":"HEAD"}}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions