Skip to content

Commit 254bd68

Browse files
committed
subrepo reset now accepts a commit-ish parameter
1 parent c921237 commit 254bd68

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

lib/git-subrepo

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,15 @@ main() {
180180
#------------------------------------------------------------------------------
181181

182182
command:reset() {
183-
command-setup +subdir
183+
command-setup +subdir forced_commit
184184

185185
local reclone_up_to_date=false
186-
force_wanted=true
187-
subrepo:clone
186+
local force_wanted=true
187+
if [ -n "$forced_commit" ]; then
188+
forced_commit="$(git rev-parse "$forced_commit")"
189+
fi
188190

191+
subrepo:clone
189192
say "Subrepo '$subdir' reset to '$subrepo_remote' ($subrepo_branch)."
190193
}
191194

@@ -481,6 +484,9 @@ subrepo:clone() {
481484
if $force_wanted; then
482485
o "--force indicates a reclone."
483486
CALL subrepo:fetch
487+
if [ -n "$forced_commit" ]; then
488+
upstream_head_commit=$forced_commit
489+
fi
484490
read-gitrepo-file
485491
o "Check if we already are up to date."
486492
if [[ $upstream_head_commit == $subrepo_commit ]]; then

0 commit comments

Comments
 (0)