Skip to content

Add shallow clone support#69

Merged
Boomatang merged 2 commits into
mainfrom
depth_clone
May 9, 2026
Merged

Add shallow clone support#69
Boomatang merged 2 commits into
mainfrom
depth_clone

Conversation

@Boomatang

Copy link
Copy Markdown
Owner

Closes #68

Overview

Introduces the ability to perform shallow clones with a depth of one, significantly improving clone speed when full commit history is not required. This is particularly useful when cloning to temporary directories for quick operations.

Implementation

The -S/--shallow flag has been added to enable shallow cloning. When set, the clone operation uses --depth=1, fetching only the latest commit without history.

How Acceptance Criteria is Met

The issue requested a clone depth flag to improve clone performance. The implementation addresses this by:

  • Default behavior preserved: When the shallow flag is not set, repositories are cloned with full history
  • Fast shallow clones: The -S/--shallow flag triggers a depth-1 clone, eliminating unnecessary history transfer
  • Works with both clone modes: Shallow cloning is supported for both standard clones and worktree-based clones

Note: The current implementation uses a boolean flag for depth-1 clones rather than accepting arbitrary depth values. This simplifies the interface while addressing the primary use case of fast clones without history.

Usage

# Shallow clone to temporary directory
grab -t -S https://github.com/owner/repo

# Shallow clone with standard mode
grab -s -S https://github.com/owner/repo

Additional Changes

Fixed a memory leak in the Configuration cleanup logic by properly freeing allocated path strings in the deinit method.

Boomatang added 2 commits May 9, 2026 14:37
Due to the upgrade to zig 0.16.0 there was memory leak introduced when
cloning to temporary directories, and a panic when the GARB_PATH was set.

Signed-off-by: Jim Fitzpatrick <jimfity@gmail.com>
New flag added to allow the shallow cloning of repos.

Signed-off-by: Jim Fitzpatrick <jimfity@gmail.com>
@Boomatang Boomatang merged commit 59af577 into main May 9, 2026
2 checks passed
@Boomatang Boomatang deleted the depth_clone branch May 9, 2026 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Set Clone Depth

1 participant