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

straight-freeze-versions + straight-thaw-versions is not no-op #294

Closed
antifuchs opened this issue Jul 14, 2018 · 4 comments
Closed

straight-freeze-versions + straight-thaw-versions is not no-op #294

antifuchs opened this issue Jul 14, 2018 · 4 comments

Comments

@antifuchs
Copy link
Contributor

As suggested in #292 (comment), I made a reproducer repo for the issue I'm seeing: https://github.com/antifuchs/straight.el-repro-case-1 - it's an init file pulling in ace-window, and a lock file locking that to an older version.

To reproduce:

  1. Clone the repo above
  2. emacs -Q init.el
  3. C-M-x to evaluate the init file (this will bootstrap straight, so it's going to take a while)
  4. M-x straight-thaw-versions
  5. M-x straight-freeze-versions
  6. In the clone from above, run git diff

On my machine, git diff says that the ace-window version changed to the latest. I'd expect there to be no differences. This also reproduces for me if I restart emacs between steps 4 and 5.

I'm testing this on GNU Emacs 26.1 (build 1, x86_64-apple-darwin13.4.0, Carbon Version 157 AppKit 1265.21) of 2018-04-15 - the latest bottle from https://github.com/railwaycat/homebrew-emacsmacport

@antifuchs
Copy link
Contributor Author

antifuchs commented Jul 14, 2018

I just stepped through the freeze process, and it looks like straight-vc-git--ensure-head (via straight-vc-git--ensure-local, via straight-vc-git--ensure-head-pushed invoked from the freeze function) is what resets the checkout for ace-window to the master branch. I'll step through this some more & hopefully will find the exact trace of git things that happen when it does.

EDIT: OK, I think I see it: straight-vc-git--ensure-head checks out master (or whatever the default branch is) in the repo if master isn't checked out (i.e. it's frozen at a particular revision) and straight-vc-git-auto-fast-forward is set to the default, t. That makes re-freezing a repo freezes whatever the master branch is (or something even more complicated).

@raxod502
Copy link
Member

Oh. Yes, that is the intended behavior, except that it causes this horrible effect because #66 has not been fixed yet. I think that #66 is the correct way to address this problem—you do want to make sure that the default branch is checked out (otherwise how can you be sure that the commit will be accessible when the configuration is cloned on another machine?) but of course M-x straight-thaw-versions followed by M-x straight-freeze-versions should be a no-op, whereas currently it is not. Thawing versions should reset the default branch rather than detaching HEAD.

@antifuchs
Copy link
Contributor Author

Ah, that makes a ton of sense - I think resetting the branch to the previously checked-out rev would be quite reasonable (if that rev was an ancestor of the remote's pushed branch).

@raxod502 raxod502 changed the title straight-freeze-versions does not freeze active versions straight-freeze-versions + straight-thaw-versions is not no-op Jul 15, 2018
antifuchs added a commit to antifuchs/straight.el that referenced this issue Apr 20, 2019
This should address radian-software#294: When thawing, we no longer leave detached
heads lying around, so freezing the repo will be much more likely to
be a high-touch operation. Also, this should leave the repos that we
*do* have in a much nicer state for people to work on.
antifuchs added a commit to antifuchs/straight.el that referenced this issue May 1, 2019
This should address radian-software#294: When thawing, we no longer leave detached
heads lying around, so freezing the repo will be much more likely to
be a high-touch operation. Also, this should leave the repos that we
*do* have in a much nicer state for people to work on.
raxod502 pushed a commit that referenced this issue May 4, 2019
* New function straight-vc-commit-present-p: check if a SHA is fetched

This function should allow us to detect if a "git fetch" is necessary
upon thawing the repo.

* Automatically fetch the repo when the thawed-to commit is missing

This should address #58: If we're unable to find the commit locally,
the easiest way to get it is probably to fetch it.

* Normalize repos when thawing

Since we're already going to munge the repo state, we might as well
return it to the master branch and thus get it to a place where the
fetch can do something reasonable.

* Instead of decapitating via checkout, reset the HEAD ref

This should address #294: When thawing, we no longer leave detached
heads lying around, so freezing the repo will be much more likely to
be a high-touch operation. Also, this should leave the repos that we
*do* have in a much nicer state for people to work on.

* Remove note about running fetch before thawing.

With the auto-fetching behavior, I believe this should be unnecessary
now.

* Adjust straight-vc-check-out-commit to normalize the repo

This requires the interface for the function to change: Previously it
took just the local-repo, now it takes the whole recipe (because
that's what normalization uses).
@raxod502
Copy link
Member

raxod502 commented May 4, 2019

This should be fixed by #375.

@raxod502 raxod502 closed this as completed May 4, 2019
hartzell pushed a commit to hartzell/straight.el that referenced this issue Jun 14, 2019
* New function straight-vc-commit-present-p: check if a SHA is fetched

This function should allow us to detect if a "git fetch" is necessary
upon thawing the repo.

* Automatically fetch the repo when the thawed-to commit is missing

This should address radian-software#58: If we're unable to find the commit locally,
the easiest way to get it is probably to fetch it.

* Normalize repos when thawing

Since we're already going to munge the repo state, we might as well
return it to the master branch and thus get it to a place where the
fetch can do something reasonable.

* Instead of decapitating via checkout, reset the HEAD ref

This should address radian-software#294: When thawing, we no longer leave detached
heads lying around, so freezing the repo will be much more likely to
be a high-touch operation. Also, this should leave the repos that we
*do* have in a much nicer state for people to work on.

* Remove note about running fetch before thawing.

With the auto-fetching behavior, I believe this should be unnecessary
now.

* Adjust straight-vc-check-out-commit to normalize the repo

This requires the interface for the function to change: Previously it
took just the local-repo, now it takes the whole recipe (because
that's what normalization uses).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants