summaryrefslogtreecommitdiff
path: root/dgit
diff options
context:
space:
mode:
authorIan Jackson <ijackson@chiark.greenend.org.uk>2018-07-01 12:41:40 +0100
committerIan Jackson <ijackson@chiark.greenend.org.uk>2018-07-04 01:59:22 +0100
commitd9d77b27a18c939cb1ca280b2f18e15389ec88ff (patch)
tree652e7cab73667b032d890a2d149753991d625858 /dgit
parent66d6b40a1474ef84fe0e4a68bd7428f5ab1b0e31 (diff)
dgit: checkout: New command.
Closes:#878443. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Diffstat (limited to 'dgit')
-rwxr-xr-xdgit34
1 files changed, 34 insertions, 0 deletions
diff --git a/dgit b/dgit
index c7336dd..ca57375 100755
--- a/dgit
+++ b/dgit
@@ -4643,6 +4643,40 @@ END
pull();
}
+sub cmd_checkout {
+ parseopts();
+ package_from_d_control();
+ @ARGV==1 or badusage "dgit checkout needs a suite argument";
+ ($isuite) = @ARGV;
+ notpushing();
+
+ foreach my $canon (qw(0 1)) {
+ if (!$canon) {
+ $csuite= $isuite;
+ } else {
+ undef $csuite;
+ canonicalise_suite();
+ }
+ if (length git_get_ref lref()) {
+ # local branch already exists, yay
+ last;
+ }
+ if (!length git_get_ref lrref()) {
+ if (!$canon) {
+ # nope
+ next;
+ }
+ dofetch();
+ }
+ # now lrref exists
+ runcmd (@git, qw(update-ref), lref(), lrref(), '');
+ last;
+ }
+ local $ENV{GIT_REFLOG_ACTION} = git_reflog_action_msg
+ "dgit checkout $isuite";
+ runcmd (@git, qw(checkout), lref());
+}
+
sub cmd_update_vcs_git () {
my $specsuite;
if (@ARGV==0 || $ARGV[0] =~ m/^-/) {