Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Backend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ fn build_invoke_handler<R: tauri::Runtime>() -> impl Fn(tauri::ipc::Invoke<R>) -
tauri_commands::show_licenses,
tauri_commands::browse_directory,
tauri_commands::add_repo,
tauri_commands::list_backends_cmd,
tauri_commands::set_backend_cmd,
tauri_commands::validate_git_url,
tauri_commands::validate_add_path,
tauri_commands::validate_clone_input,
Expand Down
2 changes: 1 addition & 1 deletion Backend/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub struct AppState {
impl AppState {
pub fn new_with_config() -> Self {
let cfg = AppConfig::load_or_default(); // reads ~/.config/openvcs/openvcs.conf
let mut s = Self {
let s = Self {
config: RwLock::new(cfg),
repo_config: RwLock::new(RepoConfig::default()),
..Default::default()
Expand Down
3 changes: 1 addition & 2 deletions Backend/src/tauri_commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,5 @@ pub use updater::*;
pub use themes::*;

pub(crate) use shared::{
current_repo_or_err, get_repo_root, lfs_config, progress_bridge, run_repo_task, LfsEnvGuard,
ProgressPayload,
current_repo_or_err, lfs_config, progress_bridge, run_repo_task, LfsEnvGuard, ProgressPayload,
};
9 changes: 1 addition & 8 deletions Backend/src/tauri_commands/shared.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::path::{Path, PathBuf};
use std::path::PathBuf;
use std::sync::Arc;

use openvcs_core::models::VcsEvent;
Expand Down Expand Up @@ -117,10 +117,3 @@ impl Drop for LfsEnvGuard {
}
}
}

pub(crate) fn get_repo_root(state: &State<'_, AppState>) -> Result<PathBuf, String> {
state
.current_repo()
.map(|repo| repo.inner().workdir().to_path_buf())
.ok_or_else(|| "No repository selected".to_string())
}
35 changes: 13 additions & 22 deletions crates/openvcs-git-libgit2/src/lowlevel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,8 @@ impl Git {
}

// 2) Remote branch name like "origin/feature"
let mut tried_remote = false;
if name.contains('/') {
if repo.find_branch(name, g::BranchType::Remote).is_ok() {
tried_remote = true;
let local = name.split('/').last().unwrap_or(name);
if repo.find_branch(local, g::BranchType::Local).is_err() {
// Create local branch at the remote target
Expand All @@ -272,22 +270,20 @@ impl Git {
}

// 3) Try default remote "origin/<name>"
if !tried_remote {
let remote_short = format!("origin/{name}");
if repo.find_branch(&remote_short, g::BranchType::Remote).is_ok() {
let local = name;
if repo.find_branch(local, g::BranchType::Local).is_err() {
let rb = repo.find_branch(&remote_short, g::BranchType::Remote)?;
let target = rb.get().target().ok_or_else(|| g::Error::from_str("remote branch has no target"))?;
let commit = repo.find_commit(target)?;
repo.branch(local, &commit, false)?;
let mut lb = repo.find_branch(local, g::BranchType::Local)?;
lb.set_upstream(Some(&remote_short))?;
}
checkout_ref(repo, &format!("refs/heads/{local}"))?;
info!("created and checked out tracking branch '{}' for remote '{}'", local, remote_short);
return Ok(());
let remote_short = format!("origin/{name}");
if repo.find_branch(&remote_short, g::BranchType::Remote).is_ok() {
let local = name;
if repo.find_branch(local, g::BranchType::Local).is_err() {
let rb = repo.find_branch(&remote_short, g::BranchType::Remote)?;
let target = rb.get().target().ok_or_else(|| g::Error::from_str("remote branch has no target"))?;
let commit = repo.find_commit(target)?;
repo.branch(local, &commit, false)?;
let mut lb = repo.find_branch(local, g::BranchType::Local)?;
lb.set_upstream(Some(&remote_short))?;
}
checkout_ref(repo, &format!("refs/heads/{local}"))?;
info!("created and checked out tracking branch '{}' for remote '{}'", local, remote_short);
return Ok(());
}

// 4) Fallback to local ref (may detach if it's a commit)
Expand All @@ -297,7 +293,6 @@ impl Git {
})
}


pub fn ensure_remote(&self, name: &str, url: &str) -> Result<()> {
info!("ensuring remote '{name}' points to '{url}'");

Expand Down Expand Up @@ -371,10 +366,6 @@ impl Git {
})
}

pub fn fetch(&self, remote: &str, refspec: &str) -> Result<Option<Oid>> {
self.fetch_with_progress(remote, refspec, |_| {})
}

pub fn fast_forward(&self, upstream: &str) -> Result<()> {
info!("fetch + fast-forward to '{upstream}'");

Expand Down
2 changes: 1 addition & 1 deletion crates/openvcs-git/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ impl Vcs for GitSystem {
}
if let Err(_) = Self::run_git(Some(&self.workdir), args.clone()) {
for p in paths {
let mut single = vec!["restore".to_string(), "--staged".into(), "--worktree".into(), "--source=HEAD".into(), "--".into(), Self::path_str(p)?.to_string()];
let single = vec!["restore".to_string(), "--staged".into(), "--worktree".into(), "--source=HEAD".into(), "--".into(), Self::path_str(p)?.to_string()];
let _ = Self::run_git(Some(&self.workdir), single);
}
}
Expand Down
Loading