ingydotnet / git-subrepo

MIT License
3.18k stars 263 forks source link

Allow pulling specific sha #590

Closed fherreazcue closed 1 year ago

fherreazcue commented 1 year ago

This is a feature request.

The current behaviour of git subrepo pull <subdir> is to fetch the latest version of the subrepo. Could there be an option to fetch a specific sha, which is not the latest?

As a use case, say a repo called "Big" has a subrepo called "shared", and the current git log subrepo/shared/fetch reads:

commit b8669b1 (refs/subrepo/shared/fetch)
    added stuff with a bug

commit a4ba997
    nice changes wanted in "Big" repo

commit 4ff079ee (refs/subrepo/shared/commit, refs/subrepo/shared/branch, subrepo/shared)
    current version of "shared" subrepo in "Big" repo

The current behaviour only allows to get the latest version (with a bug), but not the "nice changes"... If something like git subrepo pull <subdir> <sha> is implemented, then the "Big" repo could simply do:

git subrepo pull shared a4ba997
admorgan commented 1 year ago

This already works, you can use git subrepo -b <sha> <path> and it will pull up to that SHA, but you can't do a git subrepo push until you change the branch to an actual branch because your SHA doesn't have an appropriate REF.