Straight.el: Correctly handle non-master default upstream branches

Created on 13 Dec 2020  Â·  2Comments  Â·  Source: raxod502/straight.el

What's wrong

If an upstream repository chooses a default branch other than master, and the recipe doesn't specify that branch, cloning will fail. Here is an example:

https://github.com/minad/marginalia/issues/24

(In this case, it so happens that without f89731c (melpa/melpa#7274), it would have worked, but this does not negate the fact that straight.el should be handling default branches correctly.)

Directions to reproduce

(straight-use-package marginalia) will result in the git clone failure shown in https://github.com/minad/marginalia/issues/24. This is because straight-vc-git-default-branch results in a default branch choice of master, which results in straight.el attempting to clone with --branch master.

Suggested fix

If no branch is specified, simply omit the --branch option from the git clone command. This will allow git clone to do the right thing. In fact I'm not sure if there's any need for straight-vc-git-default-branch at all; ideally it could be scrapped, because git already knows how to figure out the default branch, and in general that should not be overridden.

Version information

  • Emacs version: 27.1
  • Operating system: openSUSE Tumbleweed
branch bug compatibility duplicate git melpa repository management

Most helpful comment

Oh, nice! I was only testing on master and was not aware of #543 / #630. I can now confirm that this works on develop. Thanks a lot!

All 2 comments

Is this occurring for you on the most recent version of the development branch?

543/#630 should've taken care of this.

The following test case builds fine and has marganila checked out at it's "main" branch on my system:

Test Case

(straight-bug-report
  :user-dir "straight-marginalia"
  :pre-bootstrap 
  (setq straight-repository-branch "develop")
  :post-bootstrap 
  (straight-use-package
   '(marginalia :post-build
                (message
                 (shell-command-to-string "git branch")))))

  • Test run at: 2020-12-13 23:29:51
  • system-type: gnu/linux
  • straight-version: prerelease (HEAD -> develop, origin/develop) 742bc66 2020-12-05
  • emacs-version: GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.23, cairo version 1.17.4) of 2020-12-05

Output

Bootstrapping straight.el...
Bootstrapping straight.el...done
Rebuilding all packages due to build cache schema change
Looking for gnu-elpa-mirror recipe → Cloning melpa...
Looking for gnu-elpa-mirror recipe → Cloning melpa...done
Looking for emacsmirror-mirror recipe → Cloning gnu-elpa-mirror...
Looking for emacsmirror-mirror recipe → Cloning gnu-elpa-mirror...done
Looking for emacsmirror-mirror recipe → Cloning el-get...
Looking for emacsmirror-mirror recipe → Cloning el-get...done
Looking for straight recipe → Cloning emacsmirror-mirror...
Looking for straight recipe → Cloning emacsmirror-mirror...done
Building straight...
Building straight...done

Test run with version: prerelease (HEAD -> develop, origin/develop) 949a0a7 2020-12-13
Cloning marginalia...
Cloning marginalia...done
Building marginalia...

* main

Building marginalia...done

Oh, nice! I was only testing on master and was not aware of #543 / #630. I can now confirm that this works on develop. Thanks a lot!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mclearc picture mclearc  Â·  4Comments

hlissner picture hlissner  Â·  3Comments

eflanigan00 picture eflanigan00  Â·  4Comments

aspiers picture aspiers  Â·  4Comments

progfolio picture progfolio  Â·  3Comments