You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2019/07/18 21:16:21 UTC
[GitHub] [mynewt-newt] ccollins476ad opened a new pull request #312: Use
"detached head" instead of local branches
ccollins476ad opened a new pull request #312: Use "detached head" instead of local branches
URL: https://github.com/apache/mynewt-newt/pull/312
## SUMMARY
This PR changes how newt interacts with git. Newt used to use a mix of "detached head" and local branches. With this PR, newt uses "detached head" exclusively.
## OLD BEHAVIOR
Newt used a combination of "detached head" and local branches.
* When upgrading to a version mapped to a branch, newt would check out a local branch with the appropriate name. For example, when upgrading to 0.0.0, newt would check out a local "master" branch.
* When upgrading to a version mapped to a tag or a commit hash, newt would put the repo in a "detached head" state.
This inconsistency comes from the `git checkout` command. Git puts a repo in a different state depending on the type of commit being checked out.
## NEW BEHAVIOR
Newt uses "detached head" exclusively. When upgrading to a version mapped to a branch or tag, newt looks up the corresponding commit hash and checks it out.
In addition, this PR adds a clarification in semantics:
> Only the following commands make modifications to git repos:
> * new
> * install
> * upgrade
> * info -r
>
> All other commands leave the git repos untouched. E.g., they do not run `git fetch`, `git checkout`, or `git remote set-url`.
This change simplifies working with custom branches.
## IMPROVEMENTS
This change improves newt in several ways:
1. Lower chance of git conflicts. When newt used local branches, there was always a chance of pulling incompatible commits into an existing branch. This was especially likely when using `newt sync` and changing a repo's remote URL.
2. No need for the `newt sync` command. The sync command was only necessary due to newt's use of local branches. Now, `newt upgrade` alone does the right thing: it fetches from `origin` and checks out the correct commit. For branch-backed versions, newt checks out the latest
commit in the branch.
The `newt sync` command has been deprecated. Now it prints a warning message and performs a `newt upgrade`.
3. Proper support for branches and tags in `project.yml`. Newt has always allowed the `<hash>-commit` notation for a repo version string, but it did not correctly handle `<branch>-commit` or `<tag>-commit`. Now these version strings work correctly.
## NOTES
In my opinion, we should think about deprecating `newt install`. This command doesn't seem very useful; just use `newt upgrade`.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services