short SHA value format in repo manifests

93 views
Skip to first unread message

Igor Krymgand

unread,
Aug 7, 2025, 2:56:31 PMAug 7
to Repo and Gerrit Discussion
greetings

I am trying to use short SHA values (8 digits) as a revision
 <extend-project name="PROJ_AAA" revision="c7cb79bd" />

however when running repo sync i get the following error 
fetching:  0% (0/1) 0:00 | 1 job | 0:00 PROJ_AAA @ PROJ_AAA fatal: couldn't find remote ref refs/heads/9dcb10d30d

Based on the error - looks like short SHA value was mistakenly considered by repo as a branch name. Looking full sha value works fine.
Ara short SHA supported by repo? is there a way to explicitly indicate to repo that the revision is SHA and not branch?

Thanks
Igor

mfick

unread,
Aug 7, 2025, 3:18:49 PMAug 7
to Repo and Gerrit Discussion
On Thursday, August 7, 2025 at 12:56:31 PM UTC-6 igor.k...@gmail.com wrote:
greetings

I am trying to use short SHA values (8 digits) as a revision
 <extend-project name="PROJ_AAA" revision="c7cb79bd" />

Short shas are generally meant for humans, not scripts, probably best to avoid doing this.
 
however when running repo sync i get the following error 
fetching:  0% (0/1) 0:00 | 1 job | 0:00 PROJ_AAA @ PROJ_AAA fatal: couldn't find remote ref refs/heads/9dcb10d30d

Based on the error - looks like short SHA value was mistakenly considered by repo as a branch name. Looking full sha value works fine.
Ara short SHA supported by repo? is there a way to explicitly indicate to repo that the revision is SHA and not branch?

How do you propose that repo know whether you mean a short sha or a branch, as all sha1s are legally also branch (and tag) names.
 
-Martin

Igor Krymgand

unread,
Aug 7, 2025, 3:45:43 PMAug 7
to Repo and Gerrit Discussion
Thanks Martin.
Does it mean that short sha is not supported?

how does repo currently identify long sha? long sha works and are not misinterpreted as branches....

for the future I can think of helper prefix. Something like  revision="sha/12345678"

Best
Igor

Igor Krymgand

unread,
Aug 7, 2025, 4:03:01 PMAug 7
to Repo and Gerrit Discussion
or using ^0 postfix to sha value as done in git ....

mfick

unread,
Aug 7, 2025, 4:13:06 PMAug 7
to Repo and Gerrit Discussion
On Thursday, August 7, 2025 at 1:45:43 PM UTC-6 igor.k...@gmail.com wrote:
Thanks Martin.
Does it mean that short sha is not supported?

how does repo currently identify long sha? long sha works and are not misinterpreted as branches....

I believe most tools explicitly assume that a 40 character hex string, which is also a legal branch name, is a SHA1. Since this is not great, as it could collide with a real branch name which happens to be 40 characters long, I suspect that no one wants to expand this to create more collisions.

for the future I can think of helper prefix. Something like  revision="sha/12345678"

This suffers the same problem, it is a legal branch name,

-Martin 

Igor Krymgand

unread,
Aug 7, 2025, 4:16:15 PMAug 7
to Repo and Gerrit Discussion
"sha:12345" - this is illegal branch name ... it is not about the syntax - it is about the approach...u can find appropriate syntax if u want

mfick

unread,
Aug 7, 2025, 4:20:39 PMAug 7
to Repo and Gerrit Discussion
On Thursday, August 7, 2025 at 2:16:15 PM UTC-6 igor.k...@gmail.com wrote:
"sha:12345" - this is illegal branch name ... it is not about the syntax - it is about the approach...u can find appropriate syntax if u want

Good point, my bad. FYI, I am not a repo dev, I'm just trying to help you come up with a proposal that will be easy to implement.

I still think it is a bad idea to use short shas in a manifest, it's a bit like using tinyurls, or a search statement,

-Martin

Igor Krymgand

unread,
Aug 7, 2025, 4:27:36 PMAug 7
to Repo and Gerrit Discussion
thanks Martin.

in my case - i get short SHAs as an input ... so it it what it is and I cannot change it ... need to find a way to build a manifest out of short SHAs....

Kai Lei

unread,
Aug 8, 2025, 9:12:27 PMAug 8
to Igor Krymgand, Repo and Gerrit Discussion
based on current code, it can't support short commit id, you might need to update multiple source files like the following to support "sha:short_commit_id"

git_config.py:
ID_RE = re.compile(r"^[0-9a-f]{40}$")
def IsId(rev):
    return ID_RE.match(rev)

project.py:
is_sha1 = bool(IsId(self.revisionExpr))



--
--
To unsubscribe, email repo-discuss...@googlegroups.com
More info at http://groups.google.com/group/repo-discuss?hl=en

---
You received this message because you are subscribed to the Google Groups "Repo and Gerrit Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to repo-discuss...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/repo-discuss/a2d07587-ea4e-42a4-950a-31a266289d22n%40googlegroups.com.

Igor Krymgand

unread,
Aug 9, 2025, 2:55:30 PMAug 9
to Repo and Gerrit Discussion
thanks Kai

I found this code too, I think the possible fix may not be too complicated 

1. update IsID(rev)   implementation to parse short shas , I would choose original git syntax for sha values with ^0 postfix like abcd123^0
 
  I have a strong feeling that nothing else will be needed as now sha values will look like <value>
^0  which is natively acceptable by git....

2. If the above is not enough then maybe update ToLocal implementation in git_config.py to strip ^0 from the rev can complement the solution.

I may try the above locally ....
Reply all
Reply to author
Forward
0 new messages