Skip to content

fix(git): use origin as remote name#8626

Merged
jdx merged 1 commit intojdx:mainfrom
bentinata:fix/clone-remote-origin
Mar 19, 2026
Merged

fix(git): use origin as remote name#8626
jdx merged 1 commit intojdx:mainfrom
bentinata:fix/clone-remote-origin

Conversation

@bentinata
Copy link
Copy Markdown
Contributor

Remote name "origin" is assumed during fetch.
There's no simple way to get current upstream remote name using git.

  1. branch_name = git symbolic-ref --short HEAD
  2. remote_name = git config branch.$(branch_name).remote
  3. git fetch $(remote_name)

Instead of fixing how we fetch, this fix how we clone instead.
This may fix: #5299

Remote name "origin" is assumed during fetch.
There's no simple way to get current upstream remote name using git.

1. branch_name = git symbolic-ref --short HEAD
2. remote_name = git config branch.$(branch_name).remote
3. git fetch $(remote_name)

Instead of fixing how we fetch, this fix how we clone instead.
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a modification to the git clone command within the application's Git utility. By explicitly specifying "origin" as the remote name during cloning, the change ensures that subsequent Git operations, particularly git fetch, consistently interact with the expected remote. This standardization helps prevent potential issues arising from differing remote names and improves the reliability of Git operations within the system.

Highlights

  • Git Clone Remote Name: The git clone command now explicitly sets the remote name to "origin" using the -o origin flag.
  • Addressing Fetch Assumptions: This change aims to resolve issues where git fetch implicitly assumes the remote name "origin" by ensuring consistency during the cloning process.
Changelog
  • src/git.rs
    • Modified the git clone command to include the -o origin flag, explicitly setting the remote name.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Mar 17, 2026

Greptile Summary

This PR adds -o origin to the git clone CLI invocation in src/git.rs to explicitly force the remote name to "origin". Without this flag, a user whose global or system git config sets clone.defaultRemoteName to a non-"origin" value would end up with a cloned repository whose remote has a different name, causing all subsequent git fetch origin …, git ls-remote origin …, and git config --get remote.origin.url calls to fail because they all hard-code "origin" as the remote name.

Key changes:

  • clone() (CLI path): adds .arg("-o").arg("origin") before the repository URL so the remote is always named "origin".
  • The gix / libgit2 code path (gix::prepare_clone) is not changed; gix defaults to "origin" for new clones and is not affected by clone.defaultRemoteName in the same way.
  • The string literal "origin" is now used in five places in the file (clone, update_ref, get_remote_url ×2, remote_sha). Extracting it to a module-level constant would improve maintainability, but is not required for correctness.

Confidence Score: 5/5

  • Safe to merge — a minimal, targeted fix with no risk of regression.
  • The change is exactly two lines that pass a well-documented git flag. It only affects the CLI clone path, has no side effects on the gix path, and directly aligns the cloned remote name with every downstream caller that already assumes "origin". The fix is correct and non-breaking.
  • No files require special attention.

Important Files Changed

Filename Overview
src/git.rs Adds -o origin to the git clone CLI invocation to explicitly name the remote "origin", ensuring consistency with all downstream fetch/ls-remote calls that hard-code "origin".

Sequence Diagram

sequenceDiagram
    participant Caller
    participant Git as Git (src/git.rs)
    participant GitCLI as git (CLI)

    Caller->>Git: clone(url, options)
    alt libgit2 / gix enabled
        Git->>GitCLI: gix::prepare_clone(url, dir)<br/>(remote name defaults to "origin" in gix)
    else CLI path (default)
        Git->>GitCLI: git clone -q -o origin -c core.autocrlf=false --depth 1 url dir
        Note over GitCLI: -o origin explicitly names<br/>the remote "origin"
    end

    Caller->>Git: update(gitref)
    Git->>GitCLI: git fetch --prune --update-head-ok origin refspec
    Note over GitCLI: Assumes remote is named "origin"

    Caller->>Git: get_remote_url()
    Git->>GitCLI: git config --get remote.origin.url
    Note over GitCLI: Assumes remote is named "origin"

    Caller->>Git: remote_sha(branch)
    Git->>GitCLI: git ls-remote origin branch
    Note over GitCLI: Assumes remote is named "origin"
Loading

Last reviewed commit: 639e42c

Comment thread src/git.rs
Comment on lines +154 to +155
.arg("-o")
.arg("origin")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Consider extracting "origin" to a named constant

With this change, the string literal "origin" now appears in five separate places in the file: here in clone, in update_ref (line 98), in get_remote_url (lines 265 and 271), and in remote_sha (line 292). Introducing a single module-level constant would make future remote-name changes trivial and document the intent clearly:

const REMOTE_NAME: &str = "origin";

This is purely a maintainability suggestion — the current change is correct as-is.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request modifies the git clone command to explicitly set the remote name to origin. This change ensures consistency with other parts of the codebase that assume origin as the remote name for operations like fetch and ls-remote. By enforcing this at clone time, it pragmatically resolves potential issues where a user's Git configuration might specify a different default remote name. The change is correct and I have no further feedback.

@jdx jdx merged commit e7edef4 into jdx:main Mar 19, 2026
33 of 35 checks passed
jdx pushed a commit that referenced this pull request Mar 21, 2026
### 🐛 Bug Fixes

- **(config)** resolve trust hash collision for same-name directories by
@tdragon in [#8628](#8628)
- **(docs)** fix width of tools table by @himkt in
[#8625](#8625)
- **(docs)** prevent homepage hero atmosphere overflow by @nygmaaa in
[#8642](#8642)
- **(doctor)** detect PATH ordering issues when mise is activated by
@jdx in [#8585](#8585)
- **(git)** use origin as remote name by @bentinata in
[#8626](#8626)
- **(installer)** normalize current version before comparison by @tak848
in [#8649](#8649)
- **(lockfile)** Resolve symlink when updating lockfiles by @chancez in
[#8589](#8589)
- **(python)** verify checksums for precompiled binary downloads by
@malept in [#8593](#8593)
- **(rust)** resolve relative CARGO_HOME/RUSTUP_HOME to absolute paths
by @simonepri in [#8604](#8604)
- **(task)** correctly resolve task name for _default files with
extensions by @youta1119 in
[#8646](#8646)
- **(tasks)** global file tasks not properly marked as such by @roele in
[#8618](#8618)
- **(tasks)** handle broken pipe in table print and task completion
output by @vmaleze in [#8608](#8608)
- use dark/light logo variants in README for GitHub dark mode by @jdx in
[#8656](#8656)
- failing rebuild of runtime symlinks for shared tools by @roele in
[#8647](#8647)
- add spaces around current element operator in flutter version_expr by
@roele in [#8616](#8616)
- complete task arguments correctly by @KevSlashNull in
[#8601](#8601)

### 📚 Documentation

- switch body font to DM Sans and darken dark mode background by @jdx in
[6e3ad34](6e3ad34)
- use Cormorant Garamond for headers and Roc Grotesk for body text by
@jdx in
[010812a](010812a)
- resolve chaotic heading hierarchy in task-arguments.md by @muzimuzhi
in [#8644](#8644)

### 🧪 Testing

- fix test_java and mark as slow by @roele in
[#8634](#8634)

### 📦️ Dependency Updates

- update docker/dockerfile:1 docker digest to 4a43a54 by @renovate[bot]
in [#8657](#8657)
- update ghcr.io/jdx/mise:alpine docker digest to 2584470 by
@renovate[bot] in [#8658](#8658)

### 📦 Registry

- add viteplus (npm:vite-plus) by @risu729 in
[#8594](#8594)
- remove backend.options for podman by @roele in
[#8633](#8633)
- add pi.dev coding agent by @dector in
[#8635](#8635)
- add ormolu ([github:tweag/ormolu](https://github.com/tweag/ormolu)) by
@3w36zj6 in [#8617](#8617)
- use version_expr for dart and sort versions by @roele in
[#8631](#8631)

### New Contributors

- @bentinata made their first contribution in
[#8626](#8626)
- @tdragon made their first contribution in
[#8628](#8628)
- @nygmaaa made their first contribution in
[#8642](#8642)
- @youta1119 made their first contribution in
[#8646](#8646)
- @chancez made their first contribution in
[#8589](#8589)
- @dector made their first contribution in
[#8635](#8635)
- @tak848 made their first contribution in
[#8649](#8649)

## 📦 Aqua Registry Updates

#### New Packages (5)

- [`acsandmann/rift`](https://github.com/acsandmann/rift)
-
[`alltuner/mise-completions-sync`](https://github.com/alltuner/mise-completions-sync)
- [`berbicanes/apiark`](https://github.com/berbicanes/apiark)
-
[`gitlab.com/graphviz/graphviz`](https://github.com/gitlab.com/graphviz/graphviz)
-
[`jorgelbg/pinentry-touchid`](https://github.com/jorgelbg/pinentry-touchid)

#### Updated Packages (7)

- [`UpCloudLtd/upcloud-cli`](https://github.com/UpCloudLtd/upcloud-cli)
- [`aquaproj/registry-tool`](https://github.com/aquaproj/registry-tool)
- [`go-swagger/go-swagger`](https://github.com/go-swagger/go-swagger)
-
[`gopinath-langote/1build`](https://github.com/gopinath-langote/1build)
- [`sassman/t-rec-rs`](https://github.com/sassman/t-rec-rs)
- [`sharkdp/fd`](https://github.com/sharkdp/fd)
- [`temporalio/cli`](https://github.com/temporalio/cli)
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.

2 participants