Skip to content
Snippets Groups Projects
Commit 46ca68de authored by Dabrien 'Dabe' Murphy's avatar Dabrien 'Dabe' Murphy Committed by Jack Nagel
Browse files

Modify "git rev-parse --verify" args in "has_ref?"


Per the `git-rev-parse(1)` manpage:

  --verify Verify that exactly one parameter is provided, and that it
  can be turned into a raw 20-byte SHA-1 that can be used to access the
  object database. If so, emit it to the standard output; otherwise,
  error out.

  If you want to make sure that the output actually names an object in
  your object database and/or can be used as a specific type of object
  For example, git rev-parse "$VAR^{commit}" will make sure $VAR names
  an existing object that is a commit-ish (i.e. a commit, or an
  annotated tag that points at a commit).

That actually means that:

  git rev-parse --verify af8e768e2bd3b4398bca033998f83b0eb8874914

will _always_ return the SHA-1 hash — regardless of whether or not
that's actually a valid reference!

Thus, when `GitDownloadStragtegy#update_repo` tries to check
`has_ref?`, it mistakenly succeeds, and doesn't actually do a `git fetch
origin`.

The fix is to use:

  git rev-parse --verify "af8e768e2bd3b4398bca033998f83b0eb8874914^{commit}"

Fixes Homebrew/homebrew#31045.
Closes Homebrew/homebrew#31054.

Signed-off-by: default avatarJack Nagel <jacknagel@gmail.com>
parent 9c5149b8
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment