Skip to content

Commit

Permalink
git clone: Add depth argument
Browse files Browse the repository at this point in the history
  • Loading branch information
Veykril committed Sep 15, 2024
1 parent 23ca20c commit 6ed25c6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
* Initial support for shallow git repositories has been implemented. However
deepening the history of a shallow repository is not yet supported.

* `jj git clone` now accepts a `--depth <DEPTH>` option, which
allows to clone the repository with a given depth.

### Fixed bugs

* Fixed panic when parsing invalid conflict markers of a particular form.
Expand Down
8 changes: 7 additions & 1 deletion cli/src/commands/git/clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use std::fs;
use std::io;
use std::io::Write;
use std::num::NonZeroU32;
use std::path::Path;
use std::path::PathBuf;

Expand Down Expand Up @@ -60,6 +61,9 @@ pub struct GitCloneArgs {
/// Whether or not to colocate the Jujutsu repo with the git repo
#[arg(long)]
colocate: bool,
/// Create a shallow clone of the given depth
#[arg(long)]
depth: Option<NonZeroU32>,
}

fn absolute_git_source(cwd: &Path, source: &str) -> String {
Expand Down Expand Up @@ -132,6 +136,7 @@ pub fn cmd_git_clone(
ui,
command,
args.colocate,
args.depth,
remote_name,
&source,
&canonical_wc_path,
Expand Down Expand Up @@ -195,6 +200,7 @@ fn do_git_clone(
ui: &mut Ui,
command: &CommandHelper,
colocate: bool,
depth: Option<NonZeroU32>,
remote_name: &str,
source: &str,
wc_path: &Path,
Expand All @@ -219,7 +225,7 @@ fn do_git_clone(
git::fetch(
fetch_tx.repo_mut(),
&git_repo,
None,
depth,
remote_name,
&[StringPattern::everything()],
cb,
Expand Down
1 change: 1 addition & 0 deletions cli/tests/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,7 @@ The Git repo will be a bare git repo stored inside the `.jj/` directory.
Default value: `origin`
* `--colocate` — Whether or not to colocate the Jujutsu repo with the git repo
* `--depth <DEPTH>` — Create a shallow clone of the given depth
Expand Down

0 comments on commit 6ed25c6

Please sign in to comment.