diff --git a/lib/git-subrepo b/lib/git-subrepo index 38655703..5f3b1d47 100755 --- a/lib/git-subrepo +++ b/lib/git-subrepo @@ -37,6 +37,7 @@ git subrepo Commands: clone Clone a remote repository into a local subdirectory init Turn a current subdirectory into a subrepo + reset Reset subrepo performing a forced reclone pull Pull upstream changes to the subrepo push Push local subrepo changes upstream @@ -178,6 +179,19 @@ main() { # info to the user. #------------------------------------------------------------------------------ +command:reset() { + command-setup +subdir forced_commit + + local reclone_up_to_date=false + local force_wanted=true + if [ -n "$forced_commit" ]; then + forced_commit="$(git rev-parse "$forced_commit")" + fi + + subrepo:clone + say "Subrepo '$subdir' reset to '$subrepo_remote' ($subrepo_branch)." +} + # `git subrepo clone []` command: command:clone() { command-setup +subrepo_remote subdir:guess-subdir @@ -470,6 +484,9 @@ subrepo:clone() { if $force_wanted; then o "--force indicates a reclone." CALL subrepo:fetch + if [ -n "$forced_commit" ]; then + upstream_head_commit=$forced_commit + fi read-gitrepo-file o "Check if we already are up to date." if [[ $upstream_head_commit == $subrepo_commit ]]; then @@ -1077,6 +1094,7 @@ get-command-options() { } options_help='all' +options_reset='branch remote' options_branch='all fetch force' options_clean='ALL all force' options_clone='branch edit force message method'