From d9d77b27a18c939cb1ca280b2f18e15389ec88ff Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 1 Jul 2018 12:41:40 +0100 Subject: dgit: checkout: New command. Closes:#878443. Signed-off-by: Ian Jackson --- debian/changelog | 3 +++ dgit | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/debian/changelog b/debian/changelog index a45d633..62fb2bc 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,5 +1,8 @@ dgit (5.7~) unstable; urgency=medium + New feature: + * dgit checkout: new subcommand. Closes:#878443. + Bugfixes: * dgit update-vcs-git: Honour --package properly. 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/^-/) { -- cgit v1.2.3