From ddf4a58a9115366cc7ce481e6446a79b4bd2fa25 Mon Sep 17 00:00:00 2001 From: Marcel Date: Sat, 25 Jul 2020 11:04:08 +0200 Subject: [PATCH 1/2] add reset command to perform a forced reclone --- lib/git-subrepo | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/git-subrepo b/lib/git-subrepo index 38655703..b77ab813 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,16 @@ main() { # info to the user. #------------------------------------------------------------------------------ +command:reset() { + command-setup +subdir + + local reclone_up_to_date=false + force_wanted=true + subrepo:clone + + say "Subrepo '$subdir' reset to '$subrepo_remote' ($subrepo_branch)." +} + # `git subrepo clone []` command: command:clone() { command-setup +subrepo_remote subdir:guess-subdir @@ -1077,6 +1088,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' From 8a0a1301e79a24efec4fc0daf46156de851489d0 Mon Sep 17 00:00:00 2001 From: Marcel Date: Sat, 25 Jul 2020 11:41:44 +0200 Subject: [PATCH 2/2] subrepo reset now accepts a commit-ish parameter --- lib/git-subrepo | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/git-subrepo b/lib/git-subrepo index b77ab813..5f3b1d47 100755 --- a/lib/git-subrepo +++ b/lib/git-subrepo @@ -180,12 +180,15 @@ main() { #------------------------------------------------------------------------------ command:reset() { - command-setup +subdir + command-setup +subdir forced_commit local reclone_up_to_date=false - force_wanted=true - subrepo:clone + 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)." } @@ -481,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