Skip to content
This repository has been archived by the owner on Sep 11, 2020. It is now read-only.

git rev-parse? #599

Open
ankurmittal opened this issue Sep 19, 2017 · 10 comments
Open

git rev-parse? #599

ankurmittal opened this issue Sep 19, 2017 · 10 comments

Comments

@ankurmittal
Copy link

ankurmittal commented Sep 19, 2017

How do i find commit hash for a particular ref, ref can be a commit hash, branch name, tag name, etc
eg
a891109d49d61fc0792912f0d741b45ec1516525
a891109
refs/heads/branch
heads/branch
branch
refs/tags/tag
tag

@orirawlings
Copy link
Contributor

There exists a method (*Repository).ResolveRevision which satisfies part of the behavior of rev-parse, including resolving the relative operators (like ~, ^, etc.) but it is missing support for other basic scenarios (like the ones you describe).

@mcuadros was the intent that the internal/revision package would implement the full gitrevisions spec? If so, I think we want to add support for full and short hash literals as well as reference name disambiguation.

There are a handful of other gitrevisions that require broader feature support which is currently missing in this library. For example, reflog and upstream revisions.

@ankurmittal
Copy link
Author

any update?

@mcuadros
Copy link
Contributor

@orirawlings the goals is cover all the cases. So will be great if any wants to implement it.

@antham
Copy link
Contributor

antham commented Nov 25, 2017

This case a891109d49d61fc0792912f0d741b45ec1516525 isn't taken in account, I didn't implement it, but I think it won't be that hard.
Those 2, refs/heads/branch and refs/tags/tag work actually, I tried with a repository of mine and it's resolved with the right sha .
Those cases heads/branch, branch and tag are bugs, I tried, they are correctly parsed as Ref but they are not resolved in the right way afterwards, I need to check why to fix that.

@antham
Copy link
Contributor

antham commented Dec 1, 2017

@mcuadros this issue needs to be reopened, this case a891109d49d61fc0792912f0d741b45ec1516525 is not covered yet, I'm working on it.

@mcuadros mcuadros reopened this Dec 1, 2017
@ankurmittal
Copy link
Author

Also are you planning to cover short hashes?

@antham
Copy link
Contributor

antham commented Dec 1, 2017

Yep I'm going to do so as well

@andreimc
Copy link

andreimc commented Aug 7, 2018

@antham any progress on shorthand hashes ?

@antham
Copy link
Contributor

antham commented Aug 7, 2018

@andreimc I had some trouble to have a good solution for this problem and left it aside the time to think about it and find something better, time flies.... Let me recheck this week.

@antham
Copy link
Contributor

antham commented Aug 18, 2018

After some search, I think it would be necessary to do something with the layer that interact with git directly, at a upper level we only handle full hash and as I see we can only iterate over commit which is very slow

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants