just playing with tangled
at ig/vimdiffwarn 44 lines 1.7 kB view raw
1// Copyright 2020-2023 The Jujutsu Authors 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// https://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15use jj_lib::git; 16 17use crate::cli_util::CommandHelper; 18use crate::command_error::CommandError; 19use crate::git_util::print_git_import_stats; 20use crate::ui::Ui; 21 22/// Update repo with changes made in the underlying Git repo 23/// 24/// If a working-copy commit gets abandoned, it will be given a new, empty 25/// commit. This is true in general; it is not specific to this command. 26#[derive(clap::Args, Clone, Debug)] 27pub struct GitImportArgs {} 28 29pub fn cmd_git_import( 30 ui: &mut Ui, 31 command: &CommandHelper, 32 _args: &GitImportArgs, 33) -> Result<(), CommandError> { 34 let mut workspace_command = command.workspace_helper(ui)?; 35 let git_settings = workspace_command.settings().git_settings()?; 36 let mut tx = workspace_command.start_transaction(); 37 // In non-colocated repo, Git HEAD will never be moved internally by jj. 38 // That's why cmd_git_export() doesn't export the HEAD ref. 39 git::import_head(tx.repo_mut())?; 40 let stats = git::import_refs(tx.repo_mut(), &git_settings)?; 41 print_git_import_stats(ui, tx.repo(), &stats, true)?; 42 tx.finish(ui, "import git refs")?; 43 Ok(()) 44}