Compare commits

..
7 Commits
Author SHA1 Message Date
Christoph d800417d6d Merge pull request 'Improve global search: Add diffing from results with query highlighting' (#1) from FixSearch into master
publish / publish-tauri (, windows-latest) (release) Successful in 6m34s
Reviewed-on: #1
2026-06-30 18:33:59 +00:00
Christoph Brandau 405f302db9 Improve global search: Add diffing from results with query highlighting
Users can now open a diff for a specific search hit directly from the global search results. The original search query will be highlighted within the diff view, making it easier to locate the relevant changes.

Additionally, add `--no-textconv` to git commands used in search and diff operations. This prevents failures when git encounters binary files that textconv drivers might otherwise attempt to process.
2026-06-30 20:32:59 +02:00
Christoph 2cc1d34fc3 Update version to 0.0.6 2026-06-30 19:19:22 +02:00
Christoph Brandau 089aae5f5b Merge remote-tracking branch 'origin/master'
publish / publish-tauri (, windows-latest) (release) Successful in 7m17s
2026-06-30 19:17:25 +02:00
Christoph Brandau 841d1a41b7 Suppress Git console window on Windows
When executing Git commands on Windows, a console window would briefly flash. This change applies the CREATE_NO_WINDOW flag to prevent this, providing a smoother user experience.
2026-06-30 19:17:17 +02:00
Christoph d57b574fe1 Update version to 0.0.5 2026-06-30 17:27:18 +02:00
Christoph ec1f10d535 Update version to 0.0.3
publish / publish-tauri (, windows-latest) (release) Successful in 6m45s
2026-06-30 16:58:36 +02:00
8 changed files with 127 additions and 40 deletions
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "tauri-git-lite",
"version": "0.0.2",
"version": "0.0.6",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "tauri-git-lite",
"version": "0.0.2",
"version": "0.0.6",
"dependencies": {
"@lucide/svelte": "^1.21.0",
"@tailwindcss/vite": "^4.3.1",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "git-lite",
"version": "0.0.2",
"version": "0.0.6",
"private": true,
"type": "module",
"scripts": {
+34 -17
View File
@@ -12,6 +12,12 @@ use std::{
time::Duration,
};
#[cfg(windows)]
use std::os::windows::process::CommandExt;
#[cfg(windows)]
const CREATE_NO_WINDOW: u32 = 0x08000000;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
#[serde(rename_all = "lowercase")]
pub enum FileStatusKind {
@@ -143,6 +149,13 @@ const EMPTY_TREE_HASH: &str = "4b825dc642cb6eb9a060e54bf8d69288fbee4904";
const SEARCH_CANCELLED_MESSAGE: &str = "Suche wurde abgebrochen.";
static CANCELLABLE_GIT_OUTPUT_COUNTER: AtomicU64 = AtomicU64::new(0);
fn git_command() -> Command {
let mut command = Command::new("git");
#[cfg(windows)]
command.creation_flags(CREATE_NO_WINDOW);
command
}
#[derive(Debug, Default, Clone)]
pub struct SearchCancellationState {
cancelled: Arc<Mutex<BTreeSet<String>>>,
@@ -342,7 +355,7 @@ pub fn pull(
(Some(u), Some(p)) if !u.is_empty() || !p.is_empty() => {
run_git_authenticated_output(&repo, pull_args, u, p)?
}
_ => Command::new("git")
_ => git_command()
.arg("-C")
.arg(&repo)
.args(pull_args)
@@ -429,7 +442,7 @@ pub fn get_remote_url(path: String) -> Result<Option<String>, String> {
}
fn remote_url_for(repo: &Path, remote: &str) -> Option<String> {
let out = Command::new("git")
let out = git_command()
.arg("-C")
.arg(repo)
.args(["remote", "get-url", remote])
@@ -452,7 +465,7 @@ fn upstream_remote_name(repo: &Path) -> Option<String> {
if branch.is_empty() || branch == "HEAD" {
return None;
}
let out = Command::new("git")
let out = git_command()
.arg("-C")
.arg(repo)
.args(["config", &format!("branch.{branch}.remote")])
@@ -530,7 +543,7 @@ pub fn merge_branch(path: String, branch: String) -> Result<GitStatus, String> {
return Err("Branch-Name darf nicht leer sein.".to_string());
}
let output = Command::new("git")
let output = git_command()
.arg("-C")
.arg(&repo)
.args(["merge", "--no-edit", branch])
@@ -1106,7 +1119,7 @@ fn is_binary_bytes(bytes: &[u8]) -> bool {
fn index_stage_size(repo: &Path, stage: u8, file: &str) -> Option<u64> {
let spec = format!(":{stage}:{file}");
let output = Command::new("git")
let output = git_command()
.arg("-C")
.arg(repo)
.args(["cat-file", "-s", spec.as_str()])
@@ -1139,7 +1152,7 @@ pub fn resolve_conflict(path: String, file: String, content: String) -> Result<G
fn read_index_stage(repo: &Path, stage: u8, file: &str) -> Option<String> {
let spec = format!(":{stage}:{file}");
let output = Command::new("git")
let output = git_command()
.arg("-C")
.arg(repo)
.args(["show", spec.as_str()])
@@ -1325,6 +1338,10 @@ fn search_candidate_commits(
OsString::from("--all"),
OsString::from("--reverse"),
OsString::from("--format=%H"),
// Skip textconv diff drivers so git does not extract binary files
// (e.g. .docx / Office temp "~$" lock files) to temp files, which can
// fail with "unsupported filetype" and abort the whole search.
OsString::from("--no-textconv"),
];
if !case_sensitive {
args.push(OsString::from("-i"));
@@ -1369,7 +1386,7 @@ fn max_parent_match_count(
fn read_text_blob(repo: &Path, commit: &str, file: &str) -> Result<Option<String>, String> {
let spec = format!("{commit}:{file}");
let output = Command::new("git")
let output = git_command()
.arg("-C")
.arg(repo)
.args(["show", spec.as_str()])
@@ -1434,7 +1451,7 @@ fn first_added_match_line(
check_search_cancelled(cancellation)?;
let output = run_git_with_paths_cancellable(
repo,
&["diff", "--unified=0", parent, commit],
&["diff", "--no-textconv", "--unified=0", parent, commit],
&[file.to_string()],
cancellation,
"Git-Diff fuer Suchtreffer fehlgeschlagen",
@@ -1823,7 +1840,7 @@ fn local_branch_name_for_remote(remote_branch: &str) -> Option<&str> {
}
fn ref_exists(repo: &Path, ref_name: &str) -> Result<bool, String> {
let output = Command::new("git")
let output = git_command()
.arg("-C")
.arg(repo)
.args(["show-ref", "--verify", "--quiet", ref_name])
@@ -2048,7 +2065,7 @@ where
{
let askpass = write_askpass_script()?;
let result = Command::new("git")
let result = git_command()
.arg("-C")
.arg(repo)
.args(args)
@@ -2157,7 +2174,7 @@ where
let stderr_file = std::fs::File::create(&stderr_path)
.map_err(|err| format!("Git-Fehlerdatei konnte nicht erstellt werden: {err}"))?;
let mut child = Command::new("git")
let mut child = git_command()
.arg("-C")
.arg(repo)
.args(args)
@@ -2218,7 +2235,7 @@ where
I: IntoIterator<Item = S>,
S: AsRef<OsStr>,
{
let output = Command::new("git")
let output = git_command()
.arg("-C")
.arg(path)
.args(args)
@@ -2442,7 +2459,7 @@ mod tests {
I: IntoIterator<Item = S>,
S: AsRef<OsStr>,
{
let output = Command::new("git")
let output = git_command()
.arg("-C")
.arg(repo)
.args(args)
@@ -2463,7 +2480,7 @@ mod tests {
I: IntoIterator<Item = S>,
S: AsRef<OsStr>,
{
let output = Command::new("git")
let output = git_command()
.arg("-C")
.arg(repo)
.args(args)
@@ -2971,7 +2988,7 @@ mod tests {
run_git_test(&repo.path, ["commit", "-q", "-am", "main change"]);
// The merge is expected to fail with a conflict, so run git directly.
let _ = Command::new("git")
let _ = git_command()
.arg("-C")
.arg(&repo.path)
.args(["merge", "--no-edit", "feature"])
@@ -3024,7 +3041,7 @@ mod tests {
fs::write(repo.path.join("file.txt"), "ours change\n").expect("main change");
run_git_test(&repo.path, ["commit", "-q", "-am", "main change"]);
let _ = Command::new("git")
let _ = git_command()
.arg("-C")
.arg(&repo.path)
.args(["merge", "--no-edit", "feature"])
@@ -3065,7 +3082,7 @@ mod tests {
fs::write(repo.path.join("img.bin"), [0u8, 7, 7]).expect("main binary");
run_git_test(&repo.path, ["commit", "-q", "-am", "main bin"]);
let _ = Command::new("git")
let _ = git_command()
.arg("-C")
.arg(&repo.path)
.args(["merge", "--no-edit", "feature"])
+1 -1
View File
@@ -1,7 +1,7 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "GitLite",
"version": "0.0.2",
"version": "0.0.6",
"identifier": "com.git-lite",
"build": {
"beforeDevCommand": "npm run dev",
+32 -13
View File
@@ -96,8 +96,10 @@
let comparison: GitCommitComparison | null = null;
let compareDialogOpen = false;
let selectedDiffPath = "";
let diffHighlightQuery = "";
let pendingRestoreFile: { commit: GitCommit; file: GitCommitFile } | null = null;
let globalSearchOpen = false;
let lastSearchQuery = "";
let globalSearchResults: GitSearchHit[] = [];
let globalSearchBusy = false;
let globalSearchError = "";
@@ -746,6 +748,7 @@
const result = await compareCommits(activeRepoPath, compareFrom, compareTo);
comparison = result;
selectedDiffPath = result.files[0]?.path ?? "";
diffHighlightQuery = "";
pendingRestoreFile = null;
compareDialogOpen = true;
});
@@ -757,6 +760,19 @@
const result = await diffFileAgainstWorkingTree(activeRepoPath, historyCommit.hash, selectedExplorerPath);
comparison = result;
selectedDiffPath = result.files[0]?.path ?? selectedExplorerPath;
diffHighlightQuery = "";
pendingRestoreFile = null;
compareDialogOpen = true;
});
}
async function diffSearchHit(hit: GitSearchHit) {
if (!activeRepoPath) return;
await runOperation(`Diffing ${hit.file}`, async () => {
const result = await diffFileAgainstWorkingTree(activeRepoPath, hit.commit_hash, hit.file);
comparison = result;
selectedDiffPath = result.files[0]?.path ?? hit.file;
diffHighlightQuery = lastSearchQuery;
pendingRestoreFile = null;
compareDialogOpen = true;
});
@@ -785,6 +801,7 @@
if (!activeRepoPath || globalSearchBusy) return;
const searchId = `search-${Date.now()}-${Math.random().toString(36).slice(2)}`;
globalSearchId = searchId;
lastSearchQuery = query;
globalSearchBusy = true;
globalSearchError = "";
globalSearchResults = [];
@@ -1109,19 +1126,6 @@
/>
{/if}
<!-- Compare diff dialog -->
{#if compareDialogOpen && comparison}
<CompareDialog
{comparison}
{selectedDiffPath}
{isBusy}
restoreLabel={pendingRestoreFile ? "Restore file" : ""}
onClose={closeCompareDialog}
onRestore={restorePreviewedCommitFile}
onSelectFile={selectDiffFile}
/>
{/if}
{#if globalSearchOpen}
<GlobalSearchDialog
{hasRepository}
@@ -1132,6 +1136,21 @@
onClose={closeGlobalSearchDialog}
onSearch={runGlobalSearch}
onCancel={cancelGlobalSearch}
onDiff={diffSearchHit}
/>
{/if}
<!-- Compare diff dialog (rendered last so it overlays the search dialog when opened from a hit) -->
{#if compareDialogOpen && comparison}
<CompareDialog
{comparison}
{selectedDiffPath}
{isBusy}
highlightQuery={diffHighlightQuery}
restoreLabel={pendingRestoreFile ? "Restore file" : ""}
onClose={closeCompareDialog}
onRestore={restorePreviewedCommitFile}
onSelectFile={selectDiffFile}
/>
{/if}
+24 -1
View File
@@ -1123,6 +1123,19 @@
.split-cell.add { background: rgba(78,202,118,0.09); color: #5dd88a; }
.split-cell.empty { background: rgba(0,0,0,0.06); }
/* Search-hit highlight: amber, distinct from add (green) / del (red).
Higher specificity so it overrides the add/del backgrounds on a matched line. */
.split-diff .split-cell.match {
background: rgba(240,182,72,0.22);
color: #f3c969;
box-shadow: inset 2px 0 0 rgba(240,182,72,0.9);
}
.split-diff .split-num.match {
background: rgba(240,182,72,0.2);
color: rgba(240,182,72,0.9);
border-right-color: rgba(240,182,72,0.35);
}
.split-col-headers {
display: grid;
grid-template-columns: 1fr 1fr;
@@ -1254,11 +1267,21 @@
}
.search-hit-top {
display: grid;
grid-template-columns: auto minmax(0, 1fr) auto;
grid-template-columns: auto minmax(0, 1fr) auto auto;
align-items: center;
gap: 8px;
min-width: 0;
}
.search-hit-diff {
display: inline-flex;
align-items: center;
gap: 5px;
padding: 3px 9px;
font-size: 11px;
font-weight: 800;
letter-spacing: 0.04em;
white-space: nowrap;
}
.search-hit-top .hash {
padding: 2px 7px;
border: 1px solid rgba(90,140,248,0.22);
+20 -4
View File
@@ -15,6 +15,8 @@
selectedDiffPath: string;
isBusy: boolean;
restoreLabel?: string;
/** When opened from a search hit, the term to highlight on matching lines. */
highlightQuery?: string;
onClose: () => void;
onRestore?: () => void;
onSelectFile: (file: GitDiffFile) => void;
@@ -25,11 +27,25 @@
selectedDiffPath = "",
isBusy = false,
restoreLabel = "",
highlightQuery = "",
onClose = () => {},
onRestore = undefined,
onSelectFile = () => {},
}: Props = $props();
// Needle = first non-empty line of the search query, lowercased for matching.
let highlightNeedle = $derived(
highlightQuery
.split("\n")
.map((line) => line.trim())
.find((line) => line.length > 0)
?.toLowerCase() ?? ""
);
function isMatch(text?: string): boolean {
return highlightNeedle.length > 0 && !!text && text.toLowerCase().includes(highlightNeedle);
}
let beforePane = $state<HTMLDivElement | null>(null);
let afterPane = $state<HTMLDivElement | null>(null);
let isSyncingSplitScroll = false;
@@ -259,8 +275,8 @@
{#if row.type === "span"}
<div class="split-span split-{row.kind}">{row.text}</div>
{:else}
<div class="split-num" class:del={row.leftKind === "del"} class:empty={row.leftKind === "empty"}>{row.leftNum ?? ""}</div>
<div class="split-cell" class:del={row.leftKind === "del"} class:empty={row.leftKind === "empty"}>{row.leftText ?? " "}</div>
<div class="split-num" class:del={row.leftKind === "del"} class:empty={row.leftKind === "empty"} class:match={isMatch(row.leftText)}>{row.leftNum ?? ""}</div>
<div class="split-cell" class:del={row.leftKind === "del"} class:empty={row.leftKind === "empty"} class:match={isMatch(row.leftText)}>{row.leftText ?? " "}</div>
{/if}
{/each}
</div>
@@ -276,8 +292,8 @@
{#if row.type === "span"}
<div class="split-span split-{row.kind}">{row.text}</div>
{:else}
<div class="split-num" class:add={row.rightKind === "add"} class:empty={row.rightKind === "empty"}>{row.rightNum ?? ""}</div>
<div class="split-cell" class:add={row.rightKind === "add"} class:empty={row.rightKind === "empty"}>{row.rightText ?? " "}</div>
<div class="split-num" class:add={row.rightKind === "add"} class:empty={row.rightKind === "empty"} class:match={isMatch(row.rightText)}>{row.rightNum ?? ""}</div>
<div class="split-cell" class:add={row.rightKind === "add"} class:empty={row.rightKind === "empty"} class:match={isMatch(row.rightText)}>{row.rightText ?? " "}</div>
{/if}
{/each}
</div>
+13 -1
View File
@@ -1,5 +1,5 @@
<script lang="ts">
import { CalendarDays, FileCode, LoaderCircle, Search, User, X } from "@lucide/svelte";
import { CalendarDays, FileCode, GitCompare, LoaderCircle, Search, User, X } from "@lucide/svelte";
import type { GitSearchHit } from "../types";
interface Props {
@@ -11,6 +11,7 @@
onClose: () => void;
onSearch: (query: string, caseSensitive: boolean, limit: number) => void | Promise<void>;
onCancel: () => void | Promise<void>;
onDiff: (hit: GitSearchHit) => void | Promise<void>;
}
let {
@@ -22,6 +23,7 @@
onClose = () => {},
onSearch = () => {},
onCancel = () => {},
onDiff = () => {},
}: Props = $props();
let query = $state("");
@@ -148,6 +150,16 @@
{#if hit.matches_added > 1}
<span class="pill pill-active">+{hit.matches_added} matches</span>
{/if}
<button
class="btn-secondary search-hit-diff"
type="button"
disabled={isBusy}
title={`Compare this version of ${hit.file} with the current version`}
onclick={() => onDiff(hit)}
>
<GitCompare size={14} aria-hidden="true" />
DIFF
</button>
</header>
<div class="search-hit-meta">