-
Notifications
You must be signed in to change notification settings - Fork 533
Git::Branch function update_ref doesn't work as expected #599
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
Comments
mblythe86
added a commit
to mblythe86/ruby-git
that referenced
this issue
Nov 4, 2022
Fixes both ruby-git#599 and ruby-git#600
mblythe86
added a commit
to mblythe86/ruby-git
that referenced
this issue
Nov 4, 2022
Fixes both ruby-git#599 and ruby-git#600 Also fixes argument name of update_ref. I'm assuming it's supposed to be analogous to the command line `git update-ref`, which doesn't directly use a branch name. Signed-off-by: Matt Blythe <mblythester+git@gmail.com>
mblythe86
added a commit
to mblythe86/ruby-git
that referenced
this issue
Nov 4, 2022
Fixes both ruby-git#599 and ruby-git#600 Also fixes argument name of update_ref. I'm assuming it's supposed to be analogous to the command line `git update-ref`, which doesn't directly use a branch name. Signed-off-by: Matthew Blythe <mblythester+git@gmail.com>
jcouball
pushed a commit
to mblythe86/ruby-git
that referenced
this issue
Feb 26, 2023
Fixes both ruby-git#599 and ruby-git#600 Also fixes argument name of update_ref. I'm assuming it's supposed to be analogous to the command line `git update-ref`, which doesn't directly use a branch name. Signed-off-by: Matthew Blythe <mblythester+git@gmail.com>
jcouball
added a commit
that referenced
this issue
Feb 26, 2023
* Branch-related bugfixes Fixes both #599 and #600 Also fixes argument name of update_ref. I'm assuming it's supposed to be analogous to the command line `git update-ref`, which doesn't directly use a branch name. Signed-off-by: Matthew Blythe <mblythester+git@gmail.com> * Add test for Branch#update_ref Signed-off-by: James Couball <jcouball@yahoo.com> --------- Signed-off-by: Matthew Blythe <mblythester+git@gmail.com> Signed-off-by: James Couball <jcouball@yahoo.com> Co-authored-by: Matthew Blythe <mblythester+git@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Subject of the issue
Git::Branch#update_ref creates the wrong ref name, resulting in "refname is ambiguous" warnings.
Your environment
Steps to reproduce
Expected behaviour
I'd expect
git.branch('testing').update_ref(<HASH>)
to behave the same asgit branch -f testing <HASH>
from the command line.If that were the case, the code above should print the following (sha values may vary):
Actual behaviour
The code above prints this:
It looks like instead of updating the file
.git/refs/heads/testing
with the new hash, instead the call toupdate_ref()
creates a new file.git/testing
with the new hash.Discussion
For reference, this is the current implementation of Git::Branch#update_ref:
And this is the implementation of Git::Lib#update_ref that it's calling:
I think the
branch
naming of that function argument is problematic, since it just passes through to thegit update-ref
command, which accepts a 'ref' as an argument, not a branch name. If we really intend for that function to accept a branch name, then the implementation should probably change to prependrefs/heads/
before calling the command. However, this makes the behavior of the function diverge from the behavior of the command, which is probably undesirable.With that in mind, I think the fix needs to happen in Git::Branch#update_ref to call Git::Lib#update_ref with the right ref name instead of just using the 'full branch' name.
Recommendation
Git::Branch#update_ref:
Git::Lib#update_ref:
The text was updated successfully, but these errors were encountered: