diff --git a/.gitignore b/.gitignore index c9e483e1..45793f1e 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ target/ target .mooncakes/ .moonagent/ +.flaker/ .repos/ .jj/tools/git-shim/shim.log tools/git-shim/shim.log diff --git a/flaker.toml b/flaker.toml new file mode 100644 index 00000000..05c4727a --- /dev/null +++ b/flaker.toml @@ -0,0 +1,28 @@ +[repo] +owner = "bit-vcs" +name = "bit" + +[storage] +path = ".flaker/data" + +[adapter] +type = "command" + +[runner] +type = "custom" +command = "git-compat" +list = "node tools/flaker-list-git-compat-tests.mjs" +execute = "node tools/flaker-run-git-compat-tests.mjs" + +[affected] +resolver = "glob" +config = "tools/flaker-affected-rules.toml" + +[quarantine] +auto = true +flaky_rate_threshold = 0.3 +min_runs = 5 + +[flaky] +window_days = 14 +detection_threshold = 0.1 diff --git a/justfile b/justfile index bc4ac637..4f6ca47c 100644 --- a/justfile +++ b/justfile @@ -30,6 +30,9 @@ test: moon test --target wasm -p mizchi/bit/runtime -f storage_runtime_wbtest.mbt moon test --target native --no-parallelize -j 1 just test-git-compat-allowlist + just test-flaker-affected-rules + just test-flaker-cli-wrapper + just test-flaker-git-compat just test-js-build # Update snapshot tests (both js and native) @@ -100,6 +103,18 @@ test-js-build: sync-npm-lib-raw sync-npm-bit-cjs bundle-js-lib-minimal bundle-js test-git-compat-allowlist: node --test tools/git-compat-allowlist.test.mjs +# Verify flaker-focused git-compat inventory helpers +test-flaker-git-compat: + node --test tools/flaker-git-compat.test.mjs + +# Verify flaker git-compat affected mapping config and examples +test-flaker-affected-rules: + node --test tools/flaker-affected-rules.test.mjs + +# Verify flaker CLI wrapper guidance for unsupported resolver versions +test-flaker-cli-wrapper: + node --test tools/flaker-cli-wrapper.test.mjs + # Verify JS-exported lib on a pure in-memory host test-js-lib: build-js-lib node tools/verify-libgit2-js.mjs @@ -363,6 +378,46 @@ compat-random-run: compat-random-aggregate results_dir="compat-random-results": bash tools/aggregate-git-compat-random.sh {{results_dir}} +# Focused local git-compat sampling via flaker +flaker-git-compat-sample strategy="weighted" count="25" changed="": + @if ! command -v flaker >/dev/null 2>&1; then \ + echo "flaker CLI is required; install @mizchi/flaker first" >&2; \ + exit 1; \ + fi + @if { [ "{{strategy}}" = "affected" ] || [ "{{strategy}}" = "hybrid" ]; } && [ -z "{{changed}}" ]; then \ + echo "changed=... is required when strategy={{strategy}}" >&2; \ + exit 1; \ + fi + @args="sample --strategy {{strategy}} --count {{count}}"; \ + if [ -n "{{changed}}" ]; then \ + args="$args --changed {{changed}}"; \ + fi; \ + node tools/flaker-cli-wrapper.mjs $args + +# Focused local git-compat execution via flaker +flaker-git-compat-run strategy="weighted" count="25" changed="": build + @if ! command -v flaker >/dev/null 2>&1; then \ + echo "flaker CLI is required; install @mizchi/flaker first" >&2; \ + exit 1; \ + fi + @if { [ "{{strategy}}" = "affected" ] || [ "{{strategy}}" = "hybrid" ]; } && [ -z "{{changed}}" ]; then \ + echo "changed=... is required when strategy={{strategy}}" >&2; \ + exit 1; \ + fi + @args="run --strategy {{strategy}} --count {{count}}"; \ + if [ -n "{{changed}}" ]; then \ + args="$args --changed {{changed}}"; \ + fi; \ + node tools/flaker-cli-wrapper.mjs $args + +# Inspect which git-compat suites flaker sees as affected +flaker-git-compat-affected changed: + @if ! command -v flaker >/dev/null 2>&1; then \ + echo "flaker CLI is required; install @mizchi/flaker first" >&2; \ + exit 1; \ + fi + node tools/flaker-cli-wrapper.mjs affected --changed {{changed}} + # Trigger Git Compat Randomized workflow via workflow_dispatch compat-random-dispatch shards="1" ratio="50" target_shard="0" seed="": @if ! command -v gh >/dev/null 2>&1; then \ diff --git a/moon.mod.json b/moon.mod.json index 67053d05..b5d166d3 100644 --- a/moon.mod.json +++ b/moon.mod.json @@ -1,13 +1,13 @@ { "name": "mizchi/bit", - "version": "0.39.0", + "version": "0.39.2", "deps": { "moonbitlang/async": "0.16.6", "mizchi/zlib": "0.3.0", "moonbitlang/x": "0.4.40", "mizchi/tempfile": "0.1.0", "mizchi/llm": "0.2.2", - "mizchi/bitflow": "0.3.1", + "mizchi/bitflow": "0.4.0", "mizchi/x": "0.1.4", "bobzhang/toml": "0.1.7", "mizchi/libgit2": "0.1.0" diff --git a/src/apply/apply.mbt b/src/apply/apply.mbt index dc0cd788..65c900da 100644 --- a/src/apply/apply.mbt +++ b/src/apply/apply.mbt @@ -20,11 +20,11 @@ pub fn reverse_patch(patch : String) -> String { let lines : Array[String] = [] for line_view in patch.split("\n") { let line = line_view.to_string() - if line.has_prefix("+") && !(line.has_prefix("+++")) { + if line.has_prefix("+") && !line.has_prefix("+++") { lines.push( "-" + String::unsafe_substring(line, start=1, end=line.length()), ) - } else if line.has_prefix("-") && !(line.has_prefix("---")) { + } else if line.has_prefix("-") && !line.has_prefix("---") { lines.push( "+" + String::unsafe_substring(line, start=1, end=line.length()), ) @@ -56,7 +56,7 @@ pub fn parse_patches(patch : String) -> Array[PatchInfo] { let line = all_lines[i] // Detect start of a diff (git format or non-git format) let is_git_diff = line.has_prefix("diff --git ") - let is_nongit_diff = !(is_git_diff) && line.has_prefix("diff ") + let is_nongit_diff = !is_git_diff && line.has_prefix("diff ") if is_git_diff || is_nongit_diff { let mut old_name = "" let mut new_name = "" @@ -208,11 +208,11 @@ pub fn parse_patches(patch : String) -> Array[PatchInfo] { break } if hunkline.has_prefix("+") && - !(hunkline.has_prefix("+++ ")) && + !hunkline.has_prefix("+++ ") && hunkline != "+++" { additions += 1 } else if hunkline.has_prefix("-") && - !(hunkline.has_prefix("--- ")) && + !hunkline.has_prefix("--- ") && hunkline != "---" { deletions += 1 } diff --git a/src/cmd/bit/add.mbt b/src/cmd/bit/add.mbt index b8a919a7..62260399 100644 --- a/src/cmd/bit/add.mbt +++ b/src/cmd/bit/add.mbt @@ -29,7 +29,7 @@ async fn run_add_hook( ) -> Int { let hook_git_dir = add_abs_path(git_dir) let hook_path = hook_git_dir + "/hooks/" + hook_name - if !(fs.is_file(hook_path)) { + if !fs.is_file(hook_path) { return 0 } @process.run(hook_path, [], inherit_env=true, cwd=add_abs_path(root)) catch { @@ -110,39 +110,39 @@ async fn handle_add(args : Array[String]) -> Unit raise Error { let paths : Array[String] = [] for raw_arg in args { let arg = raw_arg - if !(end_of_options) && arg == "--" { + if !end_of_options && arg == "--" { end_of_options = true continue } match arg { - "-A" | "--all" if !(end_of_options) => add_all = true - "-u" | "--update" if !(end_of_options) => update_only = true - "--no-all" | "--ignore-removal" if !(end_of_options) => + "-A" | "--all" if !end_of_options => add_all = true + "-u" | "--update" if !end_of_options => update_only = true + "--no-all" | "--ignore-removal" if !end_of_options => ignore_removal = true - "-f" | "--force" if !(end_of_options) => force = true - "--refresh" if !(end_of_options) => refresh = true - "-N" | "--intent-to-add" if !(end_of_options) => intent_to_add = true - "-n" | "--dry-run" if !(end_of_options) => dry_run = true - "--ignore-missing" if !(end_of_options) => ignore_missing = true - "--ignore-errors" if !(end_of_options) => { + "-f" | "--force" if !end_of_options => force = true + "--refresh" if !end_of_options => refresh = true + "-N" | "--intent-to-add" if !end_of_options => intent_to_add = true + "-n" | "--dry-run" if !end_of_options => dry_run = true + "--ignore-missing" if !end_of_options => ignore_missing = true + "--ignore-errors" if !end_of_options => { ignore_errors = true ignore_errors_explicit = true } - "--no-ignore-errors" if !(end_of_options) => { + "--no-ignore-errors" if !end_of_options => { ignore_errors = false ignore_errors_explicit = true } - "-v" | "--verbose" if !(end_of_options) => verbose = true - "--interactive" if !(end_of_options) => interactive = true - "--chmod=+x" if !(end_of_options) => chmod_mode = Some("+x") - "--chmod=-x" if !(end_of_options) => chmod_mode = Some("-x") - _ if end_of_options || !(arg.has_prefix("-")) => paths.push(arg) + "-v" | "--verbose" if !end_of_options => verbose = true + "--interactive" if !end_of_options => interactive = true + "--chmod=+x" if !end_of_options => chmod_mode = Some("+x") + "--chmod=-x" if !end_of_options => chmod_mode = Some("-x") + _ if end_of_options || !arg.has_prefix("-") => paths.push(arg) _ if arg.has_prefix("-") => warn_unimplemented_arg("add", arg) _ => () } } // Read add.ignore-errors config (only if not explicitly set via CLI flag) - if !(ignore_errors_explicit) { + if !ignore_errors_explicit { let rfs2 : &@bitcore.RepoFileSystem = fs let config_path2 = git_dir + "/config" if fs.is_file(config_path2) { @@ -220,7 +220,7 @@ async fn handle_add(args : Array[String]) -> Unit raise Error { } return } - if paths.length() == 0 && !(update_only) { + if paths.length() == 0 && !update_only { eprint_line("Nothing specified, nothing added.") if add_should_show_empty_pathspec_hint(fs, root) { eprint_line("hint: Maybe you wanted to say 'git add .'?") @@ -236,7 +236,7 @@ async fn handle_add(args : Array[String]) -> Unit raise Error { expand_add_stage_paths(fs, root, paths, force) } let requested_stage_paths = requested_paths - let stage_paths = if ignore_removal && !(update_only) { + let stage_paths = if ignore_removal && !update_only { let unmerged_paths = @bitlib.read_unmerged_paths(fs, git_dir) match add_filter_stage_paths_for_no_all( @@ -323,7 +323,7 @@ async fn handle_add(args : Array[String]) -> Unit raise Error { } } } - if !(force) && add_has_explicit_ignored_path(fs, root, paths) { + if !force && add_has_explicit_ignored_path(fs, root, paths) { eprint_line( "The following paths are ignored by one of your .gitignore files.", ) @@ -391,7 +391,7 @@ fn add_apply_intent_to_add( continue } let abs = root + "/" + path - if !(rfs.is_file(abs)) { + if !rfs.is_file(abs) { continue } let id = match empty_id { @@ -465,7 +465,7 @@ async fn add_collect_update_requested_paths( selected[path] = true } } - if !(matched) { + if !matched { eprint_line( "error: pathspec '\{raw}' did not match any file(s) known to git", ) @@ -546,7 +546,7 @@ async fn handle_add_dry_run( } let stage_paths = expand_add_stage_paths(fs, root, paths, force) let unmatched = add_collect_unmatched_pathspecs(fs, root, paths, force) - if unmatched.length() > 0 && !(ignore_missing) { + if unmatched.length() > 0 && !ignore_missing { eprint_line("fatal: pathspec '\{unmatched[0]}' did not match any files") @sys.exit(1) } @@ -601,7 +601,7 @@ async fn add_collect_unmatched_pathspecs( let normalized = normalize_add_path(entry.path) tracked[normalized] = true let folded = normalized.to_lower() - if !(tracked_folded.contains(folded)) { + if !tracked_folded.contains(folded) { tracked_folded[folded] = normalized } } @@ -615,7 +615,7 @@ async fn add_collect_unmatched_pathspecs( for p in visible_paths { visible_map[p] = true let folded = p.to_lower() - if !(visible_folded.contains(folded)) { + if !visible_folded.contains(folded) { visible_folded[folded] = p } } @@ -639,7 +639,7 @@ async fn add_collect_unmatched_pathspecs( } else { false } - if !(matched) { + if !matched { out.push(path) } } @@ -690,7 +690,7 @@ async fn add_refresh_index_entries( selected[path] = true } } - if !(matched) { + if !matched { eprint_line("fatal: pathspec '\{raw}' did not match any files") @sys.exit(1) } @@ -698,12 +698,12 @@ async fn add_refresh_index_entries( } let refreshed : Array[@bitlib.IndexEntry] = [] for entry in entries { - if !(selected.contains(entry.path)) { + if !selected.contains(entry.path) { refreshed.push(entry) continue } let abs = root + "/" + entry.path - if !(fs.is_file(abs)) { + if !fs.is_file(abs) { refreshed.push(entry) continue } @@ -824,7 +824,7 @@ fn add_normalize_input_path(root : String, raw_path : String) -> String { if path.length() == 0 { return path } - let normalized = if !(path.has_prefix("/")) { + let normalized = if !path.has_prefix("/") { let cwd_rel = add_repo_relative_cwd(root) if cwd_rel.length() > 0 { if path == "." { @@ -954,7 +954,7 @@ async fn expand_add_stage_paths( let normalized = normalize_add_path(entry.path) tracked_map[normalized] = true let folded = normalized.to_lower() - if !(tracked_folded.contains(folded)) { + if !tracked_folded.contains(folded) { tracked_folded[folded] = normalized } } @@ -963,7 +963,7 @@ async fn expand_add_stage_paths( for p in visible_paths { visible_map[p] = true let folded = p.to_lower() - if !(visible_folded.contains(folded)) { + if !visible_folded.contains(folded) { visible_folded[folded] = p } } @@ -1044,7 +1044,7 @@ fn add_is_embedded_repo_dir( return false } let abs = root + "/" + rel - if !(fs.is_dir(abs)) { + if !fs.is_dir(abs) { return false } let dot_git = abs + "/.git" @@ -1064,7 +1064,7 @@ fn add_collect_embedded_repo_paths( out : Array[String], ) -> Unit raise Error { let dir = if rel.length() == 0 { root } else { root + "/" + rel } - if !(fs.is_dir(dir)) { + if !fs.is_dir(dir) { return } for name in fs.readdir(dir) { @@ -1077,7 +1077,7 @@ fn add_collect_embedded_repo_paths( } let child_rel = if rel.length() == 0 { name } else { rel + "/" + name } let child_abs = root + "/" + child_rel - if !(fs.is_dir(child_abs)) { + if !fs.is_dir(child_abs) { continue } if @bitlib.is_ignored_path(fs, root, child_rel, true) { @@ -1123,7 +1123,7 @@ fn collect_all_addable_paths( out : Array[String], ) -> Unit raise Error { let dir = if rel.length() == 0 { root } else { root + "/" + rel } - if !(fs.is_dir(dir)) { + if !fs.is_dir(dir) { return } for name in fs.readdir(dir) { @@ -1190,7 +1190,7 @@ fn add_has_ignored_under( rel : String, ) -> Bool raise Error { let dir = if rel.length() == 0 { root } else { root + "/" + rel } - if !(fs.is_dir(dir)) { + if !fs.is_dir(dir) { return false } for name in fs.readdir(dir) { @@ -1320,14 +1320,14 @@ async fn handle_add_chmod_dry_run( } else { false } - if !(in_index) && !(in_stage) && !(is_dir_match) { + if !in_index && !in_stage && !is_dir_match { eprint_line("fatal: pathspec '\{path}' did not match any files") @sys.exit(128) } } for entry in entries { if matched_paths.contains(entry.path) { - if !(add_is_regular_file_mode(entry.mode)) { + if !add_is_regular_file_mode(entry.mode) { eprint_line("cannot chmod \{mode} '\{entry.path}'") had_error = true } diff --git a/src/cmd/bit/ai.mbt b/src/cmd/bit/ai.mbt index aa378246..f1edc24a 100644 --- a/src/cmd/bit/ai.mbt +++ b/src/cmd/bit/ai.mbt @@ -13,7 +13,7 @@ fn read_file_text( rel_path : String, ) -> String? { let path = root + "/" + rel_path - if !(fs.is_file(path)) { + if !fs.is_file(path) { return None } let content = fs.read_file(path) catch { _ => return None } @@ -65,7 +65,7 @@ fn merge_index_and_worktree_diffs( merged[item.path] = item } for item in index_diffs { - if !(merged.contains(item.path)) { + if !merged.contains(item.path) { merged[item.path] = item } } @@ -659,7 +659,7 @@ async fn handle_ai_commit(args : Array[String]) -> Unit raise Error { split_commits, user_instructions, ) = parse_ai_commit_options(args) - if !(generate_message) { + if !generate_message { handle_commit(commit_args) return } @@ -688,7 +688,7 @@ async fn handle_ai_commit(args : Array[String]) -> Unit raise Error { provider=None, ) let units = split_diff_units(diff_files) - if !(split_commits) || units.length() == 1 { + if !split_commits || units.length() == 1 { let message = @rebase_ai.ai_generate_commit_message( rfs, root, @@ -717,7 +717,7 @@ async fn handle_ai_commit(args : Array[String]) -> Unit raise Error { let path_map : Map[String, Bool] = {} let unit_paths : Array[String] = [] for file in unit.diffs { - if !(path_map.contains(file.path)) { + if !path_map.contains(file.path) { path_map[file.path] = true unit_paths.push(file.path) } @@ -799,8 +799,8 @@ async fn handle_ai_merge(args : Array[String]) -> Unit raise Error { } } handle_merge(merge_args) - if !(merge_args_has(merge_args, "--continue")) && - !(merge_args_has(merge_args, "--abort")) { + if !merge_args_has(merge_args, "--continue") && + !merge_args_has(merge_args, "--abort") { let conflict_paths = @rebase_ai.find_conflict_marker_paths(rfs, root) if conflict_paths.length() > 0 { let resolved = @rebase_ai.ai_resolve_conflict_paths( @@ -918,7 +918,7 @@ async fn handle_ai_cherry_pick(args : Array[String]) -> Unit raise Error { } let mut commit_ref : String? = None for arg in cherry_pick_args { - if !(arg.has_prefix("-")) { + if !arg.has_prefix("-") { commit_ref = Some(arg) break } diff --git a/src/cmd/bit/am.mbt b/src/cmd/bit/am.mbt index eec46f02..c389778b 100644 --- a/src/cmd/bit/am.mbt +++ b/src/cmd/bit/am.mbt @@ -39,7 +39,7 @@ async fn handle_am(args : Array[String]) -> Unit raise Error { directory = Some( String::unsafe_substring(arg, start=12, end=arg.length()), ) - _ if !(arg.has_prefix("-")) => mbox_files.push(arg) + _ if !arg.has_prefix("-") => mbox_files.push(arg) _ => () } i += 1 @@ -57,7 +57,7 @@ async fn handle_am(args : Array[String]) -> Unit raise Error { fs.write_string(git_dir + "/HEAD", orig_head + "\n") } remove_dir_recursive(fs, am_dir) - if !(quiet) { + if !quiet { print_line("Aborting.") } } @@ -65,7 +65,7 @@ async fn handle_am(args : Array[String]) -> Unit raise Error { } // Handle --skip if skip { - if !(fs.is_dir(am_dir)) { + if !fs.is_dir(am_dir) { raise @bitcore.GitError::InvalidObject("No am in progress") } let next_file = am_dir + "/next" @@ -81,7 +81,7 @@ async fn handle_am(args : Array[String]) -> Unit raise Error { } // Handle --continue or apply new patches if continue_am { - if !(fs.is_dir(am_dir)) { + if !fs.is_dir(am_dir) { raise @bitcore.GitError::InvalidObject("No am in progress") } apply_remaining_patches( @@ -95,7 +95,7 @@ async fn handle_am(args : Array[String]) -> Unit raise Error { let input = decode_bytes(input_bytes) if input.length() > 0 { fs.mkdir_p(am_dir) - let patches = parse_mbox(input, keep_cr && !(no_keep_cr)) + let patches = parse_mbox(input, keep_cr && !no_keep_cr) if patches.length() == 0 { remove_dir_recursive(fs, am_dir) raise @bitcore.GitError::InvalidObject("No patches found in input") @@ -124,7 +124,7 @@ async fn handle_am(args : Array[String]) -> Unit raise Error { let all_patches : Array[MboxPatch] = [] for file in mbox_files { let content = decode_bytes(fs.read_file(file)) - let patches = parse_mbox(content, keep_cr && !(no_keep_cr)) + let patches = parse_mbox(content, keep_cr && !no_keep_cr) for p in patches { all_patches.push(p) } @@ -289,7 +289,7 @@ async fn apply_remaining_patches( let patch_file = am_dir + "/" + zero_pad(next, 4) let msg_file = am_dir + "/msg-" + zero_pad(next, 4) let info_file = am_dir + "/info-" + zero_pad(next, 4) - if !(fs.is_file(patch_file)) { + if !fs.is_file(patch_file) { next += 1 fs.write_string(am_dir + "/next", next.to_string()) continue @@ -320,7 +320,7 @@ async fn apply_remaining_patches( } } } - if !(quiet) { + if !quiet { print_line("Applying: \{subject}") } apply_patch_to_worktree(fs, root, patch_content, three_way) @@ -476,7 +476,7 @@ fn apply_patch_to_worktree( ///| fn parse_hunk_header(line : String) -> (Int, Int, Int, Int)? { - if !(line.has_prefix("@@ ")) { + if !line.has_prefix("@@ ") { return None } let content = String::unsafe_substring(line, start=3, end=line.length()) diff --git a/src/cmd/bit/apply.mbt b/src/cmd/bit/apply.mbt index 45806f87..0e28a29b 100644 --- a/src/cmd/bit/apply.mbt +++ b/src/cmd/bit/apply.mbt @@ -30,7 +30,7 @@ async fn handle_apply(args : Array[String]) -> Unit raise Error { "-v" | "--verbose" => verbose = true "-q" | "--quiet" => quiet = true "--recount" => () // no-op, bit always counts from actual lines - _ if !(arg.has_prefix("-")) => patch_files.push(arg) + _ if !arg.has_prefix("-") => patch_files.push(arg) _ => () } i += 1 @@ -49,7 +49,7 @@ async fn handle_apply(args : Array[String]) -> Unit raise Error { if reverse { let reversed = @apply.reverse_patch(patch_content) if check_mode { - if !(quiet) { + if !quiet { print_line("Patch would apply cleanly.") } } else if stat_mode || numstat || summary { @@ -61,7 +61,7 @@ async fn handle_apply(args : Array[String]) -> Unit raise Error { } } } else if check_mode { - if !(quiet) { + if !quiet { print_line("Patch would apply cleanly.") } } else if stat_mode || numstat || summary { diff --git a/src/cmd/bit/archive.mbt b/src/cmd/bit/archive.mbt index 763fb78d..96bab190 100644 --- a/src/cmd/bit/archive.mbt +++ b/src/cmd/bit/archive.mbt @@ -41,7 +41,7 @@ async fn handle_archive(args : Array[String]) -> Unit raise Error { break } else if arg.has_prefix("-") { warn_unimplemented_arg("archive", arg) - } else if !(tree_ish_set) { + } else if !tree_ish_set { tree_ish = arg tree_ish_set = true } else { diff --git a/src/cmd/bit/bench_cat_file_wbtest.mbt b/src/cmd/bit/bench_cat_file_wbtest.mbt index c0bfa406..d68d09ce 100644 --- a/src/cmd/bit/bench_cat_file_wbtest.mbt +++ b/src/cmd/bit/bench_cat_file_wbtest.mbt @@ -21,17 +21,17 @@ fn ensure_catfile_bench_repo() -> Array[String] { return bench_catfile_oids.val } let marker = bench_catfile_root + "/.bench_ready" - if !(@fs.path_exists(bench_catfile_root)) { + if !@fs.path_exists(bench_catfile_root) { @fs.create_dir(bench_catfile_root) catch { _ => () } } - if !(@fs.path_exists(bench_catfile_repo)) { + if !@fs.path_exists(bench_catfile_repo) { @fs.create_dir(bench_catfile_repo) catch { _ => () } } - if !(@fs.path_exists(marker)) { + if !@fs.path_exists(marker) { let fs = OsFs::new() ignore(try? @bitrepo.init_repo(fs, bench_catfile_repo)) for i in 0..<50 { diff --git a/src/cmd/bit/bench_e2e_clone_fetch_wbtest.mbt b/src/cmd/bit/bench_e2e_clone_fetch_wbtest.mbt index e243fe84..1b8dca64 100644 --- a/src/cmd/bit/bench_e2e_clone_fetch_wbtest.mbt +++ b/src/cmd/bit/bench_e2e_clone_fetch_wbtest.mbt @@ -38,7 +38,7 @@ fn e2e_cleanup_tree(fs : OsFs, path : String) -> Unit { } return } - if !(fs.is_dir(path)) { + if !fs.is_dir(path) { return } let entries = fs.readdir(path) catch { _ => [] } diff --git a/src/cmd/bit/bench_grep_wbtest.mbt b/src/cmd/bit/bench_grep_wbtest.mbt index a3a5ea87..f159bcbf 100644 --- a/src/cmd/bit/bench_grep_wbtest.mbt +++ b/src/cmd/bit/bench_grep_wbtest.mbt @@ -25,7 +25,7 @@ fn bench_grep_cleanup_tree(fs : OsFs, path : String) -> Unit { } return } - if !(fs.is_dir(path)) { + if !fs.is_dir(path) { return } let entries = fs.readdir(path) catch { _ => [] } diff --git a/src/cmd/bit/bench_init_wbtest.mbt b/src/cmd/bit/bench_init_wbtest.mbt index e0da631f..c71161af 100644 --- a/src/cmd/bit/bench_init_wbtest.mbt +++ b/src/cmd/bit/bench_init_wbtest.mbt @@ -18,7 +18,7 @@ let bench_startup_repeat : Int = 3 ///| fn ensure_bench_dir(path : String) -> Unit { - if !(@fs.path_exists(path)) { + if !@fs.path_exists(path) { @fs.create_dir(path) catch { _ => () } diff --git a/src/cmd/bit/bench_log_wbtest.mbt b/src/cmd/bit/bench_log_wbtest.mbt index 2d16d403..6eb11466 100644 --- a/src/cmd/bit/bench_log_wbtest.mbt +++ b/src/cmd/bit/bench_log_wbtest.mbt @@ -26,7 +26,7 @@ fn bench_log_cleanup_tree(fs : OsFs, path : String) -> Unit { } return } - if !(fs.is_dir(path)) { + if !fs.is_dir(path) { return } let entries = fs.readdir(path) catch { _ => [] } diff --git a/src/cmd/bit/bench_status_wbtest.mbt b/src/cmd/bit/bench_status_wbtest.mbt index 3e591d27..37cf1a9b 100644 --- a/src/cmd/bit/bench_status_wbtest.mbt +++ b/src/cmd/bit/bench_status_wbtest.mbt @@ -25,7 +25,7 @@ fn bench_status_cleanup_tree(fs : OsFs, path : String) -> Unit { } return } - if !(fs.is_dir(path)) { + if !fs.is_dir(path) { return } let entries = fs.readdir(path) catch { _ => [] } diff --git a/src/cmd/bit/bisect.mbt b/src/cmd/bit/bisect.mbt index f2b69d47..f41c7ea9 100644 --- a/src/cmd/bit/bisect.mbt +++ b/src/cmd/bit/bisect.mbt @@ -108,8 +108,8 @@ async fn bisect_start( if arg == "--" { break } - if !(arg.has_prefix("-")) { - if !(bad_set) { + if !arg.has_prefix("-") { + if !bad_set { bisect_mark(wfs, rfs, git_dir, ["bad", arg], "bad") bad_set = true } else { @@ -132,7 +132,7 @@ async fn bisect_mark( let bisect_start_path = git_dir + "/BISECT_START" let bisect_log_path = git_dir + "/BISECT_LOG" let bisect_refs_dir = git_dir + "/refs/bisect" - if !(rfs.is_file(bisect_start_path)) { + if !rfs.is_file(bisect_start_path) { @stdio.stderr.write("error: not in a bisect session") @stdio.stderr.write("use 'git bisect start' first") @sys.exit(1) @@ -172,7 +172,7 @@ async fn bisect_skip( let bisect_start_path = git_dir + "/BISECT_START" let bisect_log_path = git_dir + "/BISECT_LOG" let bisect_refs_dir = git_dir + "/refs/bisect" - if !(rfs.is_file(bisect_start_path)) { + if !rfs.is_file(bisect_start_path) { @stdio.stderr.write("error: not in a bisect session") @sys.exit(1) } @@ -202,7 +202,7 @@ fn bisect_compute_next( ) -> BisectNextResult raise Error { let bisect_refs_dir = git_dir + "/refs/bisect" let bad_path = bisect_refs_dir + "/bad" - if !(rfs.is_file(bad_path)) { + if !rfs.is_file(bad_path) { return Waiting("status: waiting for bad commit") } let bad_hex = rfs.read_file(bad_path) |> decode_bytes |> trim_string @@ -454,7 +454,7 @@ async fn bisect_replay( } let filename = args[1] let fs = OsFs::new() - if !(fs.is_file(filename)) { + if !fs.is_file(filename) { raise @bitcore.GitError::InvalidObject( "cannot read file '\{filename}' for replaying", ) @@ -507,7 +507,7 @@ async fn bisect_visualize( ) -> Unit raise Error { let bisect_refs_dir = git_dir + "/refs/bisect" let bad_path = bisect_refs_dir + "/bad" - if !(rfs.is_file(bad_path)) { + if !rfs.is_file(bad_path) { raise @bitcore.GitError::InvalidObject( "bisect visualize requires a bad commit", ) @@ -543,7 +543,7 @@ async fn bisect_terms( _args : Array[String], ) -> Unit raise Error { let bisect_terms_path = git_dir + "/BISECT_TERMS" - if !(rfs.is_file(bisect_terms_path)) { + if !rfs.is_file(bisect_terms_path) { raise @bitcore.GitError::InvalidObject("no terms saved") } let content = decode_bytes(rfs.read_file(bisect_terms_path)) @@ -644,7 +644,7 @@ async fn bisect_log( git_dir : String, ) -> Unit raise Error { let bisect_log_path = git_dir + "/BISECT_LOG" - if !(rfs.is_file(bisect_log_path)) { + if !rfs.is_file(bisect_log_path) { @stdio.stderr.write("error: no bisect log found") @sys.exit(1) } diff --git a/src/cmd/bit/blame.mbt b/src/cmd/bit/blame.mbt index 1fcdd7d6..5c17b034 100644 --- a/src/cmd/bit/blame.mbt +++ b/src/cmd/bit/blame.mbt @@ -45,7 +45,7 @@ fn blame_builtin_supports_args( root : String, args : Array[String], ) -> Bool { - if !(fs.is_dir(root + "/.git")) { + if !fs.is_dir(root + "/.git") { return false } let mut saw_double_dash = false @@ -100,7 +100,7 @@ fn blame_extract_target_path( } "-L" if i + 1 < args.length() => i += 2 _ if arg.has_prefix("-L") => i += 1 - _ if !(arg.has_prefix("-")) => { + _ if !arg.has_prefix("-") => { if file_path is None { let test_path = root + "/" + arg if fs.is_file(test_path) { @@ -129,7 +129,7 @@ fn blame_read_path_diff_driver( path } let attr_path = root + "/.gitattributes" - if !(fs.is_file(attr_path)) { + if !fs.is_file(attr_path) { return None } let text = decode_bytes( @@ -236,7 +236,7 @@ fn blame_repo_requires_real_git( git_dir : String, args : Array[String], ) -> Bool { - if !(blame_builtin_supports_args(fs, root, args)) { + if !blame_builtin_supports_args(fs, root, args) { return true } if blame_repo_prefers_real_git(fs, git_dir) { @@ -319,7 +319,7 @@ async fn handle_blame(args : Array[String]) -> Unit raise Error { saw_double_dash = true i += 1 } - _ if saw_double_dash || !(arg.has_prefix("-")) => { + _ if saw_double_dash || !arg.has_prefix("-") => { positionals.push(arg) i += 1 } @@ -776,7 +776,7 @@ fn normalize_whitespace(s : String) -> String { let mut in_space = true // Start true to trim leading spaces for c in s { if c == ' ' || c == '\t' { - if !(in_space) { + if !in_space { result.write_char(' ') in_space = true } @@ -922,7 +922,7 @@ async fn output_blame_incremental(lines : Array[BlameLine]) -> Unit raise Error let sha = line.commit_id.to_hex() print_line("\{sha} \{line.line_no} \{line.line_no} 1") // Only output full header for first occurrence of each commit - if !(seen_commits.get(sha).unwrap_or(false)) { + if !seen_commits.get(sha).unwrap_or(false) { seen_commits[sha] = true print_line("author \{line.author}") print_line("author-time \{line.author_time}") diff --git a/src/cmd/bit/branch.mbt b/src/cmd/bit/branch.mbt index e4383a45..48922924 100644 --- a/src/cmd/bit/branch.mbt +++ b/src/cmd/bit/branch.mbt @@ -99,13 +99,13 @@ async fn handle_branch(args : Array[String]) -> Unit raise Error { i += 1 continue } - "--merged" if i + 1 < args.length() && !(args[i + 1].has_prefix("-")) => { + "--merged" if i + 1 < args.length() && !args[i + 1].has_prefix("-") => { merged_filter = Some(args[i + 1]) i += 2 continue } "--merged" => merged_filter = Some("HEAD") - "--no-merged" if i + 1 < args.length() && !(args[i + 1].has_prefix("-")) => { + "--no-merged" if i + 1 < args.length() && !args[i + 1].has_prefix("-") => { no_merged_filter = Some(args[i + 1]) i += 2 continue @@ -119,7 +119,7 @@ async fn handle_branch(args : Array[String]) -> Unit raise Error { no_merged_filter = Some( String::unsafe_substring(arg, start=12, end=arg.length()), ) - _ if !(arg.has_prefix("-")) => { + _ if !arg.has_prefix("-") => { if new_branch is None { new_branch = Some(arg) } else if start_point is None { @@ -243,7 +243,7 @@ async fn handle_branch(args : Array[String]) -> Unit raise Error { @sys.exit(1) } let refname = normalize_local_branch_ref(name) - if !(force_create) && + if !force_create && @bitlib.resolve_ref(fs, git_dir, refname) is Some(_) { @stdio.stderr.write( "fatal: a branch named '\{name}' already exists", @@ -307,7 +307,7 @@ async fn handle_branch(args : Array[String]) -> Unit raise Error { None => if list_mode { // List local branches - if !(show_remotes) { + if !show_remotes { if merged_filter is Some(_) || no_merged_filter is Some(_) { branch_list_with_merge_filter( fs, git_dir, verbose, merged_filter, no_merged_filter, @@ -318,7 +318,7 @@ async fn handle_branch(args : Array[String]) -> Unit raise Error { } else { @bitlib.list_branches_text(fs, git_dir) } - let output_lines = if column_active && !(verbose) { + let output_lines = if column_active && !verbose { branch_format_columns( lines, branch_term_columns(), @@ -389,10 +389,10 @@ async fn branch_list_with_merge_filter( let is_merged = @bitlib.is_ancestor_of(fs, git_dir, b.id, tid) let should_show = match (merged_filter, no_merged_filter) { (Some(_), _) => is_merged - (_, Some(_)) => !(is_merged) + (_, Some(_)) => !is_merged _ => true } - if !(should_show) { + if !should_show { continue } if verbose { @@ -518,7 +518,7 @@ fn branch_apply_column_mode( raise @bitcore.GitError::InvalidObject("unsupported option '\{token}'") } } - if saw_layout && !(saw_enable) { + if saw_layout && !saw_enable { next_enabled_state = "enabled" } (next_enabled_state, next_dense) @@ -533,7 +533,7 @@ fn branch_resolve_column_mode( ) -> (Bool, Bool, Bool) raise @bitcore.GitError { let mut enabled_state = "disabled" let mut dense = false - if !(verbose) { + if !verbose { match column_ui { Some(value) => { let (next_enabled_state, next_dense) = branch_apply_column_mode( @@ -670,7 +670,7 @@ fn branch_format_columns( } line += items[idx] let newline = x == cols - 1 || idx + rows >= items.length() - if !(newline) { + if !newline { let cell_width = widths[x] + padding line += " ".repeat(cell_width - lengths[idx]) } diff --git a/src/cmd/bit/branch_wbtest.mbt b/src/cmd/bit/branch_wbtest.mbt index 1cd993d6..22d80027 100644 --- a/src/cmd/bit/branch_wbtest.mbt +++ b/src/cmd/bit/branch_wbtest.mbt @@ -35,7 +35,7 @@ test "branch: column config enables dense layout when non-verbose" { ) assert_true(active) assert_true(dense) - assert_true(!(explicit_enabled)) + assert_true(!explicit_enabled) } ///| @@ -46,8 +46,8 @@ test "branch: verbose ignores config columns but tracks explicit column" { Some("column"), Some("dense"), ) - assert_true(!(config_active)) - assert_true(!(config_explicit)) + assert_true(!config_active) + assert_true(!config_explicit) let (explicit_active, explicit_dense, explicit_enabled) = branch_resolve_column_mode( Some("column"), @@ -56,6 +56,6 @@ test "branch: verbose ignores config columns but tracks explicit column" { Some("dense"), ) assert_true(explicit_active) - assert_true(!(explicit_dense)) + assert_true(!explicit_dense) assert_true(explicit_enabled) } diff --git a/src/cmd/bit/bundle.mbt b/src/cmd/bit/bundle.mbt index 99977d7f..4798ee27 100644 --- a/src/cmd/bit/bundle.mbt +++ b/src/cmd/bit/bundle.mbt @@ -45,7 +45,7 @@ async fn handle_bundle_create(args : Array[String]) -> Unit raise Error { "--all" => all = true _ if arg.has_prefix("^") => excludes.push(String::unsafe_substring(arg, start=1, end=arg.length())) - _ if !(arg.has_prefix("-")) => + _ if !arg.has_prefix("-") => if bundle_file is None { bundle_file = Some(arg) } else { @@ -74,7 +74,7 @@ async fn handle_bundle_create(args : Array[String]) -> Unit raise Error { let prereq_hexes : Array[String] = [] let prereq_seen : Map[String, Bool] = {} let add_prereq = fn(hex : String) -> Unit { - if !(prereq_seen.contains(hex)) { + if !prereq_seen.contains(hex) { prereq_seen[hex] = true prereq_hexes.push(hex) } @@ -166,13 +166,13 @@ fn collect_bundle_objects( @bitcore.ObjectType::Commit => { let info = @bitcore.parse_commit(obj.data) // Add tree - if !(visited.contains(info.tree.to_hex())) { + if !visited.contains(info.tree.to_hex()) { queue.push(info.tree) } // Add parents for parent in info.parents { - if !(visited.contains(parent.to_hex())) && - !(exclude_ids.contains(parent.to_hex())) { + if !visited.contains(parent.to_hex()) && + !exclude_ids.contains(parent.to_hex()) { queue.push(parent) } } @@ -180,7 +180,7 @@ fn collect_bundle_objects( @bitcore.ObjectType::Tree => { let entries = @bitcore.parse_tree(obj.data) for entry in entries { - if !(visited.contains(entry.id.to_hex())) { + if !visited.contains(entry.id.to_hex()) { queue.push(entry.id) } } @@ -197,7 +197,7 @@ fn collect_bundle_objects( end=line.length(), ) let target = @bitcore.ObjectId::from_hex(target_hex) - if !(visited.contains(target_hex)) { + if !visited.contains(target_hex) { queue.push(target) } break @@ -222,7 +222,7 @@ async fn handle_bundle_verify(args : Array[String]) -> Unit raise Error { for arg in args { match arg { "-q" | "--quiet" => quiet = true - _ if !(arg.has_prefix("-")) => bundle_file = Some(arg) + _ if !arg.has_prefix("-") => bundle_file = Some(arg) _ if arg.has_prefix("-") => warn_unimplemented_arg("bundle", arg) _ => () } @@ -238,7 +238,7 @@ async fn handle_bundle_verify(args : Array[String]) -> Unit raise Error { match @bitrepo.rev_parse(fs, git_dir, prereq) { Some(_) => () None => { - if !(quiet) { + if !quiet { eprint_line("error: Repository lacks prerequisite commit: " + prereq) } ok = false @@ -246,7 +246,7 @@ async fn handle_bundle_verify(args : Array[String]) -> Unit raise Error { } } if ok { - if !(quiet) { + if !quiet { print_line("The bundle contains \{refs.length()} ref(s)") for item in refs { let (id, name) = item @@ -264,7 +264,7 @@ async fn handle_bundle_list_heads(args : Array[String]) -> Unit raise Error { let fs = OsFs::new() let mut bundle_file : String? = None for arg in args { - if !(arg.has_prefix("-")) { + if !arg.has_prefix("-") { bundle_file = Some(arg) } else { warn_unimplemented_arg("bundle", arg) @@ -287,7 +287,7 @@ async fn handle_bundle_unbundle(args : Array[String]) -> Unit raise Error { let git_dir = find_git_dir(fs) let mut bundle_file : String? = None for arg in args { - if !(arg.has_prefix("-")) { + if !arg.has_prefix("-") { bundle_file = Some(arg) } else { warn_unimplemented_arg("bundle", arg) diff --git a/src/cmd/bit/cat_file.mbt b/src/cmd/bit/cat_file.mbt index f64f46b3..9744a247 100644 --- a/src/cmd/bit/cat_file.mbt +++ b/src/cmd/bit/cat_file.mbt @@ -1200,7 +1200,7 @@ fn cat_file_collect_batch_all_objects( let (hex, _) = item ids.push(hex) } - if !(unordered) { + if !unordered { ids.sort() } let out : Array[@bitcore.ObjectId] = [] @@ -1236,7 +1236,7 @@ fn cat_file_collect_batch_all_object_disk_records( cat_file_append_pack_disk_records(fs, pack, out) } } - if !(unordered) { + if !unordered { out.sort_by((a, b) => { String::compare( a.id.to_hex() + " " + a.disk_size.to_string(), @@ -1328,7 +1328,7 @@ fn cat_file_read_alternate_object_dirs( ) -> Array[String] { let out : Array[String] = [] let alt_path = git_dir + "/objects/info/alternates" - if !(fs.is_file(alt_path)) { + if !fs.is_file(alt_path) { return out } let data = fs.read_file(alt_path) catch { _ => return out } @@ -1345,7 +1345,7 @@ fn cat_file_read_alternate_object_dirs( } else { normalize_path(base_dir + "/" + line) } - if !(fs.is_dir(objects_dir)) { + if !fs.is_dir(objects_dir) { continue } if seen.contains(objects_dir) { @@ -1651,7 +1651,7 @@ fn cat_file_validate_midx_large_offsets( objects_dir : String, ) -> Bool { let midx_path = objects_dir + "/pack/multi-pack-index" - if !(fs.is_file(midx_path)) { + if !fs.is_file(midx_path) { return false } let data = fs.read_file(midx_path) catch { _ => return false } @@ -1837,7 +1837,7 @@ fn cat_file_find_reachable_commit_by_message( } let info = @bitcore.parse_commit(o.data) catch { _ => continue } for parent in info.parents { - if !(seen.contains(parent.to_hex())) { + if !seen.contains(parent.to_hex()) { queue.push(parent) } } diff --git a/src/cmd/bit/check_attr.mbt b/src/cmd/bit/check_attr.mbt index 6f3461ec..f2688eea 100644 --- a/src/cmd/bit/check_attr.mbt +++ b/src/cmd/bit/check_attr.mbt @@ -52,7 +52,7 @@ async fn handle_check_attr(args : Array[String]) -> Unit raise Error { if a == "--" { break } - if !(a.has_prefix("-")) { + if !a.has_prefix("-") { attrs.push(a) } j += 1 @@ -76,7 +76,7 @@ async fn handle_check_attr(args : Array[String]) -> Unit raise Error { } } } - if paths.length() == 0 && !(use_stdin) { + if paths.length() == 0 && !use_stdin { eprint_line( "usage: git check-attr [-a | --all | ...] [--] ...", ) @@ -240,7 +240,7 @@ fn check_attr_resolve( for rule in rules { if check_attr_pattern_matches(normalized, rule.pattern) { for attr in rule.attrs { - if !(resolved.contains(attr.0)) { + if !resolved.contains(attr.0) { order.push(attr.0) } resolved[attr.0] = attr.1 diff --git a/src/cmd/bit/check_ignore.mbt b/src/cmd/bit/check_ignore.mbt index 93a70822..bf43d003 100644 --- a/src/cmd/bit/check_ignore.mbt +++ b/src/cmd/bit/check_ignore.mbt @@ -39,7 +39,7 @@ async fn handle_check_ignore(args : Array[String]) -> Unit raise Error { i += 1 } // non-matching requires verbose - if non_matching && !(verbose) { + if non_matching && !verbose { eprint_line("fatal: -n / --non-matching is only valid with -v") @sys.exit(128) return @@ -58,7 +58,7 @@ async fn handle_check_ignore(args : Array[String]) -> Unit raise Error { } } } - if paths.length() == 0 && !(use_stdin) { + if paths.length() == 0 && !use_stdin { eprint_line("usage: git check-ignore [] ...") @sys.exit(128) return @@ -117,7 +117,7 @@ async fn handle_check_ignore(args : Array[String]) -> Unit raise Error { let ignored = path_matcher.is_ignored(normalized, is_dir) if ignored { had_match = true - if !(quiet) { + if !quiet { if verbose { // Verbose: show which rule matched let match_info = check_ignore_find_rule( @@ -142,7 +142,7 @@ async fn handle_check_ignore(args : Array[String]) -> Unit raise Error { print_str("::\t" + path + line_sep) } } - if !(had_match) { + if !had_match { @sys.exit(1) } } @@ -230,7 +230,7 @@ fn check_ignore_scan_file( let mut result_source = "" let mut result_linenum = 0 let mut result_pattern = "" - if !(fs.is_file(file_path)) { + if !fs.is_file(file_path) { return (result_source, result_linenum, result_pattern) } let content = decode_bytes( diff --git a/src/cmd/bit/check_ref_format.mbt b/src/cmd/bit/check_ref_format.mbt index 244cdd34..5d5b2265 100644 --- a/src/cmd/bit/check_ref_format.mbt +++ b/src/cmd/bit/check_ref_format.mbt @@ -45,11 +45,11 @@ async fn handle_check_ref_format(args : Array[String]) -> Unit raise Error { if normalize { // Normalize first (collapse slashes), then validate let normalized = check_ref_format_normalize(refname) - if !(check_ref_format_valid(normalized, allow_onelevel~)) { + if !check_ref_format_valid(normalized, allow_onelevel~) { @sys.exit(1) } print_line(normalized) - } else if !(check_ref_format_valid(refname, allow_onelevel~)) { + } else if !check_ref_format_valid(refname, allow_onelevel~) { @sys.exit(1) } } @@ -123,7 +123,7 @@ fn check_ref_format_valid( i += 1 } // Must have at least one slash unless allow_onelevel - if !(has_slash) && !(allow_onelevel) { + if !has_slash && !allow_onelevel { return false } true @@ -137,7 +137,7 @@ fn check_ref_format_normalize(refname : String) -> String { let mut prev_slash = false for c in chars { if c == '/' { - if !(prev_slash) { + if !prev_slash { result.write_char('/') } prev_slash = true diff --git a/src/cmd/bit/checkout.mbt b/src/cmd/bit/checkout.mbt index 50b69d13..e7c7822c 100644 --- a/src/cmd/bit/checkout.mbt +++ b/src/cmd/bit/checkout.mbt @@ -48,13 +48,13 @@ async fn handle_checkout(args : Array[String]) -> Unit raise Error { i += 1 } let targets = if detach_head && - !(saw_separator) && + !saw_separator && pre_separator_targets.length() == 0 { ["HEAD"] } else { pre_separator_targets } - if !(saw_separator) && targets.length() == 0 { + if !saw_separator && targets.length() == 0 { raise @bitcore.GitError::InvalidObject("No target specified for checkout") } ignore(quiet) @@ -98,7 +98,7 @@ async fn handle_checkout(args : Array[String]) -> Unit raise Error { "refs/heads/" + branch_name, ) is Some(_) - if branch_exists && !(force_create) { + if branch_exists && !force_create { raise @bitcore.GitError::InvalidObject( "branch '\{branch_name}' already exists", ) @@ -369,7 +369,7 @@ fn checkout_parse_tracking_source( } let remote = parts[0] let (remotes, _) = @bitlib.read_repo_config(rfs, git_dir) - if !(remotes.contains(remote)) { + if !remotes.contains(remote) { return None } let branch = String::unsafe_substring( @@ -501,7 +501,7 @@ fn checkout_restore_paths_from_spec_mode( } let merged_entries : Array[@bitlib.IndexEntry] = [] for entry in current_entries { - if !(selected_paths.contains(entry.path)) { + if !selected_paths.contains(entry.path) { merged_entries.push(entry) } } @@ -518,7 +518,7 @@ fn checkout_resolve_common_git_dir( git_dir : String, ) -> String { let commondir_path = git_dir + "/commondir" - if !(fs.is_file(commondir_path)) { + if !fs.is_file(commondir_path) { return git_dir } let raw = decode_bytes(fs.read_file(commondir_path) catch { _ => b"" }) @@ -594,7 +594,7 @@ async fn checkout_with_promisor_retry( ) if missing_ids.length() > 0 { ignore(pdb.fetch_missing(fs, missing_ids)) - if !(wrote_trace_round) { + if !wrote_trace_round { append_checkout_fetch_trace(fs) wrote_trace_round = true } @@ -627,7 +627,7 @@ async fn checkout_with_promisor_retry( Some(db) => db None => { let db = @bitlibnative.native_promisor_db(fs, git_dir) - if !(db.has_promisor()) { + if !db.has_promisor() { raise err } promisor_db = Some(db) @@ -638,7 +638,7 @@ async fn checkout_with_promisor_retry( if fetched.length() == 0 { raise err } - if !(wrote_trace_round) { + if !wrote_trace_round { append_checkout_fetch_trace(fs) wrote_trace_round = true } @@ -738,7 +738,7 @@ fn current_checkout_location( Some(target) if target.has_prefix("refs/") => return Some(target) _ => () } - if !(fs.is_file(head_path)) { + if !fs.is_file(head_path) { return None } let head = trim_string(@utf8.decode_lossy(fs.read_file(head_path)[:])) @@ -765,7 +765,7 @@ fn load_previous_checkout_location( git_dir : String, ) -> String? raise Error { let path = checkout_prev_location_path(git_dir) - if !(fs.is_file(path)) { + if !fs.is_file(path) { return None } let prev = trim_string(@utf8.decode_lossy(fs.read_file(path)[:])) diff --git a/src/cmd/bit/checkout_index.mbt b/src/cmd/bit/checkout_index.mbt index 38db8b96..d217db88 100644 --- a/src/cmd/bit/checkout_index.mbt +++ b/src/cmd/bit/checkout_index.mbt @@ -35,7 +35,7 @@ async fn handle_checkout_index(args : Array[String]) -> Unit raise Error { "--" => past_dashdash = true _ if arg.has_prefix("--prefix=") => prefix = String::unsafe_substring(arg, start=9, end=arg.length()) - _ if arg.has_prefix("-") && !(past_dashdash) => + _ if arg.has_prefix("-") && !past_dashdash => warn_unimplemented_arg("checkout-index", arg) _ => positional.push(arg) } @@ -75,7 +75,7 @@ async fn handle_checkout_index(args : Array[String]) -> Unit raise Error { } } } - if files_to_checkout.length() == 0 && !(all) { + if files_to_checkout.length() == 0 && !all { // Nothing to do — git checkout-index with no args does nothing return } @@ -104,7 +104,7 @@ async fn handle_checkout_index(args : Array[String]) -> Unit raise Error { root + "/" + path } // Check if file already exists (unless --force or --temp) - if !(force) && !(temp) && fs.is_file(dest_path) { + if !force && !temp && fs.is_file(dest_path) { eprint_line("git checkout-index: \{path} already exists, no checkout") continue } diff --git a/src/cmd/bit/checkout_wbtest.mbt b/src/cmd/bit/checkout_wbtest.mbt index d0d0d476..65135cc8 100644 --- a/src/cmd/bit/checkout_wbtest.mbt +++ b/src/cmd/bit/checkout_wbtest.mbt @@ -18,7 +18,7 @@ async fn checkout_wbtest_collect_shim_git_output( // Build the native binary first so exit codes propagate correctly // (moon run swallows non-zero exit codes) let bit_exe = repo_root + "/_build/native/release/build/cmd/bit/bit.exe" - if !(fs.is_file(bit_exe)) { + if !fs.is_file(bit_exe) { let build_code = @process.run( "moon", ["build", "--target", "native", "--release"], diff --git a/src/cmd/bit/cherry.mbt b/src/cmd/bit/cherry.mbt index b7f9b68c..3e4704aa 100644 --- a/src/cmd/bit/cherry.mbt +++ b/src/cmd/bit/cherry.mbt @@ -11,7 +11,7 @@ async fn handle_cherry(args : Array[String]) -> Unit raise Error { let arg = args[i] match arg { "-v" => verbose = true - _ if !(arg.has_prefix("-")) => + _ if !arg.has_prefix("-") => if upstream is None { upstream = Some(arg) } else if head is None { @@ -260,7 +260,7 @@ fn cherry_compute_tree_diff( } for item in parent { let (path, _) = item - if !(current_map.contains(path)) { + if !current_map.contains(path) { diff.push((path, "D")) } } diff --git a/src/cmd/bit/cherry_pick.mbt b/src/cmd/bit/cherry_pick.mbt index d41e6141..c42b022c 100644 --- a/src/cmd/bit/cherry_pick.mbt +++ b/src/cmd/bit/cherry_pick.mbt @@ -5,7 +5,7 @@ fn cherry_pick_is_supported_noop_arg(arg : String) -> Bool { ///| fn cherry_pick_is_positional_arg(arg : String) -> Bool { - arg == "-" || !(arg.has_prefix("-")) + arg == "-" || !arg.has_prefix("-") } ///| @@ -38,7 +38,7 @@ fn cherry_pick_collect_linear_replay_commits( _ => None } } - if !(reached_stop) { + if !reached_stop { return [] } commits.rev_in_place() @@ -251,7 +251,7 @@ async fn handle_subdir_cherry_pick( Some(pt) => pt.to_hex() != utree.to_hex() None => true } - if !(changed) { + if !changed { print_line("Commit \{spec} does not change \{subdir_path}, skipping.") return } diff --git a/src/cmd/bit/clean.mbt b/src/cmd/bit/clean.mbt index 621fe407..c138e7d0 100644 --- a/src/cmd/bit/clean.mbt +++ b/src/cmd/bit/clean.mbt @@ -21,13 +21,13 @@ async fn handle_clean(args : Array[String]) -> Unit raise Error { force = true remove_dirs = true } - _ if !(arg.has_prefix("-")) => paths.push(arg) + _ if !arg.has_prefix("-") => paths.push(arg) _ if arg.has_prefix("-") => warn_unimplemented_arg("clean", arg) _ => () } } // git clean requires -f unless -n is specified - if !(force) && !(dry_run) { + if !force && !dry_run { @stdio.stderr.write( "fatal: clean.requireForce defaults to true and neither -i, -n, nor -f given; refusing to clean", ) @@ -62,7 +62,7 @@ async fn handle_clean(args : Array[String]) -> Unit raise Error { print_line("Would remove \{path}") } else if fs.is_file(abs_path) { fs.remove_file(abs_path) - if !(quiet) { + if !quiet { print_line("Removing \{path}") } // Track parent directory for potential removal @@ -70,7 +70,7 @@ async fn handle_clean(args : Array[String]) -> Unit raise Error { match path.rev_find("/") { Some(idx) => { let parent = String::unsafe_substring(path, start=0, end=idx) - if !(dirs_to_check.contains(parent)) { + if !dirs_to_check.contains(parent) { dirs_to_check.push(parent) } } @@ -79,13 +79,13 @@ async fn handle_clean(args : Array[String]) -> Unit raise Error { } } else if fs.is_dir(abs_path) && remove_dirs { remove_dir_recursive(fs, abs_path) - if !(quiet) { + if !quiet { print_line("Removing \{path}/") } } } // Remove empty directories if -d flag - if remove_dirs && !(dry_run) { + if remove_dirs && !dry_run { // Sort by depth (deepest first) dirs_to_check.sort_by((a, b) => b.length() - a.length()) for dir in dirs_to_check { @@ -102,7 +102,7 @@ async fn handle_clean(args : Array[String]) -> Unit raise Error { err if @async.is_cancellation_error(err) => raise err _ => () } - if !(quiet) { + if !quiet { print_line("Removing \{dir}/") } } diff --git a/src/cmd/bit/clone.mbt b/src/cmd/bit/clone.mbt index 7f1fc464..1b866a8b 100644 --- a/src/cmd/bit/clone.mbt +++ b/src/cmd/bit/clone.mbt @@ -26,7 +26,7 @@ fn clone_maybe_enable_sparse_checkout( sparse_checkout : Bool, bare : Bool, ) -> Unit raise Error { - if !(sparse_checkout) || bare { + if !sparse_checkout || bare { return } @bitlib.sparse_checkout_init(fs, fs, root, cone=true) @@ -454,7 +454,7 @@ async fn handle_clone(args : Array[String]) -> Unit raise Error { } let mut clone_root = target let mut use_env_work_tree = false - if !(bare) { + if !bare { match @sys.get_env_var("GIT_WORK_TREE") { Some(work_tree) => { clone_root = absolutize_clone_path( @@ -469,7 +469,7 @@ async fn handle_clone(args : Array[String]) -> Unit raise Error { None => () } } - if !(quiet) { + if !quiet { if bare { print_line("Cloning into bare repository '\{relative_target}'...") } else { @@ -520,7 +520,7 @@ async fn handle_clone(args : Array[String]) -> Unit raise Error { ref_format~, template_dir~, ) - if !(bare) && !(no_checkout) { + if !bare && !no_checkout { match @bitlib.resolve_head_commit(fs, clone_git_dir) { Some(commit_id) => { warn_case_insensitive_collisions_from_commit( @@ -554,7 +554,7 @@ async fn handle_clone(args : Array[String]) -> Unit raise Error { // For file:// URLs with --depth or --filter, delegate to real git // which handles the upload-pack transport natively. let is_local_path = remote_display.has_prefix("/") && - !(remote_display.has_prefix("file://")) + !remote_display.has_prefix("file://") let is_file_url = remote_display.has_prefix("file://") let needs_transport = filter.is_partial() || depth > 0 if is_file_url && needs_transport { @@ -562,8 +562,7 @@ async fn handle_clone(args : Array[String]) -> Unit raise Error { return } let use_transport_clone = ( - (no_local && !(is_local_path) && !(is_file_url)) || - needs_transport + (no_local && !is_local_path && !is_file_url) || needs_transport ) && separate_git_dir is None && remote_name == "origin" @@ -590,17 +589,17 @@ async fn handle_clone(args : Array[String]) -> Unit raise Error { refs, template_dir~, ) - if bare && !(initialized_empty_clone) { + if bare && !initialized_empty_clone { promote_transport_clone_to_bare_layout(fs, clone_root) } - if ref_format == "reftable" && !(initialized_empty_clone) { + if ref_format == "reftable" && !initialized_empty_clone { configure_reftable_ref_storage(fs, clone_git_dir) } - if refs.length() == 0 && !(initialized_empty_clone) { + if refs.length() == 0 && !initialized_empty_clone { raise @bitcore.GitError::InvalidObject("Clone failed: no refs found") } finalize_transport_clone_tracking(fs, clone_git_dir, remote_name, bare) - if clone_filter.is_partial() && !(no_checkout) && !(bare) { + if clone_filter.is_partial() && !no_checkout && !bare { let checkout_spec = read_head_checkout_spec_for_clone( fs, clone_git_dir, ) @@ -630,8 +629,8 @@ async fn handle_clone(args : Array[String]) -> Unit raise Error { ref_format~, template_dir~, ) - if !(bare) && !(filter.is_partial()) { - if !(no_checkout) { + if !bare && !filter.is_partial() { + if !no_checkout { match @bitlib.resolve_head_commit(fs, clone_git_dir) { Some(commit_id) => { warn_case_insensitive_collisions_from_commit( @@ -646,9 +645,9 @@ async fn handle_clone(args : Array[String]) -> Unit raise Error { } } if ref_spec is Some(refname) && - !(bare) && - !(filter.is_partial()) && - !(no_checkout) { + !bare && + !filter.is_partial() && + !no_checkout { let local_branch_ref = "refs/heads/" + refname if @bitlib.resolve_ref(fs, clone_git_dir, local_branch_ref) is Some(_) { let checked_id = run_checkout_with_sensitive_hooks( @@ -715,17 +714,17 @@ async fn handle_clone(args : Array[String]) -> Unit raise Error { let initialized_empty_clone = initialize_empty_transport_clone( fs, clone_root, remote_url, bare, remote_name, ref_format, refs, ) - if bare && !(initialized_empty_clone) { + if bare && !initialized_empty_clone { promote_transport_clone_to_bare_layout(fs, clone_root) } - if ref_format == "reftable" && !(initialized_empty_clone) { + if ref_format == "reftable" && !initialized_empty_clone { configure_reftable_ref_storage(fs, clone_git_dir) } - if refs.length() == 0 && !(initialized_empty_clone) { + if refs.length() == 0 && !initialized_empty_clone { raise @bitcore.GitError::InvalidObject("Clone failed: no refs found") } finalize_transport_clone_tracking(fs, clone_git_dir, remote_name, bare) - if clone_filter.is_partial() && !(no_checkout) && !(bare) { + if clone_filter.is_partial() && !no_checkout && !bare { let checkout_spec = read_head_checkout_spec_for_clone(fs, clone_git_dir) let checked_id = checkout_with_promisor_retry_clone( fs, clone_root, checkout_spec, @@ -737,8 +736,8 @@ async fn handle_clone(args : Array[String]) -> Unit raise Error { fs, fs, clone_root, clone_git_dir, checked_id, ) } - if !(bare) && !(clone_filter.is_partial()) { - if !(no_checkout) { + if !bare && !clone_filter.is_partial() { + if !no_checkout { match @bitlib.resolve_head_commit(fs, clone_git_dir) { Some(commit_id) => { warn_case_insensitive_collisions_from_commit( @@ -753,9 +752,9 @@ async fn handle_clone(args : Array[String]) -> Unit raise Error { } } if ref_spec is Some(refname) && - !(bare) && - !(clone_filter.is_partial()) && - !(no_checkout) { + !bare && + !clone_filter.is_partial() && + !no_checkout { match resolve_remote_ref_id(remote_url, refname) { Some((commit_id, branch)) => { let mut db = @bitlib.ObjectDb::load_lazy(fs, clone_git_dir) @@ -845,7 +844,7 @@ async fn handle_clone(args : Array[String]) -> Unit raise Error { } emit_clone_bundle_trace_events(fs, bundle_uris) clone_maybe_enable_sparse_checkout(fs, clone_root, sparse_checkout, bare) - if recurse_submodules && !(bare) && !(no_checkout) { + if recurse_submodules && !bare && !no_checkout { clone_configure_submodule_active_filters( fs, clone_git_dir, recurse_submodule_filters, ) @@ -986,7 +985,7 @@ fn initialize_empty_transport_clone( ) let fetch_specs = ["+refs/heads/*:refs/remotes/" + remote_name + "/*"] remote_add(fs, fs, git_dir, remote_name, remote_url, fetch_specs, false, None) - if !(bare) { + if !bare { setup_clone_branch_tracking(fs, git_dir, default_branch, remote_name) } true @@ -1017,7 +1016,7 @@ fn finalize_transport_clone_tracking( remote_branch_ref, ) pack_remote_tracking_refs(fs, git_dir, remote_name) - if !(bare) { + if !bare { setup_clone_branch_tracking( fs, git_dir, default_branch, remote_name, ) @@ -1105,7 +1104,7 @@ fn clone_detect_relay_session(remote_url : String) -> (String, String)? { return None } for c in segment { - if !(clone_is_session_id_char(c)) { + if !clone_is_session_id_char(c) { return None } } @@ -1219,7 +1218,7 @@ fn configure_reftable_ref_storage( let reftable_dir = git_dir + "/reftable" fs.mkdir_p(reftable_dir) let tables_list_path = reftable_dir + "/tables.list" - if !(fs.is_file(tables_list_path)) { + if !fs.is_file(tables_list_path) { fs.write_string(tables_list_path, "") } set_config( @@ -1239,7 +1238,7 @@ async fn resolve_clone_transport_filter( prefer_v2 : Bool, requested : @protocol.FilterSpec, ) -> @protocol.FilterSpec raise Error { - if !(requested.is_partial()) { + if !requested.is_partial() { return requested } let (_, caps, version, _symrefs) = @bitnative.discover_upload_refs_http( @@ -1271,7 +1270,7 @@ fn clone_caps_contain_token(caps : Array[String], token : String) -> Bool { return true } // Skip expensive word splitting if token is not a substring of cap - if !(cap.contains(token)) { + if !cap.contains(token) { continue } let words = clone_split_words(cap) @@ -1328,7 +1327,7 @@ async fn discover_clone_bundle_uris( prefer_v2 : Bool, config_overrides : Map[String, String], ) -> Array[String] raise Error { - if !(clone_config_is_true(config_overrides, "transfer.bundleuri")) { + if !clone_config_is_true(config_overrides, "transfer.bundleuri") { return [] } let spec = @protocol.parse_remote(remote) @@ -1341,7 +1340,7 @@ async fn discover_clone_bundle_uris( if version != @protocol.ProtocolVersion::V2 { return [] } - if !(clone_caps_contain_token(caps, "bundle-uri")) { + if !clone_caps_contain_token(caps, "bundle-uri") { return [] } let req = build_bundle_uri_request_for_clone() @@ -1443,7 +1442,7 @@ fn parse_bundle_uri_lines_for_clone(lines : Array[String]) -> Array[String] { heuristic = value.to_lower() continue } - if !(key.has_prefix("bundle.")) { + if !key.has_prefix("bundle.") { continue } let tail = String::unsafe_substring(key, start=7, end=key.length()) @@ -1458,7 +1457,7 @@ fn parse_bundle_uri_lines_for_clone(lines : Array[String]) -> Array[String] { if name.length() == 0 { continue } - if !(seen_name.contains(name)) { + if !seen_name.contains(name) { seen_name[name] = true names_in_order.push(name) } @@ -1540,7 +1539,7 @@ async fn run_postclone_hook( } hooks_ensure_sensitive_hook_approval(wfs, rfs, root, "postclone") let hook_path = git_dir + "/hooks/postclone" - if !(rfs.is_file(hook_path)) { + if !rfs.is_file(hook_path) { return () } let code = @process.run(hook_path, [], inherit_env=true, cwd=root) catch { @@ -1616,7 +1615,7 @@ fn cleanup_failed_clone( ///| fn promote_transport_clone_to_bare_layout(fs : OsFs, root : String) -> Unit { let nested_git_dir = root + "/.git" - if !(fs.is_dir(nested_git_dir)) { + if !fs.is_dir(nested_git_dir) { return () } let root_entries = fs.readdir(root) catch { _ => [] } @@ -1675,7 +1674,7 @@ fn ensure_clone_path_available(fs : OsFs, path : String) -> Unit raise Error { "path exists and is not dir: " + path, ) } - if fs.is_dir(path) && !(is_empty_dir(fs, path)) { + if fs.is_dir(path) && !is_empty_dir(fs, path) { raise @bitcore.GitError::InvalidObject( "destination path exists and is not an empty directory: " + path, ) @@ -1703,7 +1702,7 @@ fn resolve_local_clone_checkout_target( ///| fn read_head_checkout_spec_for_clone(fs : OsFs, git_dir : String) -> String { let head_path = git_dir + "/HEAD" - if !(fs.is_file(head_path)) { + if !fs.is_file(head_path) { return "HEAD" } let head = trim_string( @@ -1747,7 +1746,7 @@ async fn checkout_with_promisor_retry_clone( Some(db) => db None => { let db = @bitlibnative.native_promisor_db(fs, git_dir) - if !(db.has_promisor()) { + if !db.has_promisor() { raise err } promisor_db = Some(db) @@ -1865,7 +1864,7 @@ async fn warn_case_insensitive_collisions_from_commit( git_dir : String, commit_id : @bitcore.ObjectId, ) -> Unit raise Error { - if !(worktree_is_case_insensitive_for_clone(fs, git_dir)) { + if !worktree_is_case_insensitive_for_clone(fs, git_dir) { return } let db = @bitlib.ObjectDb::load_lazy(fs, git_dir) catch { _ => return } diff --git a/src/cmd/bit/clone_wbtest.mbt b/src/cmd/bit/clone_wbtest.mbt index d6e8728e..e4b72f34 100644 --- a/src/cmd/bit/clone_wbtest.mbt +++ b/src/cmd/bit/clone_wbtest.mbt @@ -171,7 +171,7 @@ fn cleanup_clone_wbtest_tree(fs : OsFs, path : String) -> Unit { } return } - if !(fs.is_dir(path)) { + if !fs.is_dir(path) { return } let entries = fs.readdir(path) catch { _ => [] } diff --git a/src/cmd/bit/commit.mbt b/src/cmd/bit/commit.mbt index 17401346..7f99cd47 100644 --- a/src/cmd/bit/commit.mbt +++ b/src/cmd/bit/commit.mbt @@ -65,11 +65,11 @@ fn commit_storage_runtime_delegate_args( if commit_has_merge_state(fs, git_dir) { return None } - if !(commit_has_no_verify_flag(args)) && + if !commit_has_no_verify_flag(args) && fs.is_file(git_dir + "/hooks/pre-commit") { return None } - if !(parsed.quiet) && get_subdir_info(fs, git_dir) is Some(_) { + if !parsed.quiet && get_subdir_info(fs, git_dir) is Some(_) { return None } Some({ @@ -90,7 +90,7 @@ async fn handle_commit(args : Array[String]) -> Unit raise Error { ignore(commit_args_require_standalone_error(args)) if commit_should_use_storage_runtime(args) && - !(commit_signing_requested(git_dir, args)) { + !commit_signing_requested(git_dir, args) { match commit_storage_runtime_delegate_args(fs, git_dir, args) { Some(commit_args) => { // Pass resolved author/committer to storage_runtime via env bridge @@ -236,7 +236,7 @@ async fn handle_commit(args : Array[String]) -> Unit raise Error { i += 2 continue } - _ if arg.has_prefix("-m") && !(arg.has_prefix("-ma")) => { + _ if arg.has_prefix("-m") && !arg.has_prefix("-ma") => { commit_check_message_source_conflict(message_source, "m") message_source = "m" messages.push(string_slice_from(arg, 2)) @@ -450,7 +450,7 @@ async fn handle_commit(args : Array[String]) -> Unit raise Error { allow_empty_message~, ) } - } else if should_edit && !(no_edit) { + } else if should_edit && !no_edit { // -c or --edit: open editor with existing message message = read_commit_message_from_editor( fs, @@ -466,7 +466,7 @@ async fn handle_commit(args : Array[String]) -> Unit raise Error { } // Validate empty message let stripped_msg = commit_prepare_message_for_validation(msg, cleanup_mode) - if stripped_msg.length() == 0 && !(allow_empty_message) { + if stripped_msg.length() == 0 && !allow_empty_message { eprint_line("Aborting commit due to empty commit message.") @sys.exit(1) } @@ -497,7 +497,7 @@ async fn handle_commit(args : Array[String]) -> Unit raise Error { Some(flag) => flag None => signing_commit_config_enabled(git_dir) } - if !(no_verify) { + if !no_verify { let hook_status = run_pre_commit_hook(fs, root, git_dir) if hook_status != 0 { raise @bitcore.GitError::InvalidObject("pre-commit hook failed") @@ -603,10 +603,10 @@ async fn handle_commit(args : Array[String]) -> Unit raise Error { Some(idx) => string_slice_to(msg, idx) None => msg } - if !(quiet) { + if !quiet { let branch_name = commit_get_current_branch(rfs, git_dir) let head_parent = @bitlib.resolve_head_commit(rfs, git_dir) - let is_root = head_parent is None && !(amend) + let is_root = head_parent is None && !amend let branch_display = match branch_name { Some(name) => if is_root { name + " (root-commit)" } else { name } None => if is_root { "(root-commit)" } else { "HEAD" } @@ -684,7 +684,7 @@ fn read_merge_head_ids( git_dir : String, ) -> Array[@bitcore.ObjectId] raise Error { let path = git_dir + "/MERGE_HEAD" - if !(fs.is_file(path)) { + if !fs.is_file(path) { return [] } let ids : Array[@bitcore.ObjectId] = [] @@ -846,7 +846,7 @@ async fn commit_signed( let parent = @bitlib.resolve_head_commit(rfs, git_dir) let entries = @bitlib.read_index_entries(rfs, git_dir) let tree_id = if entries.length() == 0 { - if !(allow_empty) { + if !allow_empty { raise @bitcore.GitError::InvalidObject("Empty index") } match parent { @@ -1025,7 +1025,7 @@ async fn commit_with_merge_heads( let head_parent = @bitlib.resolve_head_commit(rfs, git_dir) let entries = @bitlib.read_index_entries(rfs, git_dir) let tree_id = if entries.length() == 0 { - if !(allow_empty) { + if !allow_empty { raise @bitcore.GitError::InvalidObject("Empty index") } match head_parent { @@ -1301,7 +1301,7 @@ async fn commit_show_diffstat( } // Check deleted files for path, _ in old_entries { - if !(new_entries.contains(path)) { + if !new_entries.contains(path) { files_changed += 1 } } @@ -1322,7 +1322,7 @@ async fn commit_show_diffstat( } } for path, old_id in old_entries { - if !(new_entries.contains(path)) { + if !new_entries.contains(path) { deletions += commit_blob_line_count(rfs, db, old_id) } } @@ -1431,8 +1431,7 @@ async fn commit_handle_pathspec_staging( for pathspec in pathspecs { let rel_path = commit_resolve_pathspec(root, pathspec) // Check if path exists in index or as a file - if !(index_paths.contains(rel_path)) && - !(fs.is_file(root + "/" + rel_path)) { + if !index_paths.contains(rel_path) && !fs.is_file(root + "/" + rel_path) { eprint_line( "error: pathspec '\{pathspec}' did not match any file(s) known to git", ) @@ -1576,7 +1575,7 @@ fn abs_path(path : String) -> String { async fn run_pre_commit_hook(fs : OsFs, root : String, git_dir : String) -> Int { let hook_git_dir = abs_path(git_dir) let hook_path = hook_git_dir + "/hooks/pre-commit" - if !(fs.is_file(hook_path)) { + if !fs.is_file(hook_path) { return 0 } let work_root = abs_path(root) diff --git a/src/cmd/bit/commit_graph.mbt b/src/cmd/bit/commit_graph.mbt index b7d82c3b..3bf1b135 100644 --- a/src/cmd/bit/commit_graph.mbt +++ b/src/cmd/bit/commit_graph.mbt @@ -7,7 +7,7 @@ async fn validate_commit_graph_hash_version( ) -> Unit { let rfs : &@bitcore.RepoFileSystem = fs let graph_path = git_dir + "/objects/info/commit-graph" - if !(rfs.is_file(graph_path)) { + if !rfs.is_file(graph_path) { return } let data = rfs.read_file(graph_path) catch { _ => return } @@ -45,7 +45,7 @@ async fn check_commit_graph_paranoia( } let rfs : &@bitcore.RepoFileSystem = fs let graph_path = git_dir + "/objects/info/commit-graph" - if !(rfs.is_file(graph_path)) { + if !rfs.is_file(graph_path) { return } let data = rfs.read_file(graph_path) catch { _ => return } @@ -116,7 +116,7 @@ async fn check_commit_graph_paranoia( // Check if object exists in the database (loose or packed) let hex = oid.to_hex() let exists = commit_graph_object_exists(db, rfs, hex) - if !(exists) { + if !exists { eprint_line( "error: commit \{hex} exists in commit-graph but not in the object database", ) diff --git a/src/cmd/bit/commit_graph_write.mbt b/src/cmd/bit/commit_graph_write.mbt index 30a14e5e..403e9cbb 100644 --- a/src/cmd/bit/commit_graph_write.mbt +++ b/src/cmd/bit/commit_graph_write.mbt @@ -295,7 +295,7 @@ async fn write_commit_graph( } // Write file let info_dir = git_dir + "/objects/info" - if !(rfs.is_dir(info_dir)) { + if !rfs.is_dir(info_dir) { fs.mkdir_p(info_dir) } let graph_path = info_dir + "/commit-graph" @@ -328,7 +328,7 @@ fn cgraph_walk_commits( out.push(id) let info = @bitcore.parse_commit(o.data) catch { _ => continue } for parent in info.parents { - if !(seen.contains(parent.to_hex())) { + if !seen.contains(parent.to_hex()) { stack.push(parent) } } diff --git a/src/cmd/bit/commit_tree.mbt b/src/cmd/bit/commit_tree.mbt index 448f36d3..997caa09 100644 --- a/src/cmd/bit/commit_tree.mbt +++ b/src/cmd/bit/commit_tree.mbt @@ -20,7 +20,7 @@ async fn handle_commit_tree(args : Array[String]) -> Unit raise Error { "-p" if i + 1 < args.length() => { let parent_hex = args[i + 1] let parent_id = commit_tree_resolve_hex(rfs, git_dir, parent_hex) - if !(parents.contains(parent_id)) { + if !parents.contains(parent_id) { parents.push(parent_id) } i += 2 @@ -51,7 +51,7 @@ async fn handle_commit_tree(args : Array[String]) -> Unit raise Error { String::unsafe_substring(arg, start=2, end=arg.length()), ) _ if arg.has_prefix("--gpg-sign=") => () - _ if !(arg.has_prefix("-")) && tree_hex is None => tree_hex = Some(arg) + _ if !arg.has_prefix("-") && tree_hex is None => tree_hex = Some(arg) _ if arg.has_prefix("-") => warn_unimplemented_arg("commit-tree", arg) _ => () } @@ -136,7 +136,7 @@ fn get_commit_tree_ident( let mut email = email_from_env.unwrap_or("") let name_set = name_from_env is Some(_) let email_set = email_from_env is Some(_) - if (!(name_set) && name == "") || (!(email_set) && email == "") { + if (!name_set && name == "") || (!email_set && email == "") { let config_path = git_dir + "/config" if fs.is_file(config_path) { let content = decode_bytes( @@ -156,7 +156,7 @@ fn get_commit_tree_ident( continue } if in_user { - if !(name_set) && name == "" && line.has_prefix("name") { + if !name_set && name == "" && line.has_prefix("name") { match line.find("=") { Some(idx) => name = trim_chars( @@ -170,7 +170,7 @@ fn get_commit_tree_ident( None => () } } - if !(email_set) && email == "" && line.has_prefix("email") { + if !email_set && email == "" && line.has_prefix("email") { match line.find("=") { Some(idx) => email = trim_chars( diff --git a/src/cmd/bit/config.mbt b/src/cmd/bit/config.mbt index 08e27519..dd9f88f8 100644 --- a/src/cmd/bit/config.mbt +++ b/src/cmd/bit/config.mbt @@ -298,7 +298,7 @@ async fn handle_config(args : Array[String]) -> Unit raise Error { replace_all_mode || unset_mode || unset_all || - (!(get_mode) && value is Some(_)) + (!get_mode && value is Some(_)) if config_path == "-" && write_to_config { eprint_line("fatal: writing to stdin is not supported") @sys.exit(1) @@ -357,7 +357,7 @@ async fn handle_config(args : Array[String]) -> Unit raise Error { } // Check if specified config file exists (required for explicit scope modes in read operations) let is_read_op = list_mode || get_mode || get_all_mode || get_regexp_mode - if is_read_op && config_path != "-" && !(@fs.path_exists(config_path)) { + if is_read_op && config_path != "-" && !@fs.path_exists(config_path) { if config_path_override is Some(_) || (global_mode && @sys.get_env_var("GIT_CONFIG_GLOBAL") is Some(_)) || (system_mode && @sys.get_env_var("GIT_CONFIG_SYSTEM") is Some(_)) { @@ -376,9 +376,9 @@ async fn handle_config(args : Array[String]) -> Unit raise Error { } let need_multi_source = (show_scope || show_origin) && config_path_override is None && - !(global_mode) && - !(system_mode) && - !(local_mode) + !global_mode && + !system_mode && + !local_mode if need_multi_source { // Multi-source list with scope/origin prefix let rfs3 : &@bitcore.RepoFileSystem = fs @@ -534,16 +534,16 @@ async fn handle_config(args : Array[String]) -> Unit raise Error { ) None => false } - if !(found) { + if !found { @sys.exit(1) } } else { // Multi-source get-regexp when no explicit scope let need_multi_source = (show_scope || show_origin) && config_path_override is None && - !(global_mode) && - !(system_mode) && - !(local_mode) + !global_mode && + !system_mode && + !local_mode let mut found = false if need_multi_source { let rfs4 : &@bitcore.RepoFileSystem = fs @@ -659,7 +659,7 @@ async fn handle_config(args : Array[String]) -> Unit raise Error { origin=regexp_origin, ) } - if !(found) { + if !found { @sys.exit(1) } } @@ -704,14 +704,14 @@ async fn handle_config(args : Array[String]) -> Unit raise Error { } guard key is Some(k) else { // No key given: check if any action mode was specified - if !(get_mode) && - !(get_all_mode) && - !(unset_mode) && - !(unset_all) && - !(replace_all_mode) && - !(remove_section_mode) && - !(rename_section_mode) && - !(get_regexp_mode) { + if !get_mode && + !get_all_mode && + !unset_mode && + !unset_all && + !replace_all_mode && + !remove_section_mode && + !rename_section_mode && + !get_regexp_mode { eprint_line("error: no action specified") @sys.exit(2) } @@ -817,14 +817,14 @@ async fn handle_config(args : Array[String]) -> Unit raise Error { // Read config if fixed_value_mode { let has_pattern = value_pattern is Some(_) || value is Some(_) - if !(has_pattern) { + if !has_pattern { raise @bitcore.GitError::InvalidObject( "value required for --fixed-value", ) } } if get_all_mode { - let vp : String? = if get_mode && !(get_color_mode) { + let vp : String? = if get_mode && !get_color_mode { match value_pattern { Some(p) => Some(p) None => value @@ -897,7 +897,7 @@ async fn handle_config(args : Array[String]) -> Unit raise Error { } } } else { - let vp : String? = if get_mode && !(get_color_mode) { + let vp : String? = if get_mode && !get_color_mode { match value_pattern { Some(p) => Some(p) None => value @@ -1286,7 +1286,7 @@ async fn validate_config_file(config_path : String, content : String) -> Unit { } } } - if !(in_section) { + if !in_section { // Line outside any section — syntax error eprint_line("fatal: bad config line \{line_num} in \{location}") @sys.exit(128) @@ -1301,17 +1301,15 @@ async fn validate_config_file(config_path : String, content : String) -> Unit { // Valid key: only alphanumeric + '-' let mut valid_key = true for c in kpart { - if !( - (c >= 'a' && c <= 'z') || - (c >= 'A' && c <= 'Z') || - (c >= '0' && c <= '9') || - c == '-', - ) { + if !((c >= 'a' && c <= 'z') || + (c >= 'A' && c <= 'Z') || + (c >= '0' && c <= '9') || + c == '-') { valid_key = false break } } - if !(valid_key) { + if !valid_key { eprint_line("fatal: bad config line \{line_num} in \{location}") @sys.exit(128) } @@ -1335,15 +1333,15 @@ async fn validate_config_file(config_path : String, content : String) -> Unit { continue } if c == '"' { - in_quote = !(in_quote) + in_quote = !in_quote } // Check for unquoted comment — stop scanning - if !(in_quote) && (c == '#' || c == ';') { + if !in_quote && (c == '#' || c == ';') { break } } // Check if continuation line (escaped newline at end) - if in_quote && !(escaped) && !(val_part.has_suffix("\\")) { + if in_quote && !escaped && !val_part.has_suffix("\\") { // Unclosed quote without continuation eprint_line("fatal: bad config line \{line_num} in \{location}") @sys.exit(128) @@ -1423,7 +1421,7 @@ fn remove_empty_sections( let remove_headers : Array[Int] = [] for range in section_ranges { let (idx, matches, keys, comments) = range - if matches && !(keys) && !(comments) { + if matches && !keys && !comments { // Don't remove if a preceding comment (not part of continuation) exists // before the section header. Scan backwards skipping blank lines. let mut skip_section = false @@ -1444,7 +1442,7 @@ fn remove_empty_sections( is_continuation = true } } - if !(is_continuation) { + if !is_continuation { skip_section = true } } @@ -1480,7 +1478,7 @@ fn remove_empty_sections( } let result : Array[String] = [] for i, line in lines { - if !(remove_set[i]) { + if !remove_set[i] { result.push(line) } } @@ -1586,7 +1584,7 @@ fn is_continuation_context(line : String) -> Bool { start=ei + 1, end=line.length(), ) - !(has_unquoted_comment_before_backslash(after_eq)) + !has_unquoted_comment_before_backslash(after_eq) } } } @@ -1601,10 +1599,10 @@ fn has_unquoted_comment_before_backslash(value : String) -> Bool { if c == '"' { // Check if it's escaped let escaped = if i > 0 { value[i - 1] == '\\' } else { false } - if !(escaped) { - in_quote = !(in_quote) + if !escaped { + in_quote = !in_quote } - } else if !(in_quote) && (c == '#' || c == ';') { + } else if !in_quote && (c == '#' || c == ';') { last_comment_pos = i break } @@ -1648,7 +1646,7 @@ async fn list_config( scope? : String = "", origin? : String = "", ) -> Unit raise Error { - if !(fs.is_file(config_path)) { + if !fs.is_file(config_path) { return } let content = decode_bytes(fs.read_file(config_path)) @@ -1819,7 +1817,7 @@ fn get_config_value( value_pattern : String?, fixed_value : Bool, ) -> String? raise Error { - if !(fs.is_file(config_path)) { + if !fs.is_file(config_path) { return None } let raw_content = decode_bytes(fs.read_file(config_path)) @@ -1847,7 +1845,7 @@ fn get_all_config_values( value_pattern : String?, fixed_value : Bool, ) -> Array[String] raise Error { - if !(fs.is_file(config_path)) { + if !fs.is_file(config_path) { return [] } let raw_content = decode_bytes(fs.read_file(config_path)) @@ -2347,7 +2345,7 @@ fn regex_char_class_matches(pc : Array[Char], pi : Int, c : Char) -> Bool { i += 1 } if negate { - !(matched) + !matched } else { matched } @@ -2364,7 +2362,7 @@ fn config_value_pattern_matches(text : String, pattern : String) -> Bool { } let result = config_regex_matches(text, actual) if negate { - !(result) + !result } else { result } @@ -2409,7 +2407,7 @@ fn set_config_with_fixed_value( } let encoded_value = encode_config_value(value) let comment_suffix = format_comment_suffix(comment) - if !(rfs.is_file(config_path)) { + if !rfs.is_file(config_path) { // Create new config file wfs.write_string( config_path, @@ -2534,7 +2532,7 @@ fn set_config_with_fixed_value( match parse_section_header_line(trimmed) { Some((hs, hsub, rest, _)) => { in_sec2 = section_header_matches(hs, hsub, section, subsection) - if in_sec2 && !(replaced) && rest.length() > 0 { + if in_sec2 && !replaced && rest.length() > 0 { let inline_eq_idx = rest.find("=") let mut inline_match = false match inline_eq_idx { @@ -2575,7 +2573,7 @@ fn set_config_with_fixed_value( result.push(line) } None => { - if in_sec2 && !(replaced) { + if in_sec2 && !replaced { let eq_idx = trimmed.find("=") match eq_idx { Some(idx) => { @@ -2630,7 +2628,7 @@ fn set_config_with_fixed_value( let trimmed = trim_string(line) match parse_section_header_line(trimmed) { Some((hs, hsub, rest, dot_form)) => { - if in_section && !(found) { + if in_section && !found { // Insert at end of previous section result.push("\t" + name + " = " + encoded_value + comment_suffix) found = true @@ -2643,7 +2641,7 @@ fn set_config_with_fixed_value( section_end = i } // Handle inline key-value after section header: [section] key = value - if in_section && rest.length() > 0 && !(add_mode) { + if in_section && rest.length() > 0 && !add_mode { let rest_eq = rest.find("=") match rest_eq { Some(rei) => { @@ -2668,7 +2666,7 @@ fn set_config_with_fixed_value( result.push(line) } None => { - if in_section && !(add_mode) { + if in_section && !add_mode { let eq_idx = trimmed.find("=") match eq_idx { Some(idx) => { @@ -2694,7 +2692,7 @@ fn set_config_with_fixed_value( } } } - if !(found) { + if !found { if in_section || in_section_for_insert { // In matching section at end of file, append here result.push("\t" + name + " = " + encoded_value + comment_suffix) @@ -2704,7 +2702,7 @@ fn set_config_with_fixed_value( let new_result : Array[String] = [] for i, line in result { new_result.push(line) - if i == section_end && !(found) { + if i == section_end && !found { new_result.push("\t" + name + " = " + encoded_value + comment_suffix) found = true } @@ -2715,7 +2713,7 @@ fn set_config_with_fixed_value( ) return } - if !(found) { + if !found { // Add new section at end result.push(section_header) result.push("\t" + name + " = " + encoded_value + comment_suffix) @@ -2735,7 +2733,7 @@ fn unset_config( ) -> Unit raise Error { let rfs : &@bitcore.RepoFileSystem = fs let wfs : &@bitcore.FileSystem = fs - if !(rfs.is_file(config_path)) { + if !rfs.is_file(config_path) { return } guard parse_config_key(key) is Some((section, subsection, name)) else { @@ -2748,7 +2746,7 @@ fn unset_config( ignore(lines.pop()) } // First pass: count matching entries for ambiguous detection - if !(unset_all) && value_pattern is None { + if !unset_all && value_pattern is None { let match_count = count_config_matches(lines, section, subsection, name_l) if match_count > 1 { raise @bitcore.GitError::InvalidObject("key '\{key}' has multiple values") @@ -2823,7 +2821,7 @@ fn unset_config( if unset_all { continue } - if !(removed) { + if !removed { removed = true continue } @@ -2862,7 +2860,7 @@ fn unset_config( val, value_pattern, fixed_value, ) if should_remove { - if unset_all || !(removed) { + if unset_all || !removed { removed = true // Check if line has continuation if line.has_suffix("\\") { @@ -2876,7 +2874,7 @@ fn unset_config( None => { let key_only = trim_chars(trimmed, " \t") if key_only.to_lower() == name_l && value_pattern is None { - if unset_all || !(removed) { + if unset_all || !removed { removed = true continue } @@ -2886,7 +2884,7 @@ fn unset_config( } result.push(line) } - if !(removed) { + if !removed { @sys.exit(5) } let cleaned = remove_empty_sections(result, section, subsection) @@ -2980,7 +2978,7 @@ fn replace_all_config( let encoded_value = encode_config_value(value) let comment_suffix = format_comment_suffix(comment) let new_line = "\t" + name + " = " + encoded_value + comment_suffix - if !(rfs.is_file(config_path)) { + if !rfs.is_file(config_path) { let section_header = match subsection { Some(sub) => "[\{section} \"\{sub}\"]" None => "[\{section}]" @@ -3199,7 +3197,7 @@ async fn get_regexp_config( scope? : String = "", origin? : String = "", ) -> Bool raise Error { - if !(fs.is_file(config_path)) { + if !fs.is_file(config_path) { return false } let raw_content = decode_bytes(fs.read_file(config_path)) @@ -3348,7 +3346,7 @@ fn remove_config_section_file( ) -> Unit raise Error { let rfs : &@bitcore.RepoFileSystem = fs let wfs : &@bitcore.FileSystem = fs - if !(rfs.is_file(config_path)) { + if !rfs.is_file(config_path) { return } let parts : Array[String] = [] @@ -3390,7 +3388,7 @@ fn remove_config_section_file( None => if in_section { continue } else { result.push(line) } } } - if !(found_section) { + if !found_section { raise @bitcore.GitError::InvalidObject("no such section: '\{section_key}'") } wfs.write_string(config_path, ensure_trailing_newline(result.join("\n"))) @@ -3405,7 +3403,7 @@ fn rename_config_section( ) -> Unit raise Error { let rfs : &@bitcore.RepoFileSystem = fs let wfs : &@bitcore.FileSystem = fs - if !(rfs.is_file(config_path)) { + if !rfs.is_file(config_path) { raise @bitcore.GitError::InvalidObject("no such section: '\{old_name}'") } // Reject empty names @@ -3425,7 +3423,7 @@ fn rename_config_section( new_sec_parts.push(p.to_string()) } let new_sec_name = new_sec_parts[0] - if !(is_valid_section_name(new_sec_name)) { + if !is_valid_section_name(new_sec_name) { raise @bitcore.GitError::InvalidObject( "invalid section name: '\{new_name}'", ) @@ -3514,7 +3512,7 @@ fn rename_config_section( None => result.push(line) } } - if !(found) { + if !found { raise @bitcore.GitError::InvalidObject("no such section: '\{old_name}'") } wfs.write_string(config_path, ensure_trailing_newline(result.join("\n"))) diff --git a/src/cmd/bit/count_objects.mbt b/src/cmd/bit/count_objects.mbt index 805954a5..bf70d2a7 100644 --- a/src/cmd/bit/count_objects.mbt +++ b/src/cmd/bit/count_objects.mbt @@ -30,7 +30,7 @@ async fn handle_count_objects(args : Array[String]) -> Unit raise Error { for i = 0; i < 256; i = i + 1 { let hex = count_objects_hex_byte(i) let subdir = objects_dir + "/" + hex - if !(rfs.is_dir(subdir)) { + if !rfs.is_dir(subdir) { continue } let entries = rfs.readdir(subdir) catch { _ => continue } @@ -46,7 +46,7 @@ async fn handle_count_objects(args : Array[String]) -> Unit raise Error { loose_size += data.length().to_int64() } } - if !(verbose) { + if !verbose { let size_kb = (loose_size + 1023L) / 1024L if human_readable { print_line( @@ -80,7 +80,7 @@ async fn handle_count_objects(args : Array[String]) -> Unit raise Error { () } else if entry != "." && entry != ".." && - !(entry.has_prefix("multi-pack-index")) { + !entry.has_prefix("multi-pack-index") { garbage_count += 1 let gpath = pack_dir + "/" + entry let data = rfs.read_file(gpath) catch { _ => continue } @@ -141,7 +141,7 @@ fn count_objects_hex_byte(n : Int) -> String { ///| fn count_objects_format_size(bytes : Int64, human : Bool) -> String { - if !(human) { + if !human { let kb = (bytes + 1023L) / 1024L return "\{kb} kilobytes" } diff --git a/src/cmd/bit/credential.mbt b/src/cmd/bit/credential.mbt index 24da7e4d..7932585f 100644 --- a/src/cmd/bit/credential.mbt +++ b/src/cmd/bit/credential.mbt @@ -12,7 +12,7 @@ async fn handle_credential(args : Array[String]) -> Unit raise Error { ) return } - _ if !(arg.has_prefix("-")) => positional.push(arg) + _ if !arg.has_prefix("-") => positional.push(arg) _ => () } } diff --git a/src/cmd/bit/describe.mbt b/src/cmd/bit/describe.mbt index 64b03d0b..58071755 100644 --- a/src/cmd/bit/describe.mbt +++ b/src/cmd/bit/describe.mbt @@ -23,7 +23,7 @@ async fn handle_describe(args : Array[String]) -> Unit raise Error { ) _ if arg.has_prefix("--dirty=") => dirty_mark = String::unsafe_substring(arg, start=8, end=arg.length()) - _ if !(arg.has_prefix("-")) => commit_ref = arg + _ if !arg.has_prefix("-") => commit_ref = arg _ => () } } @@ -34,7 +34,7 @@ async fn handle_describe(args : Array[String]) -> Unit raise Error { } // Get all tags let tags = get_all_tags(rfs, git_dir, use_tags) - if tags.length() == 0 && !(always) { + if tags.length() == 0 && !always { @stdio.stderr.write("fatal: No names found, cannot describe anything.") @sys.exit(128) } @@ -42,7 +42,7 @@ async fn handle_describe(args : Array[String]) -> Unit raise Error { let result = find_closest_tag(rfs, git_dir, tid, tags) match result { Some((tag_name, distance, tag_commit)) => { - let output = if distance == 0 && !(long_format) { + let output = if distance == 0 && !long_format { tag_name + dirty_mark } else { let short_sha = String::unsafe_substring( @@ -80,7 +80,7 @@ fn get_all_tags( ) -> Map[String, @bitcore.ObjectId] raise Error { let tags : Map[String, @bitcore.ObjectId] = {} let tags_dir = git_dir + "/refs/tags" - if !(rfs.is_dir(tags_dir)) { + if !rfs.is_dir(tags_dir) { return tags } let entries = rfs.readdir(tags_dir) catch { _ => return tags } @@ -162,7 +162,7 @@ fn find_closest_tag( Some(o) => { let info = @bitcore.parse_commit(o.data) for p in info.parents { - if !(visited.get(p.to_hex()).unwrap_or(false)) { + if !visited.get(p.to_hex()).unwrap_or(false) { queue.push((p, distance + 1)) } } diff --git a/src/cmd/bit/diff.mbt b/src/cmd/bit/diff.mbt index 6f76ef84..d27466f1 100644 --- a/src/cmd/bit/diff.mbt +++ b/src/cmd/bit/diff.mbt @@ -292,7 +292,7 @@ fn diff_current_relative_prefix(root : String) -> String { let cwd = diff_effective_cwd(root) let root_norm = normalize_path(root) let cwd_norm = normalize_path(cwd) - if cwd_norm == root_norm || !(is_path_prefix(cwd_norm, root_norm)) { + if cwd_norm == root_norm || !is_path_prefix(cwd_norm, root_norm) { return "" } let mut suffix = String::unsafe_substring( @@ -372,7 +372,7 @@ fn diff_apply_relative_path(path : String, prefix : String) -> String? { if trimmed.length() == 0 { return Some(path) } - if !(path.has_prefix(trimmed)) { + if !path.has_prefix(trimmed) { return None } let mut rest = String::unsafe_substring( @@ -534,7 +534,7 @@ fn diff_filter_ignore_all_space( for file in files { let mode_changed = file.old_mode != file.new_mode if mode_changed || - !(diff_ignore_all_space_equal(file.old_content, file.new_content)) { + !diff_ignore_all_space_equal(file.old_content, file.new_content) { out.push(file) } } @@ -600,7 +600,7 @@ fn diff_conflict_marker_size( path : String, ) -> Int { let attr_path = root + "/.gitattributes" - if !(fs.is_file(attr_path)) { + if !fs.is_file(attr_path) { return 7 } let content = @utf8.decode_lossy( @@ -619,8 +619,7 @@ fn diff_conflict_marker_size( words.push(token) } } - if words.length() < 2 || - !(diff_gitattributes_pattern_matches(path, words[0])) { + if words.length() < 2 || !diff_gitattributes_pattern_matches(path, words[0]) { continue } for i in 1.. String { - if !(compact_summary) { + if !compact_summary { return file.path } let suffix = match file.kind { @@ -1199,7 +1198,7 @@ fn diff_extra_unmerged_name_only_paths( } let extra : Array[String] = [] for path, _ in unmerged_paths { - if !(diff_path_matches_filters(path, filters)) { + if !diff_path_matches_filters(path, filters) { continue } let display_path = match relative_prefix { @@ -1282,10 +1281,8 @@ fn diff_should_auto_no_index( path_a : String, path_b : String, ) -> Bool { - if !( - diff_no_index_operand_exists(fs, root, path_a) && - diff_no_index_operand_exists(fs, root, path_b), - ) { + if !(diff_no_index_operand_exists(fs, root, path_a) && + diff_no_index_operand_exists(fs, root, path_b)) { return false } path_a.has_prefix("../") || @@ -1333,19 +1330,17 @@ fn diff_has_dirty_submodules( ) -> Bool raise Error { let index_entries = @bitlib.read_index_entries(rfs, git_dir) for entry in index_entries { - if !(is_gitlink_mode_for_diff(entry.mode)) { + if !is_gitlink_mode_for_diff(entry.mode) { continue } if filters.length() > 0 && - !( - filters - .iter() - .any(fn(filter) { ls_files_pathspec_matches(entry.path, filter) }), - ) { + !filters + .iter() + .any(fn(filter) { ls_files_pathspec_matches(entry.path, filter) }) { continue } let sub_root = root + "/" + entry.path - if !(fs.is_dir(sub_root)) { + if !fs.is_dir(sub_root) { continue } let sub_git_dir = resolve_git_dir(rfs, sub_root) @@ -1522,9 +1517,9 @@ async fn handle_diff(args : Array[String]) -> Unit raise Error { let num_str = string_slice_from(arg, 10) context_lines = @string.parse_int(num_str) } - _ if !(arg.has_prefix("-")) => - if !(no_index) && - !(diff_is_existing_fs_path(fs, root, arg)) && + _ if !arg.has_prefix("-") => + if !no_index && + !diff_is_existing_fs_path(fs, root, arg) && (arg.contains("^!") || arg.contains("..")) { if range_spec is None { range_spec = Some(arg) @@ -1551,8 +1546,8 @@ async fn handle_diff(args : Array[String]) -> Unit raise Error { _ if arg.has_prefix("-") => warn_unimplemented_arg("diff", arg) _ => () } - } else if !(no_index) && - !(diff_is_existing_fs_path(fs, root, arg)) && + } else if !no_index && + !diff_is_existing_fs_path(fs, root, arg) && (arg.contains("^!") || arg.contains("..")) { if range_spec is None { range_spec = Some(arg) @@ -1601,7 +1596,7 @@ async fn handle_diff(args : Array[String]) -> Unit raise Error { } else { paths } - if !(no_index) && + if !no_index && range_spec is None && ref_target is None && path_args.length() >= 2 && @@ -1644,7 +1639,7 @@ async fn handle_diff(args : Array[String]) -> Unit raise Error { ), relative_prefix, ) - if !(quiet) { + if !quiet { for line in diff_collect_no_index_output_lines( entries, output, context_lines, no_prefix, @@ -1755,7 +1750,7 @@ async fn handle_diff(args : Array[String]) -> Unit raise Error { let display_files = diff_apply_relative_files(files, relative_prefix) // If an external diff program is configured, use it instead of built-in output match diff_get_external_command(rfs, git_dir) { - Some(ext_cmd) if !(check_mode) && !(quiet) => { + Some(ext_cmd) if !check_mode && !quiet => { diff_run_external(ext_cmd, root, files) if exit_code && display_files.length() > 0 { @sys.exit(1) @@ -1771,16 +1766,16 @@ async fn handle_diff(args : Array[String]) -> Unit raise Error { } let has_dirty_submodules = submodule_mode && exit_code && - !(cached) && + !cached && range_spec is None && diff_has_dirty_submodules(fs, rfs, root, git_dir, normalized_path_args) if check_mode { for issue in check_issues { print_line("\{issue.path}:\{issue.line}: \{issue.message}") } - } else if !(quiet) { + } else if !quiet { let extra_unmerged = if output.name_only && - !(cached) && + !cached && ref_target is None && range_spec is None { diff_extra_unmerged_name_only_paths( @@ -1860,13 +1855,15 @@ async fn handle_diff_files(args : Array[String]) -> Unit raise Error { delegate_to_diff = false } _ if arg.has_prefix("--ignore-submodules=") => - ignore_submodules = !( - String::unsafe_substring(arg, start=20, end=arg.length()) + ignore_submodules = !(String::unsafe_substring( + arg, + start=20, + end=arg.length(), + ) .trim() .to_lower() == - "none", - ) - _ if !(arg.has_prefix("-")) => filters.push(arg) + "none") + _ if !arg.has_prefix("-") => filters.push(arg) _ => () } } else { @@ -1890,7 +1887,7 @@ async fn handle_diff_files(args : Array[String]) -> Unit raise Error { if exit_code { @sys.exit(1) } - if !(quiet) && !(no_patch_only) { + if !quiet && !no_patch_only { if name_only { for change in changes { print_line(change.path) @@ -1998,12 +1995,12 @@ async fn handle_diff_index(args : Array[String]) -> Unit raise Error { let rfs : &@bitcore.RepoFileSystem = fs let git_dir = resolve_git_dir(rfs, root) let target = treeish.unwrap_or("HEAD") - if !(cached) { + if !cached { let changes = diff_collect_raw_changes_against_tree( fs, rfs, root, git_dir, target, filters, ) let has_changes = changes.length() > 0 - if !(quiet) && !(no_patch_only) { + if !quiet && !no_patch_only { if name_only { for change in changes { print_line(change.path) @@ -2035,12 +2032,12 @@ async fn handle_diff_index(args : Array[String]) -> Unit raise Error { } let stale : Array[@bitlib.IndexEntry] = [] for entry in stale_all { - if !(staged_paths.contains(entry.path)) { + if !staged_paths.contains(entry.path) { stale.push(entry) } } let has_changes = staged.length() > 0 || stale.length() > 0 - if !(quiet) && !(no_patch_only) { + if !quiet && !no_patch_only { if name_only { for file in staged { print_line(file.path) @@ -2051,10 +2048,7 @@ async fn handle_diff_index(args : Array[String]) -> Unit raise Error { } else { for file in staged { print_line( - format_diff_index_line_from_diff_file( - file, - worktree_compare=!(cached), - ), + format_diff_index_line_from_diff_file(file, worktree_compare=!cached), ) } for entry in stale { @@ -2183,7 +2177,7 @@ fn diff_filter_raw_submodule_changes( changes : Array[DiffRawWorktreeChange], ignore_submodules : Bool, ) -> Array[DiffRawWorktreeChange] { - if !(ignore_submodules) { + if !ignore_submodules { return changes } let filtered : Array[DiffRawWorktreeChange] = [] @@ -2193,7 +2187,7 @@ fn diff_filter_raw_submodule_changes( (_, Some(0o160000)) => true _ => false } - if !(is_gitlink) { + if !is_gitlink { filtered.push(change) } } @@ -2270,7 +2264,7 @@ async fn diff_collect_raw_changes_against_index( let entries = @bitlib.read_index_entries(fs, git_dir) let changes : Array[DiffRawWorktreeChange] = [] for entry in entries { - if !(diff_path_matches_filters(entry.path, filters)) { + if !diff_path_matches_filters(entry.path, filters) { continue } // Match git's stat-based behavior: when the index has zero stat data @@ -2342,14 +2336,14 @@ async fn diff_collect_raw_changes_against_tree( let paths : Array[String] = [] for entry in tree_entries { let path = entry.0 - if diff_path_matches_filters(path, filters) && !(seen.contains(path)) { + if diff_path_matches_filters(path, filters) && !seen.contains(path) { seen[path] = true paths.push(path) } } for entry in index_entries { let path = entry.path - if diff_path_matches_filters(path, filters) && !(seen.contains(path)) { + if diff_path_matches_filters(path, filters) && !seen.contains(path) { seen[path] = true paths.push(path) } @@ -2382,14 +2376,14 @@ async fn collect_diff_index_stale_entries( let entries = @bitlib.read_index_entries(fs, git_dir) let stale : Array[@bitlib.IndexEntry] = [] for entry in entries { - if !(diff_path_matches_filters(entry.path, filters)) { + if !diff_path_matches_filters(entry.path, filters) { continue } if is_gitlink_mode_for_diff(entry.mode) { continue } let mut is_stale = entry.mtime_sec == 0 && entry.mtime_nsec == 0 - if !(is_stale) { + if !is_stale { let abs = root + "/" + entry.path let mtime_result : Result[(Int64, Int), Error] = try? @asyncfs.mtime( abs, @@ -2402,7 +2396,7 @@ async fn collect_diff_index_stale_entries( } Err(_) => is_stale = true } - if !(is_stale) && entry.mode != 0o120000 { + if !is_stale && entry.mode != 0o120000 { let size_result : Result[Bytes, Error] = try? fs.read_file(abs) match size_result { Ok(content) => if content.length() != entry.size { is_stale = true } @@ -2567,7 +2561,7 @@ async fn diff_worktree_against_ref( } } for file in worktree { - if !(seen.contains(file.path)) { + if !seen.contains(file.path) { // Only in worktree diff — the file exists in index identical to ref, // but has working tree changes result.push(file) @@ -2654,7 +2648,7 @@ async fn try_handle_submodule_range_diff( let changes : Array[(String, @bitcore.ObjectId, @bitcore.ObjectId)] = [] for item in new_entries.to_array() { let (path, new_entry) = item - if !(is_gitlink_mode_for_diff(new_entry.mode)) { + if !is_gitlink_mode_for_diff(new_entry.mode) { continue } match old_entries.get(path) { @@ -2819,11 +2813,11 @@ fn resolve_submodule_git_dir_candidates( candidates.push(worktree_git) } let linked_modules = git_dir + "/modules/" + submodule_name - if rfs.is_dir(linked_modules) && !(candidates.contains(linked_modules)) { + if rfs.is_dir(linked_modules) && !candidates.contains(linked_modules) { candidates.push(linked_modules) } let common_modules = repo_git_dir + "/modules/" + submodule_name - if rfs.is_dir(common_modules) && !(candidates.contains(common_modules)) { + if rfs.is_dir(common_modules) && !candidates.contains(common_modules) { candidates.push(common_modules) } candidates @@ -3087,10 +3081,10 @@ fn diff_no_index_patch_lines( if i == 0 { lines.push("diff --git \{header_old_label} \{header_new_label}") } else if line.has_prefix("index ") { - if !(diff_no_index_should_suppress_index(entry)) { + if !diff_no_index_should_suppress_index(entry) { lines.push(line) } - } else if !(replaced_old) && line.has_prefix("--- ") { + } else if !replaced_old && line.has_prefix("--- ") { replaced_old = true if mode_only { continue @@ -3100,7 +3094,7 @@ fn diff_no_index_patch_lines( _ => "--- \{old_label}" } lines.push(old_line) - } else if !(replaced_new) && line.has_prefix("+++ ") { + } else if !replaced_new && line.has_prefix("+++ ") { replaced_new = true if mode_only { continue @@ -3221,10 +3215,7 @@ async fn diff_no_index_is_file_like(fs : OsFs, abs_path : String) -> Bool { abs_path == "/dev/null" || fs.is_file(abs_path) || diff_no_index_is_named_pipe(abs_path) || - ( - @bitio.read_symlink_target_path(abs_path) is Some(_) && - !(fs.is_dir(abs_path)) - ) + (@bitio.read_symlink_target_path(abs_path) is Some(_) && !fs.is_dir(abs_path)) } ///| @@ -3233,8 +3224,8 @@ async fn diff_no_index_uses_stream_read(fs : OsFs, abs_path : String) -> Bool { diff_no_index_is_named_pipe(abs_path) || ( @bitio.read_symlink_target_path(abs_path) is Some(_) && - !(fs.is_file(abs_path)) && - !(fs.is_dir(abs_path)) + !fs.is_file(abs_path) && + !fs.is_dir(abs_path) ) } @@ -3250,9 +3241,9 @@ async fn diff_no_index_read_path( match @bitio.read_symlink_target_path(abs_path) { Some(target) => // Only treat as symlink content if the target doesn't exist (broken symlink) - if !(fs.is_file(abs_path)) && - !(fs.is_dir(abs_path)) && - !(diff_no_index_is_named_pipe(abs_path)) { + if !fs.is_file(abs_path) && + !fs.is_dir(abs_path) && + !diff_no_index_is_named_pipe(abs_path) { return @utf8.encode(target) } None => () @@ -3431,8 +3422,8 @@ fn diff_no_index_file_mode(fs : OsFs, abs_path : String) -> Int { return 0o100644 } if @bitio.read_symlink_target_path(abs_path) is Some(_) && - !(fs.is_file(abs_path)) && - !(fs.is_dir(abs_path)) { + !fs.is_file(abs_path) && + !fs.is_dir(abs_path) { return 0o100644 } ignore(fs) @@ -3586,7 +3577,7 @@ async fn diff_no_index_dirs( continue } set_b[name] = true - if !(set_a.contains(name)) { + if !set_a.contains(name) { all_names.push(name) } } @@ -3636,7 +3627,7 @@ async fn diff_no_index_dirs( suppress_index: false, }) } - } else if in_a && !(in_b) { + } else if in_a && !in_b { if fs.is_file(path_a) { let content = diff_no_index_read_path(fs, path_a) out.push({ @@ -3655,7 +3646,7 @@ async fn diff_no_index_dirs( } else if fs.is_dir(path_a) { diff_no_index_push_dir_entries(fs, out, path_a, rel_a, false) } - } else if !(in_a) && in_b { + } else if !in_a && in_b { if fs.is_file(path_b) { let content = diff_no_index_read_path(fs, path_b) out.push({ diff --git a/src/cmd/bit/diff_tree.mbt b/src/cmd/bit/diff_tree.mbt index 46e13980..2f15b178 100644 --- a/src/cmd/bit/diff_tree.mbt +++ b/src/cmd/bit/diff_tree.mbt @@ -66,7 +66,7 @@ async fn handle_diff_tree(args : Array[String]) -> Unit raise Error { _ if arg.has_prefix("-l") => () // -l0 etc - rename limit _ if arg.has_prefix("--pretty") => () // --pretty, --pretty=format:... _ if arg.has_prefix("--format") => () // --format=... - _ if !(arg.has_prefix("-")) => positional.push(arg) + _ if !arg.has_prefix("-") => positional.push(arg) _ if arg.has_prefix("-") => warn_unimplemented_arg("diff-tree", arg) _ => () } @@ -124,7 +124,7 @@ async fn handle_diff_tree(args : Array[String]) -> Unit raise Error { let new_id = commit_tree_resolve_hex(rfs, git_dir, positional[1]) let old_tree = diff_tree_resolve_to_tree(db, rfs, old_id) let new_tree = diff_tree_resolve_to_tree(db, rfs, new_id) - if !(suppress) { + if !suppress { diff_tree_output( db, rfs, @@ -176,7 +176,7 @@ async fn diff_tree_process_commit( // For merge commits (>1 parent), skip output unless -c/--cc (which we accept but don't implement yet) if info.parents.length() > 1 { // Print commit id line for merge commits but no diff - if !(no_commit_id) { + if !no_commit_id { print_line(commit_id.to_hex()) } return @@ -195,10 +195,10 @@ async fn diff_tree_process_commit( } else { return } - if !(no_commit_id) { + if !no_commit_id { print_line(commit_id.to_hex()) } - if !(suppress) { + if !suppress { diff_tree_output( db, fs, @@ -341,7 +341,7 @@ async fn diff_tree_output( } } for path, entry in old_entries { - if !(new_entries.contains(path)) { + if !new_entries.contains(path) { if diff_tree_filter_matches(diff_filter, "D") { results.push((path, entry.mode, "000000", entry.id, zero_id, "D")) } diff --git a/src/cmd/bit/difftool.mbt b/src/cmd/bit/difftool.mbt index 3e9c7997..5505d3ac 100644 --- a/src/cmd/bit/difftool.mbt +++ b/src/cmd/bit/difftool.mbt @@ -46,7 +46,7 @@ async fn handle_difftool(args : Array[String]) -> Unit raise Error { } break } - _ if !(arg.has_prefix("-")) => positional.push(arg) + _ if !arg.has_prefix("-") => positional.push(arg) _ if arg.has_prefix("-") => warn_unimplemented_arg("difftool", arg) _ => () } diff --git a/src/cmd/bit/doc.mbt b/src/cmd/bit/doc.mbt index 698c0693..b597d7bb 100644 --- a/src/cmd/bit/doc.mbt +++ b/src/cmd/bit/doc.mbt @@ -73,7 +73,7 @@ async fn handle_x_doc_show( match @xdoc.read_page(rfs, root, args[0]) { Ok(content) => { print_str(content) - if content.length() == 0 || !(content.has_suffix("\n")) { + if content.length() == 0 || !content.has_suffix("\n") { print_line("") } } @@ -179,7 +179,7 @@ async fn handle_x_doc(args : Array[String]) -> Unit raise Error { let wfs : &@bitcore.FileSystem = fs let rfs : &@bitcore.RepoFileSystem = fs let git_dir = resolve_git_dir(rfs, root) - if !(rfs.is_dir(git_dir)) { + if !rfs.is_dir(git_dir) { eprint_line("fatal: not a git repository") @sys.exit(1) } diff --git a/src/cmd/bit/fast_export.mbt b/src/cmd/bit/fast_export.mbt index 999b7f97..ef73807d 100644 --- a/src/cmd/bit/fast_export.mbt +++ b/src/cmd/bit/fast_export.mbt @@ -83,7 +83,7 @@ async fn handle_fast_export(args : Array[String]) -> Unit raise Error { break } } - if !(found) { + if !found { target_refs.push((name, id)) } } @@ -256,7 +256,7 @@ async fn handle_fast_export(args : Array[String]) -> Unit raise Error { } // Find deleted files for path, _entry in parent_files { - if !(tree_files.contains(path)) { + if !tree_files.contains(path) { file_ops.push("D \{path}") } } @@ -313,7 +313,7 @@ async fn handle_fast_export(args : Array[String]) -> Unit raise Error { let msg_bytes = @utf8.encode(message) buf.write_string("data \{msg_bytes.length()}\n") buf.write_string(message) - if !(message.has_suffix("\n")) { + if !message.has_suffix("\n") { buf.write_string("\n") } // from (first parent) @@ -395,7 +395,7 @@ async fn handle_fast_export(args : Array[String]) -> Unit raise Error { let tag_msg_bytes = @utf8.encode(tag_message) buf.write_string("data \{tag_msg_bytes.length()}\n") buf.write_string(tag_message) - if !(tag_message.has_suffix("\n")) { + if !tag_message.has_suffix("\n") { buf.write_string("\n") } buf.write_string("\n") diff --git a/src/cmd/bit/fast_import.mbt b/src/cmd/bit/fast_import.mbt index eb4e4228..5874051a 100644 --- a/src/cmd/bit/fast_import.mbt +++ b/src/cmd/bit/fast_import.mbt @@ -158,7 +158,7 @@ async fn handle_fast_import(args : Array[String]) -> Unit raise Error { parser.skip_line() } } - if require_done && !(done_seen) { + if require_done && !done_seen { eprint_line("fatal: stream did not end with 'done' command") @sys.exit(1) } @@ -195,7 +195,7 @@ async fn handle_fast_import(args : Array[String]) -> Unit raise Error { fs.write_string(abs_path, buf.to_string()) } // Print stats unless quiet - if !(quiet) { + if !quiet { let total = num_blobs + num_commits + num_tags eprint_line( "fast-import statistics: \{total} objects (\{num_blobs} blobs, \{num_commits} commits, \{num_tags} tags)", diff --git a/src/cmd/bit/fetch.mbt b/src/cmd/bit/fetch.mbt index a254a3be..4ef275b1 100644 --- a/src/cmd/bit/fetch.mbt +++ b/src/cmd/bit/fetch.mbt @@ -68,7 +68,7 @@ fn fetch_resolve_default_remote( } } } - if !(ambiguous) { + if !ambiguous { match matched_name { Some(name) => return (name, Some(url)) None => () @@ -94,7 +94,7 @@ fn fetch_resolve_default_remote( } } } - if !(multiple) { + if !multiple { match single_name { Some(name) => return (name, single_url) None => () @@ -211,7 +211,7 @@ async fn handle_fetch(args : Array[String]) -> Unit raise Error { "unknown option '" + option_name_without_prefix(arg) + "'", ) } - if !(arg.has_prefix("-")) { + if !arg.has_prefix("-") { positional_args.push(arg) i += 1 continue @@ -316,7 +316,7 @@ async fn handle_fetch(args : Array[String]) -> Unit raise Error { preferred_sender~, preferred_repo~, ) - if !(quiet) { + if !quiet { print_line("Relay peer selected: \{relay_sender} -> \{relay_fetch_url}") } resolved_remote_url = relay_fetch_url @@ -340,7 +340,7 @@ async fn handle_fetch(args : Array[String]) -> Unit raise Error { } if explicit_no_filter { filter = @protocol.FilterSpec::NoFilter - } else if !(explicit_filter_flag) && inherited_filter.is_partial() { + } else if !explicit_filter_flag && inherited_filter.is_partial() { filter = inherited_filter } let local_root = match @sys.get_env_var("GIT_SHIM_CWD") { @@ -370,7 +370,7 @@ async fn handle_fetch(args : Array[String]) -> Unit raise Error { local_promisor_remote || is_partial_clone ) && - !(has_oid_refspec) + !has_oid_refspec fetch_from_remote( fs, git_dir, diff --git a/src/cmd/bit/fetch_pack.mbt b/src/cmd/bit/fetch_pack.mbt index 5d4f8408..3f6fc4e5 100644 --- a/src/cmd/bit/fetch_pack.mbt +++ b/src/cmd/bit/fetch_pack.mbt @@ -45,7 +45,7 @@ async fn handle_fetch_pack(args : Array[String]) -> Unit raise Error { _ if arg.has_prefix("--server-option=") => () _ if arg.has_prefix("--negotiation-tip=") => () _ if arg == "--" => () - _ if !(arg.has_prefix("-")) => positional.push(arg) + _ if !arg.has_prefix("-") => positional.push(arg) _ if arg.has_prefix("-") => warn_unimplemented_arg("fetch-pack", arg) _ => () } diff --git a/src/cmd/bit/for_each_ref.mbt b/src/cmd/bit/for_each_ref.mbt index 695bc85e..9c02d230 100644 --- a/src/cmd/bit/for_each_ref.mbt +++ b/src/cmd/bit/for_each_ref.mbt @@ -193,7 +193,7 @@ async fn handle_for_each_ref(args : Array[String]) -> Unit raise Error { break } } - if !(matched) { + if !matched { continue } } @@ -237,7 +237,7 @@ async fn handle_for_each_ref(args : Array[String]) -> Unit raise Error { _ => () } } - if !(matches_points_at) { + if !matches_points_at { continue } } @@ -281,7 +281,7 @@ async fn handle_for_each_ref(args : Array[String]) -> Unit raise Error { // --merged: ref's commit must be ancestor of (or equal to) merged_id match merged_id { Some(mid) => - if !(for_each_ref_is_ancestor(fs, db_for_filter, cid, mid)) { + if !for_each_ref_is_ancestor(fs, db_for_filter, cid, mid) { continue } None => () @@ -297,7 +297,7 @@ async fn handle_for_each_ref(args : Array[String]) -> Unit raise Error { // --contains: ref's commit must have contains_id as ancestor match contains_id { Some(coid) => - if !(for_each_ref_is_ancestor(fs, db_for_filter, coid, cid)) { + if !for_each_ref_is_ancestor(fs, db_for_filter, coid, cid) { continue } None => () @@ -488,7 +488,7 @@ async fn for_each_ref_collect_root_refs( for entry in entries { let name = entry // Root ref syntax: all uppercase, hyphens, underscores - if !(for_each_ref_is_root_ref_syntax(name)) { + if !for_each_ref_is_root_ref_syntax(name) { continue } // Skip pseudo refs (FETCH_HEAD, MERGE_HEAD) @@ -503,7 +503,7 @@ async fn for_each_ref_collect_root_refs( continue } // Check if it's a root ref (HEAD, *_HEAD, or known irregular root refs) - if !(for_each_ref_is_root_ref(name)) { + if !for_each_ref_is_root_ref(name) { continue } // Read the ref file @@ -1023,7 +1023,7 @@ async fn for_each_ref_validate_atom(atom : String) -> Unit { } catch { _ => () } - if !(valid) { + if !valid { eprint_line("fatal: positive value expected objectname:short=" + val_str) @sys.exit(1) } @@ -1039,7 +1039,7 @@ async fn for_each_ref_validate_atom(atom : String) -> Unit { start=colon_pos + 1, end=atom.length(), ) - if !(for_each_ref_valid_date_format(date_arg)) { + if !for_each_ref_valid_date_format(date_arg) { eprint_line("fatal: unknown date format " + date_arg) @sys.exit(1) } @@ -1062,7 +1062,7 @@ async fn for_each_ref_validate_atom(atom : String) -> Unit { } } // Validate unknown atom names (must be last check) - if !(for_each_ref_is_known_atom(atom)) { + if !for_each_ref_is_known_atom(atom) { eprint_line("fatal: unknown field name '" + atom + "'") @sys.exit(1) } @@ -1451,7 +1451,7 @@ fn for_each_ref_match_pattern(refname : String, pattern : String) -> Bool { start=star_pos + 1, end=pattern.length(), ) - if !(refname.has_prefix(prefix)) { + if !refname.has_prefix(prefix) { return false } if suffix.length() == 0 { @@ -1723,22 +1723,20 @@ fn for_each_ref_format_needs_object(format : String) -> Bool { FixedArray::makei(end_pos - start, fn(j) { chars[start + j] }), ) // Atoms that DON'T need object data - if !( - atom == "refname" || - atom.has_prefix("refname:") || - atom == "objectname" || - atom.has_prefix("objectname:") || - atom == "HEAD" || - atom == "if" || - atom.has_prefix("if:") || - atom == "then" || - atom == "else" || - atom == "end" || - atom.has_prefix("color:") || - atom.has_prefix("align:") || - atom.has_prefix("is-base:") || - atom.has_prefix("ahead-behind:"), - ) { + if !(atom == "refname" || + atom.has_prefix("refname:") || + atom == "objectname" || + atom.has_prefix("objectname:") || + atom == "HEAD" || + atom == "if" || + atom.has_prefix("if:") || + atom == "then" || + atom == "else" || + atom == "end" || + atom.has_prefix("color:") || + atom.has_prefix("align:") || + atom.has_prefix("is-base:") || + atom.has_prefix("ahead-behind:")) { return true } i = end_pos + 1 @@ -1921,7 +1919,7 @@ async fn for_each_ref_format( None => break } } - if !(found_target) { + if !found_target { break } } @@ -2029,9 +2027,9 @@ async fn for_each_ref_format( } else { // Simple %(if) - true if value is non-empty (git's is_empty: whitespace-only = empty) if_result = if if_cond_raw.length() > 0 { - !(for_each_ref_is_empty_bytes(if_cond_raw)) + !for_each_ref_is_empty_bytes(if_cond_raw) } else { - !(for_each_ref_is_empty_value(if_cond_value)) + !for_each_ref_is_empty_value(if_cond_value) } } if_state = 2 // then branch @@ -2153,7 +2151,7 @@ async fn for_each_ref_format( continue } // In then/else branch, only output if condition matches - if if_state == 2 && !(if_result) { + if if_state == 2 && !if_result { i = end_pos + 1 continue } @@ -2749,7 +2747,7 @@ fn for_each_ref_if_output_active( 0 => true // normal mode 1 => false // evaluating condition, don't output 2 => if_result // then branch: output if condition true - 3 => !(if_result) // else branch: output if condition false + 3 => !if_result // else branch: output if condition false _ => true } } @@ -3046,7 +3044,7 @@ async fn for_each_ref_find_base( for item in commit_refs { let (refname, cid) = item let hex = cid.to_hex() - if !(commit_set.contains(hex)) { + if !commit_set.contains(hex) { commit_set[hex] = refname } } @@ -3075,17 +3073,17 @@ async fn for_each_ref_find_base( start=7, end=line.length(), ) - if !(visited.contains(parent_hex)) { + if !visited.contains(parent_hex) { visited[parent_hex] = true let parent_id = @bitcore.ObjectId::from_hex(parent_hex) catch { _ => continue } queue.push(parent_id) } - } else if !(line.has_prefix("tree ")) && - !(line.has_prefix("author ")) && - !(line.has_prefix("committer ")) && - !(line.has_prefix("parent ")) { + } else if !line.has_prefix("tree ") && + !line.has_prefix("author ") && + !line.has_prefix("committer ") && + !line.has_prefix("parent ") { // Past header lines break } @@ -3268,10 +3266,10 @@ fn for_each_ref_short_refname( let prefix = rule_prefixes[i] let suffix = rule_suffixes[i] // Check if refname matches this rule - if !(refname.has_prefix(prefix)) { + if !refname.has_prefix(prefix) { continue } - if suffix.length() > 0 && !(refname.has_suffix(suffix)) { + if suffix.length() > 0 && !refname.has_suffix(suffix) { continue } let short_name = String::unsafe_substring( @@ -3295,7 +3293,7 @@ fn for_each_ref_short_refname( break } } - if !(ambiguous) { + if !ambiguous { return short_name } } @@ -3494,7 +3492,7 @@ fn for_each_ref_upstream_atom( _ => None }) is Some(_) - if !(upstream_exists) { + if !upstream_exists { // Upstream is gone if atom == "upstream:trackshort" { return "" @@ -3676,7 +3674,7 @@ fn for_each_ref_push_atom( _ => None }) is Some(_) - if !(push_exists) { + if !push_exists { if atom == "push:trackshort" { return "" } @@ -3836,14 +3834,14 @@ fn for_each_ref_ahead_behind_commits( // Count ahead: commits reachable from local but not upstream let mut ahead = 0 for entry in local_ancestors { - if !(upstream_ancestors.contains(entry.0)) { + if !upstream_ancestors.contains(entry.0) { ahead += 1 } } // Count behind: commits reachable from upstream but not local let mut behind = 0 for entry in upstream_ancestors { - if !(local_ancestors.contains(entry.0)) { + if !local_ancestors.contains(entry.0) { behind += 1 } } @@ -3870,7 +3868,7 @@ fn for_each_ref_walk_ancestors( Some(o) if o.obj_type == @bitcore.ObjectType::Commit => { let info = @bitcore.parse_commit(o.data) catch { _ => continue } for parent in info.parents { - if !(out.contains(parent.to_hex())) { + if !out.contains(parent.to_hex()) { queue.push(parent) } } @@ -3932,7 +3930,7 @@ async fn for_each_ref_commit_atom( } else { raw_line } - if !(past_headers) { + if !past_headers { if line.length() == 0 { past_headers = true continue @@ -4411,7 +4409,7 @@ async fn for_each_ref_format_trailers_atom( } } // Default: if no only= was set and no key filter, show all trailers (including non-trailer lines) - if !(only_set) && keys.length() == 0 { + if !only_set && keys.length() == 0 { only = false } let trailers = for_each_ref_parse_trailers(message) @@ -4429,14 +4427,14 @@ async fn for_each_ref_format_trailers_atom( break } } - if !(key_matched) { + if !key_matched { continue } // Non-trailer lines: only include if only=no } else if only { continue } - } else if only && !(is_trailer) { + } else if only && !is_trailer { continue } // Format the line diff --git a/src/cmd/bit/for_each_repo.mbt b/src/cmd/bit/for_each_repo.mbt index c8030c48..dac83b79 100644 --- a/src/cmd/bit/for_each_repo.mbt +++ b/src/cmd/bit/for_each_repo.mbt @@ -79,9 +79,9 @@ async fn handle_for_each_repo(args : Array[String]) -> Unit raise Error { // Expand ~ to HOME let path = for_each_repo_expand_path(val) // Check if directory exists - if !(rfs.is_dir(path)) { + if !rfs.is_dir(path) { eprint_line("error: cannot change to '\{path}'") - if !(keep_going) { + if !keep_going { @sys.exit(1) } result = 1 @@ -89,7 +89,7 @@ async fn handle_for_each_repo(args : Array[String]) -> Unit raise Error { } let ret = run_git_command(command_args, cwd=Some(path)) if ret != 0 { - if !(keep_going) { + if !keep_going { @sys.exit(ret) } result = 1 diff --git a/src/cmd/bit/format_patch.mbt b/src/cmd/bit/format_patch.mbt index 1751bfba..4b6ab3e7 100644 --- a/src/cmd/bit/format_patch.mbt +++ b/src/cmd/bit/format_patch.mbt @@ -143,7 +143,7 @@ fn parse_format_patch_options(args : Array[String]) -> FormatPatchOptions { ) i += 1 } - _ if is_format_patch_count_arg(arg) || !(arg.has_prefix("-")) => { + _ if is_format_patch_count_arg(arg) || !arg.has_prefix("-") => { revisions.push(arg) i += 1 } @@ -286,9 +286,7 @@ async fn handle_format_patch(args : Array[String]) -> Unit raise Error { bit_config_get(git_dir, "format", "outputDirectory").unwrap_or(".") } } - if !(opts.stdout_mode) && - opts.output_file is None && - !(rfs.is_dir(output_dir)) { + if !opts.stdout_mode && opts.output_file is None && !rfs.is_dir(output_dir) { wfs.mkdir_p(output_dir) } let total = commits.length() @@ -657,7 +655,7 @@ fn sanitize_filename(s : String) -> String { (c >= '0' && c <= '9') { sb.write_char(c) last_was_dash = false - } else if !(last_was_dash) { + } else if !last_was_dash { sb.write_char('-') last_was_dash = true } diff --git a/src/cmd/bit/fsck.mbt b/src/cmd/bit/fsck.mbt index 2101adca..7e918646 100644 --- a/src/cmd/bit/fsck.mbt +++ b/src/cmd/bit/fsck.mbt @@ -52,11 +52,11 @@ async fn handle_fsck(args : Array[String]) -> Unit raise Error { let (head_errors, head_oid) = fsck_check_and_resolve_head(fs, git_dir) errors += head_errors // Phase 2: Verify loose objects (hash check) - if !(connectivity_only) { + if !connectivity_only { errors += fsck_verify_loose_objects(fs, objects_dir) } // Phase 3: Verify pack files - if !(connectivity_only) { + if !connectivity_only { errors += fsck_verify_packs(fs, objects_dir) } // Phase 4: Connectivity check via pure lib function @@ -69,7 +69,7 @@ async fn handle_fsck(args : Array[String]) -> Unit raise Error { Some(id) => ref_tips.push(id) None => () } - if !(no_reflogs) { + if !no_reflogs { fsck_collect_reflog_tips(fs, git_dir, ref_tips) } let need_extra = show_root || show_tags @@ -89,7 +89,7 @@ async fn handle_fsck(args : Array[String]) -> Unit raise Error { if need_all { let all_objects = @bitlib.fsck_enumerate_objects(db) for hex in all_objects { - if !(result.reachable.contains(hex)) { + if !result.reachable.contains(hex) { let obj_type = @bitlib.fsck_object_type(db, fs, hex) if show_unreachable { eprint_line("unreachable \{obj_type} \{hex}") @@ -127,7 +127,7 @@ async fn fsck_check_and_resolve_head( git_dir : String, ) -> (Int, @bitcore.ObjectId?) { let head_path = git_dir + "/HEAD" - if !(fs.is_file(head_path)) { + if !fs.is_file(head_path) { eprint_line("error: HEAD is missing") return (1, None) } @@ -148,7 +148,7 @@ async fn fsck_check_and_resolve_head( start=5, end=trimmed.length(), ) - if !(refname.has_prefix("refs/heads/")) { + if !refname.has_prefix("refs/heads/") { eprint_line("warning: HEAD points to non-branch '\{refname}'") } let resolved = fsck_resolve_ref(fs, git_dir, refname) @@ -187,7 +187,7 @@ fn fsck_resolve_ref( return Some(id) } let packed_path = git_dir + "/packed-refs" - if !(fs.is_file(packed_path)) { + if !fs.is_file(packed_path) { return None } let packed = @utf8.decode_lossy(fs.read_file(packed_path)[:]) catch { @@ -219,7 +219,7 @@ fn fsck_resolve_ref( ///| async fn fsck_verify_loose_objects(fs : OsFs, objects_dir : String) -> Int { let mut errors = 0 - if !(fs.is_dir(objects_dir)) { + if !fs.is_dir(objects_dir) { return 0 } let entries = fs.readdir(objects_dir) catch { _ => return 0 } @@ -228,7 +228,7 @@ async fn fsck_verify_loose_objects(fs : OsFs, objects_dir : String) -> Int { continue } let subdir = objects_dir + "/" + entry - if !(fs.is_dir(subdir)) { + if !fs.is_dir(subdir) { continue } let files = fs.readdir(subdir) catch { _ => continue } @@ -252,7 +252,7 @@ async fn fsck_verify_loose_objects(fs : OsFs, objects_dir : String) -> Int { continue } } - if !(@bitlib.fsck_verify_loose_hash(raw, hex)) { + if !@bitlib.fsck_verify_loose_hash(raw, hex) { eprint_line("error: hash mismatch for \{hex}") errors += 1 } @@ -265,17 +265,17 @@ async fn fsck_verify_loose_objects(fs : OsFs, objects_dir : String) -> Int { async fn fsck_verify_packs(fs : OsFs, objects_dir : String) -> Int { let mut errors = 0 let pack_dir = objects_dir + "/pack" - if !(fs.is_dir(pack_dir)) { + if !fs.is_dir(pack_dir) { return 0 } let entries = fs.readdir(pack_dir) catch { _ => return 0 } for entry in entries { - if !(entry.has_suffix(".idx")) { + if !entry.has_suffix(".idx") { continue } let stem = String::unsafe_substring(entry, start=0, end=entry.length() - 4) let pack_file = pack_dir + "/" + stem + ".pack" - if !(fs.is_file(pack_file)) { + if !fs.is_file(pack_file) { eprint_line("error: pack index \{entry} has no corresponding pack file") errors += 1 } @@ -290,7 +290,7 @@ fn fsck_collect_reflog_tips( tips : Array[@bitcore.ObjectId], ) -> Unit { let logs_dir = git_dir + "/logs" - if !(fs.is_dir(logs_dir)) { + if !fs.is_dir(logs_dir) { return } fsck_collect_reflog_tips_dir(fs, git_dir, logs_dir, tips) diff --git a/src/cmd/bit/gc.mbt b/src/cmd/bit/gc.mbt index ec6c4818..24e24491 100644 --- a/src/cmd/bit/gc.mbt +++ b/src/cmd/bit/gc.mbt @@ -17,13 +17,13 @@ async fn handle_gc(args : Array[String]) -> Unit raise Error { ignore(aggressive) // Not yet implemented, treat as regular gc if prune_only { let result = @bitlib.prune_repo(fs, fs, root) - if !(quiet) && result.pruned.length() > 0 { + if !quiet && result.pruned.length() > 0 { print_line("Pruned \{result.pruned.length()} unreachable objects") } return } let result = @bitlib.gc_repo(fs, fs, root) - if !(quiet) { + if !quiet { match result.pack { Some(pack) => print_line( diff --git a/src/cmd/bit/gitconfig.mbt b/src/cmd/bit/gitconfig.mbt index 9324b187..8854e78d 100644 --- a/src/cmd/bit/gitconfig.mbt +++ b/src/cmd/bit/gitconfig.mbt @@ -12,7 +12,7 @@ pub fn load_global_aliases(fs : OsFs) -> Map[String, String] { let path = find_global_gitconfig_path() match path { Some(p) => { - if !(fs.is_file(p)) { + if !fs.is_file(p) { return empty } let bytes = fs.read_file(p) catch { _ => return empty } @@ -120,20 +120,20 @@ pub fn split_alias_command(value : String) -> Array[String] { escape = false continue } - if c == '\\' && !(in_single) { + if c == '\\' && !in_single { escape = true continue } - if c == '\'' && !(in_double) { - in_single = !(in_single) + if c == '\'' && !in_double { + in_single = !in_single continue } - if c == '"' && !(in_single) { - in_double = !(in_double) + if c == '"' && !in_single { + in_double = !in_double continue } - if (c == ' ' || c == '\t') && !(in_single) && !(in_double) { - if !(sb.is_empty()) { + if (c == ' ' || c == '\t') && !in_single && !in_double { + if !sb.is_empty() { args.push(sb.to_string()) sb.reset() } @@ -144,7 +144,7 @@ pub fn split_alias_command(value : String) -> Array[String] { if escape { sb.write_char('\\') } - if !(sb.is_empty()) { + if !sb.is_empty() { args.push(sb.to_string()) } args @@ -168,7 +168,7 @@ fn find_global_gitconfig_path() -> String? { ///| fn parse_section_name(line : String) -> String? { - if !(line.has_prefix("[")) || !(line.has_suffix("]")) { + if !line.has_prefix("[") || !line.has_suffix("]") { return None } if line.length() < 2 { diff --git a/src/cmd/bit/grep.mbt b/src/cmd/bit/grep.mbt index 395b3628..84970c01 100644 --- a/src/cmd/bit/grep.mbt +++ b/src/cmd/bit/grep.mbt @@ -48,7 +48,7 @@ async fn handle_grep(args : Array[String]) -> Unit raise Error { if options_terminated { if use_expr && grep_expr_expects_pattern(expr_tokens) { grep_push_expr_pattern(expr_tokens, arg) - } else if !(use_expr) && patterns.length() == 0 { + } else if !use_expr && patterns.length() == 0 { grep_append_pattern(patterns, expr_tokens, use_expr, arg) } else if arg == "--" { pathspec_only = true @@ -235,7 +235,7 @@ async fn handle_grep(args : Array[String]) -> Unit raise Error { i += 1 } "--and" => { - if !(use_expr) { + if !use_expr { grep_move_patterns_to_expr_tokens(patterns, expr_tokens) use_expr = true } @@ -243,7 +243,7 @@ async fn handle_grep(args : Array[String]) -> Unit raise Error { i += 1 } "--or" => { - if !(use_expr) { + if !use_expr { grep_move_patterns_to_expr_tokens(patterns, expr_tokens) use_expr = true } @@ -251,7 +251,7 @@ async fn handle_grep(args : Array[String]) -> Unit raise Error { i += 1 } "--not" => { - if !(use_expr) { + if !use_expr { grep_move_patterns_to_expr_tokens(patterns, expr_tokens) use_expr = true } @@ -375,7 +375,7 @@ async fn handle_grep(args : Array[String]) -> Unit raise Error { "--threads" if i + 1 < args.length() => i += 2 _ if arg.has_prefix("--threads=") => i += 1 "(" | "\\(" => { - if !(use_expr) { + if !use_expr { grep_move_patterns_to_expr_tokens(patterns, expr_tokens) use_expr = true } @@ -383,24 +383,24 @@ async fn handle_grep(args : Array[String]) -> Unit raise Error { i += 1 } ")" | "\\)" => { - if !(use_expr) { + if !use_expr { grep_move_patterns_to_expr_tokens(patterns, expr_tokens) use_expr = true } expr_tokens.push(@bitgrep.GrepExprToken::RParen) i += 1 } - _ if !(arg.has_prefix("-")) => { + _ if !arg.has_prefix("-") => { if use_expr && grep_expr_expects_pattern(expr_tokens) { grep_push_expr_pattern(expr_tokens, arg) - } else if !(use_expr) && patterns.length() == 0 { + } else if !use_expr && patterns.length() == 0 { grep_append_pattern(patterns, expr_tokens, use_expr, arg) } else if no_index && treeish is None && grep_has_future_pathspec_separator(args, i + 1) && grep_token_is_treeish(fs, git_dir, arg) { treeish = Some(arg) - } else if !(no_index) && + } else if !no_index && treeish is None && paths.length() == 0 && ( @@ -542,7 +542,7 @@ async fn handle_grep(args : Array[String]) -> Unit raise Error { ) } } - let raw_matches = if recurse_submodules && !(no_index) && treeish is None { + let raw_matches = if recurse_submodules && !no_index && treeish is None { grep_merge_file_matches( raw_matches, grep_collect_recurse_submodule_matches( @@ -554,7 +554,7 @@ async fn handle_grep(args : Array[String]) -> Unit raise Error { raw_matches } let matches = grep_limit_file_matches(raw_matches, max_count) - if quiet && !(files_without_match) { + if quiet && !files_without_match { if matches.length() > 0 { return } @@ -624,7 +624,7 @@ async fn handle_grep(args : Array[String]) -> Unit raise Error { let display_path = grep_format_output_path_raw( search_root, treeish, path, show_full_name, ) - if !(quiet) { + if !quiet { grep_print_path_atom(display_path, null_terminated) } } @@ -634,7 +634,7 @@ async fn handle_grep(args : Array[String]) -> Unit raise Error { } @sys.exit(1) } - if !(had_output) { + if !had_output { @sys.exit(1) } return @@ -669,7 +669,7 @@ async fn handle_grep(args : Array[String]) -> Unit raise Error { if printed_any { if show_break { print_line("") - } else if !(show_heading) { + } else if !show_heading { print_line(grep_color_wrap("--", color_spec.separator)) } } @@ -686,7 +686,7 @@ async fn handle_grep(args : Array[String]) -> Unit raise Error { if printed_any { if show_break { print_line("") - } else if !(show_heading) { + } else if !show_heading { print_line(grep_color_wrap("--", color_spec.separator)) } } @@ -1181,7 +1181,7 @@ fn grep_build_prefix( ) -> String { let sep = sign.to_string() let out = StringBuilder::new() - if !(show_heading) { + if !show_heading { out.write_string(grep_color_wrap(file_path, color_spec.filename)) out.write_string(grep_color_wrap(sep, color_spec.separator)) } @@ -1236,7 +1236,7 @@ async fn grep_print_file_match_with_context( ) let matched_columns : Map[Int, Int] = {} for item in file_match.matches { - if !(matched_columns.contains(item.line_number)) { + if !matched_columns.contains(item.line_number) { matched_columns[item.line_number] = item.column } } @@ -1289,7 +1289,7 @@ async fn grep_print_file_match_with_context( } else { None } - if !(first_range) { + if !first_range { print_line(grep_color_wrap("--", color_spec.separator)) } first_range = false @@ -1392,14 +1392,14 @@ async fn grep_print_whole_function_match( } let matched_columns : Map[Int, Int] = {} for item in file_match.matches { - if !(matched_columns.contains(item.line_number)) { + if !matched_columns.contains(item.line_number) { matched_columns[item.line_number] = item.column } } let mut first_range = true for i in 0.. 1 { let prev = trim_string(lines[current - 2]) - if prev == "" || !(prev.has_prefix("#")) { + if prev == "" || !prev.has_prefix("#") { break } current -= 1 @@ -1902,11 +1902,11 @@ async fn grep_resolve_no_index_paths( normalize_path(root + "/" + raw_path) } let exists = fs.is_file(abs_path) || fs.is_dir(abs_path) - if !(exists) { + if !exists { eprint_line("fatal: no such path in the working tree: '" + raw_path + "'") @sys.exit(128) } - if !(grep_path_is_within_root(normalized_root, abs_path)) { + if !grep_path_is_within_root(normalized_root, abs_path) { eprint_line("fatal: '" + raw_path + "' is outside the directory tree") @sys.exit(128) } @@ -1981,7 +1981,7 @@ fn grep_collect_recurse_submodule_matches( let submodule_paths = grep_submodule_relative_paths(paths, full_path) guard submodule_paths is Some(local_paths) else { continue } let sub_root = root + "/" + entry.path - if !(fs.is_dir(sub_root)) { + if !fs.is_dir(sub_root) { continue } let sub_git_dir = resolve_git_dir(fs, sub_root) @@ -2164,7 +2164,7 @@ fn grep_invocation_repo_relative_path(root : String) -> String? { return Some("") } let root_prefix = normalized_root + "/" - if !(normalized_cwd.has_prefix(root_prefix)) { + if !normalized_cwd.has_prefix(root_prefix) { return None } Some( diff --git a/src/cmd/bit/handlers_core_wbtest.mbt b/src/cmd/bit/handlers_core_wbtest.mbt index 7cfc63e1..c9e2eacc 100644 --- a/src/cmd/bit/handlers_core_wbtest.mbt +++ b/src/cmd/bit/handlers_core_wbtest.mbt @@ -6,7 +6,7 @@ fn cleanup_tree(fs : OsFs, path : String) -> Unit { } return } - if !(fs.is_dir(path)) { + if !fs.is_dir(path) { return } let entries = fs.readdir(path) catch { _ => [] } diff --git a/src/cmd/bit/handlers_remote_pull_wbtest.mbt b/src/cmd/bit/handlers_remote_pull_wbtest.mbt index 8a8feb75..6687719b 100644 --- a/src/cmd/bit/handlers_remote_pull_wbtest.mbt +++ b/src/cmd/bit/handlers_remote_pull_wbtest.mbt @@ -262,7 +262,7 @@ async fn handlers_remote_pull_wbtest_collect_shim_git( // Build the native binary first so exit codes propagate correctly // (moon run swallows non-zero exit codes) let bit_exe = repo_root + "/_build/native/release/build/cmd/bit/bit.exe" - if !(fs.is_file(bit_exe)) { + if !fs.is_file(bit_exe) { let build_code = @process.run( "moon", ["build", "--target", "native", "--release"], diff --git a/src/cmd/bit/handlers_remote_push_wbtest.mbt b/src/cmd/bit/handlers_remote_push_wbtest.mbt index 9128ede4..250c41a5 100644 --- a/src/cmd/bit/handlers_remote_push_wbtest.mbt +++ b/src/cmd/bit/handlers_remote_push_wbtest.mbt @@ -716,7 +716,7 @@ test "push delete: prune_empty_parent_dirs removes empty nested ref dirs" { prune_empty_parent_dirs( fs, fs, "/repo/.git/refs/heads/branch/conflict", "/repo/.git/refs/heads", ) - assert_true(!(fs.is_dir("/repo/.git/refs/heads/branch"))) + assert_true(!fs.is_dir("/repo/.git/refs/heads/branch")) assert_true(fs.is_dir("/repo/.git/refs/heads")) } diff --git a/src/cmd/bit/hash_object.mbt b/src/cmd/bit/hash_object.mbt index 694be032..23a13cac 100644 --- a/src/cmd/bit/hash_object.mbt +++ b/src/cmd/bit/hash_object.mbt @@ -35,14 +35,14 @@ async fn handle_hash_object(args : Array[String]) -> Unit raise Error { let raw_content = read_all_stdin() let rfs : &@bitcore.RepoFileSystem = fs let content = if resolved_path_hint.length() > 0 && - !(hash_args.no_filters) { + !hash_args.no_filters { let autocrlf = @bitlib.read_autocrlf_setting(rfs, git_dir) let attrs = @bitlib.resolve_eol_attrs(rfs, root, resolved_path_hint) @bitlib.clean_for_storage(raw_content, attrs, autocrlf) } else { raw_content } - if !(hash_args.literally) { + if !hash_args.literally { hash_object_validate_content(hash_args.obj_type, content, algo~) } let id = @bitobject.hash_object_content_with_algo( @@ -67,8 +67,8 @@ async fn handle_hash_object(args : Array[String]) -> Unit raise Error { fs, root, git_dir, algo, hash_args, text, ) } - if !(hash_args.stdin_mode) && - !(hash_args.stdin_paths) && + if !hash_args.stdin_mode && + !hash_args.stdin_paths && hash_args.paths.length() == 0 { @runtime.run_storage_command( fs, @@ -125,7 +125,7 @@ async fn hash_object_process_file_paths( let attrs = @bitlib.resolve_eol_attrs(rfs, root, filter_rel) @bitlib.clean_for_storage(content, attrs, autocrlf) } - if !(hash_args.literally) { + if !hash_args.literally { hash_object_validate_content(hash_args.obj_type, normalized, algo~) } let id = @bitobject.hash_object_content_with_algo( @@ -268,14 +268,14 @@ async fn hash_object_validate_content( match obj_type { @bitcore.ObjectType::Commit => { let text = @utf8.decode_lossy(content[:]) - if !(text.has_prefix("tree ")) { + if !text.has_prefix("tree ") { eprint_line("fatal: corrupt commit") @sys.exit(128) } } @bitcore.ObjectType::Tag => { let text = @utf8.decode_lossy(content[:]) - if !(text.has_prefix("object ")) { + if !text.has_prefix("object ") { eprint_line("fatal: corrupt tag") @sys.exit(128) } diff --git a/src/cmd/bit/helpers.mbt b/src/cmd/bit/helpers.mbt index 069764bc..89cd0894 100644 --- a/src/cmd/bit/helpers.mbt +++ b/src/cmd/bit/helpers.mbt @@ -438,7 +438,7 @@ fn repository_format_error( } None => () } - if !(in_extensions) { + if !in_extensions { continue } match repository_extension_key(trimmed) { @@ -988,7 +988,7 @@ async fn run_merge_with_sensitive_hooks( ///| fn make_relative_to_cwd(path : String) -> String { - if !(path.has_prefix("/")) { + if !path.has_prefix("/") { return path } let cwd = match @sys.get_env_var("GIT_SHIM_PWD") { @@ -1024,7 +1024,7 @@ fn quote_origin_path(path : String) -> String { break } } - if !(needs_quote) { + if !needs_quote { return path } let buf = StringBuilder::new() diff --git a/src/cmd/bit/helpers_shared.mbt b/src/cmd/bit/helpers_shared.mbt index 00fe2f04..4260ff6c 100644 --- a/src/cmd/bit/helpers_shared.mbt +++ b/src/cmd/bit/helpers_shared.mbt @@ -68,7 +68,7 @@ fn normalize_path(path : String) -> String { } else if part == ".." { if parts.length() > 0 && parts[parts.length() - 1] != ".." { let _ = parts.pop() - } else if !(path.has_prefix("/")) { + } else if !path.has_prefix("/") { parts.push(part) } } else { diff --git a/src/cmd/bit/hooks.mbt b/src/cmd/bit/hooks.mbt index cff3cf37..3d009e25 100644 --- a/src/cmd/bit/hooks.mbt +++ b/src/cmd/bit/hooks.mbt @@ -99,7 +99,7 @@ fn list_hooks_in_dir( dir : String, prefix : String?, ) -> Array[String] { - if !(fs.is_dir(dir)) { + if !fs.is_dir(dir) { return [] } let names : Array[String] = [] @@ -113,7 +113,7 @@ fn list_hooks_in_dir( continue } match prefix { - Some(p) if !(entry.has_prefix(p)) => continue + Some(p) if !entry.has_prefix(p) => continue _ => () } names.push(entry) @@ -147,12 +147,12 @@ fn list_hooks_with_status( let available = list_available_hooks(fs, root, prefix) let names = [] for name in active { - if !(names.contains(name)) { + if !names.contains(name) { names.push(name) } } for name in available { - if !(names.contains(name)) { + if !names.contains(name) { names.push(name) } } @@ -222,7 +222,7 @@ fn hooks_file_checksum( rfs : &@bitcore.RepoFileSystem, path : String, ) -> String? { - if !(rfs.is_file(path)) { + if !rfs.is_file(path) { return None } let content = rfs.read_file(path) catch { _ => return None } @@ -236,7 +236,7 @@ fn hooks_read_approved_checksum( hook_name : String, ) -> String? { let path = hooks_approved_checksum_path(root, hook_name) - if !(rfs.is_file(path)) { + if !rfs.is_file(path) { return None } let raw = decode_bytes(rfs.read_file(path) catch { _ => return None }) @@ -256,7 +256,7 @@ fn hooks_write_approved_checksum( checksum : String, ) -> Unit { let dir = join_repo_marker(root, ".bit/hooks/.approved") - if !(rfs.is_dir(dir)) { + if !rfs.is_dir(dir) { wfs.mkdir_p(dir) catch { _ => () } @@ -287,7 +287,7 @@ fn hooks_is_current_checksum_approved( if is_always_prompt_hook(hook_name) { return false } - if !(is_sensitive_hook(hook_name)) { + if !is_sensitive_hook(hook_name) { return true } match hooks_active_checksum(rfs, root, hook_name) { @@ -337,7 +337,7 @@ async fn hooks_prompt_approve_checksum( ) let bytes : Array[Byte] = [] let mut finished = false - while !(finished) { + while !finished { match @stdio.stdin.read_some(max_len=64) { None => finished = true Some(chunk) => @@ -374,10 +374,10 @@ async fn hooks_ensure_sensitive_hook_approval( root : String, hook_name : String, ) -> Unit { - if !(is_sensitive_hook(hook_name)) { + if !is_sensitive_hook(hook_name) { return } - if !(hooks_is_current_checksum_approved(fs, root, hook_name)) { + if !hooks_is_current_checksum_approved(fs, root, hook_name) { match hooks_active_checksum(fs, root, hook_name) { Some(current) => hooks_prompt_approve_checksum(wfs, fs, root, hook_name, current) @@ -428,17 +428,17 @@ async fn handle_x_hooks_set( } let name = args[0] let source = args[1] - if !(is_valid_hook_name(name)) { + if !is_valid_hook_name(name) { eprint_line("fatal: invalid hook name '\{name}'") @sys.exit(1) } let source_path = abs_path(source) - if !(fs.is_file(source_path)) { + if !fs.is_file(source_path) { eprint_line("fatal: cannot read hook source '\{source_path}'") @sys.exit(1) } let dir = bit_hooks_dir(root) - if !(fs.is_dir(dir)) { + if !fs.is_dir(dir) { fs.mkdir_p(dir) } let target = bit_hooks_file_path(root, name) @@ -465,17 +465,17 @@ async fn handle_x_hooks_approve( @sys.exit(1) } let name = args[0] - if !(is_valid_hook_name(name)) { + if !is_valid_hook_name(name) { eprint_line("fatal: invalid hook name '\{name}'") @sys.exit(1) } let source = bit_hooks_file_path(root, name) - if !(fs.is_file(source)) { + if !fs.is_file(source) { eprint_line("fatal: hook '\{name}' is not available") @sys.exit(1) } let target_dir = hooks_dir(git_dir) - if !(fs.is_dir(target_dir)) { + if !fs.is_dir(target_dir) { fs.mkdir_p(target_dir) } let target = hooks_file_path(git_dir, name) @@ -508,7 +508,7 @@ async fn handle_x_hooks_unapprove( @sys.exit(1) } let name = args[0] - if !(is_valid_hook_name(name)) { + if !is_valid_hook_name(name) { eprint_line("fatal: invalid hook name '\{name}'") @sys.exit(1) } @@ -540,7 +540,7 @@ async fn handle_x_hooks_remove( @sys.exit(1) } let name = args[0] - if !(is_valid_hook_name(name)) { + if !is_valid_hook_name(name) { eprint_line("fatal: invalid hook name '\{name}'") @sys.exit(1) } @@ -563,7 +563,7 @@ async fn handle_x_hooks(args : Array[String]) -> Unit raise Error { let fs = OsFs::new() let rfs : &@bitcore.RepoFileSystem = fs let git_dir = resolve_git_dir(rfs, root) - if !(fs.is_dir(git_dir)) { + if !fs.is_dir(git_dir) { eprint_line("fatal: not a git repository") @sys.exit(1) } diff --git a/src/cmd/bit/hq.mbt b/src/cmd/bit/hq.mbt index 312652af..71d1a369 100644 --- a/src/cmd/bit/hq.mbt +++ b/src/cmd/bit/hq.mbt @@ -269,7 +269,7 @@ async fn handle_hq_get(args : Array[String]) -> Unit raise Error { ///| /// hq list command handler async fn handle_hq_list(args : Array[String]) -> Unit { - let query : String? = if args.length() > 0 && !(args[0].has_prefix("-")) { + let query : String? = if args.length() > 0 && !args[0].has_prefix("-") { Some(args[0]) } else { None @@ -296,7 +296,7 @@ fn list_repos_recursive( if fs.is_dir(current + "/.git") { // Apply query filter match query { - Some(q) if !(rel_path.contains(q)) => () + Some(q) if !rel_path.contains(q) => () _ => repos.push(rel_path) } return repos diff --git a/src/cmd/bit/hub_helpers.mbt b/src/cmd/bit/hub_helpers.mbt index 4d339fd8..62da1576 100644 --- a/src/cmd/bit/hub_helpers.mbt +++ b/src/cmd/bit/hub_helpers.mbt @@ -89,7 +89,7 @@ fn parse_hub_merge_policy_toml( in_merge_section = section_name == "merge" continue } - if !(in_merge_section) { + if !in_merge_section { continue } let eq_idx = line.find("=") @@ -168,7 +168,7 @@ fn load_hub_merge_policy( git_dir : String, ) -> @hub.PrMergePolicy raise @bitcore.GitError { let policy_path = hub_merge_policy_path(git_dir) - if !(fs.is_file(policy_path)) { + if !fs.is_file(policy_path) { return default_hub_merge_policy() } let content = decode_bytes(fs.read_file(policy_path)) diff --git a/src/cmd/bit/hub_issue.mbt b/src/cmd/bit/hub_issue.mbt index f1d103f4..d1d74b0d 100644 --- a/src/cmd/bit/hub_issue.mbt +++ b/src/cmd/bit/hub_issue.mbt @@ -124,7 +124,7 @@ fn parse_work_item_state_for_list( "Unknown \{unknown_state_label} state: \{value}", ) } - if !(allow_merged) && parsed == @hub.WorkItemState::Merged { + if !allow_merged && parsed == @hub.WorkItemState::Merged { raise @bitcore.GitError::InvalidObject( "Unknown \{unknown_state_label} state: \{value}", ) @@ -410,7 +410,7 @@ async fn handle_hub_issue_list(args : Array[String]) -> Unit raise Error { match args[j] { "--all" => show_all = true "--tree" => show_tree = true - "--relay" if j + 1 < args.length() && !(args[j + 1].has_prefix("-")) => { + "--relay" if j + 1 < args.length() && !args[j + 1].has_prefix("-") => { relay_url = Some(args[j + 1]) j += 1 } @@ -475,12 +475,12 @@ async fn handle_hub_issue_list(args : Array[String]) -> Unit raise Error { if filter_labels.length() > 0 { let mut has_all = true for label in filter_labels { - if !(issue.labels.contains(label)) { + if !issue.labels.contains(label) { has_all = false break } } - if !(has_all) { + if !has_all { continue } } diff --git a/src/cmd/bit/hub_pr.mbt b/src/cmd/bit/hub_pr.mbt index 6126a91b..20411eca 100644 --- a/src/cmd/bit/hub_pr.mbt +++ b/src/cmd/bit/hub_pr.mbt @@ -199,7 +199,7 @@ async fn handle_hub_pr_status(args : Array[String]) -> Unit raise Error { let author = get_author_string() let mut mine_count = 0 for pr in open_prs { - if pr.author() == author && !(branch_ids.contains(pr.id())) { + if pr.author() == author && !branch_ids.contains(pr.id()) { if mine_count == 0 { print_line("Open pull requests authored by \{author}:") } diff --git a/src/cmd/bit/hub_search.mbt b/src/cmd/bit/hub_search.mbt index b054d3ff..0c904949 100644 --- a/src/cmd/bit/hub_search.mbt +++ b/src/cmd/bit/hub_search.mbt @@ -71,7 +71,7 @@ fn push_unique_search_type( types : Array[HubSearchType], t : HubSearchType, ) -> Unit { - if !(hub_search_has_type(types, t)) { + if !hub_search_has_type(types, t) { types.push(t) } } @@ -125,7 +125,7 @@ fn parse_hub_search_types(value : String) -> Array[HubSearchType]? { if token.length() == 0 { continue } - if !(append_hub_search_types_by_token(out, token)) { + if !append_hub_search_types_by_token(out, token) { return None } } @@ -172,7 +172,7 @@ fn parse_hub_search_options( "Unknown hub search type: \{value}", ) } - if !(type_filter_set) { + if !type_filter_set { types = [] type_filter_set = true } @@ -194,7 +194,7 @@ fn parse_hub_search_options( "Unknown hub search type: \{value}", ) } - if !(type_filter_set) { + if !type_filter_set { types = [] type_filter_set = true } @@ -350,7 +350,7 @@ fn matches_labels_filter( lower_labels.push(label.to_lower()) } for required in required_labels { - if !(lower_labels.contains(required.to_lower())) { + if !lower_labels.contains(required.to_lower()) { return false } } @@ -454,10 +454,10 @@ async fn handle_hub_search(args : Array[String]) -> Unit raise Error { if search_limit_reached(options.limit, results.length()) { break } - if !(matches_pr_state_filter(options.state, pr.state())) { + if !matches_pr_state_filter(options.state, pr.state()) { continue } - if !(matches_labels_filter(options.labels, pr.labels())) { + if !matches_labels_filter(options.labels, pr.labels()) { continue } if include_pr && @@ -477,7 +477,7 @@ async fn handle_hub_search(args : Array[String]) -> Unit raise Error { if search_limit_reached(options.limit, results.length()) { break } - if !(matches_author_filter(options.author, comment.author())) { + if !matches_author_filter(options.author, comment.author()) { continue } if matches_query_filter(options.query, [ @@ -498,7 +498,7 @@ async fn handle_hub_search(args : Array[String]) -> Unit raise Error { if search_limit_reached(options.limit, results.length()) { break } - if !(matches_author_filter(options.author, review.author())) { + if !matches_author_filter(options.author, review.author()) { continue } if matches_query_filter(options.query, [ @@ -523,10 +523,10 @@ async fn handle_hub_search(args : Array[String]) -> Unit raise Error { if search_limit_reached(options.limit, results.length()) { break } - if !(matches_issue_state_filter(options.state, issue.state())) { + if !matches_issue_state_filter(options.state, issue.state()) { continue } - if !(matches_labels_filter(options.labels, issue.labels())) { + if !matches_labels_filter(options.labels, issue.labels()) { continue } if include_issue && @@ -550,7 +550,7 @@ async fn handle_hub_search(args : Array[String]) -> Unit raise Error { if search_limit_reached(options.limit, results.length()) { break } - if !(matches_author_filter(options.author, comment.author())) { + if !matches_author_filter(options.author, comment.author()) { continue } if matches_query_filter(options.query, [ @@ -633,10 +633,10 @@ async fn handle_hub_search_with_defaults( if search_limit_reached(options.limit, results.length()) { break } - if !(matches_pr_state_filter(options.state, pr.state())) { + if !matches_pr_state_filter(options.state, pr.state()) { continue } - if !(matches_labels_filter(options.labels, pr.labels())) { + if !matches_labels_filter(options.labels, pr.labels()) { continue } if include_pr && @@ -656,7 +656,7 @@ async fn handle_hub_search_with_defaults( if search_limit_reached(options.limit, results.length()) { break } - if !(matches_author_filter(options.author, comment.author())) { + if !matches_author_filter(options.author, comment.author()) { continue } if matches_query_filter(options.query, [ @@ -677,7 +677,7 @@ async fn handle_hub_search_with_defaults( if search_limit_reached(options.limit, results.length()) { break } - if !(matches_author_filter(options.author, review.author())) { + if !matches_author_filter(options.author, review.author()) { continue } if matches_query_filter(options.query, [ @@ -702,10 +702,10 @@ async fn handle_hub_search_with_defaults( if search_limit_reached(options.limit, results.length()) { break } - if !(matches_issue_state_filter(options.state, issue.state())) { + if !matches_issue_state_filter(options.state, issue.state()) { continue } - if !(matches_labels_filter(options.labels, issue.labels())) { + if !matches_labels_filter(options.labels, issue.labels()) { continue } if include_issue && @@ -729,7 +729,7 @@ async fn handle_hub_search_with_defaults( if search_limit_reached(options.limit, results.length()) { break } - if !(matches_author_filter(options.author, comment.author())) { + if !matches_author_filter(options.author, comment.author()) { continue } if matches_query_filter(options.query, [ diff --git a/src/cmd/bit/hub_stores.mbt b/src/cmd/bit/hub_stores.mbt index cb19f758..edb35655 100644 --- a/src/cmd/bit/hub_stores.mbt +++ b/src/cmd/bit/hub_stores.mbt @@ -132,7 +132,7 @@ fn parse_hub_init_prompt_override(input : String) -> Bool? { async fn read_hub_init_approval() -> Bool { let bytes : Array[Byte] = [] let mut finished = false - while !(finished) { + while !finished { match @stdio.stdin.read_some(max_len=1) { None => finished = true Some(chunk) => @@ -184,10 +184,8 @@ fn compute_hub_origin_sync_plan(content : String) -> HubOriginSyncPlan { add_default_push_refspec: false, } Some(remote) => { - let add_fetch_notes = !( - remote.fetch.contains(hub_notes_fetch_refspec()), - ) - let add_push_notes = !(remote.push.contains(hub_notes_push_refspec())) + let add_fetch_notes = !remote.fetch.contains(hub_notes_fetch_refspec()) + let add_push_notes = !remote.push.contains(hub_notes_push_refspec()) { has_origin: true, add_fetch_notes, @@ -215,7 +213,7 @@ fn apply_hub_origin_sync_plan( git_dir : String, plan : HubOriginSyncPlan, ) -> Unit raise Error { - if !(plan.has_origin) { + if !plan.has_origin { return () } let config_path = hub_sync_config_path(git_dir) @@ -303,10 +301,10 @@ async fn ensure_hub_initialized( let fs = OsFs::new() let had_metadata = hub_metadata_is_initialized(fs, git_dir) let interactive = hub_should_prompt() - if !(had_metadata) { + if !had_metadata { if interactive { print_hub_init_metadata_prompt(command_name, git_dir) - if !(read_hub_init_approval()) { + if !read_hub_init_approval() { eprint_line("fatal: hub metadata initialization was not approved") @sys.exit(1) } @@ -316,17 +314,17 @@ async fn ensure_hub_initialized( ensure_hub_merge_policy_file(fs, git_dir) } let plan = load_hub_origin_sync_plan(fs, git_dir) - if !(plan.has_origin) { + if !plan.has_origin { return () } let needs_sync_config = plan.add_fetch_notes || plan.add_push_notes - if !(needs_sync_config) { + if !needs_sync_config { return () } - if !(explicit || !(had_metadata)) { + if !(explicit || !had_metadata) { return () } - if !(interactive) { + if !interactive { return () } print_hub_init_sync_prompt(command_name, plan) diff --git a/src/cmd/bit/hub_sync.mbt b/src/cmd/bit/hub_sync.mbt index 286aaa03..ea3cfe5f 100644 --- a/src/cmd/bit/hub_sync.mbt +++ b/src/cmd/bit/hub_sync.mbt @@ -456,11 +456,11 @@ fn hub_sync_is_valid_room_name(room : String) -> Bool { let mut first = true for c in room { if first { - if !(hub_sync_room_leading_char(c)) { + if !hub_sync_room_leading_char(c) { return false } first = false - } else if !(hub_sync_room_safe_char(c)) { + } else if !hub_sync_room_safe_char(c) { return false } } @@ -483,7 +483,7 @@ fn hub_sync_is_valid_room_token(room_token : String) -> Bool { return false } for c in room_token { - if !(hub_sync_room_token_safe_char(c)) { + if !hub_sync_room_token_safe_char(c) { return false } } @@ -526,7 +526,7 @@ fn build_hub_sync_issue_url( Some(value) => value None => hub_sync_generate_room(relay_base) } - if !(hub_sync_is_valid_room_name(room)) { + if !hub_sync_is_valid_room_name(room) { raise @bitcore.GitError::InvalidObject( "hub sync issue-url: invalid room name: \{room}", ) @@ -535,7 +535,7 @@ fn build_hub_sync_issue_url( Some(value) => value None => hub_sync_generate_room_token(relay_base, room) } - if !(hub_sync_is_valid_room_token(room_token)) { + if !hub_sync_is_valid_room_token(room_token) { raise @bitcore.GitError::InvalidObject( "hub sync issue-url: invalid room token", ) @@ -734,7 +734,7 @@ async fn run_hub_notify_hook( record : @hub.HubRecord, ) -> Int { let hook_path = git_dir + "/hooks/hub-notify" - if !(fs.is_file(hook_path)) { + if !fs.is_file(hook_path) { return -1 } @process.run( diff --git a/src/cmd/bit/index_pack.mbt b/src/cmd/bit/index_pack.mbt index 329bdf04..f63e525f 100644 --- a/src/cmd/bit/index_pack.mbt +++ b/src/cmd/bit/index_pack.mbt @@ -253,8 +253,7 @@ fn check_sha1_collisions_with_repo( } match existing { Some(base) => - if base.obj_type != obj.obj_type || - !(Bytes::equal(base.data, obj.data)) { + if base.obj_type != obj.obj_type || !Bytes::equal(base.data, obj.data) { raise @bitcore.GitError::PackfileError("SHA1 COLLISION FOUND") } None => () @@ -980,7 +979,7 @@ async fn handle_index_pack(args : Array[String]) -> Unit raise Error { objects.iter(), ) for base_hex in ref_delta_base_ids { - if !(pack_ids.contains(base_hex)) { + if !pack_ids.contains(base_hex) { for base in bases { let id = @bitobject.hash_object_content_with_algo( hash_algo, diff --git a/src/cmd/bit/init.mbt b/src/cmd/bit/init.mbt index 02773ae4..d92da85e 100644 --- a/src/cmd/bit/init.mbt +++ b/src/cmd/bit/init.mbt @@ -50,7 +50,7 @@ async fn handle_init(args : Array[String]) -> Unit raise Error { i += 1 } "--shared" => - if i + 1 < args.length() && !(args[i + 1].has_prefix("-")) { + if i + 1 < args.length() && !args[i + 1].has_prefix("-") { shared_mode = Some(args[i + 1]) i += 1 } else { @@ -102,7 +102,7 @@ async fn handle_init(args : Array[String]) -> Unit raise Error { object_format = Some(value) object_format_explicit = true } - _ if !(arg.has_prefix("-")) => target_dir = Some(arg) + _ if !arg.has_prefix("-") => target_dir = Some(arg) _ if arg.has_prefix("-") => warn_unimplemented_arg("init", arg) _ => () } @@ -110,7 +110,7 @@ async fn handle_init(args : Array[String]) -> Unit raise Error { } // Resolve ref format from env if not explicitly set via --ref-format let mut ref_format_from_env = false - if ref_format_env_deferred && !(ref_format_explicit) { + if ref_format_env_deferred && !ref_format_explicit { let env_ref_format = match @sys.get_env_var("GIT_DEFAULT_REF_FORMAT") { Some(value) => Some(value) None => @sys.get_env_var("GIT_TEST_DEFAULT_REF_FORMAT") @@ -250,7 +250,7 @@ async fn handle_init(args : Array[String]) -> Unit raise Error { init_normalize_path(if d.has_prefix("/") { d } else { root + "/" + d }), ) None => - if use_bit && !(bare) && effective_git_dir is None { + if use_bit && !bare && effective_git_dir is None { Some(path + "/.bit") } else { None @@ -295,7 +295,7 @@ async fn handle_init(args : Array[String]) -> Unit raise Error { // using --separate-git-dir, resolve and move the symlink target. // After this, the symlink becomes dangling and write_string will create // the target file through the dangling symlink (POSIX behavior). - if resolved_sep_git_dir is Some(sep_dir) && !(bare) { + if resolved_sep_git_dir is Some(sep_dir) && !bare { let dot_git = path + "/.git" let readlink_result = try? @process.collect_output( "readlink", @@ -329,7 +329,7 @@ async fn handle_init(args : Array[String]) -> Unit raise Error { fn resolve_dot_git_to_common_dir(fs : OsFs, dot_git_path : String) -> String { let mut resolved = dot_git_path // Follow gitdir: pointer if it's a file - if !(fs.is_dir(resolved)) && fs.is_file(resolved) { + if !fs.is_dir(resolved) && fs.is_file(resolved) { let content = decode_bytes((try? fs.read_file(resolved)).unwrap_or(b"")) let trimmed = content.trim_end(chars="\r\n").to_string() if trimmed.has_prefix("gitdir: ") { @@ -370,9 +370,7 @@ async fn handle_init(args : Array[String]) -> Unit raise Error { // This handles the case where we're running from a linked worktree with // --separate-git-dir: actual_git_dir was set to sep_dir which doesn't exist, // so we need to find the existing git dir from path/.git instead. - if resolved_sep_git_dir is Some(sep_dir) && - actual_git_dir == sep_dir && - !(bare) { + if resolved_sep_git_dir is Some(sep_dir) && actual_git_dir == sep_dir && !bare { let dot_git = path + "/.git" let resolved_from_dot_git = resolve_dot_git_to_common_dir(fs, dot_git) if resolved_from_dot_git != dot_git { @@ -498,7 +496,7 @@ async fn handle_init(args : Array[String]) -> Unit raise Error { } // Read init.defaultRefFormat from config, and feature.experimental fallback let mut ref_format_from_config = false - if !(ref_format_explicit) && ref_format == "files" { + if !ref_format_explicit && ref_format == "files" { let rfs3 : &@bitcore.RepoFileSystem = fs match find_global_gitconfig_path() { Some(config_path) => { @@ -524,8 +522,8 @@ async fn handle_init(args : Array[String]) -> Unit raise Error { None => () } // feature.experimental=true → default to reftable (only if no explicit env, flag, or config) - if !(ref_format_from_config) && - !(ref_format_from_env) && + if !ref_format_from_config && + !ref_format_from_env && ref_format == "files" { let fe_val = get_config_value( rfs3, @@ -600,7 +598,7 @@ async fn handle_init(args : Array[String]) -> Unit raise Error { } // Determine work_tree for config let config_work_tree : String? = match work_tree_env { - Some(wt) if bit_dir_env is Some(_) && !(bare) => + Some(wt) if bit_dir_env is Some(_) && !bare => Some(if wt.has_prefix("/") { wt } else { root + "/" + wt }) _ => None } @@ -624,13 +622,13 @@ async fn handle_init(args : Array[String]) -> Unit raise Error { // to be moved first. Also create a gitdir file at the old common dir location. let mut pre_moved_common_dir = false let mut old_common_dir : String? = None - if resolved_sep_git_dir is Some(sep_dir) && is_reinit && !(bare) { + if resolved_sep_git_dir is Some(sep_dir) && is_reinit && !bare { // Check if actual_git_dir is not the default location for this path let default_git_dir = path + "/.git" // Only pre-move for linked worktrees (where actual_git_dir was resolved via commondir). // For simple gitdir redirects (no commondir), the library handles the move itself. let dot_git_for_premove = path + "/.git" - let has_commondir = if !(fs.is_dir(dot_git_for_premove)) && + let has_commondir = if !fs.is_dir(dot_git_for_premove) && fs.is_file(dot_git_for_premove) { // Follow gitdir: pointer to check for commondir let gf = decode_bytes( @@ -738,7 +736,7 @@ async fn handle_init(args : Array[String]) -> Unit raise Error { } None => () } - if ref_format == "reftable" && !(is_reinit) { + if ref_format == "reftable" && !is_reinit { bootstrap_reftable_head_table(fs, actual_git_dir, branch) } apply_init_shared_permissions(fs, actual_git_dir, shared_mode) @@ -788,7 +786,7 @@ async fn handle_init(args : Array[String]) -> Unit raise Error { fs.write_string(wt_dot_git, "gitdir: " + wt_dir + "\n") // Also update the gitdir file in worktrees// // to have correct path from new location - if !(wt_path.has_prefix("/")) { + if !wt_path.has_prefix("/") { // Was relative, recalculate from new location let rel = compute_relative_path(wt_dir, wt_dot_git) fs.write_string(gitdir_file, rel + "\n") @@ -807,7 +805,7 @@ async fn handle_init(args : Array[String]) -> Unit raise Error { } } // Print appropriate message (unless quiet) - if !(quiet) { + if !quiet { let verb = if is_reinit { "Reinitialized existing" } else { @@ -923,7 +921,7 @@ async fn bootstrap_reftable_head_table( branch : String, ) -> Unit { let reftable_dir = git_dir + "/reftable" - if !(fs.is_dir(reftable_dir)) { + if !fs.is_dir(reftable_dir) { return } for entry in fs.readdir(reftable_dir) { @@ -1011,7 +1009,7 @@ fn init_normalize_path(p : String) -> String { ".." => if result.length() > 0 && result[result.length() - 1] != ".." { let _ = result.pop() - } else if !(is_absolute) { + } else if !is_absolute { result.push("..") } _ => result.push(part.to_string()) diff --git a/src/cmd/bit/interactive.mbt b/src/cmd/bit/interactive.mbt index c6cf3b66..3a264d3a 100644 --- a/src/cmd/bit/interactive.mbt +++ b/src/cmd/bit/interactive.mbt @@ -132,7 +132,7 @@ fn commit_edit_buffer_template(initial_message : String?) -> String { match initial_message { Some(msg) => { sb.write_string(msg) - if !(msg.has_suffix("\n")) { + if !msg.has_suffix("\n") { sb.write_string("\n") } sb.write_string("\n") @@ -208,7 +208,7 @@ async fn read_commit_message_from_editor( Some(edit) => edit(path) None => default_commit_message_editor(path) } - if !(edited) { + if !edited { return None } guard fs.is_file(path) else { return None } diff --git a/src/cmd/bit/interpret_trailers.mbt b/src/cmd/bit/interpret_trailers.mbt index 919cc9f9..6d492fb0 100644 --- a/src/cmd/bit/interpret_trailers.mbt +++ b/src/cmd/bit/interpret_trailers.mbt @@ -92,7 +92,7 @@ async fn handle_interpret_trailers(args : Array[String]) -> Unit raise Error { result.write_string(trailer.1) result.write_char('\n') } - if !(no_divider) && existing.length() > 0 { + if !no_divider && existing.length() > 0 { // With divider, print separator line before trailers // but --parse implies --no-divider } diff --git a/src/cmd/bit/log.mbt b/src/cmd/bit/log.mbt index 83d43a31..ed316913 100644 --- a/src/cmd/bit/log.mbt +++ b/src/cmd/bit/log.mbt @@ -141,7 +141,7 @@ fn log_find_tripledot(arg : String) -> Int { ///| fn is_short_count_flag(arg : String) -> Bool { - if !(arg.has_prefix("-")) || arg.length() <= 1 { + if !arg.has_prefix("-") || arg.length() <= 1 { return false } let raw = String::unsafe_substring(arg, start=1, end=arg.length()) @@ -291,7 +291,7 @@ fn log_storage_runtime_delegate_args( } i += 1 } - if !(seen_oneline) || !(seen_limit) { + if !seen_oneline || !seen_limit { return None } let parsed = storage_runtime_parse_command("log", args) catch { @@ -326,7 +326,7 @@ fn log_should_use_storage_runtime_in_repo( args : Array[String], ) -> Bool { log_should_use_storage_runtime(args) && - !(log_storage_runtime_blocked_by_repo_config(rfs, git_dir)) + !log_storage_runtime_blocked_by_repo_config(rfs, git_dir) } ///| @@ -576,7 +576,7 @@ fn log_resolve_decorate_mode( ) if config_entries.length() > 0 { let entry = config_entries[config_entries.length() - 1] - if !(entry.has_value) { + if !entry.has_value { return LogDecorationDisplayMode::Short } return log_parse_decorate_mode(entry.value).unwrap_or( @@ -618,7 +618,7 @@ fn log_has_missing_exclude_decoration_value( let entries = log_read_config_entries( rfs, git_dir, "log", "excludeDecoration", ) - entries.iter().any(fn(entry) { !(entry.has_value) }) + entries.iter().any(fn(entry) { !entry.has_value }) } ///| @@ -649,15 +649,13 @@ fn log_should_include_decoration_ref( exclude_patterns : Array[String], include_all_refs : Bool, ) -> Bool { - if !(include_all_refs) && log_ref_hidden_by_default(refname) { + if !include_all_refs && log_ref_hidden_by_default(refname) { return false } if include_patterns.length() > 0 && - !( - include_patterns - .iter() - .any(p => log_decoration_pattern_matches(refname, p)), - ) { + !include_patterns + .iter() + .any(p => log_decoration_pattern_matches(refname, p)) { return false } if exclude_patterns @@ -1276,14 +1274,14 @@ fn log_resolve_pretty_color_directive( let mut always = false let mut target = lower if lower.has_prefix("auto,") { - if !(data.pretty_color_enabled) { + if !data.pretty_color_enabled { return ("", -1) } target = String::unsafe_substring(lower, start=5, end=lower.length()) } else if lower.has_prefix("always,") { always = true target = String::unsafe_substring(lower, start=7, end=lower.length()) - } else if !(data.pretty_color_enabled) { + } else if !data.pretty_color_enabled { return ("", -1) } if target == "reset" || target == "normal" { @@ -1504,13 +1502,11 @@ fn log_build_ref_names( let all_ref_list = @bitrepo.show_ref(rfs, git_dir) let db = @bitlib.ObjectDb::load(rfs, log_resolve_common_git_dir(rfs, git_dir)) for item in all_ref_list { - if !( - log_should_include_decoration_ref( - item.0, - options.include_patterns, - options.exclude_patterns, - options.include_all_refs, - ), + if !log_should_include_decoration_ref( + item.0, + options.include_patterns, + options.exclude_patterns, + options.include_all_refs, ) { continue } @@ -1646,7 +1642,7 @@ fn log_resolve_common_git_dir( git_dir : String, ) -> String { let commondir_path = git_dir + "/commondir" - if !(rfs.is_file(commondir_path)) { + if !rfs.is_file(commondir_path) { return git_dir } let raw = @utf8.decode_lossy( @@ -1683,7 +1679,7 @@ fn log_read_graft_parents( commit_id : @bitcore.ObjectId, ) -> Array[@bitcore.ObjectId]? { let graft_path = log_resolve_common_git_dir(rfs, git_dir) + "/info/grafts" - if !(rfs.is_file(graft_path)) { + if !rfs.is_file(graft_path) { return None } let content = @utf8.decode_lossy( @@ -2152,11 +2148,11 @@ fn log_commit_diff_statuses( for file in diff_files { match file.kind { @bitdiff.DiffKind::Added => - if !(renamed_added.contains(file.path)) { + if !renamed_added.contains(file.path) { statuses["A"] = true } @bitdiff.DiffKind::Deleted => - if !(renamed_deleted.contains(file.path)) { + if !renamed_deleted.contains(file.path) { statuses["D"] = true } @bitdiff.DiffKind::Modified => () @@ -2171,12 +2167,12 @@ fn log_commit_matches_diff_filter_with_statuses( include_bits : Map[String, Bool], exclude : Map[String, Bool], ) -> Bool { - if !(log_has_diff_filter(include_bits, exclude)) { + if !log_has_diff_filter(include_bits, exclude) { return true } if include_bits.length() == 0 { for key, _ in statuses { - if !(exclude.contains(key)) { + if !exclude.contains(key) { return true } } @@ -2206,7 +2202,7 @@ fn log_commit_matches_diff_filter( detect_renames : Bool, detect_copies : Bool, ) -> Bool raise Error { - if !(log_has_diff_filter(include_bits, exclude)) { + if !log_has_diff_filter(include_bits, exclude) { return true } let statuses = log_commit_diff_statuses( @@ -2258,7 +2254,7 @@ fn log_commit_matches_history_filters( detect_renames : Bool, detect_copies : Bool, ) -> Bool raise Error { - if !(log_commit_matches_pathspecs(rfs, git_dir, db, commit_id, pathspecs)) { + if !log_commit_matches_pathspecs(rfs, git_dir, db, commit_id, pathspecs) { return false } log_commit_matches_diff_filter( @@ -2337,7 +2333,7 @@ fn log_collect_raw_results( } } for path, entry in old_entries { - if !(new_entries.contains(path)) { + if !new_entries.contains(path) { deleted.push((path, entry)) } } @@ -2450,16 +2446,14 @@ fn log_grep_patterns_match( if patterns.length() == 0 { return true } - if !(all_match) { + if !all_match { return grep_patterns_match_message( message, patterns, pattern_type, ignore_case, ) } for pattern in patterns { - if !( - grep_message_matches_pattern( - message, pattern, pattern_type, ignore_case, - ), + if !grep_message_matches_pattern( + message, pattern, pattern_type, ignore_case, ) { return false } @@ -2490,7 +2484,7 @@ fn log_validate_reflog_grep_options( walk_reflogs : Bool, grep_reflog_patterns : Array[String], ) -> Unit raise Error { - if grep_reflog_patterns.length() > 0 && !(walk_reflogs) { + if grep_reflog_patterns.length() > 0 && !walk_reflogs { raise @bitcore.GitError::InvalidObject( "fatal: the option '--grep-reflog' requires '--walk-reflogs'", ) @@ -2533,26 +2527,22 @@ fn log_commit_matches_text_filters( all_match, ) let effective_message_match = if grep_patterns.length() > 0 && invert_grep { - !(message_match) + !message_match } else { message_match } - if !(effective_message_match) { + if !effective_message_match { return false } let author_text = data.author_name + " <" + data.author_email + ">" - if !( - log_identity_patterns_match( - author_text, author_patterns, pattern_type, ignore_case, - ), + if !log_identity_patterns_match( + author_text, author_patterns, pattern_type, ignore_case, ) { return false } let committer_text = data.committer_name + " <" + data.committer_email + ">" - if !( - log_identity_patterns_match( - committer_text, committer_patterns, pattern_type, ignore_case, - ), + if !log_identity_patterns_match( + committer_text, committer_patterns, pattern_type, ignore_case, ) { return false } @@ -2904,7 +2894,7 @@ fn log_sanitize_subject_for_format(s : String) -> String { (c >= '0' && c <= '9') { sb.write_char(c) last_was_dash = false - } else if !(last_was_dash) { + } else if !last_was_dash { sb.write_char('-') last_was_dash = true } @@ -3451,7 +3441,7 @@ async fn handle_log(args : Array[String]) -> Unit raise Error { "--graph" => graph = true "--all" => all_refs = true "--" => pathspec_mode = true - "--not" => not_mode = !(not_mode) + "--not" => not_mode = !not_mode "--end-of-options" => end_of_options = true "--source" => source = true "--left-right" => left_right = true @@ -3465,7 +3455,7 @@ async fn handle_log(args : Array[String]) -> Unit raise Error { branch_patterns.push("*") saw_revision_input = true } - "--glob" if i + 1 < args.length() && !(args[i + 1].has_prefix("-")) => { + "--glob" if i + 1 < args.length() && !args[i + 1].has_prefix("-") => { log_append_glob_targets(rfs, git_dir, args[i + 1], revs) saw_revision_input = true i += 1 @@ -3734,7 +3724,7 @@ async fn handle_log(args : Array[String]) -> Unit raise Error { continue } if line == "--not" { - stdin_not_mode = !(stdin_not_mode) + stdin_not_mode = !stdin_not_mode continue } if line == "--all" { @@ -3769,7 +3759,7 @@ async fn handle_log(args : Array[String]) -> Unit raise Error { saw_revision_input = true continue } - if line.has_prefix("-") && !(line.has_prefix("^")) { + if line.has_prefix("-") && !line.has_prefix("^") { raise @bitcore.GitError::InvalidObject( "invalid option '" + line + "' in --stdin mode", ) @@ -3882,31 +3872,27 @@ async fn handle_log(args : Array[String]) -> Unit raise Error { let mut reflog_index = start_reflog_index while reflog_index < entries.length() && emitted < max_count { let entry = entries[entries.length() - 1 - reflog_index] - if !( - log_grep_patterns_match( - entry.message, - grep_reflog_patterns, - grep_pattern_type, - grep_ignore_case, - all_match, - ), + if !log_grep_patterns_match( + entry.message, + grep_reflog_patterns, + grep_pattern_type, + grep_ignore_case, + all_match, ) { reflog_index += 1 continue } - if !( - log_commit_matches_text_filters( - rfs, - reflog_db, - entry.new_id, - grep_patterns, - grep_pattern_type, - grep_ignore_case, - invert_grep, - all_match, - author_patterns, - committer_patterns, - ), + if !log_commit_matches_text_filters( + rfs, + reflog_db, + entry.new_id, + grep_patterns, + grep_pattern_type, + grep_ignore_case, + invert_grep, + all_match, + author_patterns, + committer_patterns, ) { reflog_index += 1 continue @@ -4052,17 +4038,15 @@ async fn handle_log(args : Array[String]) -> Unit raise Error { raw_fmt != "raw", simplify_by_decoration, ) - let selection_ref_names = if !( - log_decoration_mode_is_none(decoration_options.mode), + let selection_ref_names = if !log_decoration_mode_is_none( + decoration_options.mode, ) || simplify_by_decoration { log_build_ref_names(rfs, git_dir, decoration_options) } else { {} } - let ref_names_map = if !( - log_decoration_mode_is_none(decoration_options.mode), - ) { + let ref_names_map = if !log_decoration_mode_is_none(decoration_options.mode) { selection_ref_names } else { {} @@ -4087,7 +4071,7 @@ async fn handle_log(args : Array[String]) -> Unit raise Error { revs, branch_patterns, all_refs, - default_head=!(saw_revision_input), + default_head=!saw_revision_input, ignore_missing~, ) let targets = if no_walk_unsorted { @@ -4104,19 +4088,15 @@ async fn handle_log(args : Array[String]) -> Unit raise Error { if seen.contains(hex) { continue } - if !( - log_commit_matches_text_filters( - rfs, db, id, grep_patterns, grep_pattern_type, grep_ignore_case, invert_grep, - all_match, author_patterns, committer_patterns, - ), + if !log_commit_matches_text_filters( + rfs, db, id, grep_patterns, grep_pattern_type, grep_ignore_case, invert_grep, + all_match, author_patterns, committer_patterns, ) { continue } - if !( - log_commit_matches_history_filters( - rfs, git_dir, db, id, pathspecs, diff_filter_include, diff_filter_exclude, - detect_renames, detect_copies, - ), + if !log_commit_matches_history_filters( + rfs, git_dir, db, id, pathspecs, diff_filter_include, diff_filter_exclude, + detect_renames, detect_copies, ) { continue } @@ -4129,12 +4109,10 @@ async fn handle_log(args : Array[String]) -> Unit raise Error { continue } if simplify_by_decoration && - !( - log_should_emit_simplified_entry( - selection_ref_names, - hex, - parents.length(), - ), + !log_should_emit_simplified_entry( + selection_ref_names, + hex, + parents.length(), ) { continue } @@ -4161,7 +4139,7 @@ async fn handle_log(args : Array[String]) -> Unit raise Error { revs, branch_patterns, all_refs, - default_head=!(saw_revision_input), + default_head=!saw_revision_input, ignore_missing~, ) let start_ids : Array[@bitcore.ObjectId] = [] @@ -4227,34 +4205,30 @@ async fn handle_log(args : Array[String]) -> Unit raise Error { if seen.contains(hex) { continue } - if !( - log_commit_matches_text_filters( - rfs, - db, - entry.id, - grep_patterns, - grep_pattern_type, - grep_ignore_case, - invert_grep, - all_match, - author_patterns, - committer_patterns, - ), + if !log_commit_matches_text_filters( + rfs, + db, + entry.id, + grep_patterns, + grep_pattern_type, + grep_ignore_case, + invert_grep, + all_match, + author_patterns, + committer_patterns, ) { continue } - if !( - log_commit_matches_history_filters( - rfs, - git_dir, - db, - entry.id, - pathspecs, - diff_filter_include, - diff_filter_exclude, - detect_renames, - detect_copies, - ), + if !log_commit_matches_history_filters( + rfs, + git_dir, + db, + entry.id, + pathspecs, + diff_filter_include, + diff_filter_exclude, + detect_renames, + detect_copies, ) { continue } @@ -4267,12 +4241,10 @@ async fn handle_log(args : Array[String]) -> Unit raise Error { continue } if simplify_by_decoration && - !( - log_should_emit_simplified_entry( - selection_ref_names, - hex, - parents.length(), - ), + !log_should_emit_simplified_entry( + selection_ref_names, + hex, + parents.length(), ) { continue } @@ -4302,7 +4274,7 @@ async fn handle_log(args : Array[String]) -> Unit raise Error { return } // Show subdir-clone info if applicable (only in full format) - if !(oneline) { + if !oneline { match get_subdir_info(fs, git_dir) { Some((remote, path, base)) => { log_emit_output( @@ -4324,9 +4296,7 @@ async fn handle_log(args : Array[String]) -> Unit raise Error { rfs, git_dir, decorate_mode_override, decoration_include_patterns, decoration_exclude_patterns, clear_decorations, false, true, simplify_by_decoration, ) - let show_decorations = !( - log_decoration_mode_is_none(decoration_options.mode), - ) + let show_decorations = !log_decoration_mode_is_none(decoration_options.mode) // Determine whether we need the new walk path let need_walk = all_refs || show_decorations || @@ -4362,7 +4332,7 @@ async fn handle_log(args : Array[String]) -> Unit raise Error { revs, branch_patterns, all_refs, - default_head=!(saw_revision_input), + default_head=!saw_revision_input, ignore_missing~, ) let targets = if no_walk_unsorted { @@ -4389,19 +4359,15 @@ async fn handle_log(args : Array[String]) -> Unit raise Error { if seen.contains(hex) { continue } - if !( - log_commit_matches_text_filters( - rfs, db, id, grep_patterns, grep_pattern_type, grep_ignore_case, invert_grep, - all_match, author_patterns, committer_patterns, - ), + if !log_commit_matches_text_filters( + rfs, db, id, grep_patterns, grep_pattern_type, grep_ignore_case, invert_grep, + all_match, author_patterns, committer_patterns, ) { continue } - if !( - log_commit_matches_history_filters( - rfs, git_dir, db, id, pathspecs, diff_filter_include, diff_filter_exclude, - detect_renames, detect_copies, - ), + if !log_commit_matches_history_filters( + rfs, git_dir, db, id, pathspecs, diff_filter_include, diff_filter_exclude, + detect_renames, detect_copies, ) { continue } @@ -4412,12 +4378,10 @@ async fn handle_log(args : Array[String]) -> Unit raise Error { continue } if simplify_by_decoration && - !( - log_should_emit_simplified_entry( - selection_ref_names, - hex, - entry.parent_count, - ), + !log_should_emit_simplified_entry( + selection_ref_names, + hex, + entry.parent_count, ) { continue } @@ -4443,19 +4407,15 @@ async fn handle_log(args : Array[String]) -> Unit raise Error { if seen.contains(hex) { continue } - if !( - log_commit_matches_text_filters( - rfs, db, id, grep_patterns, grep_pattern_type, grep_ignore_case, invert_grep, - all_match, author_patterns, committer_patterns, - ), + if !log_commit_matches_text_filters( + rfs, db, id, grep_patterns, grep_pattern_type, grep_ignore_case, invert_grep, + all_match, author_patterns, committer_patterns, ) { continue } - if !( - log_commit_matches_history_filters( - rfs, git_dir, db, id, pathspecs, diff_filter_include, diff_filter_exclude, - detect_renames, detect_copies, - ), + if !log_commit_matches_history_filters( + rfs, git_dir, db, id, pathspecs, diff_filter_include, diff_filter_exclude, + detect_renames, detect_copies, ) { continue } @@ -4473,12 +4433,10 @@ async fn handle_log(args : Array[String]) -> Unit raise Error { continue } if simplify_by_decoration && - !( - log_should_emit_simplified_entry( - selection_ref_names, - hex, - entry.parent_count, - ), + !log_should_emit_simplified_entry( + selection_ref_names, + hex, + entry.parent_count, ) { continue } @@ -4552,7 +4510,7 @@ async fn handle_log(args : Array[String]) -> Unit raise Error { revs, branch_patterns, all_refs, - default_head=!(saw_revision_input), + default_head=!saw_revision_input, ignore_missing~, ) // Build start_ids from explicit targets @@ -4654,43 +4612,37 @@ async fn handle_log(args : Array[String]) -> Unit raise Error { continue } if simplify_by_decoration && - !( - log_should_emit_simplified_entry( - selection_ref_names, - entry.id.to_hex(), - entry.parent_count, - ), + !log_should_emit_simplified_entry( + selection_ref_names, + entry.id.to_hex(), + entry.parent_count, ) { continue } - if !( - log_commit_matches_text_filters( - rfs, - walk_db, - entry.id, - grep_patterns, - grep_pattern_type, - grep_ignore_case, - invert_grep, - all_match, - author_patterns, - committer_patterns, - ), + if !log_commit_matches_text_filters( + rfs, + walk_db, + entry.id, + grep_patterns, + grep_pattern_type, + grep_ignore_case, + invert_grep, + all_match, + author_patterns, + committer_patterns, ) { continue } - if !( - log_commit_matches_history_filters( - rfs, - git_dir, - walk_db, - entry.id, - pathspecs, - diff_filter_include, - diff_filter_exclude, - detect_renames, - detect_copies, - ), + if !log_commit_matches_history_filters( + rfs, + git_dir, + walk_db, + entry.id, + pathspecs, + diff_filter_include, + diff_filter_exclude, + detect_renames, + detect_copies, ) { continue } @@ -4722,43 +4674,37 @@ async fn handle_log(args : Array[String]) -> Unit raise Error { continue } if simplify_by_decoration && - !( - log_should_emit_simplified_entry( - selection_ref_names, - entry.id.to_hex(), - entry.parent_count, - ), + !log_should_emit_simplified_entry( + selection_ref_names, + entry.id.to_hex(), + entry.parent_count, ) { continue } - if !( - log_commit_matches_text_filters( - rfs, - walk_db, - entry.id, - grep_patterns, - grep_pattern_type, - grep_ignore_case, - invert_grep, - all_match, - author_patterns, - committer_patterns, - ), + if !log_commit_matches_text_filters( + rfs, + walk_db, + entry.id, + grep_patterns, + grep_pattern_type, + grep_ignore_case, + invert_grep, + all_match, + author_patterns, + committer_patterns, ) { continue } - if !( - log_commit_matches_history_filters( - rfs, - git_dir, - walk_db, - entry.id, - pathspecs, - diff_filter_include, - diff_filter_exclude, - detect_renames, - detect_copies, - ), + if !log_commit_matches_history_filters( + rfs, + git_dir, + walk_db, + entry.id, + pathspecs, + diff_filter_include, + diff_filter_exclude, + detect_renames, + detect_copies, ) { continue } @@ -4926,7 +4872,7 @@ async fn handle_whatchanged(args : Array[String]) -> Unit raise Error { ) return } - if !(acknowledged) { + if !acknowledged { @stdio.stderr.write( "'git whatchanged' is nominated for removal.\n\nhint: You can replace 'git whatchanged ' with:\nhint:\tgit log --raw --no-merges\nhint: Or make an alias:\nhint:\tgit config set --global alias.whatchanged 'log --raw --no-merges'\n\nIf you still use this command, here's what you can do:\n\n- read https://git-scm.com/docs/BreakingChanges.html\n- check if anyone has discussed this on the mailing\n list and if they came up with something that can\n help you: https://lore.kernel.org/git/?q=git%20whatchanged\n- send an email to to let us\n know that you still use this command and were unable\n to determine a suitable replacement\n\nfatal: refusing to run without --i-still-use-this\n", ) @@ -4981,7 +4927,7 @@ fn log_walk_commits( let queue : Array[(Int64, @bitcore.ObjectId)] = [] for id in start_ids { let hex = id.to_hex() - if !(visited.contains(hex)) && !(exclude_ids.contains(hex)) { + if !visited.contains(hex) && !exclude_ids.contains(hex) { // Get timestamp for sorting let ts = log_get_commit_timestamp(db, rfs, id) log_queue_insert(queue, (ts, id)) @@ -5019,7 +4965,7 @@ fn log_walk_commits( } for parent in parents_to_walk { let phex = parent.to_hex() - if !(visited.contains(phex)) && !(exclude_ids.contains(phex)) { + if !visited.contains(phex) && !exclude_ids.contains(phex) { visited[phex] = true let pts = log_get_commit_timestamp(db, rfs, parent) log_queue_insert(queue, (pts, parent)) diff --git a/src/cmd/bit/ls_files.mbt b/src/cmd/bit/ls_files.mbt index 5200d8cd..c6165f4b 100644 --- a/src/cmd/bit/ls_files.mbt +++ b/src/cmd/bit/ls_files.mbt @@ -122,7 +122,7 @@ async fn handle_ls_files(args : Array[String]) -> Unit raise Error { } for item in stage_entries { if item.stage == 0 || - !(ls_files_matches_filters(item.entry.path, path_filters)) { + !ls_files_matches_filters(item.entry.path, path_filters) { continue } let mode = format_mode(item.entry.mode) @@ -152,7 +152,7 @@ async fn handle_ls_files(args : Array[String]) -> Unit raise Error { let db = @bitlib.ObjectDb::load_lazy(fs, git_dir) // Tracked entries (cached or deleted) for e in entries { - if !(ls_files_matches_filters(e.path, path_filters)) { + if !ls_files_matches_filters(e.path, path_filters) { continue } let abs = root + "/" + e.path @@ -162,9 +162,10 @@ async fn handle_ls_files(args : Array[String]) -> Unit raise Error { continue } // Default (cached): skip deleted unless show_deleted - if !(show_deleted) && !(file_exists) && !(show_others) { - // still show in default cached mode + if !show_deleted && !file_exists && !show_others { + } + // still show in default cached mode // Detect index EOL from blob content let i_eol = match db.get(fs, e.id) { Some(obj) if obj.obj_type == @bitcore.ObjectType::Blob => @@ -197,7 +198,7 @@ async fn handle_ls_files(args : Array[String]) -> Unit raise Error { if tracked.contains(path) { continue } - if !(ls_files_matches_filters(path, path_filters)) { + if !ls_files_matches_filters(path, path_filters) { continue } let abs = root + "/" + path @@ -217,13 +218,13 @@ async fn handle_ls_files(args : Array[String]) -> Unit raise Error { } return () } - if show_ignored && !(show_others) { + if show_ignored && !show_others { let entry_map : Map[String, @bitlib.IndexEntry] = {} for entry in entries { entry_map[entry.path] = entry } for entry in entries { - if !(ls_files_matches_filters(entry.path, path_filters)) { + if !ls_files_matches_filters(entry.path, path_filters) { continue } if ls_files_cached_entry_is_ignored( @@ -286,7 +287,7 @@ async fn handle_ls_files(args : Array[String]) -> Unit raise Error { filter, ) { let (_raw, is_exclude, _is_icase) = parse_pathspec_magic(filter) - !(is_exclude) && + !is_exclude && ls_files_filter_has_wildcard(filter) && ls_files_filter_prefers_file_output(filter) }) @@ -302,8 +303,8 @@ async fn handle_ls_files(args : Array[String]) -> Unit raise Error { let explicit_file_filters : Map[String, Bool] = {} for filter in path_filters { let (_raw, is_exclude, _is_icase) = parse_pathspec_magic(filter) - if !(is_exclude) && - !(ls_files_filter_has_wildcard(filter)) && + if !is_exclude && + !ls_files_filter_has_wildcard(filter) && untracked_file_set.contains(filter) { explicit_file_filters[filter] = true } @@ -334,13 +335,13 @@ async fn handle_ls_files(args : Array[String]) -> Unit raise Error { } if should_output { if no_empty_directory && - !(ls_files_has_matching_file(dir, all_files, untracked_file_set)) { + !ls_files_has_matching_file(dir, all_files, untracked_file_set) { continue } if ls_files_is_within_untracked_dir(dir, compress_dirs) { continue } - if !(output_set.contains(out_path)) { + if !output_set.contains(out_path) { output_set[out_path] = true outputs.push(out_path) compress_dirs.push(dir) @@ -349,14 +350,14 @@ async fn handle_ls_files(args : Array[String]) -> Unit raise Error { } if path_filters.length() == 0 { for file in all_files { - if !(untracked_file_set.contains(file)) { + if !untracked_file_set.contains(file) { continue } - if !(disable_directory_compression) && + if !disable_directory_compression && ls_files_is_within_untracked_dir(file, compress_dirs) { continue } - if !(output_set.contains(file)) { + if !output_set.contains(file) { output_set[file] = true outputs.push(file) } @@ -364,11 +365,11 @@ async fn handle_ls_files(args : Array[String]) -> Unit raise Error { } else if explicit_file_filters.length() > 0 || wildcard_file_filters.length() > 0 { for file in all_files { - if !(untracked_file_set.contains(file)) { + if !untracked_file_set.contains(file) { continue } if explicit_file_filters.contains(file) { - if !(output_set.contains(file)) { + if !output_set.contains(file) { output_set[file] = true outputs.push(file) } @@ -376,7 +377,7 @@ async fn handle_ls_files(args : Array[String]) -> Unit raise Error { } for filter in wildcard_file_filters { if ls_files_pathspec_matches(file, filter) { - if !(output_set.contains(file)) { + if !output_set.contains(file) { output_set[file] = true outputs.push(file) } @@ -428,7 +429,7 @@ async fn handle_ls_files(args : Array[String]) -> Unit raise Error { let modified_paths = ls_files_collect_modified_paths(fs, root, entries) for path in modified_paths { if ls_files_matches_filters(path, path_filters) && - !(output_set.contains(path)) { + !output_set.contains(path) { output_set[path] = true outputs.push(path) } @@ -438,7 +439,7 @@ async fn handle_ls_files(args : Array[String]) -> Unit raise Error { let killed_paths = ls_files_collect_killed_paths(fs, root, entries) for path in killed_paths { if ls_files_matches_filters(path, path_filters) && - !(output_set.contains(path)) { + !output_set.contains(path) { output_set[path] = true outputs.push(path) } @@ -462,7 +463,7 @@ async fn handle_ls_files(args : Array[String]) -> Unit raise Error { // Show deleted files (in index but not in worktree) for e in entries { let abs = root + "/" + e.path - if !(fs.is_file(abs)) && ls_files_matches_filters(e.path, path_filters) { + if !fs.is_file(abs) && ls_files_matches_filters(e.path, path_filters) { print_str(make_display_path(e.path, cwd_prefix) + terminator) } } @@ -485,7 +486,7 @@ async fn handle_ls_files(args : Array[String]) -> Unit raise Error { // Use stage entries to show actual stage numbers (0, 1, 2, 3) let stage_entries = @bitlib.read_index_stage_entries(fs, git_dir) for item in stage_entries { - if !(ls_files_matches_filters(item.entry.path, path_filters)) { + if !ls_files_matches_filters(item.entry.path, path_filters) { continue } let mode = format_mode(item.entry.mode) @@ -505,7 +506,7 @@ async fn handle_ls_files(args : Array[String]) -> Unit raise Error { } } else { for entry in tracked_entries { - if !(ls_files_matches_filters(entry.path, path_filters)) { + if !ls_files_matches_filters(entry.path, path_filters) { continue } print_str(make_display_path(entry.path, cwd_prefix) + terminator) @@ -576,7 +577,7 @@ async fn ls_files_collect_killed_paths( None => break } } - if !(obstructs) { + if !obstructs { let prefix = path + "/" for tracked_path in tracked_paths { if tracked_path.has_prefix(prefix) { @@ -585,7 +586,7 @@ async fn ls_files_collect_killed_paths( } } } - if obstructs && !(killed_set.contains(path)) { + if obstructs && !killed_set.contains(path) { killed_set[path] = true killed.push(path) } @@ -603,7 +604,7 @@ async fn ls_files_collect_modified_paths( let modified_set : Map[String, Bool] = {} let diffs = @bitdiff.diff_worktree(fs, root) for diff in diffs { - if !(modified_set.contains(diff.path)) { + if !modified_set.contains(diff.path) { modified_set[diff.path] = true modified.push(diff.path) } @@ -613,13 +614,13 @@ async fn ls_files_collect_modified_paths( continue } let sub_git_dir = root + "/" + entry.path + "/.git" - if !(fs.is_dir(sub_git_dir)) && !(fs.is_file(sub_git_dir)) { + if !fs.is_dir(sub_git_dir) && !fs.is_file(sub_git_dir) { continue } let actual_git_dir = @bitlib.resolve_gitdir(fs, sub_git_dir) match @bitlib.resolve_head_commit(fs, actual_git_dir) { Some(head) => - if head != entry.id && !(modified_set.contains(entry.path)) { + if head != entry.id && !modified_set.contains(entry.path) { modified_set[entry.path] = true modified.push(entry.path) } @@ -767,7 +768,7 @@ fn ls_files_collect_cached_entries( } else { @bitlib.expand_sparse_index_entries(fs, git_dir, raw_entries) } - if !(recurse_submodules) { + if !recurse_submodules { return entries.map(fn(entry) { { path: prefix + entry.path } }) } let submodules = parse_gitmodules(fs, root) @@ -779,13 +780,13 @@ fn ls_files_collect_cached_entries( } match ls_files_find_submodule_by_path(submodules, entry.path) { Some(submodule) => { - if !(ls_files_submodule_is_active(fs, git_dir, submodule.name)) { + if !ls_files_submodule_is_active(fs, git_dir, submodule.name) { out.push({ path: prefix + entry.path }) continue } let sub_root = root + "/" + submodule.path let sub_git_marker = sub_root + "/.git" - if !(fs.is_dir(sub_git_marker)) && !(fs.is_file(sub_git_marker)) { + if !fs.is_dir(sub_git_marker) && !fs.is_file(sub_git_marker) { out.push({ path: prefix + entry.path }) continue } @@ -888,7 +889,7 @@ fn parse_gitmodules( root : String, ) -> Array[SubmoduleInfo] { let gitmodules_path = root + "/.gitmodules" - if !(fs.is_file(gitmodules_path)) { + if !fs.is_file(gitmodules_path) { return [] } let content = decode_bytes(fs.read_file(gitmodules_path)) catch { @@ -1126,14 +1127,12 @@ fn ls_files_matches_filters(path : String, filters : Array[String]) -> Bool { .iter() .any(fn(filter) { ls_files_pathspec_matches(normalized, filter) }) } - if !(included) { + if !included { return false } - !( - exclude_filters - .iter() - .any(fn(filter) { ls_files_pathspec_matches(normalized, filter) }), - ) + !exclude_filters + .iter() + .any(fn(filter) { ls_files_pathspec_matches(normalized, filter) }) } ///| @@ -1207,7 +1206,7 @@ fn ls_files_collect_unmatched_raw_filters( ) let include_filters = normalized_filters.filter(fn(filter) { let (_raw, is_exclude, _is_icase) = parse_pathspec_magic(filter) - !(is_exclude) + !is_exclude }) let matched = if include_filters.length() == 0 { candidate_paths.length() > 0 @@ -1220,7 +1219,7 @@ fn ls_files_collect_unmatched_raw_filters( .any(fn(path) { ls_files_pathspec_matches(path, filter) }) }) } - if !(matched) { + if !matched { unmatched.push(raw) } } @@ -1344,7 +1343,7 @@ fn ls_files_collect_other_paths( } match exclude_per_directory { Some(name) => - if !(per_directory_files.contains(name)) { + if !per_directory_files.contains(name) { per_directory_files.push(name) } None => () @@ -1468,7 +1467,7 @@ fn ls_files_cached_entry_is_ignored( } match exclude_per_directory { Some(name) => - if !(per_directory_files.contains(name)) { + if !per_directory_files.contains(name) { per_directory_files.push(name) } None => () @@ -1560,7 +1559,7 @@ fn ls_files_walk_other_files( let is_dir = fs.is_dir(child_path) let ignored = matcher.is_ignored(child_rel, is_dir) if is_dir { - if !(dirs_out.contains(child_rel)) { + if !dirs_out.contains(child_rel) { dirs_out.push(child_rel) } if ignored { @@ -1585,7 +1584,7 @@ fn ls_files_walk_other_files( if ignored { files_out.push(child_rel) } - } else if !(ignored) { + } else if !ignored { files_out.push(child_rel) } } @@ -1616,7 +1615,7 @@ fn ls_files_collect_candidate_dirs( } } for dir in explicit_dirs { - if !(tracked_dirs.contains(dir)) { + if !tracked_dirs.contains(dir) { seen[dir] = true } } diff --git a/src/cmd/bit/ls_files_wbtest.mbt b/src/cmd/bit/ls_files_wbtest.mbt index d8e0d621..f9bb026b 100644 --- a/src/cmd/bit/ls_files_wbtest.mbt +++ b/src/cmd/bit/ls_files_wbtest.mbt @@ -1,13 +1,13 @@ ///| test "ls-files: no wildcard filter matches exact path" { assert_true(ls_files_matches_filters("a.txt", ["a.txt"])) - assert_true(!(ls_files_matches_filters("dir/b.txt", ["a.txt"]))) + assert_true(!ls_files_matches_filters("dir/b.txt", ["a.txt"])) } ///| test "ls-files: directory prefix filter works" { assert_true(ls_files_matches_filters("dir/a.txt", ["dir"])) - assert_true(!(ls_files_matches_filters("other.txt", ["dir"]))) + assert_true(!ls_files_matches_filters("other.txt", ["dir"])) } ///| @@ -29,7 +29,7 @@ test "ls-files: wildcard directory filter matches directory output" { test "ls-files: wildcard prefix filter" { let long_name = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" assert_true(ls_files_matches_filters(long_name, ["a*"])) - assert_true(!(ls_files_matches_filters("b.txt", ["a*"]))) + assert_true(!ls_files_matches_filters("b.txt", ["a*"])) } ///| @@ -68,11 +68,9 @@ test "ls-files: wildcard filter matches index scan" { .any(fn(entry) { ls_files_pathspec_matches(entry.path, "a*") }), ) assert_true( - !( - entries - .iter() - .any(fn(entry) { ls_files_pathspec_matches(entry.path, "b*") }), - ), + !entries + .iter() + .any(fn(entry) { ls_files_pathspec_matches(entry.path, "b*") }), ) } @@ -88,7 +86,7 @@ test "ls-files: icase pathspec matches case-insensitively" { test "ls-files: exclude pathspec removes matching entries" { let filters = [":(icase)*.txt", ":(exclude)submodule/subsub/*"] assert_true(ls_files_matches_filters("submodule/g.txt", filters)) - assert_true(!(ls_files_matches_filters("submodule/subsub/e.txt", filters))) + assert_true(!ls_files_matches_filters("submodule/subsub/e.txt", filters)) } ///| @@ -133,11 +131,9 @@ test "ls-files: untracked directory compression" { ]), ) assert_true( - !( - ls_files_is_within_untracked_dir("partially_tracked/tracked.txt", [ - "partially_tracked/untracked", - ]), - ), + !ls_files_is_within_untracked_dir("partially_tracked/tracked.txt", [ + "partially_tracked/untracked", + ]), ) } @@ -146,7 +142,7 @@ test "ls-files: has matching file under directory" { let files = ["src/main.rs", "src/lib/main.rs", "readme.md"] let untracked : Map[String, Bool] = { "src/main.rs": true, "readme.md": true } assert_true(ls_files_has_matching_file("src", files, untracked)) - assert_true(!(ls_files_has_matching_file("tests", files, untracked))) + assert_true(!ls_files_has_matching_file("tests", files, untracked)) } ///| diff --git a/src/cmd/bit/ls_remote.mbt b/src/cmd/bit/ls_remote.mbt index d2a7e1d5..dff286db 100644 --- a/src/cmd/bit/ls_remote.mbt +++ b/src/cmd/bit/ls_remote.mbt @@ -72,10 +72,10 @@ async fn handle_ls_remote(args : Array[String]) -> Unit raise Error { for pair in refs { let (oid, refname) = pair // Apply filters - if show_heads && !(refname.has_prefix("refs/heads/")) { + if show_heads && !refname.has_prefix("refs/heads/") { continue } - if show_tags && !(refname.has_prefix("refs/tags/")) { + if show_tags && !refname.has_prefix("refs/tags/") { continue } if show_refs_only { @@ -93,7 +93,7 @@ async fn handle_ls_remote(args : Array[String]) -> Unit raise Error { break } } - if !(matched) { + if !matched { continue } } diff --git a/src/cmd/bit/ls_tree.mbt b/src/cmd/bit/ls_tree.mbt index 77edcbc9..7dd00629 100644 --- a/src/cmd/bit/ls_tree.mbt +++ b/src/cmd/bit/ls_tree.mbt @@ -34,7 +34,7 @@ async fn handle_ls_tree(args : Array[String]) -> Unit raise Error { _abbrev = Some(@string.parse_int(v)) catch { _ => Some(7) } } "--abbrev" => _abbrev = Some(7) - _ if !(arg.has_prefix("-")) => positional.push(arg) + _ if !arg.has_prefix("-") => positional.push(arg) _ if arg.has_prefix("-") => warn_unimplemented_arg("ls-tree", arg) _ => () } @@ -246,7 +246,7 @@ async fn print_tree_entries( } (match_found, recurse_needed) } - if !(matches_filter) && !(should_recurse_for_filter) { + if !matches_filter && !should_recurse_for_filter { continue } // Skip submodule entries when recurse_submodules is enabled @@ -298,13 +298,13 @@ async fn print_tree_entries( // With -d, only show tree entries // With -r, don't print tree entries unless -t is also specified // With -t and path filters, show tree entries we're traversing through - let should_print = if !(matches_filter) && + let should_print = if !matches_filter && !(show_trees && should_recurse_for_filter && is_tree) { false // Don't print if path doesn't match filters (unless -t and traversing trees) } else if only_trees { is_tree || is_submodule // Print tree and submodule (commit) entries } else { - !(recursive) || !(is_tree) || show_trees + !recursive || !is_tree || show_trees } if should_print { let display_path = make_display_path(path, cwd_prefix) @@ -540,7 +540,7 @@ fn c_quote_path(path : String) -> String { break } } - if !(needs_quote) { + if !needs_quote { return path } let buf = StringBuilder::new() diff --git a/src/cmd/bit/mailinfo.mbt b/src/cmd/bit/mailinfo.mbt index 60c07b05..f70b62e2 100644 --- a/src/cmd/bit/mailinfo.mbt +++ b/src/cmd/bit/mailinfo.mbt @@ -24,7 +24,7 @@ async fn handle_mailinfo(args : Array[String]) -> Unit raise Error { return } _ if arg.has_prefix("--encoding=") => () - _ if !(arg.has_prefix("-")) => positional.push(arg) + _ if !arg.has_prefix("-") => positional.push(arg) _ if arg.has_prefix("-") => warn_unimplemented_arg("mailinfo", arg) _ => () } @@ -80,14 +80,14 @@ async fn handle_mailinfo(args : Array[String]) -> Unit raise Error { continue } // Handle scissors - if scissors && !(past_scissors) { + if scissors && !past_scissors { if mailinfo_is_scissors_line(line) { past_scissors = true continue } } // Detect patch start - if !(in_patch) { + if !in_patch { if line.has_prefix("diff --git ") { in_patch = true } diff --git a/src/cmd/bit/main.mbt b/src/cmd/bit/main.mbt index 1ed3023f..88738de4 100644 --- a/src/cmd/bit/main.mbt +++ b/src/cmd/bit/main.mbt @@ -542,7 +542,7 @@ fn help_text_detail_key(cmd : String) -> String { ///| fn load_opt_in_help_text(cmd : String) -> String? { - if !(help_text_opt_in_enabled()) { + if !help_text_opt_in_enabled() { return None } let dir = match help_text_external_dir() { @@ -566,7 +566,7 @@ fn load_opt_in_help_text(cmd : String) -> String? { async fn show_command_help_from_specs(cmd : String, silent : Bool) -> Bool { for spec in show_command_help_specs() { if spec.0 == cmd { - if !(silent) { + if !silent { let summary = match load_opt_in_help_text(spec.0) { Some(details) => spec.2 + "\n\n" + details None => spec.2 @@ -583,115 +583,115 @@ async fn show_command_help_from_specs(cmd : String, silent : Bool) -> Bool { async fn show_command_help(cmd : String, silent? : Bool = false) -> Bool { match cmd { "hq" => { - if !(silent) { + if !silent { print_hq_usage() } true } "subdir-clone" => { - if !(silent) { + if !silent { print_subdir_clone_usage() } true } "worktree" => { - if !(silent) { + if !silent { show_worktree_help() } true } "hub" => { - if !(silent) { + if !silent { print_hub_deprecation_guide() } true } "relay" => { - if !(silent) { + if !silent { print_relay_usage() } true } "pr" => { - if !(silent) { + if !silent { print_hub_pr_usage() } true } "issue" => { - if !(silent) { + if !silent { print_hub_issue_usage() } true } "debug" => { - if !(silent) { + if !silent { print_debug_usage() } true } "mcp" => { - if !(silent) { + if !silent { print_mcp_usage() } true } "workspace" | "ws" => { - if !(silent) { + if !silent { print_workspace_usage() } true } "repo" => { - if !(silent) { + if !silent { print_repo_usage() } true } "init" => { - if !(silent) { + if !silent { show_init_command_help() } true } "status" => { - if !(silent) { + if !silent { show_status_command_help() } true } "add" => { - if !(silent) { + if !silent { show_add_command_help() } true } "commit" => { - if !(silent) { + if !silent { show_commit_command_help() } true } "log" => { - if !(silent) { + if !silent { show_log_command_help() } true } "show" => { - if !(silent) { + if !silent { show_show_command_help() } true } "x/hooks" => { - if !(silent) { + if !silent { print_x_hooks_usage() } true } "rebase-ai" => { - if !(silent) { + if !silent { show_simple_command_help( "git rebase-ai [] ", summary="Rebase with AI conflict resolution (OpenRouter moonshotai/kimi-k2, supports --agent-loop).", @@ -700,7 +700,7 @@ async fn show_command_help(cmd : String, silent? : Bool = false) -> Bool { true } "ai" => { - if !(silent) { + if !silent { show_simple_command_help( "bit ai []", summary="AI helpers.\n\nSubcommands:\n rebase AI-assisted rebase conflict resolution\n merge AI-assisted merge conflict resolution\n cherry-pick AI-assisted cherry-pick conflict resolution\n revert AI-assisted revert conflict resolution\n commit AI-assisted commit message workflow", @@ -751,7 +751,7 @@ async fn run_main_for_args(args : Array[String]) -> Unit { show_help() return () } - _ if !(args[i].has_prefix("-")) => break // Stop at first non-option + _ if !args[i].has_prefix("-") => break // Stop at first non-option _ => continue } } @@ -976,7 +976,7 @@ fn can_handle_global_config_in_shim(opts : GlobalOptions) -> Bool { } for entry in opts.config_overrides { let key = entry.0.to_lower() - if !(supported.iter().any(value => value == key)) { + if !supported.iter().any(value => value == key) { return false } } @@ -1010,9 +1010,9 @@ fn should_delegate_to_real_git( has_env_pairs || has_env_pairs_without_count let shim_handles_config = has_global_config && - !(has_env_parameters) && - !(has_env_pairs) && - !(has_env_pairs_without_count) && + !has_env_parameters && + !has_env_pairs && + !has_env_pairs_without_count && can_handle_global_config_in_shim(opts) match opts.subcmd { Some(cmd) => @@ -1133,7 +1133,7 @@ fn parse_global_options(args : Array[String]) -> GlobalOptions { } if in_opts && is_unsupported_global_flag(arg) { unsupported_global = true - if !(arg.contains("=")) && i + 1 < args.length() { + if !arg.contains("=") && i + 1 < args.length() { i += 2 } else { i += 1 @@ -1177,7 +1177,7 @@ async fn dispatch_command( rest : Array[String], ) -> Unit raise Error { let normalized_cmd = normalize_dispatch_command(cmd) - if !(command_handles_builtin_help(normalized_cmd)) { + if !command_handles_builtin_help(normalized_cmd) { for arg in rest { if arg == "-h" || arg == "--help" { if !(normalized_cmd |> show_command_help) { diff --git a/src/cmd/bit/main_js.mbt b/src/cmd/bit/main_js.mbt index ffb0f1a9..8aa0fa43 100644 --- a/src/cmd/bit/main_js.mbt +++ b/src/cmd/bit/main_js.mbt @@ -22,7 +22,7 @@ async fn main_js_async() -> Unit { show_help_js() return } - _ if !(args[i].has_prefix("-")) => break + _ if !args[i].has_prefix("-") => break _ => () } i += 1 diff --git a/src/cmd/bit/maintenance.mbt b/src/cmd/bit/maintenance.mbt index 13acfb80..d5781e84 100644 --- a/src/cmd/bit/maintenance.mbt +++ b/src/cmd/bit/maintenance.mbt @@ -30,20 +30,14 @@ async fn handle_maintenance(args : Array[String]) -> Unit raise Error { } match task { Some("run") | None => run_maintenance_tasks(fs, root, auto, quiet) - Some("start") => - if !(quiet) { - print_line("Scheduled maintenance started.") - } - Some("stop") => - if !(quiet) { - print_line("Scheduled maintenance stopped.") - } + Some("start") => if !quiet { print_line("Scheduled maintenance started.") } + Some("stop") => if !quiet { print_line("Scheduled maintenance stopped.") } Some("register") => - if !(quiet) { + if !quiet { print_line("Repository registered for maintenance.") } Some("unregister") => - if !(quiet) { + if !quiet { print_line("Repository unregistered from maintenance.") } Some("gc") => handle_gc([]) @@ -52,11 +46,11 @@ async fn handle_maintenance(args : Array[String]) -> Unit raise Error { write_commit_graph(fs, git_dir, true) catch { _ => () } - if !(quiet) { + if !quiet { print_line("Commit graph updated.") } } - Some("prefetch") => if !(quiet) { print_line("Prefetch completed.") } + Some("prefetch") => if !quiet { print_line("Prefetch completed.") } Some("loose-objects") => handle_repack(["-d", "-q"]) Some("incremental-repack") => handle_repack(["-d", "-q"]) Some("pack-refs") => handle_pack_refs(["--all"]) @@ -72,26 +66,26 @@ async fn run_maintenance_tasks( auto : Bool, quiet : Bool, ) -> Unit raise Error { - if !(quiet) { + if !quiet { print_line("Running maintenance tasks...") } - if !(quiet) { + if !quiet { print_line(" pack-refs") } handle_pack_refs(["--all"]) if auto { // Run GC only if needed let result = @bitlib.gc_repo(fs, fs, root) - if !(quiet) && result.pack is Some(_) { + if !quiet && result.pack is Some(_) { print_line(" gc (auto)") } } else { - if !(quiet) { + if !quiet { print_line(" gc") } handle_gc([]) } - if !(quiet) { + if !quiet { print_line("Maintenance completed.") } } @@ -102,7 +96,7 @@ fn get_config_value_simple( config_path : String, key : String, ) -> String? { - if !(fs.is_file(config_path)) { + if !fs.is_file(config_path) { return None } let content = decode_bytes(fs.read_file(config_path)) catch { diff --git a/src/cmd/bit/merge.mbt b/src/cmd/bit/merge.mbt index dc35c1ac..1b1125a5 100644 --- a/src/cmd/bit/merge.mbt +++ b/src/cmd/bit/merge.mbt @@ -81,7 +81,7 @@ async fn handle_merge(args : Array[String]) -> Unit raise Error { raise @bitcore.GitError::InvalidObject( "option '--message' requires a value", ) - _ if arg.has_prefix("-m") && !(arg.has_prefix("--")) => { + _ if arg.has_prefix("-m") && !arg.has_prefix("--") => { message = Some(string_slice_from(arg, 2)) i += 1 continue @@ -141,7 +141,7 @@ async fn handle_merge(args : Array[String]) -> Unit raise Error { i += 1 continue } - _ if arg.has_prefix("-s") && !(arg.has_prefix("--")) && arg.length() > 2 => { + _ if arg.has_prefix("-s") && !arg.has_prefix("--") && arg.length() > 2 => { strategy = Some(string_slice_from(arg, 2)) i += 1 continue @@ -157,12 +157,12 @@ async fn handle_merge(args : Array[String]) -> Unit raise Error { continue } _ if arg.has_prefix("--strategy-option=") || - (arg.has_prefix("-X") && !(arg.has_prefix("--")) && arg.length() > 2) => { + (arg.has_prefix("-X") && !arg.has_prefix("--") && arg.length() > 2) => { // Strategy options: silently ignored i += 1 continue } - _ if !(arg.has_prefix("-")) => { + _ if !arg.has_prefix("-") => { merge_heads.push(arg) i += 1 continue @@ -222,7 +222,7 @@ async fn handle_merge(args : Array[String]) -> Unit raise Error { err if @async.is_cancellation_error(err) => raise err _ => () } - if !(quiet) { + if !quiet { print_line("Merge aborted.") } } else { @@ -237,7 +237,7 @@ async fn handle_merge(args : Array[String]) -> Unit raise Error { if continue_merge { let merge_head_path = git_dir + "/MERGE_HEAD" let merge_msg_path = git_dir + "/MERGE_MSG" - if !(rfs.is_file(merge_head_path)) { + if !rfs.is_file(merge_head_path) { @stdio.stderr.write( "fatal: There is no merge in progress (MERGE_HEAD missing).", ) @@ -273,7 +273,7 @@ async fn handle_merge(args : Array[String]) -> Unit raise Error { err if @async.is_cancellation_error(err) => raise err _ => () } - if !(quiet) { + if !quiet { print_line("[\{short}] \{msg}") } return @@ -342,7 +342,7 @@ async fn handle_merge(args : Array[String]) -> Unit raise Error { wfs.write_string(head_path, commit_id.to_hex() + "\n") } let short = String::unsafe_substring(commit_id.to_hex(), start=0, end=7) - if !(quiet) { + if !quiet { print_line("Merge made by the 'ours' strategy. [\{short}]") } ignore(allow_unrelated) @@ -363,7 +363,7 @@ async fn handle_merge(args : Array[String]) -> Unit raise Error { ) match result.status { @bitlib.MergeStatus::AlreadyUpToDate => - if !(quiet) { + if !quiet { print_line("Already up to date.") } @bitlib.MergeStatus::FastForward | @bitlib.MergeStatus::Merged => { @@ -377,7 +377,7 @@ async fn handle_merge(args : Array[String]) -> Unit raise Error { ) None => () } - if !(quiet) { + if !quiet { print_line("Squash commit -- not updating HEAD") } // Save merge message for later commit @@ -387,7 +387,7 @@ async fn handle_merge(args : Array[String]) -> Unit raise Error { ) } @bitlib.MergeStatus::Conflicted => { - if !(quiet) { + if !quiet { for path in result.conflicts { let ctype = result.conflict_types.get(path).unwrap_or("content") print_line("CONFLICT (\{ctype}): Merge conflict in \{path}") @@ -406,7 +406,7 @@ async fn handle_merge(args : Array[String]) -> Unit raise Error { None => false } // Handle --ff-only - if ff_only && !(is_ff) { + if ff_only && !is_ff { @stdio.stderr.write("fatal: Not possible to fast-forward, aborting.") @sys.exit(128) } @@ -466,7 +466,7 @@ async fn handle_merge(args : Array[String]) -> Unit raise Error { ), ) let short = String::unsafe_substring(commit_id.to_hex(), start=0, end=7) - if !(quiet) { + if !quiet { print_line("Merge made by the 'ort' strategy (--no-ff). [\{short}]") } return @@ -486,31 +486,31 @@ async fn handle_merge(args : Array[String]) -> Unit raise Error { ) match result.status { @bitlib.MergeStatus::AlreadyUpToDate => - if !(quiet) { + if !quiet { print_line("Already up to date.") } @bitlib.MergeStatus::FastForward => match result.commit_id { Some(id) => { let short = String::unsafe_substring(id.to_hex(), start=0, end=7) - if !(quiet) { + if !quiet { print_line("Fast-forward to \{short}") } } - None => if !(quiet) { print_line("Fast-forward") } + None => if !quiet { print_line("Fast-forward") } } @bitlib.MergeStatus::Merged => match result.commit_id { Some(id) => { let short = String::unsafe_substring(id.to_hex(), start=0, end=7) - if !(quiet) { + if !quiet { print_line("Merge made by the 'ort' strategy. [\{short}]") } } - None => if !(quiet) { print_line("Merged") } + None => if !quiet { print_line("Merged") } } @bitlib.MergeStatus::Conflicted => { - if !(quiet) { + if !quiet { for path in result.conflicts { let ctype = result.conflict_types.get(path).unwrap_or("content") print_line("CONFLICT (\{ctype}): Merge conflict in \{path}") @@ -610,7 +610,7 @@ async fn handle_octopus_merge( @bitlib.ResetMode::Hard, ), ) - if !(quiet) { + if !quiet { for path in result.conflicts { let ctype = result.conflict_types.get(path).unwrap_or("content") print_line("CONFLICT (\{ctype}): Merge conflict in \{path}") @@ -638,7 +638,7 @@ async fn handle_octopus_merge( // Build parent list. If original HEAD was fast-forwarded to one of the // heads, exclude it (git's octopus does the same). let all_parents : Array[@bitcore.ObjectId] = [] - if !(orig_head_ffwd) { + if !orig_head_ffwd { all_parents.push(orig_hid) } for id in resolved_ids { @@ -704,7 +704,7 @@ async fn handle_octopus_merge( None => () } let short = String::unsafe_substring(commit_id.to_hex(), start=0, end=7) - if !(quiet) { + if !quiet { print_line("Merge made by the 'octopus' strategy. [\{short}]") } } @@ -725,7 +725,7 @@ fn truncate_and_append_reflog( message : String, ) -> Unit { let reflog_path = @bitlib.get_reflog_path(git_dir, refname) - if !(rfs.is_file(reflog_path)) { + if !rfs.is_file(reflog_path) { return } // Read current reflog content @@ -783,12 +783,12 @@ async fn validate_current_branch_mergeoptions( git_dir : String, ) -> Unit raise Error { let head_path = git_dir + "/HEAD" - if !(rfs.is_file(head_path)) { + if !rfs.is_file(head_path) { return } let head = decode_bytes(rfs.read_file(head_path) catch { _ => return }) |> trim_string - if !(head.has_prefix("ref: refs/heads/")) { + if !head.has_prefix("ref: refs/heads/") { return } let branch_name = String::unsafe_substring(head, start=16, end=head.length()) @@ -813,16 +813,16 @@ fn split_cmdline_has_unclosed_quote(value : String) -> Bool { escape = false continue } - if c == '\\' && !(in_single) { + if c == '\\' && !in_single { escape = true continue } - if c == '\'' && !(in_double) { - in_single = !(in_single) + if c == '\'' && !in_double { + in_single = !in_single continue } - if c == '"' && !(in_single) { - in_double = !(in_double) + if c == '"' && !in_single { + in_double = !in_double continue } } diff --git a/src/cmd/bit/merge_base.mbt b/src/cmd/bit/merge_base.mbt index 7ec0e63a..7773f371 100644 --- a/src/cmd/bit/merge_base.mbt +++ b/src/cmd/bit/merge_base.mbt @@ -266,7 +266,7 @@ async fn merge_base_fork_point( let oid_hex = oid.to_hex() // Prefer merge-base that equals a reflog entry (true fork point) if m_hex == oid_hex { - if !(best_is_reflog_entry) { + if !best_is_reflog_entry { best = Some(m) best_is_reflog_entry = true } else { @@ -279,7 +279,7 @@ async fn merge_base_fork_point( None => best = Some(m) } } - } else if !(best_is_reflog_entry) { + } else if !best_is_reflog_entry { match best { Some(prev) => if merge_base_is_ancestor(fs, git_dir, prev, m) { diff --git a/src/cmd/bit/merge_file.mbt b/src/cmd/bit/merge_file.mbt index 9021a8d7..aff7b417 100644 --- a/src/cmd/bit/merge_file.mbt +++ b/src/cmd/bit/merge_file.mbt @@ -35,7 +35,7 @@ async fn handle_merge_file(args : Array[String]) -> Unit raise Error { } else if arg.has_prefix("-L") { labels.push(arg[2:].to_string()) } else if arg.has_prefix("-") { - if !(quiet) { + if !quiet { eprint_line("fatal: unknown option '\{arg}'") } @sys.exit(128) diff --git a/src/cmd/bit/merge_index.mbt b/src/cmd/bit/merge_index.mbt index deceb8fa..96e50783 100644 --- a/src/cmd/bit/merge_index.mbt +++ b/src/cmd/bit/merge_index.mbt @@ -22,11 +22,11 @@ async fn handle_merge_index(args : Array[String]) -> Unit raise Error { "-o" => one_shot = true "-q" => quiet = true "-a" => process_all = true - _ if !(found_program) && !(arg.has_prefix("-")) => { + _ if !found_program && !arg.has_prefix("-") => { merge_program = arg found_program = true } - _ if found_program && !(arg.has_prefix("-")) => files.push(arg) + _ if found_program && !arg.has_prefix("-") => files.push(arg) _ if arg.has_prefix("-") => warn_unimplemented_arg("merge-index", arg) _ => () } @@ -39,7 +39,7 @@ async fn handle_merge_index(args : Array[String]) -> Unit raise Error { @sys.exit(1) return } - if !(process_all) && files.length() == 0 { + if !process_all && files.length() == 0 { eprint_line( "usage: git merge-index [-o] [-q] (-a | ...)", ) @@ -65,7 +65,7 @@ async fn handle_merge_index(args : Array[String]) -> Unit raise Error { let null_oid = "0000000000000000000000000000000000000000" // Process each unmerged file for path, stages in unmerged { - if !(process_all) && !(files.contains(path)) { + if !process_all && !files.contains(path) { continue } // Find stage 1 (base), 2 (ours), 3 (theirs) @@ -108,11 +108,11 @@ async fn handle_merge_index(args : Array[String]) -> Unit raise Error { stderr=@stdio.stderr, ) if code != 0 { - if !(quiet) { + if !quiet { eprint_line("merge program failed for \{path}") } had_failures = true - if !(one_shot) { + if !one_shot { @sys.exit(1) return } diff --git a/src/cmd/bit/merge_tree.mbt b/src/cmd/bit/merge_tree.mbt index 794b5ab5..236d1885 100644 --- a/src/cmd/bit/merge_tree.mbt +++ b/src/cmd/bit/merge_tree.mbt @@ -49,7 +49,7 @@ async fn handle_merge_tree(args : Array[String]) -> Unit raise Error { let db = @bitlib.ObjectDb::load(fs, git_dir) // Find merge base let base_id = merge_tree_find_base(db, fs, ours_id, theirs_id) - if base_id is None && !(allow_unrelated) { + if base_id is None && !allow_unrelated { eprint_line( "fatal: refusing to merge unrelated histories (use --allow-unrelated-histories to override)", ) diff --git a/src/cmd/bit/merge_wbtest.mbt b/src/cmd/bit/merge_wbtest.mbt index f0d117ce..9b5aceb8 100644 --- a/src/cmd/bit/merge_wbtest.mbt +++ b/src/cmd/bit/merge_wbtest.mbt @@ -39,7 +39,7 @@ async fn merge_wbtest_collect_shim_git( // Build the native binary first so exit codes propagate correctly // (moon run swallows non-zero exit codes) let bit_exe = repo_root + "/_build/native/release/build/cmd/bit/bit.exe" - if !(fs.is_file(bit_exe)) { + if !fs.is_file(bit_exe) { let build_code = @process.run( "moon", ["build", "--target", "native", "--release"], diff --git a/src/cmd/bit/mktag_cmd.mbt b/src/cmd/bit/mktag_cmd.mbt index b76089a0..311a3873 100644 --- a/src/cmd/bit/mktag_cmd.mbt +++ b/src/cmd/bit/mktag_cmd.mbt @@ -45,18 +45,18 @@ async fn mktag_validate(content : String) -> Unit { } // Line 0: object let line0 = lines[0] - if !(line0.has_prefix("object ")) { + if !line0.has_prefix("object ") { eprint_line("error: missingObject: tag missing 'object' line") @sys.exit(1) } let hex = String::unsafe_substring(line0, start=7, end=line0.length()) - if hex.length() != 40 || !(mktag_is_hex(hex)) { + if hex.length() != 40 || !mktag_is_hex(hex) { eprint_line("error: badObjectSha1: tag has too-short object SHA-1") @sys.exit(1) } // Line 1: type let line1 = lines[1] - if !(line1.has_prefix("type ")) { + if !line1.has_prefix("type ") { eprint_line("error: missingTypeEntry: tag missing 'type' line") @sys.exit(1) } @@ -70,7 +70,7 @@ async fn mktag_validate(content : String) -> Unit { } // Line 2: tag let line2 = lines[2] - if !(line2.has_prefix("tag ")) { + if !line2.has_prefix("tag ") { eprint_line("error: missingTagEntry: tag missing 'tag' line") @sys.exit(1) } @@ -81,7 +81,7 @@ async fn mktag_validate(content : String) -> Unit { } // Line 3: tagger let line3 = lines[3] - if !(line3.has_prefix("tagger ")) { + if !line3.has_prefix("tagger ") { eprint_line("error: missingTaggerEntry: tag missing 'tagger' line") @sys.exit(1) } diff --git a/src/cmd/bit/multi_pack_index.mbt b/src/cmd/bit/multi_pack_index.mbt index a2bd10ea..b3553c3f 100644 --- a/src/cmd/bit/multi_pack_index.mbt +++ b/src/cmd/bit/multi_pack_index.mbt @@ -94,7 +94,7 @@ async fn handle_multi_pack_index(args : Array[String]) -> Unit raise Error { let has_incremental_chain = fs.is_file(incremental_chain_path) match subcommand { Some("write") | Some("verify") => - if object_dir is None && !(fs.is_dir(git_dir)) { + if object_dir is None && !fs.is_dir(git_dir) { eprint_line( "fatal: not a git repository (or any of the parent directories): .git", ) @@ -172,7 +172,7 @@ async fn midx_write( let midx_path = pack_dir + "/multi-pack-index" let has_existing_midx = fs.is_file(midx_path) let existing_midx_packs : Array[String] = [] - if has_existing_midx && !(stdin_packs) { + if has_existing_midx && !stdin_packs { match midx_read_pack_usage(fs, pack_dir) { Some((pack_names, _)) => for pack_name in pack_names { @@ -217,7 +217,7 @@ async fn midx_write( String::unsafe_substring(pack_name, start=0, end=pack_name.length() - 5) + ".idx" let pack_path = pack_dir + "/" + pack_name - if !(fs.is_file(idx_path)) || !(fs.is_file(pack_path)) { + if !fs.is_file(idx_path) || !fs.is_file(pack_path) { eprint_line("could not load pack") @sys.exit(1) return @@ -239,7 +239,7 @@ async fn midx_write( String::unsafe_substring(pack_name, start=0, end=pack_name.length() - 5) + ".idx" let pack_path = pack_dir + "/" + pack_name - if !(fs.is_file(idx_path)) || !(fs.is_file(pack_path)) { + if !fs.is_file(idx_path) || !fs.is_file(pack_path) { eprint_line("could not load pack") @sys.exit(1) return @@ -317,7 +317,7 @@ async fn midx_write( if has_existing_midx { match midx_try_read_file(fs, midx_path) { Some(existing) => { - if !(midx_has_valid_checksum(existing)) { + if !midx_has_valid_checksum(existing) { eprint_line("error: checksum.mismatch in existing multi-pack-index") } if midx_bytes_equal(existing, midx_bytes) { @@ -373,7 +373,7 @@ async fn midx_verify( progress : Bool, ) -> Unit raise Error { let midx_path = pack_dir + "/multi-pack-index" - if !(fs.is_file(midx_path)) { + if !fs.is_file(midx_path) { eprint_line("error: could not open multi-pack-index") @sys.exit(1) return @@ -387,9 +387,7 @@ async fn midx_verify( @sys.exit(1) return } - if !( - data[0] == b'M' && data[1] == b'I' && data[2] == b'D' && data[3] == b'X', - ) { + if !(data[0] == b'M' && data[1] == b'I' && data[2] == b'D' && data[3] == b'X') { eprint_line("error: multi-pack-index signature is invalid") @sys.exit(1) return @@ -585,7 +583,7 @@ async fn midx_verify( idx_name } let pack_path = pack_dir + "/" + pack_name - if !(fs.is_file(idx_path)) || !(fs.is_file(pack_path)) { + if !fs.is_file(idx_path) || !fs.is_file(pack_path) { eprint_line("error: failed to load pack in position " + i.to_string()) has_error = true pack_entries.push([]) @@ -695,7 +693,7 @@ async fn midx_verify( break } } - if !(found) { + if !found { eprint_line( "error: failed to load pack entry for oid[" + i.to_string() + @@ -719,7 +717,7 @@ async fn midx_expire( progress : Bool, ) -> Unit raise Error { let midx_path = pack_dir + "/multi-pack-index" - if !(fs.is_file(midx_path)) { + if !fs.is_file(midx_path) { if progress { eprint_line("No multi-pack-index to expire") } @@ -813,7 +811,7 @@ async fn midx_repack( } let pack_path = pack_dir + "/" + pack_name let idx_path = pack_dir + "/" + midx_pack_stem(pack_name) + ".idx" - if !(fs.is_file(pack_path)) || !(fs.is_file(idx_path)) { + if !fs.is_file(pack_path) || !fs.is_file(idx_path) { continue } let pack_mtime = midx_pack_mtime(pack_path) @@ -1042,7 +1040,7 @@ fn midx_read_pack_usage( pack_dir : String, ) -> (Array[String], Array[Int])? { let midx_path = pack_dir + "/multi-pack-index" - if !(fs.is_file(midx_path)) { + if !fs.is_file(midx_path) { return None } let data = fs.read_file(midx_path) catch { _ => return None } @@ -1108,7 +1106,7 @@ fn midx_find_pack_files(fs : OsFs, pack_dir : String) -> Array[String] { let files : Array[String] = [] let entries = fs.readdir(pack_dir) catch { _ => return files } for entry in entries { - if entry.has_suffix(".pack") && !(entry.has_prefix(".")) { + if entry.has_suffix(".pack") && !entry.has_prefix(".") { files.push(entry) } } @@ -1185,8 +1183,7 @@ fn midx_select_pack_files_from_stdin( for name in include_names { match midx_normalize_stdin_pack_name(name) { Some(pack_name) => - if all_pack_set.contains(pack_name) && - !(selected_set.contains(pack_name)) { + if all_pack_set.contains(pack_name) && !selected_set.contains(pack_name) { selected_set[pack_name] = true selected.push(pack_name) } @@ -1208,7 +1205,7 @@ fn midx_select_pack_files_from_stdin( } let filtered : Array[String] = [] for name in selected { - if !(excluded_set.contains(name)) { + if !excluded_set.contains(name) { filtered.push(name) } } @@ -1772,7 +1769,7 @@ fn midx_collect_bitmap_tips( let mut drop_idx = -1 if candidates.length() > 100 { for idx, candidate in candidates { - if !(candidate.preferred) { + if !candidate.preferred { drop_idx = idx break } @@ -1803,7 +1800,7 @@ fn midx_add_bitmap_candidate( Some(existing_idx) => if preferred && existing_idx >= 0 && existing_idx < out.length() { let existing = out[existing_idx] - if !(existing.preferred) { + if !existing.preferred { out[existing_idx] = { id: existing.id, midx_pos: existing.midx_pos, @@ -2410,7 +2407,7 @@ fn midx_u32_lt(a : Int, b : Int) -> Bool { let a_neg = a < 0 let b_neg = b < 0 if a_neg != b_neg { - !(a_neg) && b_neg + !a_neg && b_neg } else { a < b } @@ -2778,7 +2775,7 @@ async fn midx_write_incremental( let mono_packs = midx_read_packs_from_midx_data(mono_data) let mut mono_valid = mono_packs.length() > 0 for mp in mono_packs { - if !(fs.is_file(pack_dir + "/" + mp)) { + if !fs.is_file(pack_dir + "/" + mp) { mono_valid = false break } @@ -2815,7 +2812,7 @@ async fn midx_write_incremental( let all_packs = midx_find_pack_files(fs, pack_dir) let new_packs : Array[String] = [] for pack_name in all_packs { - if !(known_packs.contains(pack_name)) { + if !known_packs.contains(pack_name) { new_packs.push(pack_name) } } @@ -2858,7 +2855,7 @@ async fn midx_write_incremental( String::unsafe_substring(pack_name, start=0, end=pack_name.length() - 5) + ".idx" let pack_path = pack_dir + "/" + pack_name - if !(fs.is_file(idx_path)) || !(fs.is_file(pack_path)) { + if !fs.is_file(idx_path) || !fs.is_file(pack_path) { continue } if normalized_preferred.length() > 0 && pack_name == normalized_preferred { @@ -2884,7 +2881,7 @@ async fn midx_write_incremental( Some(lid) if lid == entry.id => continue _ => // Also skip OIDs already in existing layers - if !(existing_oids.contains(entry.id.to_hex())) { + if !existing_oids.contains(entry.id.to_hex()) { unique_entries.push(entry) last_id = Some(entry.id) } else { @@ -2913,14 +2910,14 @@ async fn midx_write_incremental( let layer_data = fs.read_file(layer_path) catch { _ => continue } let layer_packs = midx_read_packs_from_midx_data(layer_data) for lp in layer_packs { - if !(midx_array_has_string(all_bitmap_packs, lp)) { + if !midx_array_has_string(all_bitmap_packs, lp) { all_bitmap_packs.push(lp) } } } // Add new packs for np in new_packs { - if !(midx_array_has_string(all_bitmap_packs, np)) { + if !midx_array_has_string(all_bitmap_packs, np) { all_bitmap_packs.push(np) } } @@ -2931,7 +2928,7 @@ async fn midx_write_incremental( "/" + String::unsafe_substring(pack_name, start=0, end=pack_name.length() - 5) + ".idx" - if !(fs.is_file(idx_path)) { + if !fs.is_file(idx_path) { continue } let entries = midx_read_pack_index(fs, idx_path, pack_idx, 0) @@ -3044,7 +3041,7 @@ async fn midx_verify_chain( let mut has_error = false for hash in hashes { let layer_path = inc_dir + "/multi-pack-index-" + hash + ".midx" - if !(fs.is_file(layer_path)) { + if !fs.is_file(layer_path) { eprint_line("error: could not open multi-pack-index layer: " + layer_path) has_error = true continue @@ -3062,9 +3059,10 @@ async fn midx_verify_chain( has_error = true continue } - if !( - data[0] == b'M' && data[1] == b'I' && data[2] == b'D' && data[3] == b'X', - ) { + if !(data[0] == b'M' && + data[1] == b'I' && + data[2] == b'D' && + data[3] == b'X') { eprint_line( "error: multi-pack-index signature is invalid in layer: " + hash, ) diff --git a/src/cmd/bit/mv.mbt b/src/cmd/bit/mv.mbt index 1ffae725..f582bd71 100644 --- a/src/cmd/bit/mv.mbt +++ b/src/cmd/bit/mv.mbt @@ -7,7 +7,7 @@ async fn handle_mv(args : Array[String]) -> Unit raise Error { for arg in args { match arg { "-f" | "--force" => force = true - _ if !(arg.has_prefix("-")) => paths.push(arg) + _ if !arg.has_prefix("-") => paths.push(arg) _ if arg.has_prefix("-") => warn_unimplemented_arg("mv", arg) _ => () } diff --git a/src/cmd/bit/name_rev.mbt b/src/cmd/bit/name_rev.mbt index 14daecdb..44b474e4 100644 --- a/src/cmd/bit/name_rev.mbt +++ b/src/cmd/bit/name_rev.mbt @@ -114,15 +114,12 @@ fn name_rev_build_ref_map( for item in all_refs { let (name, id) = item // Filter by tags if requested - if tags_only && !(name.has_prefix("refs/tags/")) { + if tags_only && !name.has_prefix("refs/tags/") { continue } // Filter by pattern if given match refs_pattern { - Some(pattern) => - if !(name_rev_match_pattern(name, pattern)) { - continue - } + Some(pattern) => if !name_rev_match_pattern(name, pattern) { continue } None => () } // Shorten the ref name for display @@ -170,7 +167,7 @@ fn name_rev_build_name_map( let commit_id = name_rev_deref_tag(rfs, db, ref_id) let hex = commit_id.to_hex() // Direct match: ref points at this commit - if !(name_map.contains(hex)) { + if !name_map.contains(hex) { name_map.set(hex, ref_name) } // Walk parents with BFS up to a depth limit @@ -198,7 +195,7 @@ fn name_rev_build_name_map( let dist = depth + 1 let name = "\{ref_name}~\{dist}" // Only set if not already named (prefer shorter names) - if !(name_map.contains(parent_hex)) { + if !name_map.contains(parent_hex) { name_map.set(parent_hex, name) } queue.push((parent, dist)) diff --git a/src/cmd/bit/notes.mbt b/src/cmd/bit/notes.mbt index f73dce1e..7251d813 100644 --- a/src/cmd/bit/notes.mbt +++ b/src/cmd/bit/notes.mbt @@ -70,7 +70,7 @@ async fn handle_notes(args : Array[String]) -> Unit raise Error { i += 1 continue } - _ if !(arg.has_prefix("-")) => { + _ if !arg.has_prefix("-") => { commit_ref = arg i += 1 continue @@ -106,7 +106,7 @@ async fn handle_notes(args : Array[String]) -> Unit raise Error { i += 1 continue } - _ if !(arg.has_prefix("-")) => { + _ if !arg.has_prefix("-") => { commit_ref = arg i += 1 continue @@ -142,7 +142,7 @@ async fn handle_notes(args : Array[String]) -> Unit raise Error { i += 1 continue } - _ if !(arg.has_prefix("-")) => { + _ if !arg.has_prefix("-") => { commit_ref = arg i += 1 continue @@ -169,7 +169,7 @@ async fn handle_notes(args : Array[String]) -> Unit raise Error { i += 1 continue } - _ if !(arg.has_prefix("-")) => { + _ if !arg.has_prefix("-") => { if from_ref is None { from_ref = Some(arg) } else if to_ref is None { @@ -215,7 +215,7 @@ async fn handle_notes(args : Array[String]) -> Unit raise Error { i += 1 continue } - _ if !(arg.has_prefix("-")) => { + _ if !arg.has_prefix("-") => { other_ref = Some(arg) i += 1 continue @@ -262,7 +262,7 @@ async fn handle_notes(args : Array[String]) -> Unit raise Error { i += 1 continue } - _ if !(arg.has_prefix("-")) => { + _ if !arg.has_prefix("-") => { if from_ref is None { from_ref = Some(arg) } else if to_ref is None { @@ -328,7 +328,7 @@ async fn notes_list( git_dir : String, notes_ref_path : String, ) -> Unit raise Error { - if !(rfs.is_file(notes_ref_path)) { + if !rfs.is_file(notes_ref_path) { return } let ref_content = decode_bytes(rfs.read_file(notes_ref_path)) @@ -361,7 +361,7 @@ async fn notes_show( } let target_hex = tid.to_hex() // Check if notes ref exists - if !(rfs.is_file(notes_ref_path)) { + if !rfs.is_file(notes_ref_path) { @stdio.stderr.write("error: no note found for \{target_hex}") @sys.exit(1) } @@ -441,7 +441,7 @@ async fn notes_add( let existing = @bitcore.parse_tree(to.data) for e in existing { if e.name == target_hex { - if !(force) { + if !force { @stdio.stderr.write( "error: note already exists for \{target_hex}", ) @@ -603,7 +603,7 @@ async fn notes_copy( @sys.exit(1) } // Load notes tree - if !(rfs.is_file(notes_ref_path)) { + if !rfs.is_file(notes_ref_path) { @stdio.stderr.write("error: no note found for \{from_hex}") @sys.exit(1) } @@ -645,7 +645,7 @@ async fn notes_copy( @stdio.stderr.write("error: no note found for \{from_hex}") @sys.exit(1) } - if dest_exists && !(force) { + if dest_exists && !force { @stdio.stderr.write("error: note already exists for \{to_hex}") @sys.exit(1) } @@ -687,7 +687,7 @@ async fn notes_remove( } let target_hex = tid.to_hex() // Check if notes ref exists - if !(rfs.is_file(notes_ref_path)) { + if !rfs.is_file(notes_ref_path) { @stdio.stderr.write("error: no note found for \{target_hex}") @sys.exit(1) } @@ -717,7 +717,7 @@ async fn notes_remove( entries.push(e) } } - if !(found) { + if !found { @stdio.stderr.write("error: no note found for \{target_hex}") @sys.exit(1) } @@ -753,7 +753,7 @@ async fn notes_prune( notes_ref_path : String, ) -> Unit raise Error { // Check if notes ref exists - if !(rfs.is_file(notes_ref_path)) { + if !rfs.is_file(notes_ref_path) { return } let ref_content = decode_bytes(rfs.read_file(notes_ref_path)) @@ -813,7 +813,7 @@ async fn load_notes_tree( git_dir : String, notes_ref_path : String, ) -> (@bitcore.ObjectId, Array[@bitcore.TreeEntry])? raise Error { - if !(rfs.is_file(notes_ref_path)) { + if !rfs.is_file(notes_ref_path) { return None } let ref_content = decode_bytes(rfs.read_file(notes_ref_path)) @@ -1075,7 +1075,7 @@ async fn notes_rewrite( } } guard source is Some(src) else { return } - if dest_exists && !(force) { + if dest_exists && !force { @stdio.stderr.write("error: note already exists for \{to_hex}") @sys.exit(1) } diff --git a/src/cmd/bit/pack_bitmap_write.mbt b/src/cmd/bit/pack_bitmap_write.mbt index c0e605c8..326fe231 100644 --- a/src/cmd/bit/pack_bitmap_write.mbt +++ b/src/cmd/bit/pack_bitmap_write.mbt @@ -39,7 +39,7 @@ fn bitmap_collect_tips( match parsed { Some(id) => { let hex = id.to_hex() - if !(seen.contains(hex)) { + if !seen.contains(hex) { match pos_by_oid.get(hex) { Some(pack_pos) => { seen[hex] = true @@ -57,7 +57,7 @@ fn bitmap_collect_tips( match head { Some(id) => { let hex = id.to_hex() - if !(seen.contains(hex)) { + if !seen.contains(hex) { match pos_by_oid.get(hex) { Some(pack_pos) => { seen[hex] = true diff --git a/src/cmd/bit/pack_objects.mbt b/src/cmd/bit/pack_objects.mbt index cbbba020..f5d9612b 100644 --- a/src/cmd/bit/pack_objects.mbt +++ b/src/cmd/bit/pack_objects.mbt @@ -1028,11 +1028,11 @@ fn collect_pack_ids_from_dir(fs : OsFs, pack_dir : String) -> Map[String, Bool] let entries = fs.readdir(pack_dir) catch { _ => [] } for entry in entries { let name = normalize_dir_entry(entry) - if !(name.has_suffix(".idx")) { + if !name.has_suffix(".idx") { continue } let idx_path = pack_dir + "/" + name - if !(fs.is_file(idx_path)) { + if !fs.is_file(idx_path) { continue } let ids = collect_pack_index_ids(fs, idx_path) @@ -1056,12 +1056,12 @@ fn collect_pack_ids_from_marker( let entries = fs.readdir(pack_dir) catch { _ => [] } for entry in entries { let name = normalize_dir_entry(entry) - if !(name.has_suffix(suffix)) { + if !name.has_suffix(suffix) { continue } let base = string_slice_to(name, name.length() - suffix.length()) let idx_path = pack_dir + "/" + base + ".idx" - if !(fs.is_file(idx_path)) { + if !fs.is_file(idx_path) { continue } let ids = collect_pack_index_ids(fs, idx_path) @@ -1089,7 +1089,7 @@ fn collect_pack_ids_from_names( name } let idx_path = pack_dir + "/" + stem + ".idx" - if !(fs.is_file(idx_path)) { + if !fs.is_file(idx_path) { continue } let ids = collect_pack_index_ids(fs, idx_path) @@ -1138,7 +1138,7 @@ fn collect_loose_object_ids( fn read_alternate_object_dirs(fs : OsFs, git_dir : String) -> Array[String] { let out : Array[String] = [] let alt_path = git_dir + "/objects/info/alternates" - if !(fs.is_file(alt_path)) { + if !fs.is_file(alt_path) { return out } let data = fs.read_file(alt_path) catch { _ => return out } @@ -1264,7 +1264,7 @@ fn dedup_objects( let out : Array[@bitcore.PackObject] = [] for obj in objects { let hex = object_hex(obj) - if !(seen.contains(hex)) { + if !seen.contains(hex) { seen[hex] = true out.push(obj) } @@ -1299,7 +1299,7 @@ fn filter_objects( let out : Array[@bitcore.PackObject] = [] for obj in objects { let hex = object_hex(obj) - if !(exclude.contains(hex)) { + if !exclude.contains(hex) { out.push(obj) } } @@ -3190,7 +3190,7 @@ async fn handle_pack_objects(args : Array[String]) -> Unit raise Error { let rev_path = base_name + "-" + hash_hex + ".rev" @pack.write_reverse_index(fs, rev_path, pack, idx_objects) } - if cfg.write_bitmap && !(cfg.stdout) { + if cfg.write_bitmap && !cfg.stdout { let bitmap_path = base_name + "-" + hash_hex + ".bitmap" write_pack_bitmap(fs, git_dir, bitmap_path, pack, idx_objects, db) } @@ -3345,7 +3345,7 @@ async fn loosen_unused_packed_objects( } for entry in entries { let name = normalize_dir_entry(entry) - if !(name.has_suffix(".idx")) { + if !name.has_suffix(".idx") { continue } // Check if this pack has a .keep file @@ -3354,7 +3354,7 @@ async fn loosen_unused_packed_objects( continue } let idx_path = pack_dir + "/" + name - if !(fs.is_file(idx_path)) { + if !fs.is_file(idx_path) { continue } // Get pack file mtime for expiration check diff --git a/src/cmd/bit/pack_objects_cruft.mbt b/src/cmd/bit/pack_objects_cruft.mbt index c9a383ea..c4f2b6af 100644 --- a/src/cmd/bit/pack_objects_cruft.mbt +++ b/src/cmd/bit/pack_objects_cruft.mbt @@ -263,17 +263,17 @@ async fn collect_cruft_objects( if name == "info" || name == "pack" { continue } - if name.length() != 2 || !(is_hex_string(name)) { + if name.length() != 2 || !is_hex_string(name) { continue } let subdir = objects_dir + "/" + name - if !(fs.is_dir(subdir)) { + if !fs.is_dir(subdir) { continue } let files = fs.readdir(subdir) catch { _ => [] } for file in files { let filename = normalize_dir_entry(file) - if filename.length() != 38 || !(is_hex_string(filename)) { + if filename.length() != 38 || !is_hex_string(filename) { continue } let hex = name + filename @@ -367,7 +367,7 @@ fn cruft_rescue_walk( .trim() .to_string() if tree_hex.length() == 40 && candidate_ids.contains(tree_hex) { - if !(rescued.contains(tree_hex)) { + if !rescued.contains(tree_hex) { rescued[tree_hex] = true cruft_rescue_walk( db, fs, tree_hex, rescued, candidate_ids, tolerate_missing, @@ -383,7 +383,7 @@ fn cruft_rescue_walk( .trim() .to_string() if parent_hex.length() == 40 && candidate_ids.contains(parent_hex) { - if !(rescued.contains(parent_hex)) { + if !rescued.contains(parent_hex) { rescued[parent_hex] = true cruft_rescue_walk( db, fs, parent_hex, rescued, candidate_ids, tolerate_missing, @@ -401,7 +401,7 @@ fn cruft_rescue_walk( for entry in entries { let entry_hex = entry.id.to_hex() if candidate_ids.contains(entry_hex) { - if !(rescued.contains(entry_hex)) { + if !rescued.contains(entry_hex) { rescued[entry_hex] = true cruft_rescue_walk( db, fs, entry_hex, rescued, candidate_ids, tolerate_missing, @@ -425,7 +425,7 @@ fn cruft_rescue_walk( .trim() .to_string() if target_hex.length() == 40 && candidate_ids.contains(target_hex) { - if !(rescued.contains(target_hex)) { + if !rescued.contains(target_hex) { rescued[target_hex] = true cruft_rescue_walk( db, fs, target_hex, rescued, candidate_ids, tolerate_missing, diff --git a/src/cmd/bit/pack_redundant.mbt b/src/cmd/bit/pack_redundant.mbt index 5bfd0c0f..cd8b6ede 100644 --- a/src/cmd/bit/pack_redundant.mbt +++ b/src/cmd/bit/pack_redundant.mbt @@ -16,16 +16,16 @@ fn load_pack_idx_entries( let entries = fs.readdir(pack_dir) catch { _ => return result } for entry in entries { let name = normalize_dir_entry(entry) - if !(name.has_suffix(".idx")) { + if !name.has_suffix(".idx") { continue } let idx_path = pack_dir + "/" + name - if !(fs.is_file(idx_path)) { + if !fs.is_file(idx_path) { continue } let base = String::unsafe_substring(name, start=0, end=name.length() - 4) let pack_path = pack_dir + "/" + base + ".pack" - if !(fs.is_file(pack_path)) { + if !fs.is_file(pack_path) { continue } let data = fs.read_file(idx_path) catch { _ => continue } @@ -66,7 +66,7 @@ async fn handle_pack_redundant(args : Array[String]) -> Unit raise Error { _ => pack_filenames.push(arg) } } - if !(i_still_use_this) { + if !i_still_use_this { @stdio.stderr.write( "WARNING: git pack-redundant has been nominated for removal.\nIf you still use this command, please add an extra\noption, '--i-still-use-this', on the command line and\nlet us know you still use it by sending an e-mail\nto git@vger.kernel.org. Thanks.\n", ) @@ -139,7 +139,7 @@ async fn handle_pack_redundant(args : Array[String]) -> Unit raise Error { } // Read stdin ignore objects (only if stdin is not a tty) let is_tty = pack_redundant_stdin_is_tty() - if !(is_tty) { + if !is_tty { let input = read_all_stdin() let lines = split_lines_bytes(input) for line in lines { @@ -210,7 +210,7 @@ async fn handle_pack_redundant(args : Array[String]) -> Unit raise Error { // Output redundant packs: idx path first, then pack path // Use paths relative to git_dir (prefixed with "./" like git does) for pack in local_packs { - if !(min_paths.contains(pack.pack_path)) { + if !min_paths.contains(pack.pack_path) { let rel_pack = make_relative_to_git_dir(pack.pack_path, git_dir) let rel_idx = pack_path_to_idx(rel_pack) print_line(rel_idx) @@ -255,7 +255,7 @@ fn pack_redundant_minimize( let covered_by_essential : Map[String, Bool] = {} for item in all_objects { let (id, _) = item - if !(missing.contains(id)) { + if !missing.contains(id) { covered_by_essential[id] = true } } diff --git a/src/cmd/bit/pack_refs.mbt b/src/cmd/bit/pack_refs.mbt index 9677f1b4..979c1be2 100644 --- a/src/cmd/bit/pack_refs.mbt +++ b/src/cmd/bit/pack_refs.mbt @@ -20,9 +20,7 @@ fn handle_pack_refs(args : Array[String]) -> Unit raise Error { let content = decode_bytes(fs.read_file(packed_refs_path)) for line_view in content.split("\n") { let line = line_view.to_string() - if line.length() > 0 && - !(line.has_prefix("#")) && - !(line.has_prefix("^")) { + if line.length() > 0 && !line.has_prefix("#") && !line.has_prefix("^") { let parts : Array[String] = line .split(" ") .map(v => v.to_string()) @@ -70,7 +68,7 @@ fn collect_refs_to_pack( refs : Array[(String, String)], all : Bool, ) -> Unit raise Error { - if !(fs.is_dir(dir)) { + if !fs.is_dir(dir) { return } let entries = fs.readdir(dir) diff --git a/src/cmd/bit/patch_id.mbt b/src/cmd/bit/patch_id.mbt index a358ca99..1fb08cdf 100644 --- a/src/cmd/bit/patch_id.mbt +++ b/src/cmd/bit/patch_id.mbt @@ -63,7 +63,7 @@ fn patch_id_compute(input : String) -> Array[(String, String)] { normalized.push(line) continue } - if !(has_diff) { + if !has_diff { continue } // Skip index lines diff --git a/src/cmd/bit/prune_packed.mbt b/src/cmd/bit/prune_packed.mbt index 3cd17b46..9babf31c 100644 --- a/src/cmd/bit/prune_packed.mbt +++ b/src/cmd/bit/prune_packed.mbt @@ -24,11 +24,11 @@ async fn handle_prune_packed(args : Array[String]) -> Unit raise Error { for entry in entries { let name = normalize_dir_entry(entry) // Only look at 2-char hex prefix directories - if name.length() != 2 || !(is_hex_string(name)) { + if name.length() != 2 || !is_hex_string(name) { continue } let dir_path = objects_dir + "/" + name - if !(fs.is_dir(dir_path)) { + if !fs.is_dir(dir_path) { continue } let files = fs.readdir(dir_path) catch { _ => continue } @@ -44,14 +44,14 @@ async fn handle_prune_packed(args : Array[String]) -> Unit raise Error { if packed_ids.contains(hex) { let file_path = dir_path + "/" + file_name if dry_run { - if !(quiet) { + if !quiet { print_line(hex) } } else { fs.remove_file(file_path) catch { _ => () } - if !(quiet) { + if !quiet { print_line(hex) } } @@ -59,7 +59,7 @@ async fn handle_prune_packed(args : Array[String]) -> Unit raise Error { } } // Try to remove empty directory - if !(dry_run) && dir_removed == dir_count && dir_count > 0 { + if !dry_run && dir_removed == dir_count && dir_count > 0 { fs.remove_dir(dir_path) catch { _ => () } diff --git a/src/cmd/bit/pull.mbt b/src/cmd/bit/pull.mbt index db1228b3..c0095d61 100644 --- a/src/cmd/bit/pull.mbt +++ b/src/cmd/bit/pull.mbt @@ -278,7 +278,7 @@ async fn handle_pull(args : Array[String]) -> Unit raise Error { preferred_sender~, preferred_repo~, ) - if !(quiet) { + if !quiet { print_line("Relay peer selected: \{relay_sender} -> \{relay_fetch_url}") } pull_url = relay_fetch_url @@ -310,8 +310,8 @@ async fn handle_pull(args : Array[String]) -> Unit raise Error { target_ref == current_head_target let autostash_enabled = pull_autostash_enabled(fs, git_dir, rebase, autostash) if pre_fetch_head is Some(_) && - !(fetch_updates_checked_out_head) && - !(autostash_enabled) && + !fetch_updates_checked_out_head && + !autostash_enabled && pull_has_uncommitted_changes(@bitlib.status(fs, root)) { raise @bitcore.GitError::InvalidObject( "Cannot pull because you have uncommitted changes.", @@ -328,12 +328,12 @@ async fn handle_pull(args : Array[String]) -> Unit raise Error { ) } let bare_repo = @bitlib.is_bare_git_dir(git_dir) - let initial_unborn_status = if pre_fetch_head is None && !(bare_repo) { + let initial_unborn_status = if pre_fetch_head is None && !bare_repo { Some(@bitlib.status(fs, root)) } else { None } - let initial_unborn_entries = if pre_fetch_head is None && !(bare_repo) { + let initial_unborn_entries = if pre_fetch_head is None && !bare_repo { @bitlib.read_index_entries(fs, git_dir) } else { [] @@ -345,12 +345,12 @@ async fn handle_pull(args : Array[String]) -> Unit raise Error { } let pre_fetch_checked_out_head_status = if pre_fetch_head is Some(_) && fetch_updates_checked_out_head && - !(bare_repo) { + !bare_repo { Some(@bitlib.status(fs, root)) } else { None } - if !(quiet) { + if !quiet { print_line("Fetching from \{pull_url}...") } fetch_from_remote( @@ -422,10 +422,10 @@ async fn handle_pull(args : Array[String]) -> Unit raise Error { match (pre_fetch_head, pre_fetch_checked_out_head_status) { (Some(old_id), Some(status)) => if old_id != tid { - if !(quiet) { + if !quiet { eprint_line("fetch updated the current branch head") } - if !(pull_can_fast_forward_checked_out_head(status, target_modes)) { + if !pull_can_fast_forward_checked_out_head(status, target_modes) { if pull_adhoc_remote { @bitlib.remove_remote_refs(fs, fs, git_dir, remote_name) } @@ -466,7 +466,7 @@ async fn handle_pull(args : Array[String]) -> Unit raise Error { } let preserved_entries : Array[@bitlib.IndexEntry] = [] let preserved_files : Map[String, Bytes] = {} - if !(bare_repo) { + if !bare_repo { let current_status = match initial_unborn_status { Some(status) => status None => @bitlib.status(fs, root) @@ -491,7 +491,7 @@ async fn handle_pull(args : Array[String]) -> Unit raise Error { preserved_paths.push(entry.path) } for path in current_status.untracked { - if !(target_modes.contains(path)) { + if !target_modes.contains(path) { preserved_paths.push(path) } } @@ -504,7 +504,7 @@ async fn handle_pull(args : Array[String]) -> Unit raise Error { } else { write_ref_file(fs, git_dir, head_target, tid) } - if !(bare_repo) { + if !bare_repo { if head_target.has_prefix("refs/heads/") { let branch = String::unsafe_substring( head_target, @@ -526,7 +526,7 @@ async fn handle_pull(args : Array[String]) -> Unit raise Error { ) None => () } - if !(quiet) { + if !quiet { print_line("Fast-forward") } if pull_adhoc_remote { @@ -555,7 +555,7 @@ async fn handle_pull(args : Array[String]) -> Unit raise Error { } if interactive_rebase { interactive_rebase_start(fs, fs, root, git_dir, rebase_upstream, tid) - if !(rfs.is_dir(git_dir + "/rebase-merge")) { + if !rfs.is_dir(git_dir + "/rebase-merge") { pull_apply_autostash(fs, fs, git_dir, root, autostash_state, quiet) } } else { @@ -574,10 +574,10 @@ async fn handle_pull(args : Array[String]) -> Unit raise Error { ) _ => () } - if !(quiet) { + if !quiet { print_line("Fast-forward") } - } else if !(quiet) { + } else if !quiet { print_line("Updated to \{id.to_hex()}") } pull_apply_autostash( @@ -585,7 +585,7 @@ async fn handle_pull(args : Array[String]) -> Unit raise Error { ) } None => { - if !(quiet) { + if !quiet { print_line("Successfully rebased.") } pull_apply_autostash( @@ -594,7 +594,7 @@ async fn handle_pull(args : Array[String]) -> Unit raise Error { } } @bitlib.RebaseStatus::NothingToRebase => { - if !(quiet) { + if !quiet { print_line("Current branch is up to date.") } pull_apply_autostash(fs, fs, git_dir, root, autostash_state, quiet) @@ -620,7 +620,7 @@ async fn handle_pull(args : Array[String]) -> Unit raise Error { ) match result.status { @bitlib.MergeStatus::AlreadyUpToDate => - if !(quiet) { + if !quiet { print_line("Already up to date.") } @bitlib.MergeStatus::FastForward => @@ -634,7 +634,7 @@ async fn handle_pull(args : Array[String]) -> Unit raise Error { None => () } let short = String::unsafe_substring(id.to_hex(), start=0, end=7) - if !(quiet) { + if !quiet { print_line("Fast-forward to \{short}") } } @@ -646,7 +646,7 @@ async fn handle_pull(args : Array[String]) -> Unit raise Error { ) None => () } - if !(quiet) { + if !quiet { print_line("Fast-forward") } } @@ -655,11 +655,11 @@ async fn handle_pull(args : Array[String]) -> Unit raise Error { match result.commit_id { Some(id) => { let short = String::unsafe_substring(id.to_hex(), start=0, end=7) - if !(quiet) { + if !quiet { print_line("Merge made by the 'ort' strategy. [\{short}]") } } - None => if !(quiet) { print_line("Merged") } + None => if !quiet { print_line("Merged") } } @bitlib.MergeStatus::Conflicted => { print_line("CONFLICT (content): Merge conflict in the following files:") @@ -845,7 +845,7 @@ async fn pull_apply_autostash( } } } - if !(quiet) { + if !quiet { print_line("Applied autostash.") } } @@ -1143,7 +1143,7 @@ fn pull_collect_initial_preserved_index_entries( ) -> Array[@bitlib.IndexEntry] { let preserved : Array[@bitlib.IndexEntry] = [] for entry in entries { - if !(target_modes.contains(entry.path)) { + if !target_modes.contains(entry.path) { preserved.push(entry) } } @@ -1216,7 +1216,7 @@ fn pull_pre_fetch_validation_error( } else if arg_remote is None && arg_refspec is None && current_branch_remote_cfg is Some(_) && - !(current_branch_has_merge) && + !current_branch_has_merge && has_head { Some("There is no tracking information for the current branch.") } else if arg_remote is Some(_) && merge_ref is None && has_head { @@ -1605,7 +1605,7 @@ fn read_config_values( ) -> Array[String] { let values : Array[String] = [] let config_path = git_dir + "/config" - if !(fs.is_file(config_path)) { + if !fs.is_file(config_path) { return values } let content = decode_bytes( @@ -1681,12 +1681,12 @@ fn resolve_remote_push_refmap_destination( remote_push_specs : Array[String], ) -> String? { let source_candidates = fetch_source_candidates(source_token) - if !(source_candidates.contains(source_ref)) { + if !source_candidates.contains(source_ref) { source_candidates.push(source_ref) } if source_ref == "HEAD" { let current_ref = "refs/heads/" + current_branch - if !(source_candidates.contains(current_ref)) { + if !source_candidates.contains(current_ref) { source_candidates.push(current_ref) } } @@ -1790,7 +1790,7 @@ fn normalize_push_ref_token( } } else if token.has_prefix("refs/") { token - } else if !(for_destination) && + } else if !for_destination && (token.contains("^") || token.contains("~") || looks_like_object_id(token)) { token } else { @@ -1846,7 +1846,7 @@ fn read_url_rewrite_rules( ) -> Array[(String, String, Bool)] { let config_path = git_dir + "/config" let rules : Array[(String, String, Bool)] = [] - if !(fs.is_file(config_path)) { + if !fs.is_file(config_path) { return rules } let content = decode_bytes( @@ -1886,15 +1886,15 @@ fn rewrite_url_by_rules( let mut best_push_only = false for i in 0.. best_prefix_len || - (prefix_len == best_prefix_len && push_only && !(best_push_only)) { + (prefix_len == best_prefix_len && push_only && !best_push_only) { best_base = Some(base) best_prefix_len = prefix_len best_push_only = push_only @@ -1960,7 +1960,7 @@ fn resolve_push_target_plan( "No upstream configured for current branch", ) } - PushDefaultMode::Simple if !(triangular) => + PushDefaultMode::Simple if !triangular => match branch_remote { Some(name) => name None => @@ -1999,7 +1999,7 @@ fn resolve_push_target_plan( } if looks_like_object_id(raw_src) && raw_dst.length() > 0 && - !(raw_dst.has_prefix("refs/")) { + !raw_dst.has_prefix("refs/") { raise @bitcore.GitError::InvalidObject( "Cannot infer destination ref from source object id", ) @@ -2055,7 +2055,7 @@ fn resolve_push_target_plan( "No upstream configured for current branch", ) } - PushDefaultMode::Simple if !(triangular) => + PushDefaultMode::Simple if !triangular => match branch_remote { Some(name) => name None => @@ -2323,14 +2323,14 @@ fn is_invalid_push_destination_refname( refname : String, allow_onelevel : Bool, ) -> Bool { - if !(refname.has_prefix("refs/")) { + if !refname.has_prefix("refs/") { return true } let rest = String::unsafe_substring(refname, start=5, end=refname.length()) if rest.length() == 0 || rest.has_suffix("/") { return true } - if !(allow_onelevel) && !(rest.contains("/")) { + if !allow_onelevel && !rest.contains("/") { return true } false @@ -2520,13 +2520,13 @@ fn resolve_ref_canonical_name_inner( } } let path = git_dir + "/" + normalized - if !(fs.is_file(path)) { + if !fs.is_file(path) { return normalized } let line = decode_bytes(fs.read_file(path) catch { _ => return normalized }) .trim() .to_string() - if !(line.has_prefix("ref: ")) { + if !line.has_prefix("ref: ") { return normalized } let target = String::unsafe_substring(line, start=5, end=line.length()) @@ -2639,7 +2639,7 @@ async fn run_push_hook_with_stdin( ) -> Int { let hook_git_dir = resolve_push_hook_git_dir(git_dir) let hook_path = hook_git_dir + "/hooks/" + hook_name - if !(fs.is_file(hook_path)) { + if !fs.is_file(hook_path) { return 0 } let stdin_path = hook_git_dir + @@ -2684,7 +2684,7 @@ async fn run_push_hook_with_args( ) -> Int { let hook_git_dir = resolve_push_hook_git_dir(git_dir) let hook_path = hook_git_dir + "/hooks/" + hook_name - if !(fs.is_file(hook_path)) { + if !fs.is_file(hook_path) { return 0 } @process.run(hook_path, args, inherit_env=true, cwd=hook_git_dir) catch { @@ -2710,7 +2710,7 @@ async fn apply_update_instead_worktree( new_id : @bitcore.ObjectId, ) -> Unit raise @bitcore.GitError { let status = @bitlib.status(fs, worktree_path) - if !(is_worktree_status_clean(status)) { + if !is_worktree_status_clean(status) { raise @bitcore.GitError::InvalidObject("working tree has pending changes") } let worktree_git_dir = match @bitlib.detect_git_dir(fs, worktree_path) { @@ -2741,7 +2741,7 @@ async fn run_push_to_checkout_hook( ) -> Int { let hook_git_dir = resolve_push_hook_git_dir(git_dir) let hook_path = hook_git_dir + "/hooks/push-to-checkout" - if !(fs.is_file(hook_path)) { + if !fs.is_file(hook_path) { return -1 } let worktree_git_dir = match @bitlib.detect_git_dir(fs, worktree_path) { diff --git a/src/cmd/bit/push.mbt b/src/cmd/bit/push.mbt index a975cd8a..05491545 100644 --- a/src/cmd/bit/push.mbt +++ b/src/cmd/bit/push.mbt @@ -4,7 +4,7 @@ fn push_delete_current_branch_policy( checked_out_worktree : String?, deny_delete_current : String?, ) -> (Bool, Bool) { - if !(has_remote_ref) || checked_out_worktree is None { + if !has_remote_ref || checked_out_worktree is None { return (false, false) } match deny_delete_current { @@ -30,7 +30,7 @@ fn push_resolve_mirror_refspecs( delete_mode : Bool, ) -> Array[String]? raise @bitcore.GitError { let mirror_active = option_mirror || remote_mirror - if !(mirror_active) { + if !mirror_active { return None } if explicit_refspec_count > 0 || push_all || push_tags || delete_mode { @@ -240,7 +240,7 @@ fn push_force_if_includes_reflog_refnames( ) -> Array[String] { let refnames : Array[String] = [] let append_refname = fn(refname : String) { - if refname.length() > 0 && !(refnames.contains(refname)) { + if refname.length() > 0 && !refnames.contains(refname) { refnames.push(refname) } } @@ -531,7 +531,7 @@ async fn handle_push(args : Array[String]) -> Unit raise Error { break } } - if !(has_main) { + if !has_main { fallback_branch = local_branches_for_default[0].name } } @@ -668,10 +668,7 @@ async fn handle_push(args : Array[String]) -> Unit raise Error { refspec_args.push("refs/tags/*:refs/tags/*") } let mut legacy_push_url : String? = None - if refspec_args.length() == 0 && - !(push_all) && - !(push_tags) && - !(delete_mode) { + if refspec_args.length() == 0 && !push_all && !push_tags && !delete_mode { match (legacy_branch_remote, explicit_remote) { (Some((legacy_name, legacy_url, legacy_branch)), Some(explicit_name)) => if explicit_name == legacy_name { @@ -846,7 +843,7 @@ async fn handle_push(args : Array[String]) -> Unit raise Error { match push_detect_relay_session(resolved_push_url) { Some((base_url, session_id)) => { let proxied = base_url + "/git/" + session_id - if !(quiet) && !(porcelain) { + if !quiet && !porcelain { print_line("Pushing via relay session: \{session_id}") } resolved_push_url = proxied @@ -868,7 +865,7 @@ async fn handle_push(args : Array[String]) -> Unit raise Error { preferred_sender~, preferred_repo~, ) - if !(quiet) && !(porcelain) { + if !quiet && !porcelain { print_line( "Relay peer selected: \{relay_sender} -> \{relay_push_url}", ) @@ -910,13 +907,13 @@ async fn handle_push(args : Array[String]) -> Unit raise Error { ) force_with_lease_rules[refname] = expectation } - let track_upstream_config = !(dry_run) && - !(push_mirror_active) && + let track_upstream_config = !dry_run && + !push_mirror_active && (set_upstream || auto_set_upstream_needed) let emit_progress = push_should_emit_progress(progress_override, quiet) if helper_is_testgit && refspec_args.length() == 0 && - !(push_all) && + !push_all && default_plan is Some(_) { if @sys.get_env_var("GIT_REMOTE_TESTGIT_NOREFSPEC") is Some(_) { raise @bitcore.GitError::InvalidObject( @@ -959,7 +956,7 @@ async fn handle_push(args : Array[String]) -> Unit raise Error { Some((remote_url, subdir_path, base_hex)) => { if porcelain { print_line("To \{remote_url}") - } else if !(quiet) { + } else if !quiet { print_line("Pushing subdir-clone to \{remote_url}...") print_line(" Subdirectory: \{subdir_path}") } @@ -986,7 +983,7 @@ async fn handle_push(args : Array[String]) -> Unit raise Error { None => { if porcelain { print_line("To \{push_target_display}") - } else if !(quiet) { + } else if !quiet { print_line("Pushing to \{url}...") } match @bitlib.resolve_local_repo_path(fs, root, url) { @@ -1114,7 +1111,7 @@ async fn handle_push(args : Array[String]) -> Unit raise Error { } if source_is_other && spec.dst.length() > 0 && - !(spec.dst.has_prefix("refs/")) { + !spec.dst.has_prefix("refs/") { let has_existing = @bitlib.resolve_ref( fs, rgd, @@ -1125,7 +1122,7 @@ async fn handle_push(args : Array[String]) -> Unit raise Error { is Some(_) || @bitlib.resolve_ref(fs, rgd, "refs/remotes/" + spec.dst) is Some(_) - if !(has_existing) { + if !has_existing { raise @bitcore.GitError::InvalidObject( "Cannot infer destination ref from source object id", ) @@ -1268,7 +1265,7 @@ async fn handle_push(args : Array[String]) -> Unit raise Error { break } } - if !(reachable) { + if !reachable { continue } push_plans.push({ @@ -1304,15 +1301,13 @@ async fn handle_push(args : Array[String]) -> Unit raise Error { force_with_lease_rules, ) { Some((tracking_based, expected_old)) => - if !(plan_item.force) && old_opt != expected_old { + if !plan_item.force && old_opt != expected_old { lease_stale = true - } else if !(plan_item.force) && + } else if !plan_item.force && tracking_based && push_use_force_if_includes && - !( - push_force_if_includes_satisfied( - fs, local_db, git_dir, "", expected_old, - ), + !push_force_if_includes_satisfied( + fs, local_db, git_dir, "", expected_old, ) { lease_stale = true } @@ -1433,17 +1428,15 @@ async fn handle_push(args : Array[String]) -> Unit raise Error { force_with_lease_rules, ) { Some((tracking_based, expected_old)) => - if !(plan_item.force) && old_opt != expected_old { + if !plan_item.force && old_opt != expected_old { lease_stale = true } else { lease_passed = true - if !(plan_item.force) && + if !plan_item.force && tracking_based && push_use_force_if_includes && - !( - push_force_if_includes_satisfied( - fs, local_db, git_dir, src_refname, expected_old, - ), + !push_force_if_includes_satisfied( + fs, local_db, git_dir, src_refname, expected_old, ) { lease_stale = true } @@ -1469,12 +1462,10 @@ async fn handle_push(args : Array[String]) -> Unit raise Error { let mut tag_conflict = false if old_opt is Some(existing_old) && existing_old != local_id && - !(plan_item.force) { + !plan_item.force { if dst_refname.has_prefix("refs/heads/") && - !( - is_ancestor_commit( - local_db, fs, existing_old, local_id, - ), + !is_ancestor_commit( + local_db, fs, existing_old, local_id, ) { non_fast_forward = true } @@ -1483,7 +1474,7 @@ async fn handle_push(args : Array[String]) -> Unit raise Error { } } if lease_passed && - !(plan_item.force) && + !plan_item.force && (non_fast_forward || tag_conflict) { effective_force_update = true non_fast_forward = false @@ -1583,7 +1574,7 @@ async fn handle_push(args : Array[String]) -> Unit raise Error { None => () } } - if !(matched) { + if !matched { raise @bitcore.GitError::InvalidObject( "Cannot resolve source ref: " + plan_item.source_ref, ) @@ -1614,21 +1605,19 @@ async fn handle_push(args : Array[String]) -> Unit raise Error { force_with_lease_rules, ) { Some((tracking_based, expected_old)) => - if !(plan_item.force) && old_opt != expected_old { + if !plan_item.force && old_opt != expected_old { lease_stale = true } else { lease_passed = true - if !(plan_item.force) && + if !plan_item.force && tracking_based && push_use_force_if_includes && - !( - push_force_if_includes_satisfied( - fs, - local_db, - git_dir, - plan_item.source_ref, - expected_old, - ), + !push_force_if_includes_satisfied( + fs, + local_db, + git_dir, + plan_item.source_ref, + expected_old, ) { lease_stale = true } @@ -1654,9 +1643,9 @@ async fn handle_push(args : Array[String]) -> Unit raise Error { let mut tag_conflict = false if old_opt is Some(existing_old) && existing_old != local_id && - !(plan_item.force) { + !plan_item.force { if plan_item.dest_ref.has_prefix("refs/heads/") && - !(is_ancestor_commit(local_db, fs, existing_old, local_id)) { + !is_ancestor_commit(local_db, fs, existing_old, local_id) { non_fast_forward = true } if plan_item.dest_ref.has_prefix("refs/tags/") { @@ -1664,7 +1653,7 @@ async fn handle_push(args : Array[String]) -> Unit raise Error { } } if lease_passed && - !(plan_item.force) && + !plan_item.force && (non_fast_forward || tag_conflict) { effective_force_update = true non_fast_forward = false @@ -1780,10 +1769,10 @@ async fn handle_push(args : Array[String]) -> Unit raise Error { "failed to push some refs to '\{url}'", ) } - if !(dry_run) && resolved_updates.length() > 0 { + if !dry_run && resolved_updates.length() > 0 { let mut has_object_updates = false for row in resolved_updates { - if row.should_apply && !(row.delete_ref) { + if row.should_apply && !row.delete_ref { has_object_updates = true break } @@ -1795,7 +1784,7 @@ async fn handle_push(args : Array[String]) -> Unit raise Error { let rfs : &@bitcore.RepoFileSystem = fs let transferred_object_ids : Map[String, Bool] = {} for row in resolved_updates { - if row.should_apply && !(row.delete_ref) { + if row.should_apply && !row.delete_ref { copy_wanted_object_graph( fs, rfs, @@ -1834,7 +1823,7 @@ async fn handle_push(args : Array[String]) -> Unit raise Error { } } for row in resolved_updates { - if !(row.should_apply) { + if !row.should_apply { continue } if row.delete_ref { @@ -1938,7 +1927,7 @@ async fn handle_push(args : Array[String]) -> Unit raise Error { } if !(porcelain || quiet) { for row in resolved_updates { - if !(row.should_apply) { + if !row.should_apply { continue } if row.delete_ref && row.old_id != @bitcore.ObjectId::zero() { @@ -1952,7 +1941,7 @@ async fn handle_push(args : Array[String]) -> Unit raise Error { let upstream_messages = push_write_upstream_config_updates( fs, git_dir, remote_name, upstream_config_updates, ) - if !(quiet) { + if !quiet { for message in upstream_messages { print_line(message) } @@ -1971,12 +1960,12 @@ async fn handle_push(args : Array[String]) -> Unit raise Error { ) } print_line("Done") - } else if !(quiet) { + } else if !quiet { print_line("Push successful") } } None => { - if emit_progress && !(dry_run) { + if emit_progress && !dry_run { eprint_line("Writing objects: 100% (1/1), done.") } let result = @bitlibnative.push_http( @@ -2020,13 +2009,13 @@ async fn handle_push(args : Array[String]) -> Unit raise Error { _ => () } } - let wrote_count = if push_negotiate && !(negotiation_failed) { + let wrote_count = if push_negotiate && !negotiation_failed { "2" } else { "5" } emit_push_trace_event(fs, "write_pack_file/wrote", wrote_count) - if push_negotiate && !(negotiation_failed) { + if push_negotiate && !negotiation_failed { emit_push_trace_event(fs, "total_rounds", "1") } } @@ -2071,7 +2060,7 @@ fn push_detect_relay_session(remote_url : String) -> (String, String)? { return None } for c in segment { - if !(push_is_session_id_char(c)) { + if !push_is_session_id_char(c) { return None } } diff --git a/src/cmd/bit/range_diff.mbt b/src/cmd/bit/range_diff.mbt index 696e2d21..61fc6e19 100644 --- a/src/cmd/bit/range_diff.mbt +++ b/src/cmd/bit/range_diff.mbt @@ -13,7 +13,7 @@ async fn handle_range_diff(args : Array[String]) -> Unit raise Error { } "--no-dual-color" | "--dual-color" | "--no-color" => () _ if arg.has_prefix("--creation-factor=") => () - _ if !(arg.has_prefix("-")) => ranges.push(arg) + _ if !arg.has_prefix("-") => ranges.push(arg) _ if arg.has_prefix("-") => warn_unimplemented_arg("range-diff", arg) _ => () } @@ -117,7 +117,7 @@ async fn handle_range_diff(args : Array[String]) -> Unit raise Error { break } } - if !(found) { + if !found { print_line( "-: ------- > " + idx2.to_string() + diff --git a/src/cmd/bit/read_tree.mbt b/src/cmd/bit/read_tree.mbt index 5fddf24c..5d276da6 100644 --- a/src/cmd/bit/read_tree.mbt +++ b/src/cmd/bit/read_tree.mbt @@ -32,7 +32,7 @@ async fn handle_read_tree(args : Array[String]) -> Unit raise Error { } _ if arg.has_prefix("--prefix=") => () _ if arg.has_prefix("--index-output=") => () - _ if !(arg.has_prefix("-")) => tree_refs.push(arg) + _ if !arg.has_prefix("-") => tree_refs.push(arg) _ if arg.has_prefix("-") => warn_unimplemented_arg("read-tree", arg) _ => () } @@ -40,7 +40,7 @@ async fn handle_read_tree(args : Array[String]) -> Unit raise Error { } // Handle --empty: clear index if empty { - if !(dry_run) { + if !dry_run { @bitlib.write_index_entries(fs, git_dir, [], hash_size~) } return @@ -63,11 +63,11 @@ async fn handle_read_tree(args : Array[String]) -> Unit raise Error { } let files = @bitlib.collect_tree_files(db, fs, tree_id) let entries = @bitlib.tree_files_to_index(db, fs, files) - if !(dry_run) { + if !dry_run { @bitlib.write_index_entries(fs, git_dir, entries, hash_size~) } // Handle -u: update working tree (unless -i: index only) - if update && !(dry_run) && !(index_only) { + if update && !dry_run && !index_only { let root = get_work_root() @bitlib.write_worktree_from_files( db, @@ -98,10 +98,10 @@ async fn handle_read_tree(args : Array[String]) -> Unit raise Error { } } let entries = @bitlib.tree_files_to_index(db, fs, merged_files) - if !(dry_run) { + if !dry_run { @bitlib.write_index_entries(fs, git_dir, entries, hash_size~) } - if update && !(dry_run) && !(index_only) { + if update && !dry_run && !index_only { let root = get_work_root() @bitlib.write_worktree_from_files( db, diff --git a/src/cmd/bit/rebase.mbt b/src/cmd/bit/rebase.mbt index c8aace76..1a8f5566 100644 --- a/src/cmd/bit/rebase.mbt +++ b/src/cmd/bit/rebase.mbt @@ -187,7 +187,7 @@ async fn handle_rebase(args : Array[String]) -> Unit raise Error { onto = Some(args[i + 1]) i += 2 } - _ if !(arg.has_prefix("-")) => { + _ if !arg.has_prefix("-") => { upstream = Some(arg) i += 1 } @@ -210,7 +210,7 @@ async fn handle_rebase(args : Array[String]) -> Unit raise Error { // Check if interactive rebase is in progress let rebase_merge_dir = git_dir + "/rebase-merge" if rfs.is_dir(rebase_merge_dir) && - !(rebase_merge_dir_uses_builtin_state(rfs, rebase_merge_dir)) { + !rebase_merge_dir_uses_builtin_state(rfs, rebase_merge_dir) { interactive_rebase_continue(wfs, rfs, root, git_dir) } else { let result = @bitlib.rebase_continue(fs, fs, root) @@ -222,7 +222,7 @@ async fn handle_rebase(args : Array[String]) -> Unit raise Error { if do_abort { let rebase_merge_dir = git_dir + "/rebase-merge" if rfs.is_dir(rebase_merge_dir) && - !(rebase_merge_dir_uses_builtin_state(rfs, rebase_merge_dir)) { + !rebase_merge_dir_uses_builtin_state(rfs, rebase_merge_dir) { interactive_rebase_abort(wfs, rfs, root, git_dir) } else { @bitlib.rebase_abort(fs, fs, root) catch { @@ -236,7 +236,7 @@ async fn handle_rebase(args : Array[String]) -> Unit raise Error { if do_skip { let rebase_merge_dir = git_dir + "/rebase-merge" if rfs.is_dir(rebase_merge_dir) && - !(rebase_merge_dir_uses_builtin_state(rfs, rebase_merge_dir)) { + !rebase_merge_dir_uses_builtin_state(rfs, rebase_merge_dir) { interactive_rebase_skip(wfs, rfs, root, git_dir) } else { let result = @bitlib.rebase_skip(fs, fs, root) @@ -738,9 +738,9 @@ fn remove_first_non_comment_line(content : String) -> String { let mut skipped_first = false for line_view in content.split("\n") { let line = line_view.to_string() - if !(skipped_first) { + if !skipped_first { let trimmed = trim_string(line) - if trimmed.length() > 0 && !(trimmed.has_prefix("#")) { + if trimmed.length() > 0 && !trimmed.has_prefix("#") { skipped_first = true continue } @@ -1194,7 +1194,7 @@ fn find_tree_subtree( break } } - if !(found) { + if !found { return None } } diff --git a/src/cmd/bit/rebase_ai.mbt b/src/cmd/bit/rebase_ai.mbt index 2b502921..4f362fec 100644 --- a/src/cmd/bit/rebase_ai.mbt +++ b/src/cmd/bit/rebase_ai.mbt @@ -140,7 +140,7 @@ fn parse_rebase_ai_args( i += 1 continue } - _ if !(arg.has_prefix("-")) => { + _ if !arg.has_prefix("-") => { upstream = Some(arg) i += 1 continue diff --git a/src/cmd/bit/receive_pack.mbt b/src/cmd/bit/receive_pack.mbt index 1113fa20..fe59b29a 100644 --- a/src/cmd/bit/receive_pack.mbt +++ b/src/cmd/bit/receive_pack.mbt @@ -30,7 +30,7 @@ async fn handle_receive_pack(args : Array[String]) -> Unit { let fs = OsFs::new() let git_dir = if root.has_suffix(".git") && !root.has_suffix("/.git") { root - } else if fs.is_file(root + "/HEAD") && !(fs.is_dir(root + "/.git")) { + } else if fs.is_file(root + "/HEAD") && !fs.is_dir(root + "/.git") { // Bare repository without .git suffix root } else { @@ -56,7 +56,7 @@ async fn handle_receive_pack(args : Array[String]) -> Unit { } // Send advertisement: always for advertise-only mode, and in // bidirectional mode (no --stateless-rpc) - if advertise || !(stateless_rpc) { + if advertise || !stateless_rpc { let haves = receive_collect_alternate_haves(fs, git_dir, root) let proto = @bitlib.get_protocol_version() let out = @bitlib.build_receive_pack_advertisement( @@ -71,7 +71,7 @@ async fn handle_receive_pack(args : Array[String]) -> Unit { @stdio.stdout.write(out) } // Process commands (unless advertise-only mode) - if !(advertise) { + if !advertise { let input = read_all_stdin() let req = @bitlib.parse_receive_pack_request(input) // Determine client capabilities @@ -97,7 +97,7 @@ async fn handle_receive_pack(args : Array[String]) -> Unit { req.updates, req.push_options, ) - if !(pre_receive_ok) { + if !pre_receive_ok { // pre-receive rejected: report all refs as rejected let result : @bitlib.ReceivePackResult = { updated: [], @@ -245,7 +245,7 @@ async fn receive_collect_alternate_haves( ) -> Array[@bitcore.ObjectId] { let haves : Array[@bitcore.ObjectId] = [] let alternates_path = git_dir + "/objects/info/alternates" - if !(fs.is_file(alternates_path)) { + if !fs.is_file(alternates_path) { return haves } let data = fs.read_file(alternates_path) catch { _ => return haves } @@ -273,7 +273,7 @@ async fn receive_collect_alternate_haves( git_dir + "/objects/" + line } // Strip /objects suffix to get the alternate git dir - if !(alt_objects_dir.has_suffix("/objects")) { + if !alt_objects_dir.has_suffix("/objects") { continue } let alt_git_dir = String::unsafe_substring( @@ -430,7 +430,7 @@ fn receive_ref_matches_proc_patterns( // Prefix match with '/' boundary: refname == prefix || refname starts with prefix + "/" let matched = refname == prefix || refname.has_prefix(prefix + "/") if matched { - return !(negated) + return !negated } } false @@ -448,7 +448,7 @@ async fn receive_run_hook( push_options : Array[String], ) -> Bool { let hook_path = git_dir + "/hooks/" + hook_name - if !(fs.is_file(hook_path)) { + if !fs.is_file(hook_path) { return true } // Compute hook path relative to root for execution with cwd=root. @@ -521,7 +521,7 @@ async fn receive_run_proc_receive_hook( push_options : Array[String], ) -> Array[@bitlib.ReceivePackProcResult] { let hook_path = git_dir + "/hooks/proc-receive" - if !(fs.is_file(hook_path)) { + if !fs.is_file(hook_path) { return updates.map(fn(u) { ( { diff --git a/src/cmd/bit/reflog.mbt b/src/cmd/bit/reflog.mbt index f888dffd..daf78e1c 100644 --- a/src/cmd/bit/reflog.mbt +++ b/src/cmd/bit/reflog.mbt @@ -119,7 +119,7 @@ fn reflog_list_all_refs( ) -> Array[String] raise Error { let logs_dir = git_dir + "/logs" let refs : Array[String] = [] - if !(rfs.is_dir(logs_dir)) { + if !rfs.is_dir(logs_dir) { return refs } reflog_walk_logs_dir(rfs, logs_dir, "", refs) @@ -442,7 +442,7 @@ async fn handle_reflog_expire( } else if parsed.refs.length() > 0 { for ref_arg in parsed.refs { let normalized = normalize_reflog_refname(rfs, git_dir, ref_arg) - if !(reflog_ref_exists_or_resolves(rfs, git_dir, normalized)) { + if !reflog_ref_exists_or_resolves(rfs, git_dir, normalized) { raise @bitcore.GitError::InvalidObject( "error: reflog could not be found: '\{ref_arg}'", ) @@ -517,7 +517,7 @@ async fn reflog_expire_single_ref( new_lines.push(line) } } - if !(dry_run) { + if !dry_run { let new_content = if new_lines.length() > 0 { new_lines.join("\n") + "\n" } else { @@ -599,10 +599,8 @@ async fn show_reflog( break } let message = "commit: " + entry.message - if !( - grep_patterns_match_message( - message, grep_patterns, grep_pattern_type, grep_ignore_case, - ), + if !grep_patterns_match_message( + message, grep_patterns, grep_pattern_type, grep_ignore_case, ) { continue } @@ -626,13 +624,11 @@ async fn show_reflog( } let idx = len - 1 - i let entry = entries[idx] - if !( - grep_patterns_match_message( - entry.message, - grep_patterns, - grep_pattern_type, - grep_ignore_case, - ), + if !grep_patterns_match_message( + entry.message, + grep_patterns, + grep_pattern_type, + grep_ignore_case, ) { continue } @@ -702,7 +698,7 @@ fn parse_reflog_show_args(args : Array[String]) -> ReflogShowArgs { grep_pattern_type_override = Some(GrepPatternType::Basic) _ if arg.has_prefix("-") => () _ => - if !(has_refname) { + if !has_refname { refname = arg has_refname = true } @@ -785,7 +781,7 @@ fn parse_reflog_max_count_value(value : String) -> Int? { ///| fn reflog_parse_short_max_count(arg : String) -> Int? { - if arg.length() <= 1 || !(arg.has_prefix("-")) { + if arg.length() <= 1 || !arg.has_prefix("-") { return None } parse_reflog_max_count_value( diff --git a/src/cmd/bit/reflog_wbtest.mbt b/src/cmd/bit/reflog_wbtest.mbt index 5de0620d..ea51ddc1 100644 --- a/src/cmd/bit/reflog_wbtest.mbt +++ b/src/cmd/bit/reflog_wbtest.mbt @@ -148,7 +148,7 @@ test "reflog: expire rejects missing plain ref in builtin path" { let normalized = normalize_reflog_refname( fs, "/repo/.git", "does-not-exist", ) - if !(reflog_ref_exists_or_resolves(fs, "/repo/.git", normalized)) { + if !reflog_ref_exists_or_resolves(fs, "/repo/.git", normalized) { raise @bitcore.GitError::InvalidObject( "error: reflog could not be found: 'does-not-exist'", ) diff --git a/src/cmd/bit/relay_ci_review.mbt b/src/cmd/bit/relay_ci_review.mbt index 49d88faf..843b8393 100644 --- a/src/cmd/bit/relay_ci_review.mbt +++ b/src/cmd/bit/relay_ci_review.mbt @@ -44,7 +44,7 @@ async fn handle_relay_ci_push(args : Array[String]) -> Unit raise Error { i += 2 continue } - _ if !(arg.has_prefix("-")) && room_arg.length() == 0 => room_arg = arg + _ if !arg.has_prefix("-") && room_arg.length() == 0 => room_arg = arg _ => () } i += 1 @@ -96,7 +96,7 @@ async fn handle_relay_ci_pull(args : Array[String]) -> Unit raise Error { i += 2 continue } - _ if !(arg.has_prefix("-")) && room_arg.length() == 0 => room_arg = arg + _ if !arg.has_prefix("-") && room_arg.length() == 0 => room_arg = arg _ => () } i += 1 @@ -218,7 +218,7 @@ async fn handle_relay_review_request(args : Array[String]) -> Unit raise Error { i += 2 continue } - _ if !(arg.has_prefix("-")) && room_arg.length() == 0 => room_arg = arg + _ if !arg.has_prefix("-") && room_arg.length() == 0 => room_arg = arg _ => () } i += 1 @@ -283,7 +283,7 @@ async fn handle_relay_review_submit(args : Array[String]) -> Unit raise Error { i += 2 continue } - _ if !(arg.has_prefix("-")) && room_arg.length() == 0 => room_arg = arg + _ if !arg.has_prefix("-") && room_arg.length() == 0 => room_arg = arg _ => () } i += 1 @@ -334,7 +334,7 @@ async fn handle_relay_review_list(args : Array[String]) -> Unit raise Error { i += 2 continue } - _ if !(arg.has_prefix("-")) && room_arg.length() == 0 => room_arg = arg + _ if !arg.has_prefix("-") && room_arg.length() == 0 => room_arg = arg _ => () } i += 1 @@ -419,7 +419,7 @@ async fn handle_relay_review_list(args : Array[String]) -> Unit raise Error { } _ => () } - if !(found) { + if !found { print_line("No reviews for PR \{pr_id}") } } diff --git a/src/cmd/bit/relay_watch.mbt b/src/cmd/bit/relay_watch.mbt index 1df49486..1210ce8b 100644 --- a/src/cmd/bit/relay_watch.mbt +++ b/src/cmd/bit/relay_watch.mbt @@ -78,7 +78,7 @@ fn relay_resolve_room_arg(arg : String) -> (String, String) { ///| /// Watch a relay room for real-time updates (poll-based). async fn handle_relay_watch(args : Array[String]) -> Unit raise Error { - let mut room_arg = if args.length() > 0 && !(args[0].has_prefix("-")) { + let mut room_arg = if args.length() > 0 && !args[0].has_prefix("-") { args[0] } else { "." @@ -232,7 +232,7 @@ fn relay_watch_summarize_hub_record(payload : Map[String, Json]) -> String { ///| /// Show who is active in a relay room. async fn handle_relay_status(args : Array[String]) -> Unit raise Error { - let mut room_arg = if args.length() > 0 && !(args[0].has_prefix("-")) { + let mut room_arg = if args.length() > 0 && !args[0].has_prefix("-") { args[0] } else { "." diff --git a/src/cmd/bit/remote.mbt b/src/cmd/bit/remote.mbt index c93ecb1d..db83e4f9 100644 --- a/src/cmd/bit/remote.mbt +++ b/src/cmd/bit/remote.mbt @@ -142,10 +142,10 @@ fn prune_empty_parent_dirs( while current.length() > 0 && current != stop_dir && current.has_prefix(stop_dir + "/") { - if !(rfs.is_dir(current)) { + if !rfs.is_dir(current) { break } - if !(is_empty_dir(rfs, current)) { + if !is_empty_dir(rfs, current) { break } fs.remove_dir(current) catch { @@ -157,7 +157,7 @@ fn prune_empty_parent_dirs( ///| fn ref_namespace_root(refname : String) -> String { - if !(refname.has_prefix("refs/")) { + if !refname.has_prefix("refs/") { "refs" } else { let mut i = 0 @@ -350,8 +350,8 @@ async fn handle_remote(args : Array[String]) -> Unit raise Error { let blocks = @bitlib.parse_config_blocks( @bitlib.read_config_content(fs, git_dir), ) - if !(@bitlib.config_has_remote_section(blocks, name)) && - !(@bitlib.legacy_remote_exists(fs, git_dir, name)) { + if !@bitlib.config_has_remote_section(blocks, name) && + !@bitlib.legacy_remote_exists(fs, git_dir, name) { die_remote(2, "error: No such remote: '\{name}'") } remote_remove(fs, fs, git_dir, name) @@ -381,7 +381,7 @@ async fn handle_remote(args : Array[String]) -> Unit raise Error { ) let old_exists = @bitlib.config_has_remote_section(blocks, old_name) || @bitlib.legacy_remote_exists(fs, git_dir, old_name) - if !(old_exists) { + if !old_exists { die_remote(2, "error: No such remote: '\{old_name}'") } let new_exists = @bitlib.config_has_remote_section(blocks, new_name) || @@ -732,7 +732,7 @@ async fn remote_remove( name : String, ) -> Unit raise Error { let config_path = git_dir + "/config" - if !(rfs.is_file(config_path)) { + if !rfs.is_file(config_path) { raise @bitcore.GitError::InvalidObject("No such remote '\{name}'") } let content = decode_bytes(rfs.read_file(config_path)) @@ -813,7 +813,7 @@ async fn remote_remove( _ => new_blocks.push(block) } } - if !(found) { + if !found { raise @bitcore.GitError::InvalidObject("No such remote '\{name}'") } fs.write_string(config_path, @bitlib.render_config_blocks(new_blocks)) @@ -853,7 +853,7 @@ fn remote_set_url( if rfs.is_file(config_path + ".lock") { raise @bitcore.GitError::InvalidObject("config file is locked") } - if !(rfs.is_file(config_path)) { + if !rfs.is_file(config_path) { raise @bitcore.GitError::InvalidObject("No such remote '\{name}'") } let content = decode_bytes(rfs.read_file(config_path)) @@ -879,14 +879,14 @@ fn remote_set_url( Some(old) => { let filtered : Array[String] = [] for u in changed_urls { - if !(@bitlib.match_url_pattern(old, u)) { + if !@bitlib.match_url_pattern(old, u) { filtered.push(u) } } if filtered.length() == changed_urls.length() { raise @bitcore.GitError::InvalidObject("No such remote '\{name}'") } - if !(push) && filtered.length() == 0 { + if !push && filtered.length() == 0 { raise @bitcore.GitError::InvalidObject("No such remote '\{name}'") } changed_urls = filtered @@ -908,14 +908,14 @@ fn remote_set_url( let mut replaced = false let updated_list : Array[String] = [] for u in changed_urls { - if !(replaced) && @bitlib.match_url_pattern(old, u) { + if !replaced && @bitlib.match_url_pattern(old, u) { updated_list.push(nu) replaced = true } else { updated_list.push(u) } } - if !(replaced) { + if !replaced { raise @bitcore.GitError::InvalidObject( "No such remote '\{name}'", ) @@ -946,7 +946,7 @@ fn remote_set_url( new_blocks.push(block) } } - if !(found) { + if !found { raise @bitcore.GitError::InvalidObject("No such remote '\{name}'") } fs.write_string(config_path, @bitlib.render_config_blocks(new_blocks)) @@ -1024,7 +1024,7 @@ async fn remote_rename( } let legacy_remotes = git_dir + "/remotes/" + old_name let legacy_branches = git_dir + "/branches/" + old_name - if !(found_remote) && fs.is_file(legacy_remotes) { + if !found_remote && fs.is_file(legacy_remotes) { let text = decode_bytes(fs.read_file(legacy_remotes)) let mut url : String? = None let fetches : Array[String] = [] @@ -1082,7 +1082,7 @@ async fn remote_rename( None => () } } - if !(found_remote) && fs.is_file(legacy_branches) { + if !found_remote && fs.is_file(legacy_branches) { let text = decode_bytes(fs.read_file(legacy_branches)).trim().to_string() if text.length() > 0 { let (url, branch) = match text.find("#") { @@ -1121,7 +1121,7 @@ async fn remote_rename( found_remote = true } } - if !(found_remote) { + if !found_remote { raise @bitcore.GitError::InvalidObject("No such remote '\{old_name}'") } if old_name != new_name && refspecs_need_update { @@ -1302,12 +1302,12 @@ async fn remote_prune( break } } - if !(matched) { + if !matched { continue } match remote_ref { Some(rref) => - if !(remote_refs.contains(rref)) { + if !remote_refs.contains(rref) { let display = local_ref.replace(old="refs/remotes/", new="") if dry_run { print_line(" * [would prune] \{display}") @@ -1322,14 +1322,14 @@ async fn remote_prune( None => () } } - if !(dry_run) { + if !dry_run { let head_path = git_dir + "/refs/remotes/" + name + "/HEAD" if fs.is_file(head_path) { let state = @bitlib.read_local_remote_head_state(fs, head_path, name) match state { @bitlib.RemoteHeadState::Symref(branch) => { let ref_path = git_dir + "/refs/remotes/" + name + "/" + branch - if !(fs.is_file(ref_path)) { + if !fs.is_file(ref_path) { print_line("warning: refs/remotes/\{name}/HEAD has become dangling") } } @@ -1389,7 +1389,7 @@ fn remote_update_collect_targets( let seen : Map[String, Bool] = {} let mut default_update = false let add_name = fn(name : String) { - if !(seen.contains(name)) { + if !seen.contains(name) { seen[name] = true names.push(name) } @@ -1402,7 +1402,7 @@ fn remote_update_collect_targets( members.length() > 0 } if targets.length() == 0 { - if !(add_group("default")) { + if !add_group("default") { default_update = true for name, _ in remotes { add_name(name) @@ -1412,7 +1412,7 @@ fn remote_update_collect_targets( } for target in targets { if target == "default" { - if !(add_group("default")) { + if !add_group("default") { default_update = true for name, _ in remotes { add_name(name) @@ -1728,7 +1728,7 @@ fn update_testgit_push_tracking( if tracking_current != Some(id) { write_ref_file(fs, git_dir, tracking_ref, id) } - if !(no_private_update) { + if !no_private_update { write_ref_file( fs, git_dir, @@ -1868,7 +1868,7 @@ fn read_global_branch_autosetuprebase( None => return None } } - if !(fs.is_file(config_path)) { + if !fs.is_file(config_path) { return None } let content = decode_bytes(fs.read_file(config_path)) @@ -2003,11 +2003,11 @@ async fn clone_local_repo( mirror, None, ) - if !(bare) && !(detached_head) { + if !bare && !detached_head { setup_clone_branch_tracking(fs, dest_git_dir, default_branch, remote_name) } // Initialize remote-tracking refs and pack non-HEAD entries to match git clone layout. - if !(mirror) { + if !mirror { for b in branches { write_ref_file( fs, @@ -2017,7 +2017,7 @@ async fn clone_local_repo( ) } } - if !(detached_head) && !(mirror) && branches.length() > 0 { + if !detached_head && !mirror && branches.length() > 0 { write_symref_file( fs, dest_git_dir, @@ -2025,7 +2025,7 @@ async fn clone_local_repo( "refs/remotes/" + remote_name + "/" + default_branch, ) } - if !(mirror) { + if !mirror { pack_remote_tracking_refs(fs, dest_git_dir, remote_name) } // Partial clone markers @@ -2046,7 +2046,7 @@ async fn clone_local_repo( fs.write_string(promisor_path, remote_url + "\n") } // Populate working tree/index from the cloned commit snapshot. - if !(bare) && !(no_checkout) { + if !bare && !no_checkout { checkout_clone_head(fs, dest_path, head_id, default_branch, detached_head) } } @@ -2251,7 +2251,7 @@ async fn clone_local_bundle( // Write refs from bundle match head_id { Some(id) => - if !(detached_head) { + if !detached_head { write_ref_file(fs, dest_git_dir, "refs/heads/" + default_branch, id) } else { fs.write_string(dest_git_dir + "/HEAD", id.to_hex() + "\n") @@ -2292,11 +2292,11 @@ async fn clone_local_bundle( false, None, ) - if !(bare) && !(detached_head) { + if !bare && !detached_head { setup_clone_branch_tracking(fs, dest_git_dir, default_branch, remote_name) } // Write remote HEAD symref - if !(detached_head) && branches.length() > 0 { + if !detached_head && branches.length() > 0 { write_symref_file( fs, dest_git_dir, @@ -2306,7 +2306,7 @@ async fn clone_local_bundle( } pack_remote_tracking_refs(fs, dest_git_dir, remote_name) // Checkout working tree - if !(bare) && !(no_checkout) { + if !bare && !no_checkout { checkout_clone_head(fs, dest_path, head_id, default_branch, detached_head) } } @@ -2324,7 +2324,7 @@ fn read_clone_source_head_fallback( }, ) let head_line = trim_string(head_content) - if head_line.length() > 0 && !(head_line.has_prefix("ref: ")) { + if head_line.length() > 0 && !head_line.has_prefix("ref: ") { let head_id : @bitcore.ObjectId? = Some( @bitcore.ObjectId::from_hex(head_line), ) catch { @@ -2489,7 +2489,7 @@ fn render_fetch_head_content( } } for entry in entries { - if !(entry.for_merge) { + if !entry.for_merge { ordered.push(entry) } } @@ -2665,7 +2665,7 @@ fn update_remote_tracking_head_ref( return () } match warning_message { - Some(msg) => if !(quiet) { println(msg) } + Some(msg) => if !quiet { println(msg) } None => () } } @@ -2695,7 +2695,7 @@ async fn fetch_local_repo( Some(path) => append_text_file(fs, path, "") None => () } - if !(quiet) { + if !quiet { eprint_line("From \{display_url}") } let src_db = @bitlib.ObjectDb::load(fs, src_git_dir) @@ -2828,7 +2828,7 @@ async fn fetch_local_repo( if normalized_dst.has_prefix("refs/tags/") { match @bitlib.resolve_ref(fs, git_dir, normalized_dst) { Some(existing) => - if existing != head_id && !(spec_force) { + if existing != head_id && !spec_force { raise @bitcore.GitError::InvalidObject( "would clobber existing tag", ) @@ -2853,7 +2853,7 @@ async fn fetch_local_repo( } if spec.src.length() == 0 || spec.src.contains("*") || - !(looks_like_object_id(spec.src)) { + !looks_like_object_id(spec.src) { continue } let object_id = @bitcore.ObjectId::from_hex(spec.src) catch { @@ -2880,8 +2880,8 @@ async fn fetch_local_repo( let allowed = visible_advertised_oids.get(object_id_hex) is Some(_) || (allow_tip_sha1_in_want && all_tip_oids.get(object_id_hex) is Some(_)) || (allow_reachable_sha1_in_want && reachable_from_visible_tip) - if !(allowed) { - if allow_reachable_sha1_in_want && !(reachable_from_visible_tip) { + if !allowed { + if allow_reachable_sha1_in_want && !reachable_from_visible_tip { raise @bitcore.GitError::InvalidObject("not our ref " + object_id_hex) } raise @bitcore.GitError::InvalidObject( @@ -2942,7 +2942,7 @@ async fn fetch_local_repo( if normalized_dst.has_prefix("refs/tags/") { match @bitlib.resolve_ref(fs, git_dir, normalized_dst) { Some(existing) => - if existing != id && !(spec_force) { + if existing != id && !spec_force { raise @bitcore.GitError::InvalidObject( "would clobber existing tag", ) @@ -2998,7 +2998,7 @@ async fn fetch_local_repo( git_dir + "/FETCH_HEAD", render_fetch_head_content(fetch_head_entries, remote_url), ) - if explicit_refspecs.length() == 0 && !(mirror_fetch) { + if explicit_refspecs.length() == 0 && !mirror_fetch { match @bitlib.read_remote_head_branch(fs, src_git_dir) { Some(remote_head_branch) => update_remote_tracking_head_ref( @@ -3008,7 +3008,7 @@ async fn fetch_local_repo( } } for dst, id in mapped_refs { - if !(update_head_ok) && dst.has_prefix("refs/heads/") { + if !update_head_ok && dst.has_prefix("refs/heads/") { let branch_name = String::unsafe_substring( dst, start=11, @@ -3034,7 +3034,7 @@ async fn fetch_local_repo( } } let tagopt = rc.tagopt - if !(fetches_tags) { + if !fetches_tags { match tagopt { Some("--no-tags") => () Some("--tags") => @@ -3049,7 +3049,7 @@ async fn fetch_local_repo( _ => if fetched_heads.length() > 0 { for refname, id in remote_refs { - if !(refname.has_prefix("refs/tags/")) { + if !refname.has_prefix("refs/tags/") { continue } let target = peel_to_commit(src_db, fs, id) @@ -3113,7 +3113,7 @@ async fn fetch_from_remote( Some(dir) => dir None => root } - if !(force_transport) { + if !force_transport { match @bitlib.resolve_local_repo_path(fs, local_root, remote_url) { Some(src_path) => { fetch_local_repo( @@ -3142,7 +3142,7 @@ async fn fetch_from_remote( let default_ref = @protocol.select_default_ref(refs, symrefs) match default_ref { None => { - if !(quiet) { + if !quiet { print_line("No refs to fetch") } return () @@ -3163,7 +3163,7 @@ async fn fetch_from_remote( if prev_id is Some(pid) && pid == commit_id { return () } - if !(quiet) { + if !quiet { print_line("Fetching from \{remote_url}...") } let pack = match transport { @@ -3190,23 +3190,23 @@ async fn fetch_from_remote( Some(db) => (db.get(fs, commit_id) catch { _ => None }) is Some(_) None => false } - if !(has_target) { + if !has_target { raise @bitcore.GitError::PackfileError( "No packfile returned and missing object \{commit_id.to_hex()}", ) } } write_ref_file(fs, git_dir, remote_ref, commit_id) - if !(quiet) { + if !quiet { print_line("From \{remote_url}") } match prev_id { None => - if !(quiet) { + if !quiet { print_line(" * [new branch] \{refname} -> \{remote_ref}") } Some(pid) => - if !(quiet) { + if !quiet { print_line( " \{pid.to_hex()}..\{commit_id.to_hex()} \{refname} -> \{remote_ref}", ) @@ -3323,7 +3323,7 @@ fn push_objects_dir_has_object( return true } let alternates_path = normalized_dir + "/info/alternates" - if !(fs.is_file(alternates_path)) { + if !fs.is_file(alternates_path) { return false } let alternate_bytes = fs.read_file(alternates_path) catch { @@ -3603,7 +3603,7 @@ async fn remote_show( break } } - if !(dest_ok) { + if !dest_ok { continue } if local_refs.contains(rname) { @@ -3616,7 +3616,7 @@ async fn remote_show( emitted[rname] = true } for lname, _ in local_refs { - if !(emitted.contains(lname)) { + if !emitted.contains(lname) { print_line(" \{lname} stale (use 'git remote prune' to remove)") } } @@ -3673,7 +3673,7 @@ async fn remote_show( } } if rc.push.length() > 0 || no_query { - let status_query = !(no_query) && remote_git_dir is Some(_) + let status_query = !no_query && remote_git_dir is Some(_) if status_query { print_line(" Local refs configured for 'git push':") } else { @@ -3727,7 +3727,7 @@ async fn remote_show( } if status_query && spec.src.has_prefix("refs/") && - !(spec.src.has_prefix("refs/heads/")) { + !spec.src.has_prefix("refs/heads/") { continue } let src_display = if spec.src.length() == 0 { diff --git a/src/cmd/bit/repack.mbt b/src/cmd/bit/repack.mbt index 7bb6c1af..fcff00cc 100644 --- a/src/cmd/bit/repack.mbt +++ b/src/cmd/bit/repack.mbt @@ -91,9 +91,7 @@ async fn handle_repack(args : Array[String]) -> Unit raise Error { } } else if arg == "--path-walk" { path_walk = true - } else if arg.has_prefix("-") && - !(arg.has_prefix("--")) && - arg.length() > 1 { + } else if arg.has_prefix("-") && !arg.has_prefix("--") && arg.length() > 1 { // Parse combined short flags like -ad, -adq, -Adl, etc. for j in 1.. Unit raise Error { // explicitly disabled via --no-write-bitmap-index or config. let is_bare = root == git_dir || is_bare_repo_dir(root) let bitmap_from_cmdline = write_bitmap - if !(write_bitmap) && !(no_write_bitmap) && all { + if !write_bitmap && !no_write_bitmap && all { // Check repack.writeBitmaps config, defaulting to true for bare repos let config_val = bit_config_get(git_dir, "repack", "writeBitmaps") match config_val { @@ -133,7 +131,7 @@ async fn handle_repack(args : Array[String]) -> Unit raise Error { } // When bitmaps were auto-enabled (not explicitly from command line), // suppress them if .keep packs exist (git behavior). - if write_bitmap && !(bitmap_from_cmdline) && !(pack_kept_objects) { + if write_bitmap && !bitmap_from_cmdline && !pack_kept_objects { let entries = fs.readdir(pack_dir) catch { _ => [] } let has_keep = entries.iter().any(fn(e) { e.has_suffix(".keep") }) if has_keep { @@ -158,21 +156,21 @@ async fn handle_repack(args : Array[String]) -> Unit raise Error { // so only loose objects are packed (existing packs are kept). po_args.push("--all") po_args.push("--reflog") - if !(all) { + if !all { po_args.push("--unpacked") po_args.push("--incremental") } if local_only { po_args.push("--local") } - if !(pack_kept_objects) { + if !pack_kept_objects { po_args.push("--honor-pack-keep") } po_args.push("--non-empty") if quiet { po_args.push("-q") } - if write_bitmap && !(no_write_bitmap) { + if write_bitmap && !no_write_bitmap { po_args.push("--write-bitmap-index") } if keep_unreachable { @@ -248,7 +246,7 @@ async fn handle_repack(args : Array[String]) -> Unit raise Error { ignore(dev_null) if code != 0 { let err_text = stderr_data.text() catch { _ => "" } - if err_text.length() > 0 && !(quiet) { + if err_text.length() > 0 && !quiet { @stdio.stderr.write(err_text) } // pack-objects returns 1 with --non-empty when nothing to pack — that's ok @@ -276,7 +274,7 @@ async fn handle_repack(args : Array[String]) -> Unit raise Error { } let stem = midx_pack_stem(old_pack) // Skip packs with .keep files (unless --pack-kept-objects) - if !(pack_kept_objects) && fs.is_file(pack_dir + "/" + stem + ".keep") { + if !pack_kept_objects && fs.is_file(pack_dir + "/" + stem + ".keep") { continue } // Skip packs in --keep-pack list @@ -299,7 +297,7 @@ async fn handle_repack(args : Array[String]) -> Unit raise Error { } } // Update server info (objects/info/packs) unless -n - if !(no_update_server_info) { + if !no_update_server_info { repack_update_server_info(fs, git_dir, pack_dir) } // Write multi-pack-index if requested @@ -307,7 +305,7 @@ async fn handle_repack(args : Array[String]) -> Unit raise Error { midx_write( fs, pack_dir, - !(quiet), + !quiet, None, false, write_bitmap, @@ -373,7 +371,7 @@ fn repack_update_server_info( let entries = fs.readdir(pack_dir) catch { _ => return } let buf = StringBuilder::new() for entry in entries { - if entry.has_suffix(".pack") && !(entry.has_prefix(".tmp-")) { + if entry.has_suffix(".pack") && !entry.has_prefix(".tmp-") { buf.write_string("P ") buf.write_string(entry) buf.write_string("\n") @@ -415,7 +413,7 @@ async fn repack_fallback( let result = @bitlib.repack_repo(fs, fs, root) catch { _ => None } match result { Some(info) => { - if !(quiet) { + if !quiet { let hex = info.pack_id.to_hex() print_line( "Repacked \{info.object_count} objects into pack-\{String::unsafe_substring(hex, start=0, end=8)}", @@ -445,7 +443,7 @@ async fn repack_fallback( } } } - None => if !(quiet) { print_line("Nothing to repack.") } + None => if !quiet { print_line("Nothing to repack.") } } } diff --git a/src/cmd/bit/replace.mbt b/src/cmd/bit/replace.mbt index a6cf1848..3d638336 100644 --- a/src/cmd/bit/replace.mbt +++ b/src/cmd/bit/replace.mbt @@ -80,7 +80,7 @@ async fn handle_replace(args : Array[String]) -> Unit raise Error { } continue } - _ if arg.has_prefix("-") && !(delete_mode) => { + _ if arg.has_prefix("-") && !delete_mode => { eprint_line("error: unknown option '\{arg}'") @sys.exit(129) } @@ -135,14 +135,14 @@ async fn handle_replace(args : Array[String]) -> Unit raise Error { replace_list(rfs, git_dir, pattern, format) return } - if positional.length() == 2 && !(list_mode) { + if positional.length() == 2 && !list_mode { // Create mode: let object_ref = positional[0] let replacement_ref = positional[1] replace_create(rfs, wfs, git_dir, object_ref, replacement_ref, force) return } - if positional.length() == 1 && !(list_mode) { + if positional.length() == 1 && !list_mode { // With one argument and no subcommand flags, it's list with a pattern replace_list(rfs, git_dir, Some(positional[0]), format) return @@ -175,17 +175,17 @@ async fn replace_list( format : String, ) -> Unit { let replace_dir = git_dir + "/refs/replace" - if !(fs.is_dir(replace_dir)) { + if !fs.is_dir(replace_dir) { return } let entries = fs.readdir(replace_dir) catch { _ => return } let oids : Array[String] = [] for name in entries { - if name.length() != 40 || !(is_hex_string(name)) { + if name.length() != 40 || !is_hex_string(name) { continue } match pattern { - Some(pat) => if !(@ignore.match_glob(pat, name)) { continue } + Some(pat) => if !@ignore.match_glob(pat, name) { continue } None => () } oids.push(name) @@ -285,7 +285,7 @@ async fn replace_create( } let replace_dir = git_dir + "/refs/replace" let ref_path = replace_dir + "/" + object_id.to_hex() - if !(force) && fs.is_file(ref_path) { + if !force && fs.is_file(ref_path) { eprint_line( "error: replace ref 'refs/replace/\{object_id.to_hex()}' already exists", ) @@ -305,7 +305,7 @@ async fn replace_delete( let oid = replace_resolve_to_oid(fs, git_dir, ref_arg) let hex = oid.to_hex() let ref_path = git_dir + "/refs/replace/" + hex - if !(fs.is_file(ref_path)) { + if !fs.is_file(ref_path) { eprint_line("error: replace ref 'refs/replace/\{hex}' not found") @sys.exit(1) } @@ -361,7 +361,7 @@ async fn replace_graft( // Create replace ref let replace_dir = git_dir + "/refs/replace" let ref_path = replace_dir + "/" + commit_id.to_hex() - if !(force) && fs.is_file(ref_path) { + if !force && fs.is_file(ref_path) { eprint_line( "error: replace ref 'refs/replace/\{commit_id.to_hex()}' already exists", ) @@ -392,7 +392,7 @@ fn replace_rebuild_commit( if in_header { if line == "\n" || line == "" { // End of header: if we haven't written parents yet, do so now - if !(wrote_parents) { + if !wrote_parents { for parent_id in new_parents { append_str("parent " + parent_id.to_hex() + "\n") } @@ -411,7 +411,7 @@ fn replace_rebuild_commit( } if line.has_prefix("parent ") { // Skip original parent lines; we'll write new ones - if !(wrote_parents) && past_tree { + if !wrote_parents && past_tree { for parent_id in new_parents { append_str("parent " + parent_id.to_hex() + "\n") } @@ -421,7 +421,7 @@ fn replace_rebuild_commit( } // Other header lines (author, committer, etc.) // If we haven't written parents yet and we're past tree, do it now - if !(wrote_parents) && past_tree { + if !wrote_parents && past_tree { for parent_id in new_parents { append_str("parent " + parent_id.to_hex() + "\n") } @@ -464,7 +464,7 @@ async fn replace_convert_graft_file( force : Bool, ) -> Unit raise Error { let graft_path = git_dir + "/info/grafts" - if !(fs.is_file(graft_path)) { + if !fs.is_file(graft_path) { eprint_line("error: could not read graft file '\{graft_path}'") @sys.exit(1) } diff --git a/src/cmd/bit/request_pull.mbt b/src/cmd/bit/request_pull.mbt index 0833fbeb..eb2a2ebb 100644 --- a/src/cmd/bit/request_pull.mbt +++ b/src/cmd/bit/request_pull.mbt @@ -9,7 +9,7 @@ async fn handle_request_pull(args : Array[String]) -> Unit raise Error { match arg { "-p" => () _ if arg.has_prefix("--signoff=") => () - _ if !(arg.has_prefix("-")) => positional.push(arg) + _ if !arg.has_prefix("-") => positional.push(arg) _ if arg.has_prefix("-") => warn_unimplemented_arg("request-pull", arg) _ => () } @@ -124,7 +124,7 @@ fn plumb_get_first_line_of_commit(data : Bytes) -> String { let mut in_body = false for line_view in text.split("\n") { let line = line_view.to_string() - if !(in_body) { + if !in_body { if line.length() == 0 { in_body = true } diff --git a/src/cmd/bit/rerere.mbt b/src/cmd/bit/rerere.mbt index d8707666..bc41af1b 100644 --- a/src/cmd/bit/rerere.mbt +++ b/src/cmd/bit/rerere.mbt @@ -14,7 +14,7 @@ async fn handle_rerere(args : Array[String]) -> Unit { ) return } - _ if !(arg.has_prefix("-")) => positional.push(arg) + _ if !arg.has_prefix("-") => positional.push(arg) _ if arg.has_prefix("-") => warn_unimplemented_arg("rerere", arg) _ => () } @@ -42,7 +42,7 @@ async fn handle_rerere(args : Array[String]) -> Unit { has_path = true ignore(positional[j]) } - if !(has_path) { + if !has_path { eprint_line("usage: git rerere forget ...") @sys.exit(1) } @@ -114,7 +114,7 @@ async fn rerere_gc(fs : OsFs, rr_cache_dir : String) -> Unit { let path = rr_cache_dir + "/" + entry if fs.is_dir(path) { let postimage = path + "/postimage" - if !(fs.is_file(postimage)) { + if !fs.is_file(postimage) { let sub_entries = fs.readdir(path) catch { _ => continue } for sub in sub_entries { fs.remove_file(path + "/" + sub) catch { diff --git a/src/cmd/bit/reset.mbt b/src/cmd/bit/reset.mbt index 1f266568..8f6df4a9 100644 --- a/src/cmd/bit/reset.mbt +++ b/src/cmd/bit/reset.mbt @@ -70,7 +70,7 @@ async fn handle_reset(args : Array[String]) -> Unit raise Error { @bitlib.ResetMode::Mixed => true _ => false } - if !(mixed_mode) { + if !mixed_mode { eprint_line("fatal: Cannot do hard/soft reset with paths.") @sys.exit(1) } @@ -127,7 +127,7 @@ async fn handle_reset(args : Array[String]) -> Unit raise Error { git_dir, skip_override=Some(skip_before_reset), ) - if !(quiet) && changed.length() > 0 { + if !quiet && changed.length() > 0 { print_line("Unstaged changes after reset:") for path in changed { print_line("M\t" + path) @@ -139,7 +139,7 @@ async fn handle_reset(args : Array[String]) -> Unit raise Error { @bitlib.ResetMode::Hard => true _ => false } - if hard_mode && !(quiet) { + if hard_mode && !quiet { let short_id = String::unsafe_substring(commit_id.to_hex(), start=0, end=7) let subject = reset_commit_subject_bytes(rfs, git_dir, commit_id) reset_print_hard_reset_message(short_id, subject) @@ -185,13 +185,13 @@ fn reset_mixed_paths( let current_entries = @bitlib.read_index_entries(rfs, git_dir) let out_map : Map[String, @bitlib.IndexEntry] = {} for entry in current_entries { - if !(reset_pathspec_matches_any(normalized_paths, entry.path)) { + if !reset_pathspec_matches_any(normalized_paths, entry.path) { out_map[entry.path] = entry } } for item in tree_files.to_array() { let (path, info) = item - if !(reset_pathspec_matches_any(normalized_paths, path)) { + if !reset_pathspec_matches_any(normalized_paths, path) { continue } let size = if info.mode == 0o160000 { @@ -312,7 +312,7 @@ fn reset_apply_intent_to_add( continue } let abs = root + "/" + entry.path - if !(rfs.is_file(abs)) { + if !rfs.is_file(abs) { continue } merged.push( @@ -360,7 +360,7 @@ async fn reset_refresh_index_entries( let abs = root + "/" + entry.path let mut out_entry = entry let mut changed = false - if !(rfs.is_file(abs)) { + if !rfs.is_file(abs) { changed = true } else { let content = rfs.read_file(abs) catch { @@ -369,7 +369,7 @@ async fn reset_refresh_index_entries( Bytes::default() } } - if !(changed) { + if !changed { let id = @bitcore.hash_blob(content) if id == entry.id { let mut mtime_sec = entry.mtime_sec @@ -403,7 +403,7 @@ async fn reset_refresh_index_entries( } } } - if changed && !(skip.contains(entry.path)) { + if changed && !skip.contains(entry.path) { changed_map[entry.path] = true } updated.push(out_entry) @@ -439,16 +439,14 @@ fn reset_read_skip_worktree_paths( } } let index_path = git_dir + "/index" - if !(fs.is_file(index_path)) { + if !fs.is_file(index_path) { return out } let data = fs.read_file(index_path) catch { _ => return out } if data.length() < 12 + 20 { return out } - if !( - data[0] == b'D' && data[1] == b'I' && data[2] == b'R' && data[3] == b'C', - ) { + if !(data[0] == b'D' && data[1] == b'I' && data[2] == b'R' && data[3] == b'C') { return out } let count = reset_read_u32_be(data, 8) @@ -502,16 +500,14 @@ fn reset_index_has_unmerged_entries( git_dir : String, ) -> Bool { let path = git_dir + "/index" - if !(fs.is_file(path)) { + if !fs.is_file(path) { return false } let data = fs.read_file(path) catch { _ => return false } if data.length() < 12 + 20 { return false } - if !( - data[0] == b'D' && data[1] == b'I' && data[2] == b'R' && data[3] == b'C', - ) { + if !(data[0] == b'D' && data[1] == b'I' && data[2] == b'R' && data[3] == b'C') { return false } let count = reset_read_u32_be(data, 8) @@ -815,7 +811,7 @@ fn reset_resolve_common_git_dir( git_dir : String, ) -> String { let commondir_path = git_dir + "/commondir" - if !(fs.is_file(commondir_path)) { + if !fs.is_file(commondir_path) { return git_dir } let raw = decode_bytes( diff --git a/src/cmd/bit/restore.mbt b/src/cmd/bit/restore.mbt index ab14c9b2..456eb322 100644 --- a/src/cmd/bit/restore.mbt +++ b/src/cmd/bit/restore.mbt @@ -108,7 +108,7 @@ async fn handle_restore(args : Array[String]) -> Unit raise Error { eprint_line("fatal: you must specify path(s) to restore") @sys.exit(128) } - if !(staged) && !(worktree) { + if !staged && !worktree { worktree = true } let special_name = restore_first_special_mode_name( @@ -135,16 +135,16 @@ async fn handle_restore(args : Array[String]) -> Unit raise Error { ) return } - if source is None && worktree && !(staged) { + if source is None && worktree && !staged { let (matched_unmerged, filtered_paths) = restore_filter_unmerged_paths( rfs, git_dir, paths, ) if matched_unmerged.length() > 0 { - if !(ignore_unmerged) { + if !ignore_unmerged { eprint_line("error: path '\{matched_unmerged[0]}' is unmerged") @sys.exit(1) } - if !(quiet) { + if !quiet { for path in matched_unmerged { eprint_line("warning: path '\{path}' is unmerged") } @@ -391,7 +391,7 @@ fn restore_expand_cli_paths( for path in raw_paths { let matched = restore_expand_single_cli_path(path, tracked_paths) for item in matched { - if !(seen.contains(item)) { + if !seen.contains(item) { expanded.push(item) seen[item] = true } @@ -408,13 +408,13 @@ fn restore_collect_tracked_paths( let tracked : Array[String] = [] let seen : Map[String, Bool] = {} for entry in @bitlib.read_index_entries(rfs, git_dir) { - if !(seen.contains(entry.path)) { + if !seen.contains(entry.path) { tracked.push(entry.path) seen[entry.path] = true } } for path, _ in @bitlib.read_unmerged_paths(rfs, git_dir) { - if !(seen.contains(path)) { + if !seen.contains(path) { tracked.push(path) seen[path] = true } diff --git a/src/cmd/bit/rev_list.mbt b/src/cmd/bit/rev_list.mbt index 3091a0ce..a2c29309 100644 --- a/src/cmd/bit/rev_list.mbt +++ b/src/cmd/bit/rev_list.mbt @@ -305,7 +305,7 @@ async fn handle_rev_list(args : Array[String]) -> Unit raise Error { end=next.length(), ) rev_list_add_glob_refs(fs, git_dir, pattern, excludes) - } else if !(next.has_prefix("-")) { + } else if !next.has_prefix("-") { excludes.push(next) } i += 1 @@ -334,7 +334,7 @@ async fn handle_rev_list(args : Array[String]) -> Unit raise Error { } _ if arg.has_prefix("^") => excludes.push(String::unsafe_substring(arg, start=1, end=arg.length())) - _ if !(arg.has_prefix("-")) && arg.contains("..") => { + _ if !arg.has_prefix("-") && arg.contains("..") => { // Handle A..B (equivalent to ^A B) and A...B (symmetric difference) let dot_pos = rev_list_find_range_dots(arg) match dot_pos { @@ -362,7 +362,7 @@ async fn handle_rev_list(args : Array[String]) -> Unit raise Error { None => refs.push(arg) } } - _ if !(arg.has_prefix("-")) => + _ if !arg.has_prefix("-") => // Handle ^@, ^!, ^-N parent suffixes if arg.has_suffix("^@") { // commit^@ = all parents of commit @@ -437,7 +437,7 @@ async fn handle_rev_list(args : Array[String]) -> Unit raise Error { continue } if line == "--not" { - stdin_not_mode = !(stdin_not_mode) + stdin_not_mode = !stdin_not_mode } else if line == "--all" { all = true } else if line == "--branches" { @@ -494,7 +494,7 @@ async fn handle_rev_list(args : Array[String]) -> Unit raise Error { stdin_end_of_options = true } else if line == "--" { () // pathspec separator, ignore - } else if line.has_prefix("-") && !(line.has_prefix("^")) { + } else if line.has_prefix("-") && !line.has_prefix("^") { // Unknown option in stdin mode eprint_line("fatal: invalid option '\{line}' in --stdin mode") @sys.exit(128) @@ -521,7 +521,7 @@ async fn handle_rev_list(args : Array[String]) -> Unit raise Error { let all_refs = @bitrepo.show_ref(fs, git_dir) for item in all_refs { let (name, _) = item - if !(rev_list_ref_excluded(name, rev_list_exclude_patterns)) { + if !rev_list_ref_excluded(name, rev_list_exclude_patterns) { refs.push(name) } } @@ -540,10 +540,10 @@ async fn handle_rev_list(args : Array[String]) -> Unit raise Error { // If no refs specified and no explicit ref source was given, default to HEAD if refs.length() == 0 && excludes.length() == 0 && - !(indexed_objects) && - !(stdin) && - !(all) && - !(had_ref_source) && + !indexed_objects && + !stdin && + !all && + !had_ref_source && rev_list_exclude_patterns.length() == 0 { refs.push("HEAD") } @@ -561,7 +561,7 @@ async fn handle_rev_list(args : Array[String]) -> Unit raise Error { match @bitrepo.rev_parse(fs, git_dir, spec) { Some(id) => { let hex = id.to_hex() - if id != @bitcore.ObjectId::zero() && !(start_seen.contains(hex)) { + if id != @bitcore.ObjectId::zero() && !start_seen.contains(hex) { start_seen[hex] = true start_ids.push(id) } @@ -600,12 +600,12 @@ async fn handle_rev_list(args : Array[String]) -> Unit raise Error { Some(obj) if obj.obj_type == @bitcore.ObjectType::Commit => { let info = @bitcore.parse_commit(obj.data) if first_parent && info.parents.length() > 0 { - if !(visited.contains(info.parents[0].to_hex())) { + if !visited.contains(info.parents[0].to_hex()) { queue.push(info.parents[0]) } } else { for parent in info.parents { - if !(visited.contains(parent.to_hex())) { + if !visited.contains(parent.to_hex()) { queue.push(parent) } } @@ -709,10 +709,10 @@ async fn handle_rev_list(args : Array[String]) -> Unit raise Error { _ => () } } - if indexed_objects && !(indexed_objects_negated) { + if indexed_objects && !indexed_objects_negated { for item in indexed_visible_objects { let hex = item.0.to_hex() - if !(object_seen.contains(hex)) { + if !object_seen.contains(hex) { object_seen[hex] = true object_ids.push(item) } @@ -828,7 +828,7 @@ async fn handle_rev_list(args : Array[String]) -> Unit raise Error { for item in object_ids { let (id, path) = item let hex = id.to_hex() - if !(commit_set.contains(hex)) { + if !commit_set.contains(hex) { let line = if no_object_names || use_bitmap || path.length() == 0 { hex } else { @@ -855,7 +855,7 @@ fn rev_list_is_digit(c : Char) -> Bool { fn rev_list_is_short_max_count_arg(arg : String) -> Bool { arg.length() > 1 && arg.get_char(0).unwrap() == '-' && - !(arg.has_prefix("--")) && + !arg.has_prefix("--") && rev_list_is_digit(arg.get_char(1).unwrap()) } @@ -908,7 +908,7 @@ fn walk_commits_to_map( Some(o) if o.obj_type == @bitcore.ObjectType::Commit => { let info = @bitcore.parse_commit(o.data) catch { _ => continue } for parent in info.parents { - if !(out.contains(parent.to_hex())) { + if !out.contains(parent.to_hex()) { queue.push(parent) } } @@ -939,7 +939,7 @@ fn collect_tree_objects( let entries = @bitcore.parse_tree(o.data) catch { _ => return () } for entry in entries { let entry_hex = entry.id.to_hex() - if !(visited.contains(entry_hex)) { + if !visited.contains(entry_hex) { let entry_path = if parent_path.length() == 0 { entry.name } else { @@ -1015,7 +1015,7 @@ fn collect_tree_objects_excluding_index( Some(index_hex) if index_hex == entry_hex => continue _ => () } - if !(visited.contains(entry_hex)) { + if !visited.contains(entry_hex) { visited[entry_hex] = true out.push((entry.id, entry_path)) } @@ -1044,7 +1044,7 @@ fn rev_list_collect_index_objects( } index_by_path[entry.path] = entry path_ids[entry.path] = hex - if !(unique_ids.contains(hex)) { + if !unique_ids.contains(hex) { unique_ids[hex] = true visible.push((entry.id, entry.path)) } @@ -1101,18 +1101,16 @@ fn rev_list_collect_matching_index_trees( parent_path + "/" + entry.name } if entry.mode.has_prefix("40") { - if !( - rev_list_collect_matching_index_trees( - db, - fs, - entry.id, - index_by_path, - matched_paths, - visible, - unique_ids, - path_ids, - parent_path=entry_path, - ), + if !rev_list_collect_matching_index_trees( + db, + fs, + entry.id, + index_by_path, + matched_paths, + visible, + unique_ids, + path_ids, + parent_path=entry_path, ) { return false } @@ -1133,7 +1131,7 @@ fn rev_list_collect_matching_index_trees( } let hex = tree_id.to_hex() path_ids[parent_path] = hex - if parent_path.length() > 0 && !(unique_ids.contains(hex)) { + if parent_path.length() > 0 && !unique_ids.contains(hex) { unique_ids[hex] = true visible.push((tree_id, parent_path)) } @@ -1261,7 +1259,7 @@ async fn rev_list_test_bitmap(fs : OsFs, git_dir : String) -> Unit raise Error { bmp_checksum_ok = false } } - if !(bmp_checksum_ok) { + if !bmp_checksum_ok { eprint_line("error: bitmap checksum mismatch") @sys.exit(1) return @@ -1288,7 +1286,7 @@ async fn rev_list_test_bitmap(fs : OsFs, git_dir : String) -> Unit raise Error { } bmp_pos = bmp_pos + 4 + 4 + word_count * 8 + 4 } - if !(valid) { + if !valid { eprint_line("error: bitmap structure invalid") @sys.exit(1) return @@ -1485,7 +1483,7 @@ fn rev_list_topo_sort_impl( for phex in ps { let deg = in_degree.get(phex).unwrap_or(1) - 1 in_degree[phex] = deg - if deg == 0 && !(emitted.get(phex).unwrap_or(false)) { + if deg == 0 && !emitted.get(phex).unwrap_or(false) { ready.push(phex) } } diff --git a/src/cmd/bit/rev_parse.mbt b/src/cmd/bit/rev_parse.mbt index 65e8340e..d50e7f00 100644 --- a/src/cmd/bit/rev_parse.mbt +++ b/src/cmd/bit/rev_parse.mbt @@ -185,7 +185,7 @@ async fn handle_rev_parse(args : Array[String]) -> Unit raise Error { continue } let a = args[vi] - if !(end_of_opts) { + if !end_of_opts { match a { "--verify" | "--quiet" @@ -215,7 +215,7 @@ async fn handle_rev_parse(args : Array[String]) -> Unit raise Error { _ => () } } - if !(a.has_prefix("-")) || end_of_opts { + if !a.has_prefix("-") || end_of_opts { rev_args.push(a) } vi += 1 @@ -224,7 +224,7 @@ async fn handle_rev_parse(args : Array[String]) -> Unit raise Error { rev_args.push(d) } if rev_args.length() != 1 { - if !(quiet) { + if !quiet { eprint_line("fatal: Needed a single revision") } @sys.exit(128) @@ -257,7 +257,7 @@ async fn handle_rev_parse(args : Array[String]) -> Unit raise Error { } } None => { - if !(quiet) { + if !quiet { eprint_line("fatal: Needed a single revision") } @sys.exit(128) @@ -494,7 +494,7 @@ async fn handle_rev_parse(args : Array[String]) -> Unit raise Error { "--symbolic-full-name" => () "--end-of-options" => { // Output --end-of-options itself in non-verify mode - if !(verify) && !(revs_only) { + if !verify && !revs_only { print_line("--end-of-options") } // All remaining args are revisions/paths, not options @@ -507,13 +507,13 @@ async fn handle_rev_parse(args : Array[String]) -> Unit raise Error { } // "--" still acts as separator in this mode if rev_arg == "--" { - if !(revs_only) { + if !revs_only { print_line("--") } process_index += 1 // Everything after "--" is a path while process_index < args.length() { - if !(revs_only) { + if !revs_only { let file_arg = args[process_index] match prefix { Some(p) => print_line(p + file_arg) @@ -566,7 +566,7 @@ async fn handle_rev_parse(args : Array[String]) -> Unit raise Error { } } None => - if !(revs_only) { + if !revs_only { raise @bitcore.GitError::InvalidObject( "unknown revision: " + rev_arg, ) @@ -596,7 +596,7 @@ async fn handle_rev_parse(args : Array[String]) -> Unit raise Error { } } None => - if !(revs_only) { + if !revs_only { raise @bitcore.GitError::InvalidObject( "unknown revision: " + rev_arg, ) @@ -647,13 +647,13 @@ async fn handle_rev_parse(args : Array[String]) -> Unit raise Error { print_line("--min-age=\{timestamp}") } "--" => { - if !(revs_only) { + if !revs_only { print_line("--") } process_index += 1 // Everything after "--" is a file path while process_index < args.length() { - if !(revs_only) { + if !revs_only { let file_arg = args[process_index] match prefix { Some(p) => print_line(p + file_arg) @@ -892,7 +892,7 @@ async fn handle_rev_parse(args : Array[String]) -> Unit raise Error { match name { Some(value) => print_line("^\{value}") None => - if !(revs_only) { + if !revs_only { raise @bitcore.GitError::InvalidObject( "unknown revision: " + arg, ) @@ -911,7 +911,7 @@ async fn handle_rev_parse(args : Array[String]) -> Unit raise Error { } } None => - if !(revs_only) { + if !revs_only { raise @bitcore.GitError::InvalidObject( "unknown revision: " + arg, ) @@ -926,7 +926,7 @@ async fn handle_rev_parse(args : Array[String]) -> Unit raise Error { match name { Some(value) => print_line(value) None => - if !(revs_only) { + if !revs_only { raise @bitcore.GitError::InvalidObject( "unknown revision: " + arg, ) @@ -946,7 +946,7 @@ async fn handle_rev_parse(args : Array[String]) -> Unit raise Error { match name { Some(value) => print_line(value) None => - if !(revs_only) { + if !revs_only { raise @bitcore.GitError::InvalidObject( "unknown revision: " + arg, ) @@ -957,7 +957,7 @@ async fn handle_rev_parse(args : Array[String]) -> Unit raise Error { resolve_fetch_head_oid(fs, git_dir) } else if effective_arg.has_prefix(":") && effective_arg.length() > 1 && - !(effective_arg.has_prefix(":/")) { + !effective_arg.has_prefix(":/") { resolve_index_path_oid(fs, git_dir, effective_arg) } else if effective_arg.find("@{") is Some(_) { match resolve_upstream_push_oid(fs, git_dir, effective_arg, quiet) { @@ -989,7 +989,7 @@ async fn handle_rev_parse(args : Array[String]) -> Unit raise Error { if prefix is Some(p) { // With --prefix, treat unresolved args as file paths print_line(p + arg) - } else if !(revs_only) { + } else if !revs_only { raise @bitcore.GitError::InvalidObject( "unknown revision: " + arg, ) @@ -1101,7 +1101,7 @@ fn rev_parse_resolve_common_git_dir( git_dir : String, ) -> String { let commondir_path = git_dir + "/commondir" - if !(fs.is_file(commondir_path)) { + if !fs.is_file(commondir_path) { return git_dir } let raw = decode_bytes( @@ -1299,7 +1299,7 @@ async fn resolve_reflog_by_date( match prev_ooid { Some(po) => { result_oid = Some(entry.new_id) - if po != entry.new_id && !(quiet) { + if po != entry.new_id && !quiet { eprint_line( "warning: log for ref \{refname} has gap after \{cutoff_date}", ) @@ -1311,7 +1311,7 @@ async fn resolve_reflog_by_date( } else { let current = @bitrepo.rev_parse(fs, git_dir, refname) result_oid = current - if !(quiet) { + if !quiet { match current { Some(cur_oid) => if cur_oid != entry.new_id { @@ -1343,7 +1343,7 @@ async fn resolve_reflog_by_date( } else { oldest.old_id } - if !(quiet) { + if !quiet { eprint_line( "warning: log for '\{display_ref}' only goes back to \{oldest_date}", ) @@ -1518,7 +1518,7 @@ async fn resolve_upstream_push_symbolic( Some(ref_name) } Some(Err(msg)) => { - if !(quiet) { + if !quiet { eprint_line("fatal: " + msg) } @sys.exit(128) @@ -1547,7 +1547,7 @@ async fn resolve_upstream_push_oid( @bitrepo.rev_parse(fs, git_dir, ref_name) } Some(Err(msg)) => { - if !(quiet) { + if !quiet { eprint_line("fatal: " + msg) } @sys.exit(128) @@ -1965,7 +1965,7 @@ fn rev_parse_resolve_git_dir_arg( ///| async fn rev_parse_require_repo(in_repo : Bool) -> Unit { - if !(in_repo) { + if !in_repo { eprint_line( "fatal: not a git repository (or any of the parent directories): .git", ) @@ -2060,7 +2060,7 @@ fn rev_parse_read_bisect_refs( let result : Array[(String, String)] = [] let bisect_dir = git_dir + "/refs/bisect" let is_dir = @fs.is_dir(bisect_dir) catch { _ => false } - if !(is_dir) { + if !is_dir { return result } let entries = @fs.read_dir(bisect_dir) catch { _ => return result } @@ -2100,7 +2100,7 @@ fn rev_parse_read_bisect_refs( break } } - if !(found) { + if !found { result.push((refname, oid)) } } @@ -2129,7 +2129,7 @@ fn rev_parse_apply_prefix_to_colon_path( start=colon_idx + 1, end=spec.length(), ) - if !(path_part.has_prefix("./")) && !(path_part.has_prefix("../")) { + if !path_part.has_prefix("./") && !path_part.has_prefix("../") { return spec } let rev_part = String::unsafe_substring(spec, start=0, end=colon_idx) @@ -2203,7 +2203,7 @@ async fn handle_parseopt(args : Array[String]) -> Unit raise Error { } usage_lines.push(lines[i]) } - if !(found_separator) { + if !found_separator { eprint_line("fatal: premature end of input") @sys.exit(128) } @@ -2432,12 +2432,12 @@ fn parseopt_format_help( } let mut has_visible_opts = false for opt in opts { - if opt.opt_type == ParseoptOption && (show_all || !(opt.hidden)) { + if opt.opt_type == ParseoptOption && (show_all || !opt.hidden) { has_visible_opts = true break } } - if !(has_visible_opts) { + if !has_visible_opts { out.write_char('\n') return out.to_string() } @@ -2455,7 +2455,7 @@ fn parseopt_format_help( } ParseoptOption => () } - if !(show_all) && opt.hidden { + if !show_all && opt.hidden { continue } if need_newline { @@ -2480,7 +2480,7 @@ fn parseopt_format_help( out.write_string("--") out.write_string(long_name) pos = pos + 2 + long_name.length() - if long_name.has_prefix("no-") && !(opt.non_neg) { + if long_name.has_prefix("no-") && !opt.non_neg { positive_name = Some( String::unsafe_substring(long_name, start=3, end=long_name.length()), ) @@ -2503,7 +2503,7 @@ fn parseopt_format_help( break } } - if !(found) { + if !found { out.write_string(" --") out.write_string(pname) let ppos = 4 + 2 + pname.length() @@ -2525,12 +2525,12 @@ fn parseopt_format_help( ///| fn parseopt_format_argh(opt : ParseoptOpt) -> String { - if !(opt.has_arg) && !(opt.opt_arg) { + if !opt.has_arg && !opt.opt_arg { return "" } let has_custom_argh = opt.argh.length() > 0 let argh = if has_custom_argh { opt.argh } else { "..." } - let literal = !(has_custom_argh) || parseopt_argh_is_literal(argh) + let literal = !has_custom_argh || parseopt_argh_is_literal(argh) if opt.opt_arg { if opt.long_name.length() > 0 { if literal { @@ -2552,12 +2552,12 @@ fn parseopt_format_argh(opt : ParseoptOpt) -> String { ///| fn parseopt_format_argh_short(opt : ParseoptOpt) -> String { - if !(opt.has_arg) && !(opt.opt_arg) { + if !opt.has_arg && !opt.opt_arg { return "" } let has_custom_argh = opt.argh.length() > 0 let argh = if has_custom_argh { opt.argh } else { "..." } - let literal = !(has_custom_argh) || parseopt_argh_is_literal(argh) + let literal = !has_custom_argh || parseopt_argh_is_literal(argh) if opt.opt_arg { if literal { "[" + argh + "]" @@ -2756,7 +2756,7 @@ fn parseopt_match_long( continue } let long_name = opt.long_name - let allow_unset = !(opt.non_neg) + let allow_unset = !opt.non_neg let mut opt_unset = false let mut check_name = long_name if long_name.has_prefix("no-") { @@ -2769,11 +2769,11 @@ fn parseopt_match_long( } else if arg_starts_with_no_no { continue } - let xor_unset = if is_unset { !(opt_unset) } else { opt_unset } - if xor_unset && !(allow_unset) { + let xor_unset = if is_unset { !opt_unset } else { opt_unset } + if xor_unset && !allow_unset { continue } - let effective_unset = if is_unset { !(opt_unset) } else { opt_unset } + let effective_unset = if is_unset { !opt_unset } else { opt_unset } if no_stripped == check_name { exact_match = Some((opt, effective_unset)) break @@ -2785,10 +2785,7 @@ fn parseopt_match_long( } abbrev_match = Some((opt, effective_unset)) } - if allow_unset && - !(is_unset) && - !(arg_starts_with_no_no) && - !(opt_unset) { + if allow_unset && !is_unset && !arg_starts_with_no_no && !opt_unset { let full_neg = "no-" + long_name if full_neg.has_prefix(opt_name) && opt_name.length() < full_neg.length() { match abbrev_match { @@ -2868,7 +2865,7 @@ fn parseopt_format_matched_long( } else { out.write_string(opt.long_name) } - } else if opt.short_name != '\u0000' && !(stuck_long) { + } else if opt.short_name != '\u0000' && !stuck_long { out.write_string(" -") out.write_char(opt.short_name) } else if opt.long_name.length() > 0 { @@ -2881,7 +2878,7 @@ fn parseopt_format_matched_long( if opt.has_arg || opt.opt_arg { match opt_value { Some(v) => { - if stuck_long && opt.long_name.length() > 0 && !(unset) { + if stuck_long && opt.long_name.length() > 0 && !unset { let out2 = StringBuilder::new() out2.write_string(" --") out2.write_string(opt.long_name) @@ -2889,7 +2886,7 @@ fn parseopt_format_matched_long( out2.write_string(shell_single_quote(v)) return ParseoptMatchOk(out2.to_string(), consumed) } - if !(stuck_long) { + if !stuck_long { out.write_char(' ') } else if opt.long_name.length() > 0 { out.write_char('=') @@ -2897,7 +2894,7 @@ fn parseopt_format_matched_long( out.write_string(shell_single_quote(v)) } None => - if opt.has_arg && !(opt.opt_arg) { + if opt.has_arg && !opt.opt_arg { if arg_idx + 1 < all_args.length() { let next_val = all_args[arg_idx + 1] consumed = 2 @@ -2964,14 +2961,14 @@ fn parseopt_match_short( out.write_char('=') out.write_string(shell_single_quote(rest)) } else { - if !(stuck_long) { + if !stuck_long { out.write_char(' ') } out.write_string(shell_single_quote(rest)) } ci = arg.length() } else { - if opt.has_arg && !(opt.opt_arg) { + if opt.has_arg && !opt.opt_arg { if arg_idx + consumed < all_args.length() { let next_val = all_args[arg_idx + consumed] consumed = consumed + 1 @@ -3068,7 +3065,7 @@ fn rev_parse_list_matching_refs( } // Build full pattern: prefix + pattern (for --glob, prefix is already in pattern) let full_pattern = if prefix.length() > 0 { prefix + pat } else { pat } - if !(rev_parse_glob_match(refname, full_pattern)) { + if !rev_parse_glob_match(refname, full_pattern) { continue } // Also try short name match for simple patterns @@ -3097,7 +3094,7 @@ fn rev_parse_list_matching_refs( break } } - if !(excluded) { + if !excluded { result.push((refname, oid)) } } @@ -3143,7 +3140,7 @@ async fn rev_parse_handle_range_op( let left_id = @bitrepo.rev_parse(fs, git_dir, left_spec) let right_id = @bitrepo.rev_parse(fs, git_dir, right_spec) guard left_id is Some(lid) && right_id is Some(rid) else { - if !(quiet) && !(revs_only) { + if !quiet && !revs_only { raise @bitcore.GitError::InvalidObject("unknown revision: " + arg) } return true @@ -3151,8 +3148,8 @@ async fn rev_parse_handle_range_op( // Verify both are commits (... only works with commits) let left_is_commit = rev_parse_is_commit(fs, git_dir, lid) let right_is_commit = rev_parse_is_commit(fs, git_dir, rid) - if !(left_is_commit) || !(right_is_commit) { - if !(quiet) && !(revs_only) { + if !left_is_commit || !right_is_commit { + if !quiet && !revs_only { raise @bitcore.GitError::InvalidObject("unknown revision: " + arg) } return true @@ -3232,7 +3229,7 @@ async fn rev_parse_handle_range_op( let left_id = @bitrepo.rev_parse(fs, git_dir, left_spec) let right_id = @bitrepo.rev_parse(fs, git_dir, right_spec) guard left_id is Some(lid) && right_id is Some(rid) else { - if !(quiet) && !(revs_only) { + if !quiet && !revs_only { raise @bitcore.GitError::InvalidObject("unknown revision: " + arg) } return true @@ -3410,7 +3407,7 @@ async fn rev_parse_handle_parent_suffix( if suffix_type == "@" { // ^@ = all parents guard base_id is Some(oid) else { - if !(quiet) && !(revs_only) { + if !quiet && !revs_only { eprint_line("fatal: bad revision '\{arg}'") @sys.exit(128) } @@ -3419,7 +3416,7 @@ async fn rev_parse_handle_parent_suffix( let parents = rev_parse_get_commit_parents(fs, git_dir, oid) if parents.length() == 0 { // tree object or root commit - error - if !(quiet) && !(revs_only) { + if !quiet && !revs_only { eprint_line("fatal: bad revision '\{arg}'") @sys.exit(128) } @@ -3446,7 +3443,7 @@ async fn rev_parse_handle_parent_suffix( if suffix_type == "!" { // ^! = commit itself, then ^parent1 ^parent2 ... guard base_id is Some(oid) else { - if !(quiet) && !(revs_only) { + if !quiet && !revs_only { eprint_line("fatal: bad revision '\{arg}'") @sys.exit(128) } @@ -3501,7 +3498,7 @@ async fn rev_parse_handle_parent_suffix( return true } guard base_id is Some(oid) else { - if !(quiet) && !(revs_only) { + if !quiet && !revs_only { eprint_line("fatal: bad revision '\{arg}'") @sys.exit(128) } diff --git a/src/cmd/bit/revert.mbt b/src/cmd/bit/revert.mbt index ee2f49f5..5dfc79d4 100644 --- a/src/cmd/bit/revert.mbt +++ b/src/cmd/bit/revert.mbt @@ -27,7 +27,7 @@ async fn handle_revert(args : Array[String]) -> Unit raise Error { "--continue" => do_continue = true "--abort" => do_abort = true "--skip" => do_skip = true - _ if !(arg.has_prefix("-")) => commits.push(arg) + _ if !arg.has_prefix("-") => commits.push(arg) _ => () } i += 1 @@ -39,7 +39,7 @@ async fn handle_revert(args : Array[String]) -> Unit raise Error { let orig_head_path = git_dir + "/ORIG_HEAD" // Handle --abort if do_abort { - if !(rfs.is_file(revert_head_path)) { + if !rfs.is_file(revert_head_path) { @stdio.stderr.write("error: no revert in progress") @sys.exit(1) } @@ -70,7 +70,7 @@ async fn handle_revert(args : Array[String]) -> Unit raise Error { } // Handle --skip if do_skip { - if !(rfs.is_file(revert_head_path)) { + if !rfs.is_file(revert_head_path) { @stdio.stderr.write("error: no revert in progress") @sys.exit(1) } @@ -90,7 +90,7 @@ async fn handle_revert(args : Array[String]) -> Unit raise Error { } // Handle --continue if do_continue { - if !(rfs.is_file(revert_head_path)) { + if !rfs.is_file(revert_head_path) { @stdio.stderr.write("error: no revert in progress") @sys.exit(1) } @@ -189,7 +189,7 @@ async fn handle_revert(args : Array[String]) -> Unit raise Error { // Files that were added in commit -> delete them for item in commit_files.to_array() { let (path, _) = item - if !(parent_files.contains(path)) { + if !parent_files.contains(path) { // File was added in commit, remove it let abs_path = root + "/" + path if rfs.is_file(abs_path) { @@ -202,7 +202,7 @@ async fn handle_revert(args : Array[String]) -> Unit raise Error { // Files that were deleted in commit -> restore them for item in parent_files.to_array() { let (path, entry) = item - if !(commit_files.contains(path)) { + if !commit_files.contains(path) { // File was deleted in commit, restore it let blob_obj = db.get(rfs, entry.id) guard blob_obj is Some(bo) else { continue } @@ -269,7 +269,7 @@ async fn handle_revert(args : Array[String]) -> Unit raise Error { @sys.exit(1) } // Create revert commit unless --no-commit - if !(no_commit) { + if !no_commit { let author = get_author_string() let timestamp = get_commit_timestamp() let new_commit_id = @bitlib.commit( diff --git a/src/cmd/bit/rm.mbt b/src/cmd/bit/rm.mbt index 905644b2..fd67350d 100644 --- a/src/cmd/bit/rm.mbt +++ b/src/cmd/bit/rm.mbt @@ -64,7 +64,7 @@ async fn handle_rm(args : Array[String]) -> Unit raise Error { } @sys.exit(1) } - if opts.cached && !(opts.force) && head_exists { + if opts.cached && !opts.force && head_exists { let st = @bitlib.status(fs, root) let staged_but_not_head : Map[String, Bool] = {} let intent_to_add_paths : Map[String, Bool] = {} @@ -94,12 +94,12 @@ async fn handle_rm(args : Array[String]) -> Unit raise Error { } } } - if !(opts.cached) && !(opts.force) { + if !opts.cached && !opts.force { let st = @bitlib.status(fs, root) let missing_worktree_paths : Map[String, Bool] = {} for path in removed_paths { let abs_path = root + "/" + path - if !(fs.is_file(abs_path)) && !(fs.is_dir(abs_path)) { + if !fs.is_file(abs_path) && !fs.is_dir(abs_path) { missing_worktree_paths[path] = true } } @@ -130,7 +130,7 @@ async fn handle_rm(args : Array[String]) -> Unit raise Error { force=opts.force, recursive=false, ) - if !(opts.quiet) { + if !opts.quiet { for path in removed_paths { print_line("rm " + rm_quote_path(path)) } @@ -179,7 +179,7 @@ fn parse_rm_options(args : Array[String]) -> RmOptions { continue } if parse_options { - if arg.has_prefix("-") && !(arg.has_prefix("--")) && arg.length() > 2 { + if arg.has_prefix("-") && !arg.has_prefix("--") && arg.length() > 2 { let mut recognized_short_cluster = true for i = 1; i < arg.length(); i = i + 1 { match arg.get_char(i).unwrap() { @@ -285,7 +285,7 @@ fn rm_partition_target_paths( raw_path, entries, recursive, cwd_prefix, root_abs, ) if matched.length() == 0 { - if !(ignore_unmatch) { + if !ignore_unmatch { unmatched_specs.push(raw_path) } continue @@ -294,23 +294,23 @@ fn rm_partition_target_paths( let sparse_matches : Array[String] = [] for path in matched { if sparse_enabled && - !(@bitlib.matches_sparse_pattern(path, sparse_patterns)) { + !@bitlib.matches_sparse_pattern(path, sparse_patterns) { sparse_matches.push(path) } else { dense_matches.push(path) } } - if !(allow_sparse) && + if !allow_sparse && dense_matches.length() == 0 && sparse_matches.length() > 0 { - if !(ignore_unmatch) { + if !ignore_unmatch { sparse_only_specs.push(raw_path) } continue } let selected = if allow_sparse { matched } else { dense_matches } for path in selected { - if !(seen.contains(path)) { + if !seen.contains(path) { seen[path] = true target_paths.push(path) } @@ -655,7 +655,7 @@ fn rm_collect_conflict_paths( let has_stage_add = staged_added.contains(path) let worktree_missing = missing_worktree_paths.contains(path) let has_staged_change = staged_modified.contains(path) || - (has_stage_add && !(worktree_missing)) + (has_stage_add && !worktree_missing) let has_unstaged_change = unstaged_modified.contains(path) if has_staged_change && has_unstaged_change { both_dirty.push(path) diff --git a/src/cmd/bit/scalar.mbt b/src/cmd/bit/scalar.mbt index 99448934..2da661e1 100644 --- a/src/cmd/bit/scalar.mbt +++ b/src/cmd/bit/scalar.mbt @@ -138,7 +138,7 @@ fn scalar_render_global_config_with_repos( new_blocks.push(block) } } - if !(found) && repos.length() > 0 { + if !found && repos.length() > 0 { let lines : Array[String] = [] for repo in repos { lines.push("\trepo = \{repo}") @@ -307,7 +307,7 @@ fn scalar_rewrite_repo_config(fs : OsFs, repo : String) -> Unit { None => new_blocks.push(block) } } - if !(has_gui) { + if !has_gui { new_blocks.push({ header: Some("[gui]"), section: Some("gui"), @@ -315,7 +315,7 @@ fn scalar_rewrite_repo_config(fs : OsFs, repo : String) -> Unit { lines: ["\tGCWarning = false # set by scalar"], }) } - if !(has_log) { + if !has_log { new_blocks.push({ header: Some("[log]"), section: Some("log"), @@ -323,7 +323,7 @@ fn scalar_rewrite_repo_config(fs : OsFs, repo : String) -> Unit { lines: ["\texcludeDecoration = refs/prefetch/* # set by scalar"], }) } - if !(has_core) { + if !has_core { new_blocks.push({ header: Some("[core]"), section: Some("core"), @@ -371,7 +371,7 @@ async fn scalar_toggle_maintenance( scalar_trace_subcommand(fs, [ "git", "maintenance", "unregister", "--force", ]) - if code != 0 && !(quiet) { + if code != 0 && !quiet { eprint_line("warning: could not toggle maintenance") } } @@ -379,7 +379,7 @@ async fn scalar_toggle_maintenance( _ => { let code = scalar_run_git_in(repo, ["maintenance", "start"]) scalar_trace_subcommand(fs, ["git", "maintenance", "start"]) - if code != 0 && !(quiet) { + if code != 0 && !quiet { eprint_line("warning: could not toggle maintenance") } } @@ -444,7 +444,7 @@ fn scalar_trace_subcommand(fs : OsFs, argv : Array[String]) -> Unit { fn scalar_ensure_trace_file(fs : OsFs) -> Unit { match @sys.get_env_var("GIT_TRACE2_EVENT") { Some(path) => - if !(fs.is_file(path)) { + if !fs.is_file(path) { fs.write_string(path, "") catch { _ => () } @@ -543,7 +543,7 @@ async fn scalar_handle_register( for arg in args { if arg == "--no-maintenance" { no_maintenance = true - } else if !(arg.has_prefix("-")) && target is None { + } else if !arg.has_prefix("-") && target is None { target = Some(arg) } } @@ -555,7 +555,7 @@ async fn scalar_handle_register( scalar_add_maintenance_repo(fs, repo) scalar_rewrite_repo_config(fs, repo) scalar_start_fsmonitor(repo) - if !(no_maintenance) { + if !no_maintenance { scalar_toggle_maintenance(fs, repo, "enable", false) } } @@ -629,7 +629,7 @@ async fn scalar_handle_reconfigure( maintenance_mode = args[i + 1] i += 1 } - _ if !(arg.has_prefix("-")) && target is None => target = Some(arg) + _ if !arg.has_prefix("-") && target is None => target = Some(arg) _ => () } i += 1 @@ -690,10 +690,10 @@ async fn scalar_handle_clone( } } let clone_args : Array[String] = ["clone", "--filter=blob:none"] - if !(parsed.tags) { + if !parsed.tags { clone_args.push("--no-tags") } - if !(scalar_clone_has_progress_flag(parsed.clone_opts)) { + if !scalar_clone_has_progress_flag(parsed.clone_opts) { if scalar_stderr_is_tty() { clone_args.push("--progress") } else { @@ -710,10 +710,10 @@ async fn scalar_handle_clone( if code != 0 { @sys.exit(code) } - if !(parsed.full_clone) { + if !parsed.full_clone { ignore(scalar_run_git_in(repo, ["sparse-checkout", "init", "--cone"])) } - if !(parsed.tags) { + if !parsed.tags { ignore( scalar_run_git_in(repo, [ "fetch", "--quiet", "--no-progress", "origin", "--no-tags", @@ -743,7 +743,7 @@ async fn scalar_handle_run( let cmd = args[0] let enlistment_arg = args[1] let enlistment = scalar_abs_path(enlistment_arg, cwd) - if !(fs.is_dir(enlistment)) { + if !fs.is_dir(enlistment) { scalar_die(1, "'\{enlistment_arg}' does not exist") return } @@ -762,7 +762,7 @@ async fn scalar_handle_run( ///| fn scalar_read_alternates(fs : OsFs, git_dir : String) -> String { let path = git_dir + "/objects/info/alternates" - if !(fs.is_file(path)) { + if !fs.is_file(path) { return "" } decode_bytes(fs.read_file(path)) catch { diff --git a/src/cmd/bit/send_pack.mbt b/src/cmd/bit/send_pack.mbt index ce8ff37f..70a75a70 100644 --- a/src/cmd/bit/send_pack.mbt +++ b/src/cmd/bit/send_pack.mbt @@ -29,7 +29,7 @@ async fn handle_send_pack(args : Array[String]) -> Unit raise Error { } _ if arg.has_prefix("--receive-pack=") => () _ if arg.has_prefix("--exec=") => () - _ if !(arg.has_prefix("-")) => + _ if !arg.has_prefix("-") => if remote is None { remote = Some(arg) } else { diff --git a/src/cmd/bit/serve.mbt b/src/cmd/bit/serve.mbt index 30dc617f..e098861b 100644 --- a/src/cmd/bit/serve.mbt +++ b/src/cmd/bit/serve.mbt @@ -80,7 +80,7 @@ fn parse_hub_serve_options(args : Array[String]) -> HubServeOptions? { i += 1 continue } - if !(arg.has_prefix("-")) && relay_url is None { + if !arg.has_prefix("-") && relay_url is None { relay_url = Some(arg) i += 1 continue @@ -463,7 +463,7 @@ async fn serve_handle_git_request( let service = serve_extract_query_param(path, "service") match service { Some("git-receive-pack") => { - if !(allow_push) { + if !allow_push { let error_body = @encoding.encode( @encoding.Encoding::UTF8, "receive-pack not enabled", @@ -498,7 +498,7 @@ async fn serve_handle_git_request( } } } else if path.has_prefix("/git-receive-pack") { - if !(allow_push) { + if !allow_push { let error_body = @encoding.encode( @encoding.Encoding::UTF8, "receive-pack not enabled", @@ -885,7 +885,7 @@ async fn serve_broadcast_push_notification( let root = normalize_repo_root(repo_root) let git_dir = root + "/.git" let incoming_dir = git_dir + "/refs/relay/incoming/heads" - if !(fs.is_dir(incoming_dir)) { + if !fs.is_dir(incoming_dir) { return } // Build broadcast payload with incoming refs diff --git a/src/cmd/bit/shell.mbt b/src/cmd/bit/shell.mbt index 6236b4d1..d8b9d774 100644 --- a/src/cmd/bit/shell.mbt +++ b/src/cmd/bit/shell.mbt @@ -75,7 +75,7 @@ fn shell_parse_interactive_command(line : String) -> (String, Array[String]) { async fn shell_read_interactive_command_line() -> String { let line_bytes : Array[Byte] = [] let mut done = false - while !(done) { + while !done { match @stdio.stdin.read_some(max_len=256) { None => break Some(chunk) => @@ -130,7 +130,7 @@ async fn shell_run_service_command(command_line : String) -> Unit raise Error { ///| async fn shell_run_interactive(fs : OsFs) -> Unit { let command_line = shell_read_interactive_command_line() - if !(fs.is_dir("git-shell-commands")) { + if !fs.is_dir("git-shell-commands") { eprint_line("fatal: interactive git shell is not enabled") @sys.exit(1) } @@ -140,12 +140,12 @@ async fn shell_run_interactive(fs : OsFs) -> Unit { let (command_name, command_args) = shell_parse_interactive_command( command_line, ) - if !(shell_is_safe_interactive_name(command_name)) { + if !shell_is_safe_interactive_name(command_name) { eprint_line("fatal: unrecognized command") @sys.exit(1) } let script_path = "git-shell-commands/" + command_name - if !(fs.is_file(script_path)) { + if !fs.is_file(script_path) { eprint_line("fatal: unrecognized command") @sys.exit(1) } diff --git a/src/cmd/bit/shortlog.mbt b/src/cmd/bit/shortlog.mbt index fc1947e9..a40bd832 100644 --- a/src/cmd/bit/shortlog.mbt +++ b/src/cmd/bit/shortlog.mbt @@ -34,7 +34,7 @@ async fn handle_shortlog(args : Array[String]) -> Unit raise Error { "-n" | "--numbered" => numbered = true "-s" | "--summary" => summary = true "-e" | "--email" => email = true - _ if arg.has_prefix("-") && !(arg.has_prefix("--")) => { + _ if arg.has_prefix("-") && !arg.has_prefix("--") => { // Could be -N for count let num_str = String::unsafe_substring(arg, start=1, end=arg.length()) let n = parse_int(num_str) @@ -113,7 +113,7 @@ async fn handle_shortlog(args : Array[String]) -> Unit raise Error { for entry in authors { let (author, commits) = entry print_line("\{author} (\{commits.length()}):") - if !(summary) { + if !summary { for commit in commits { print_line(" \{commit}") } diff --git a/src/cmd/bit/show.mbt b/src/cmd/bit/show.mbt index aea7ec23..db6a1e5d 100644 --- a/src/cmd/bit/show.mbt +++ b/src/cmd/bit/show.mbt @@ -439,14 +439,12 @@ fn show_parse_args(args : Array[String]) -> ShowArgs { grep_pattern_type_override = Some(GrepPatternType::Perl) } else if arg == "--basic-regexp" { grep_pattern_type_override = Some(GrepPatternType::Basic) - } else if arg.has_prefix("^") && - arg.length() > 1 && - !(arg.has_prefix("^{")) { + } else if arg.has_prefix("^") && arg.length() > 1 && !arg.has_prefix("^{") { range_excludes.push( String::unsafe_substring(arg, start=1, end=arg.length()), ) walk_mode = true - } else if !(arg.has_prefix("-")) { + } else if !arg.has_prefix("-") { if log_find_dotdot(arg) >= 0 || log_find_tripledot(arg) >= 0 { log_add_revision_input(arg, revs, range_excludes, symmetric_ranges) walk_mode = true @@ -489,11 +487,11 @@ fn show_concat_blocks(blocks : Array[String], compact : Bool) -> String { let mut out = blocks[0] for i in 1.. String? raise Error { let show_info = parse_show_commit(data) - if !( - grep_patterns_match_message( - show_info.message, - grep_patterns, - grep_pattern_type, - grep_ignore_case, - ), + if !grep_patterns_match_message( + show_info.message, + grep_patterns, + grep_pattern_type, + grep_ignore_case, ) { return None } if pretty_raw { let text = decode_bytes(data) let mut block = "commit \{commit_id.to_hex()}\n" + text - if !(text.has_suffix("\n")) { + if !text.has_suffix("\n") { block = block + "\n" } return Some(block) @@ -626,7 +622,7 @@ fn show_render_commit_block( lines.push(" \{line_view.to_string()}") } lines.push("") - if !(quiet) && commit_info.parents.length() > 0 { + if !quiet && commit_info.parents.length() > 0 { let parent_id = commit_info.parents[0] let parent_files = @bitlib.collect_tree_files_from_commit(db, fs, parent_id) let current_files = @bitlib.collect_tree_files_from_commit( @@ -644,7 +640,7 @@ fn show_render_commit_block( } for item in parent_files.to_array() { let (path, _) = item - if !(current_files.contains(path)) { + if !current_files.contains(path) { lines.push("diff --git a/\{path} b/\{path}\ndeleted file") } } diff --git a/src/cmd/bit/show_branches.mbt b/src/cmd/bit/show_branches.mbt index 3e51aa54..aa533664 100644 --- a/src/cmd/bit/show_branches.mbt +++ b/src/cmd/bit/show_branches.mbt @@ -29,7 +29,7 @@ async fn handle_show_branches(args : Array[String]) -> Unit raise Error { _ => 10 } } - _ if !(arg.has_prefix("-")) => specific_branches.push(arg) + _ if !arg.has_prefix("-") => specific_branches.push(arg) _ if arg.has_prefix("-") => warn_unimplemented_arg("show-branch", arg) _ => () } diff --git a/src/cmd/bit/show_ref.mbt b/src/cmd/bit/show_ref.mbt index 5e650b67..5e933bd8 100644 --- a/src/cmd/bit/show_ref.mbt +++ b/src/cmd/bit/show_ref.mbt @@ -62,7 +62,7 @@ async fn handle_show_ref(args : Array[String]) -> Unit raise Error { if show_ref_exists_without_resolution(fs, git_dir, refname) { @sys.exit(0) } else { - if !(quiet) { + if !quiet { eprint_line("error: reference does not exist") } @sys.exit(2) @@ -80,13 +80,13 @@ async fn handle_show_ref(args : Array[String]) -> Unit raise Error { // Verify object exists (git checks this for dangling refs) let obj_exists = db.get(fs, id) catch { _ => None } if obj_exists is None { - if !(quiet) { + if !quiet { eprint_line( "fatal: git show-ref: bad ref \{refname} (\{id.to_hex()})", ) } has_missing = true - } else if !(quiet) { + } else if !quiet { if hash_only { print_line(id.to_hex()) } else { @@ -118,7 +118,7 @@ async fn handle_show_ref(args : Array[String]) -> Unit raise Error { Some(head_id) => { // --head always shows HEAD regardless of patterns matched_count += 1 - if !(quiet) { + if !quiet { if hash_only { print_line(head_id.to_hex()) } else { @@ -135,7 +135,7 @@ async fn handle_show_ref(args : Array[String]) -> Unit raise Error { let is_head = refname.has_prefix("refs/heads/") let is_tag = refname.has_prefix("refs/tags/") let type_match = (heads_only && is_head) || (tags_only && is_tag) - if !(type_match) { + if !type_match { continue } } @@ -149,12 +149,12 @@ async fn handle_show_ref(args : Array[String]) -> Unit raise Error { break } } - if !(matched) { + if !matched { continue } } matched_count += 1 - if !(quiet) { + if !quiet { if hash_only { print_line(id.to_hex()) } else { @@ -227,7 +227,7 @@ fn show_ref_exists_without_resolution( let normalized = @bitlib.normalize_repo_path(refname) catch { _ => return false } - if !(normalized.has_prefix("refs/")) { + if !normalized.has_prefix("refs/") { return false } normalized @@ -237,7 +237,7 @@ fn show_ref_exists_without_resolution( return true } let packed_refs_path = git_dir + "/packed-refs" - if !(fs.is_file(packed_refs_path)) { + if !fs.is_file(packed_refs_path) { return false } let content = decode_bytes( diff --git a/src/cmd/bit/signing_helpers.mbt b/src/cmd/bit/signing_helpers.mbt index 477a2695..9b0789d6 100644 --- a/src/cmd/bit/signing_helpers.mbt +++ b/src/cmd/bit/signing_helpers.mbt @@ -213,7 +213,7 @@ fn signing_join_signature_lines(lines : Array[String]) -> String { return "" } let mut out = lines.join("\n") - if not(out.has_suffix("\n")) { + if !out.has_suffix("\n") { out = out + "\n" } out diff --git a/src/cmd/bit/sparse_checkout.mbt b/src/cmd/bit/sparse_checkout.mbt index a0d7c2ca..f41872b5 100644 --- a/src/cmd/bit/sparse_checkout.mbt +++ b/src/cmd/bit/sparse_checkout.mbt @@ -111,7 +111,7 @@ fn sparse_checkout_path_is_directory_like( return Some(false) } let git_dir = resolve_git_dir(rfs, root) - if !(rfs.is_file(git_dir + "/index")) { + if !rfs.is_file(git_dir + "/index") { return None } let entries = @bitlib.read_index_entries(rfs, git_dir) @@ -147,7 +147,7 @@ fn sparse_checkout_validate_literal_patterns( "\{pattern} is not a directory", ) } - if !(pattern.has_prefix("/")) { + if !pattern.has_prefix("/") { return Some( "warning: pass a leading slash before paths such as '\{pattern}' if you want a single file", ) @@ -229,11 +229,11 @@ fn sparse_checkout_list_state( rfs : &@bitcore.RepoFileSystem, git_dir : String, ) -> SparseCheckoutListState { - if !(@bitlib.is_sparse_checkout_enabled(rfs, git_dir)) { + if !@bitlib.is_sparse_checkout_enabled(rfs, git_dir) { return Fatal("this worktree is not sparse") } let sparse_path = git_dir + "/info/sparse-checkout" - if !(rfs.is_file(sparse_path)) { + if !rfs.is_file(sparse_path) { return Warning( "this worktree is not sparse (sparse-checkout file may not exist)", ) @@ -851,7 +851,7 @@ async fn handle_sparse_checkout_at_root( let effective_cone = sparse_checkout_effective_cone_mode( fs, git_dir, cone_flag, ) - if !(@bitlib.is_sparse_checkout_enabled(fs, git_dir)) { + if !@bitlib.is_sparse_checkout_enabled(fs, git_dir) { @bitlib.sparse_checkout_init(fs, fs, root, cone=effective_cone) } match cone_flag { @@ -888,7 +888,7 @@ async fn handle_sparse_checkout_at_root( let effective_cone = sparse_checkout_effective_cone_mode( fs, git_dir, cone_flag, ) - if !(@bitlib.is_sparse_checkout_enabled(fs, git_dir)) { + if !@bitlib.is_sparse_checkout_enabled(fs, git_dir) { @bitlib.sparse_checkout_init(fs, fs, root, cone=effective_cone) } match cone_flag { diff --git a/src/cmd/bit/sparse_checkout_wbtest.mbt b/src/cmd/bit/sparse_checkout_wbtest.mbt index 4b61ad0d..b5e3906f 100644 --- a/src/cmd/bit/sparse_checkout_wbtest.mbt +++ b/src/cmd/bit/sparse_checkout_wbtest.mbt @@ -61,7 +61,7 @@ async fn sparse_checkout_wbtest_shim_moon_path( // Build the native binary first so exit codes propagate correctly // (moon run swallows non-zero exit codes) let bit_exe = repo_root + "/_build/native/release/build/cmd/bit/bit.exe" - if !(fs.is_file(bit_exe)) { + if !fs.is_file(bit_exe) { let build_code = @process.run( "moon", ["build", "--target", "native", "--release"], diff --git a/src/cmd/bit/stash.mbt b/src/cmd/bit/stash.mbt index c9c6b338..354b9098 100644 --- a/src/cmd/bit/stash.mbt +++ b/src/cmd/bit/stash.mbt @@ -15,8 +15,7 @@ async fn handle_stash(args : Array[String]) -> Unit raise Error { first } } - let rest : Array[String] = if args.length() > 0 && - !(args[0].has_prefix("-")) { + let rest : Array[String] = if args.length() > 0 && !args[0].has_prefix("-") { args.iter().drop(1).collect() } else { args.iter().collect() diff --git a/src/cmd/bit/status.mbt b/src/cmd/bit/status.mbt index f5cf7931..d2d96d72 100644 --- a/src/cmd/bit/status.mbt +++ b/src/cmd/bit/status.mbt @@ -44,7 +44,7 @@ async fn handle_status(args : Array[String]) -> Unit raise Error { let mut git_dir = resolve_git_dir(fs, root) let mut has_git_dir = fs.is_dir(git_dir) let mut has_git_file = if has_git_dir { false } else { fs.is_file(git_dir) } - if !(has_git_dir) && !(has_git_file) { + if !has_git_dir && !has_git_file { match find_repo_root(".") { Some(found) => { root = found @@ -58,7 +58,7 @@ async fn handle_status(args : Array[String]) -> Unit raise Error { ) } } - if !(has_git_dir) && !(has_git_file) { + if !has_git_dir && !has_git_file { raise @bitcore.GitError::InvalidObject( "Not a git repository (or any of the parent directories): .git/.bit", ) @@ -94,7 +94,7 @@ async fn handle_status(args : Array[String]) -> Unit raise Error { } } // Show subdir-clone info if applicable (only in non-porcelain mode) - if !(porcelain) && !(short) { + if !porcelain && !short { match get_subdir_info(fs, git_dir) { Some((remote, path, base)) => { print_line("# subdir-clone: \{path} from \{remote}") diff --git a/src/cmd/bit/storage_runtime.mbt b/src/cmd/bit/storage_runtime.mbt index 834a275b..4638d747 100644 --- a/src/cmd/bit/storage_runtime.mbt +++ b/src/cmd/bit/storage_runtime.mbt @@ -30,7 +30,7 @@ fn storage_runtime_fail_unsupported_mode( ///| fn storage_runtime_is_short_count_flag(arg : String) -> Bool { - if !(arg.has_prefix("-")) || arg.length() <= 1 { + if !arg.has_prefix("-") || arg.length() <= 1 { return false } let raw = String::unsafe_substring(arg, start=1, end=arg.length()) @@ -142,19 +142,19 @@ fn storage_runtime_parse_add_args( let mut end_of_options = false let paths : Array[String] = [] for arg in args { - if !(end_of_options) && arg == "--" { + if !end_of_options && arg == "--" { end_of_options = true continue } match arg { - "-A" | "--all" if !(end_of_options) => add_all = true - _ if end_of_options || !(arg.has_prefix("-")) => paths.push(arg) + "-A" | "--all" if !end_of_options => add_all = true + _ if end_of_options || !arg.has_prefix("-") => paths.push(arg) _ if arg.has_prefix("-") => storage_runtime_fail_unsupported_option("add", arg) _ => () } } - if !(add_all) && paths.length() == 0 { + if !add_all && paths.length() == 0 { raise @bitcore.GitError::InvalidObject("add requires pathspec") } { add_all, paths } @@ -353,7 +353,7 @@ fn storage_runtime_parse_hash_object_args( } break } - _ if !(arg.has_prefix("-")) => paths.push(arg) + _ if !arg.has_prefix("-") => paths.push(arg) _ => storage_runtime_fail_unsupported_option("hash-object", arg) } i += 1 @@ -421,7 +421,7 @@ fn storage_runtime_parse_update_ref_args( for arg in args { match arg { "-d" | "--delete" => delete_mode = true - _ if !(arg.has_prefix("-")) => positional.push(arg) + _ if !arg.has_prefix("-") => positional.push(arg) _ => storage_runtime_fail_unsupported_option("update-ref", arg) } } diff --git a/src/cmd/bit/stripspace.mbt b/src/cmd/bit/stripspace.mbt index 6f521abb..bc084d68 100644 --- a/src/cmd/bit/stripspace.mbt +++ b/src/cmd/bit/stripspace.mbt @@ -78,7 +78,7 @@ fn stripspace_clean(input : String, strip_comments : Bool) -> String { let mut prev_blank = true // Start true to strip leading blanks for line in processed { if line.length() == 0 { - if !(prev_blank) { + if !prev_blank { result.push("") } prev_blank = true diff --git a/src/cmd/bit/subdir_clone.mbt b/src/cmd/bit/subdir_clone.mbt index 4b4ba526..1867fbdd 100644 --- a/src/cmd/bit/subdir_clone.mbt +++ b/src/cmd/bit/subdir_clone.mbt @@ -186,7 +186,7 @@ async fn subdir_clone( } // Load object database and get tree let mut db = @bitlib.ObjectDb::load_lazy(fs, temp_git_dir) - if !(from_local_repo) && db.get(fs, commit_id) is None { + if !from_local_repo && db.get(fs, commit_id) is None { let pack = @bitnative.fetch_pack_http(remote_url, [commit_id], true) let objects = @pack.parse_packfile(pack) @pack.write_packfile_with_index(fs, temp_git_dir, pack, objects) @@ -203,7 +203,7 @@ async fn subdir_clone( ) guard subdir_tree_id is Some(tree_id) else { @bitlib.subdir_remove_dir(fs, fs, temp_clone) - if !(target_existed) { + if !target_existed { @bitlib.subdir_remove_dir(fs, fs, target) } raise @bitcore.GitError::InvalidObject( diff --git a/src/cmd/bit/subdir_ops.mbt b/src/cmd/bit/subdir_ops.mbt index 7426bc52..2b4d5b37 100644 --- a/src/cmd/bit/subdir_ops.mbt +++ b/src/cmd/bit/subdir_ops.mbt @@ -121,7 +121,7 @@ fn compare_trees( // Find deleted (in A but not in B) for e in entries_a { let path = if prefix.length() > 0 { prefix + "/" + e.name } else { e.name } - if !(map_b.contains(e.name)) { + if !map_b.contains(e.name) { if e.mode == "40000" || e.mode == "040000" { // Recurse into deleted directory let sub = compare_trees_deleted(db, rfs, e.id, path) diff --git a/src/cmd/bit/submodule.mbt b/src/cmd/bit/submodule.mbt index ccdbfadb..cc5b5035 100644 --- a/src/cmd/bit/submodule.mbt +++ b/src/cmd/bit/submodule.mbt @@ -202,7 +202,7 @@ fn submodule_url_is_local_not_ssh(url : String) -> Bool { return false } match url.find(":") { - Some(colon_idx) if !(url.has_prefix("/")) => + Some(colon_idx) if !url.has_prefix("/") => match url.find("/") { Some(slash_idx) => colon_idx > slash_idx None => false @@ -238,7 +238,7 @@ fn submodule_resolve_relative_url( url : String, up_path : String?, ) -> String { - if !(submodule_relative_local_url(url)) { + if !submodule_relative_local_url(url) { return url } let mut remote_url = remote_url @@ -250,10 +250,9 @@ fn submodule_resolve_relative_url( ) } let mut is_relative = false - if submodule_url_is_local_not_ssh(remote_url) && - !(remote_url.has_prefix("/")) { + if submodule_url_is_local_not_ssh(remote_url) && !remote_url.has_prefix("/") { is_relative = true - if !(remote_url.has_prefix("./")) && !(remote_url.has_prefix("../")) { + if !remote_url.has_prefix("./") && !remote_url.has_prefix("../") { remote_url = "./" + remote_url } } @@ -322,7 +321,7 @@ fn resolve_submodule_config_url( ///| fn submodule_expand_template_dir(path : String) -> String { - if !(path.has_prefix("~/")) { + if !path.has_prefix("~/") { return path } match @sys.get_env_var("HOME") { @@ -377,7 +376,7 @@ async fn submodule_apply_template_exec_bits( submodule_apply_template_exec_bits(fs, src_path, dst_path) continue } - if !(fs.is_file(src_path)) || !(fs.is_file(dst_path)) { + if !fs.is_file(src_path) || !fs.is_file(dst_path) { continue } match @bitio.lstat_entry_meta(src_path) { @@ -615,7 +614,7 @@ fn submodule_add_existing_index_error( return Some("fatal: '\{path}' already exists in the index") } } - if has_gitlink && !(force) { + if has_gitlink && !force { return Some("fatal: '\{path}' already exists in the index") } None @@ -767,7 +766,7 @@ async fn handle_submodule_add( eprint_line("fatal: Unable to create '\{index_lock}': File exists.") @sys.exit(128) } - if !(force) && add_has_explicit_ignored_path(rfs, root, [path]) { + if !force && add_has_explicit_ignored_path(rfs, root, [path]) { for line in submodule_add_ignored_error_lines(path) { eprint_line(line) } @@ -802,12 +801,12 @@ async fn handle_submodule_add( } match submodule_add_reserved_name_path(rfs, root, git_dir, name) { Some(existing_path) => - if !(force) { + if !force { eprint_line(submodule_add_name_in_use_error(name, existing_path)) @sys.exit(128) } None => - if !(force) && reusable_modules_git_dir is Some(_) { + if !force && reusable_modules_git_dir is Some(_) { eprint_line(submodule_add_name_in_use_error(name, path)) @sys.exit(128) } @@ -905,8 +904,8 @@ async fn handle_submodule_add( } let reused_existing_repo = reusable_repo_git_dir is Some(_) let absorbed_existing_repo = if existing_embedded_repo && - !(reused_existing_repo) { - if !(fs.is_dir(modules_dir)) { + !reused_existing_repo { + if !fs.is_dir(modules_dir) { fs.mkdir_p(modules_dir) } absorb_git_dir(fs, sub_path, sub_git, modules_dir) @@ -914,11 +913,8 @@ async fn handle_submodule_add( } else { false } - let direct_existing_repo = existing_embedded_repo && - !(absorbed_existing_repo) - if !(absorbed_existing_repo) && - !(direct_existing_repo) && - !(fs.is_dir(modules_dir)) { + let direct_existing_repo = existing_embedded_repo && !absorbed_existing_repo + if !absorbed_existing_repo && !direct_existing_repo && !fs.is_dir(modules_dir) { submodule_init_modules_repo(fs, git_dir, modules_dir) } let active_sub_git_dir = if direct_existing_repo { @@ -927,7 +923,7 @@ async fn handle_submodule_add( modules_dir } let modules_config = active_sub_git_dir + "/config" - if !(direct_existing_repo) { + if !direct_existing_repo { set_config( fs, modules_config, @@ -955,8 +951,8 @@ async fn handle_submodule_add( } } let mut remote_head_branch = @bitlib.read_remote_head_branch(fs, modules_dir) - if !(reused_existing_repo) && !(direct_existing_repo) { - if progress && !(quiet) { + if !reused_existing_repo && !direct_existing_repo { + if progress && !quiet { eprint_line("Checking connectivity: 100% (1/1), done.") } fetch_submodule_objects( @@ -971,13 +967,10 @@ async fn handle_submodule_add( ) remote_head_branch = @bitlib.read_remote_head_branch(fs, modules_dir) } - let needs_worktree_checkout = !(absorbed_existing_repo) && - ( - !(fs.is_dir(sub_path)) || - (!(fs.is_file(sub_git)) && !(fs.is_dir(sub_git))) - ) + let needs_worktree_checkout = !absorbed_existing_repo && + (!fs.is_dir(sub_path) || (!fs.is_file(sub_git) && !fs.is_dir(sub_git))) if needs_worktree_checkout { - if !(fs.is_dir(sub_path)) { + if !fs.is_dir(sub_path) { fs.mkdir_p(sub_path) } let rel_path = submodule_relative_path(sub_path, modules_dir) @@ -1020,7 +1013,7 @@ async fn handle_submodule_add( active_sub_git_dir + "/HEAD", "ref: refs/heads/" + branch_name + "\n", ) - if !(direct_existing_repo) { + if !direct_existing_repo { set_config( fs, modules_config, @@ -1130,7 +1123,7 @@ fn submodule_missing_url_paths( } let missing : Array[String] = [] for path in target_paths { - if !(index_paths.contains(path)) { + if !index_paths.contains(path) { continue } match submodule_find_by_path(submodules, path) { @@ -1148,7 +1141,7 @@ fn submodule_unmatched_index_paths( ) -> Array[String] { let unmatched : Array[String] = [] for path in requested_paths { - if !(index_paths.contains(path)) { + if !index_paths.contains(path) { unmatched.push(path) } } @@ -1162,7 +1155,7 @@ fn submodule_known_paths( ) -> Array[String] { let known = index_paths.copy() for sub in submodules { - if !(known.contains(sub.path)) { + if !known.contains(sub.path) { known.push(sub.path) } } @@ -1193,7 +1186,7 @@ fn load_submodule_update_path_blocker( if fs.is_file(sub_path) { return true } - if !(fs.is_dir(sub_path)) { + if !fs.is_dir(sub_path) { return false } let entries = fs.readdir(sub_path) catch { _ => [] } @@ -1228,7 +1221,7 @@ fn load_submodule_add_path_blocker( if fs.is_file(sub_path) { return Some("path") } - if !(fs.is_dir(sub_path)) { + if !fs.is_dir(sub_path) { return None } let entries = fs.readdir(sub_path) catch { _ => [] } @@ -1321,7 +1314,7 @@ fn parse_submodule_config( ) -> Array[SubmoduleInfo] { let config_git_dir = resolve_submodule_common_git_dir(fs, git_dir) let config_path = config_git_dir + "/config" - if !(fs.is_file(config_path)) { + if !fs.is_file(config_path) { return [] } let content = decode_bytes(fs.read_file(config_path)) catch { _ => return [] } @@ -1402,7 +1395,7 @@ fn submodule_uninitialized_paths( ) -> Array[String] { let paths : Array[String] = [] for sub in submodules { - if requested_paths.length() > 0 && !(requested_paths.contains(sub.path)) { + if requested_paths.length() > 0 && !requested_paths.contains(sub.path) { continue } if read_submodule_config_value(fs, git_dir, sub.name, "url") is None { @@ -1427,7 +1420,7 @@ fn submodule_update_notice_paths( fs, git_dir, submodules, requested_paths, ) for path in uninitialized { - if !(paths.contains(path)) { + if !paths.contains(path) { paths.push(path) } } @@ -1490,7 +1483,7 @@ fn submodule_select_paths_from_filters( } found } - if !(matched) { + if !matched { return ([], Some(filter)) } } @@ -1510,7 +1503,7 @@ fn submodule_select_paths_from_filters( } matched } - if !(include_match) { + if !include_match { continue } let mut excluded = false @@ -1521,7 +1514,7 @@ fn submodule_select_paths_from_filters( break } } - if !(excluded) { + if !excluded { selected.push(path) } } @@ -1535,7 +1528,7 @@ fn submodule_active_filters( root_abs : String, ) -> Array[String] { let config_path = git_dir + "/config" - if !(fs.is_file(config_path)) { + if !fs.is_file(config_path) { return [] } let values = get_all_config_values( @@ -1617,7 +1610,7 @@ fn submodule_resolve_target_paths( None => () } } - if active_filters.length() == 0 && !(has_named_active) { + if active_filters.length() == 0 && !has_named_active { return ([], false, None) } let selected_by_filter = if active_filters.length() > 0 { @@ -1718,7 +1711,7 @@ fn read_submodule_status_head_label( head_id : @bitcore.ObjectId, ) -> String? { let head_path = sub_git_dir + "/HEAD" - if !(fs.is_file(head_path)) { + if !fs.is_file(head_path) { return None } let content = decode_bytes( @@ -1817,7 +1810,7 @@ fn gitmodules_has_unmapped_paths(content : String) -> Bool { for line_view in content.split("\n") { let line = trim_string(line_view.to_string()) if line.has_prefix("[submodule \"") && line.has_suffix("\"]") { - if in_section && has_url && !(has_path) { + if in_section && has_url && !has_path { return true } in_section = true @@ -1825,7 +1818,7 @@ fn gitmodules_has_unmapped_paths(content : String) -> Bool { has_url = false continue } - if !(in_section) { + if !in_section { continue } if line.has_prefix("path") { @@ -1834,7 +1827,7 @@ fn gitmodules_has_unmapped_paths(content : String) -> Bool { has_url = true } } - in_section && has_url && !(has_path) + in_section && has_url && !has_path } ///| @@ -1899,7 +1892,7 @@ fn submodule_upsert_config_value( } if section_start < 0 { let mut out = content - if out.length() > 0 && !(out.has_suffix("\n")) { + if out.length() > 0 && !out.has_suffix("\n") { out = out + "\n" } return out + target + "\n\t\{key} = \{value}\n" @@ -1908,13 +1901,13 @@ fn submodule_upsert_config_value( let mut inserted = false let mut i = 0 while i < lines.length() { - if i == section_end && !(inserted) { + if i == section_end && !inserted { out.push("\t\{key} = \{value}") inserted = true } if i > section_start && i < section_end { let trimmed = trim_chars(lines[i], " \t") - if trimmed.has_prefix(key + " =") && !(inserted) { + if trimmed.has_prefix(key + " =") && !inserted { out.push("\t\{key} = \{value}") inserted = true i += 1 @@ -1924,7 +1917,7 @@ fn submodule_upsert_config_value( out.push(lines[i]) i += 1 } - if !(inserted) { + if !inserted { if out.length() > 0 && out[out.length() - 1].length() == 0 { out.insert(out.length() - 1, "\t\{key} = \{value}") } else { @@ -2029,7 +2022,7 @@ async fn handle_submodule_status( match arg { "--recursive" => recursive = true "--cached" => cached = true - _ if !(arg.has_prefix("-")) => raw_paths.push(arg) + _ if !arg.has_prefix("-") => raw_paths.push(arg) _ => () } } @@ -2064,7 +2057,7 @@ async fn handle_submodule_status( parse_submodule_config(rfs, git_dir), ) for sub in submodules { - if paths.length() > 0 && !(paths.contains(sub.path)) { + if paths.length() > 0 && !paths.contains(sub.path) { continue } let sub_path = root + "/" + sub.path @@ -2072,7 +2065,7 @@ async fn handle_submodule_status( let index_id = get_submodule_index_id(rfs, git_dir, sub.path) let sub_git = sub_path + "/.git" // Check if initialized - if !(rfs.is_file(sub_git)) && !(rfs.is_dir(sub_git)) { + if !rfs.is_file(sub_git) && !rfs.is_dir(sub_git) { print_line( submodule_status_output(display_path, index_id, None, cached, None), ) @@ -2159,7 +2152,7 @@ async fn handle_submodule_init( for arg in args { match arg { "-q" | "--quiet" => quiet = true - _ if !(arg.has_prefix("-")) => raw_paths.push(arg) + _ if !arg.has_prefix("-") => raw_paths.push(arg) _ => () } } @@ -2211,7 +2204,7 @@ async fn handle_submodule_init( "" } for sub in submodules { - if restrict_paths && !(selected_paths.contains(sub.path)) { + if restrict_paths && !selected_paths.contains(sub.path) { continue } let config_url = resolve_submodule_config_url(fs, root, git_dir, sub.url) @@ -2224,7 +2217,7 @@ async fn handle_submodule_init( "url", config_url, ) - if !(already_active_paths.contains(sub.path)) { + if !already_active_paths.contains(sub.path) { updated = submodule_upsert_config_value( updated, sub.name, @@ -2237,7 +2230,7 @@ async fn handle_submodule_init( } wfs.write_string(config_path, updated) config_content = updated - if !(quiet) { + if !quiet { print_line( "Submodule '\{sub.name}' (\{config_url}) registered for path '\{sub.path}'", ) @@ -2284,7 +2277,7 @@ async fn handle_submodule_update( "--remote" => remote = true "--recursive" => recursive = true "--quiet" | "-q" => quiet = true - _ if !(arg.has_prefix("-")) => raw_paths.push(arg) + _ if !arg.has_prefix("-") => raw_paths.push(arg) _ => () } } @@ -2356,7 +2349,7 @@ async fn handle_submodule_update( } handle_submodule_init(fs, root, git_dir, init_paths, quiet~) } - let auto_init_active = !(init) && paths.length() == 0 && restrict_paths + let auto_init_active = !init && paths.length() == 0 && restrict_paths let effective_paths = if restrict_paths { selected_paths } else { [] } let notice_paths = if init || auto_init_active { [] @@ -2368,14 +2361,14 @@ async fn handle_submodule_update( for path in notice_paths { print_submodule_not_initialized(path) } - if !(init) && notice_paths.length() > 0 && submodules.length() == 0 { + if !init && notice_paths.length() > 0 && submodules.length() == 0 { return () } for sub in submodules { if notice_paths.contains(sub.path) { continue } - if restrict_paths && !(selected_paths.contains(sub.path)) { + if restrict_paths && !selected_paths.contains(sub.path) { continue } let sub_path = root + "/" + sub.path @@ -2413,8 +2406,8 @@ async fn handle_submodule_update( exit_submodule_existing_path(sub.path) } // Clone if needed - if !(sub_git_is_dir) && !(has_modules) { - if !(quiet) { + if !sub_git_is_dir && !has_modules { + if !quiet { print_line("Cloning into '\{sub.path}'...") } @bitrepo.init_repo(wfs, modules_dir, bare=true) @@ -2459,7 +2452,7 @@ async fn handle_submodule_update( (None : String?), (None : String?), ) - if !(submodule_git_dir_has_object(rfs, modules_dir, target_id)) { + if !submodule_git_dir_has_object(rfs, modules_dir, target_id) { fetch_submodule_objects( fs, root, @@ -2470,8 +2463,8 @@ async fn handle_submodule_update( ) } } - if !(sub_git_is_dir) && has_modules { - if !(rfs.is_dir(sub_path)) { + if !sub_git_is_dir && has_modules { + if !rfs.is_dir(sub_path) { fs.mkdir_p(sub_path) } // Create or refresh .git file to point to modules dir @@ -2485,8 +2478,8 @@ async fn handle_submodule_update( let sub_git_dir = @bitlib.resolve_gitdir(rfs, sub_git) let already_at_target = had_git_marker && @bitlib.resolve_head_commit(rfs, sub_git_dir) == Some(target_id) - if !(already_at_target) { - if !(quiet) { + if !already_at_target { + if !quiet { print_line( "Submodule path '\{sub.path}': checked out '\{target_id.to_hex()}'", ) @@ -2559,7 +2552,7 @@ fn submodule_collect_shallow_commit_objects( } let info = @bitcore.parse_commit(commit_obj.data) if depth <= 1 { - if !(seen_boundaries.contains(commit_hex)) { + if !seen_boundaries.contains(commit_hex) { seen_boundaries[commit_hex] = true boundary_ids.push(commit_id) } @@ -2611,7 +2604,7 @@ fn submodule_shallow_ref_targets( break } } - if !(exists) { + if !exists { let branch_id = @bitlib.resolve_ref( fs, src_git_dir, @@ -2646,7 +2639,7 @@ async fn fetch_submodule_local_repo_shallow( } else { src_path } - if !(quiet) { + if !quiet { eprint_line("From \{display_url}") } let rfs : &@bitcore.RepoFileSystem = fs @@ -2843,7 +2836,7 @@ async fn submodule_run_post_checkout_hook( ) -> Int { let fs = OsFs::new() let hook_path = git_dir + "/hooks/post-checkout" - if !(fs.is_file(hook_path)) { + if !fs.is_file(hook_path) { return 0 } let new_hex = commit_id.to_hex() @@ -2887,7 +2880,7 @@ fn get_rel_path(from : String, to : String) -> String { result = result + "../" } for i in common.. 0 && !(result.has_suffix("/")) { + if result.length() > 0 && !result.has_suffix("/") { result = result + "/" } result = result + to_parts[i] @@ -2911,7 +2904,7 @@ async fn handle_submodule_deinit( "-f" | "--force" => force = true "--all" => all = true "-q" | "--quiet" => quiet = true - _ if !(arg.has_prefix("-")) => paths.push(arg) + _ if !arg.has_prefix("-") => paths.push(arg) _ => () } } @@ -2922,7 +2915,7 @@ async fn handle_submodule_deinit( let (select_all, requested_paths) = normalize_submodule_deinit_paths( paths, cwd_prefix, root_abs, all, ) - if !(select_all) && requested_paths.length() == 0 { + if !select_all && requested_paths.length() == 0 { @sys.exit(1) return } @@ -2943,7 +2936,7 @@ async fn handle_submodule_deinit( None => () } for sub in submodules { - if !(select_all) && !(requested_paths.contains(sub.path)) { + if !select_all && !requested_paths.contains(sub.path) { continue } let sub_path = root + "/" + sub.path @@ -2962,7 +2955,7 @@ async fn handle_submodule_deinit( let has_worktree_git = rfs.is_dir(sub_worktree_git) || rfs.is_file(sub_worktree_git) // Check for local modifications - if !(force) && rfs.is_dir(sub_path) && has_worktree_git { + if !force && rfs.is_dir(sub_path) && has_worktree_git { match sub_git_dir { Some(actual_sub_git_dir) if rfs.is_dir(actual_sub_git_dir) => { let status = @bitlib.status(rfs, sub_path) catch { @@ -3047,10 +3040,10 @@ async fn handle_submodule_deinit( } } remove_submodule_worktree_git(fs, sub_path) - if !(rfs.is_dir(sub_path)) && !(rfs.is_file(sub_path)) { + if !rfs.is_dir(sub_path) && !rfs.is_file(sub_path) { fs.mkdir_p(sub_path) } - if !(quiet) { + if !quiet { match registered_url { Some(url) => print_line( @@ -3059,7 +3052,7 @@ async fn handle_submodule_deinit( None => () } } - if cleared_worktree && !(quiet) { + if cleared_worktree && !quiet { print_line("Cleared directory '\{display_path}'") } } @@ -3080,7 +3073,7 @@ fn remove_config_section( if trimmed.has_prefix("[") { skip = trimmed == target } - if !(skip) { + if !skip { lines.push(line) } } @@ -3224,7 +3217,7 @@ async fn handle_submodule_sync( match arg { "--recursive" => recursive = true "-q" | "--quiet" => quiet = true - _ if !(arg.has_prefix("-")) => paths.push(arg) + _ if !arg.has_prefix("-") => paths.push(arg) _ => () } } @@ -3244,7 +3237,7 @@ async fn handle_submodule_sync( None => () } for sub in submodules { - if paths.length() > 0 && !(paths.contains(sub.path)) { + if paths.length() > 0 && !paths.contains(sub.path) { continue } let sync_config_url = resolve_submodule_config_url( @@ -3284,7 +3277,7 @@ async fn handle_submodule_sync( let updated = update_remote_origin(content, sync_origin_url) wfs.write_string(sub_config, updated) } - if !(quiet) { + if !quiet { print_line("Synchronizing submodule url for '\{sub.path}'") } // Handle recursive @@ -3314,7 +3307,7 @@ fn update_config_value( if trimmed.has_prefix("[") { in_section = trimmed == target } - if in_section && trimmed.has_prefix(key + " =") && !(updated) { + if in_section && trimmed.has_prefix(key + " =") && !updated { lines.push("\t\{key} = \{value}") updated = true } else { @@ -3335,7 +3328,7 @@ fn update_remote_origin(content : String, url : String) -> String { if trimmed.has_prefix("[") { in_origin = trimmed == "[remote \"origin\"]" } - if in_origin && trimmed.has_prefix("url =") && !(updated) { + if in_origin && trimmed.has_prefix("url =") && !updated { lines.push("\turl = \{url}") updated = true } else { @@ -3367,7 +3360,7 @@ async fn handle_submodule_set_url( ) -> Unit raise Error { let positional : Array[String] = [] for arg in args { - if !(arg.has_prefix("-")) { + if !arg.has_prefix("-") { positional.push(arg) } } @@ -3431,7 +3424,7 @@ async fn handle_submodule_set_branch( branch = Some(args[i]) } "--default" | "-d" => default_branch = true - _ if !(arg.has_prefix("-")) => positional.push(arg) + _ if !arg.has_prefix("-") => positional.push(arg) _ => () } i += 1 @@ -3517,7 +3510,7 @@ async fn handle_submodule_foreach( for sub in submodules { let sub_path = root + "/" + sub.path let sub_git = sub_path + "/.git" - if !(rfs.is_file(sub_git)) && !(rfs.is_dir(sub_git)) { + if !rfs.is_file(sub_git) && !rfs.is_dir(sub_git) { continue } let sub_git_dir = @bitlib.resolve_gitdir(rfs, sub_git) @@ -3533,7 +3526,7 @@ async fn handle_submodule_foreach( Some(id) => id.to_hex() None => String::make(40, '0') } - if !(quiet) { + if !quiet { print_line("Entering '\{sub.path}'") } let env : Map[String, String] = { @@ -3601,14 +3594,14 @@ async fn handle_submodule_absorbgitdirs_with_prefix( let wfs : &@bitcore.FileSystem = fs let paths : Array[String] = [] for arg in args { - if !(arg.has_prefix("-")) { + if !arg.has_prefix("-") { paths.push(arg) } } let submodules = parse_gitmodules(rfs, root) let index_paths = load_submodule_index_gitlink_paths(rfs, git_dir) for path in index_paths { - if paths.length() > 0 && !(paths.contains(path)) { + if paths.length() > 0 && !paths.contains(path) { continue } if submodule_find_by_path(submodules, path) is Some(_) { @@ -3622,7 +3615,7 @@ async fn handle_submodule_absorbgitdirs_with_prefix( } } for sub in submodules { - if paths.length() > 0 && !(paths.contains(sub.path)) { + if paths.length() > 0 && !paths.contains(sub.path) { continue } let sub_path = root + "/" + sub.path @@ -3636,7 +3629,7 @@ async fn handle_submodule_absorbgitdirs_with_prefix( super_prefix + sub.path } if rfs.is_dir(sub_git) { - if !(rfs.is_dir(dest)) { + if !rfs.is_dir(dest) { wfs.mkdir_p(dest) } absorb_git_dir(fs, sub_path, sub_git, dest) diff --git a/src/cmd/bit/switch.mbt b/src/cmd/bit/switch.mbt index 410ebfa4..42d3531e 100644 --- a/src/cmd/bit/switch.mbt +++ b/src/cmd/bit/switch.mbt @@ -28,7 +28,7 @@ async fn handle_switch(args : Array[String]) -> Unit raise Error { "-c" | "--create" => { create = true force_create = false - if i + 1 < args.length() && !(args[i + 1].has_prefix("-")) { + if i + 1 < args.length() && !args[i + 1].has_prefix("-") { branch = Some(args[i + 1]) branch_from_option = true i += 2 @@ -38,7 +38,7 @@ async fn handle_switch(args : Array[String]) -> Unit raise Error { "-C" => { create = true force_create = true - if i + 1 < args.length() && !(args[i + 1].has_prefix("-")) { + if i + 1 < args.length() && !args[i + 1].has_prefix("-") { branch = Some(args[i + 1]) branch_from_option = true i += 2 @@ -48,7 +48,7 @@ async fn handle_switch(args : Array[String]) -> Unit raise Error { "-d" | "--detach" => detach = true "--orphan" => { orphan = true - if i + 1 < args.length() && !(args[i + 1].has_prefix("-")) { + if i + 1 < args.length() && !args[i + 1].has_prefix("-") { branch = Some(args[i + 1]) branch_from_option = true i += 2 @@ -69,7 +69,7 @@ async fn handle_switch(args : Array[String]) -> Unit raise Error { warn_unimplemented_arg("switch", arg) } } - _ if !(arg.has_prefix("-")) => positional.push(arg) + _ if !arg.has_prefix("-") => positional.push(arg) _ if arg.has_prefix("-") => warn_unimplemented_arg("switch", arg) _ => () } @@ -98,7 +98,7 @@ async fn handle_switch(args : Array[String]) -> Unit raise Error { raise @bitcore.GitError::InvalidObject("No branch specified") } let branch_name = normalize_switch_branch_ref(name) - if !(ignore_other_worktrees) { + if !ignore_other_worktrees { match switch_branch_in_use_path(rfs, root, branch_name) { Some(_) => { eprint_line( @@ -113,7 +113,7 @@ async fn handle_switch(args : Array[String]) -> Unit raise Error { let previous_location = current_checkout_location(rfs, git_dir) switch_write_head_ref(fs, git_dir, branch_name) save_previous_checkout_location(fs, git_dir, previous_location) - if !(quiet) { + if !quiet { print_line("Switched to a new branch '\{branch_name}'") } return @@ -140,7 +140,7 @@ async fn handle_switch(args : Array[String]) -> Unit raise Error { raise @bitcore.GitError::InvalidObject("No branch specified") } let branch_name = normalize_switch_branch_ref(name) - if !(ignore_other_worktrees) { + if !ignore_other_worktrees { match switch_branch_in_use_path(rfs, root, branch_name) { Some(_) => { eprint_line( @@ -152,8 +152,7 @@ async fn handle_switch(args : Array[String]) -> Unit raise Error { } } let refname = branch_name - if @bitlib.resolve_ref(rfs, git_dir, refname) is Some(_) && - !(force_create) { + if @bitlib.resolve_ref(rfs, git_dir, refname) is Some(_) && !force_create { raise @bitcore.GitError::InvalidObject( "branch '\{branch_name}' already exists", ) @@ -185,7 +184,7 @@ async fn handle_switch(args : Array[String]) -> Unit raise Error { } } save_previous_checkout_location(fs, git_dir, previous_location) - if !(quiet) { + if !quiet { print_line("Switched to a new branch '\{branch_name}'") } return @@ -206,7 +205,7 @@ async fn handle_switch(args : Array[String]) -> Unit raise Error { let local_branch_exists = @bitlib.resolve_ref(rfs, git_dir, target_ref) is Some(_) if local_branch_exists { - if !(ignore_other_worktrees) { + if !ignore_other_worktrees { match switch_branch_in_use_path(rfs, root, target_ref) { Some(_) => { eprint_line( @@ -220,7 +219,7 @@ async fn handle_switch(args : Array[String]) -> Unit raise Error { let previous_location = current_checkout_location(rfs, git_dir) ignore(checkout_with_promisor_retry(fs, root, target)) save_previous_checkout_location(fs, git_dir, previous_location) - if !(quiet) { + if !quiet { print_line("Switched to branch '\{target}'") } return @@ -232,7 +231,7 @@ async fn handle_switch(args : Array[String]) -> Unit raise Error { let previous_location = current_checkout_location(rfs, git_dir) ignore(checkout_with_promisor_retry(fs, root, target)) save_previous_checkout_location(fs, git_dir, previous_location) - if !(quiet) { + if !quiet { print_line("Switched to branch '\{target}'") } return diff --git a/src/cmd/bit/switch_wbtest.mbt b/src/cmd/bit/switch_wbtest.mbt index 8758abec..242695c0 100644 --- a/src/cmd/bit/switch_wbtest.mbt +++ b/src/cmd/bit/switch_wbtest.mbt @@ -18,7 +18,7 @@ async fn switch_wbtest_run_shim_git( // Build the native binary first so exit codes propagate correctly // (moon run swallows non-zero exit codes) let bit_exe = repo_root + "/_build/native/release/build/cmd/bit/bit.exe" - if !(fs.is_file(bit_exe)) { + if !fs.is_file(bit_exe) { let build_code = @process.run( "moon", ["build", "--target", "native", "--release"], @@ -216,7 +216,7 @@ async fn switch_wbtest_case_create_branch_in_unborn_repo_keeps_ref_unborn() -> U decode_bytes(fs.read_file(git_dir + "/HEAD")), "ref: refs/heads/topic\n", ) - assert_true(!(fs.is_file(git_dir + "/refs/heads/topic"))) + assert_true(!fs.is_file(git_dir + "/refs/heads/topic")) fs.write_string(repo_dir + "/topic.t", "topic\n") add_test_run_git(repo_dir, ["add", "topic.t"]) diff --git a/src/cmd/bit/symbolic_ref.mbt b/src/cmd/bit/symbolic_ref.mbt index 062b18c7..9766710e 100644 --- a/src/cmd/bit/symbolic_ref.mbt +++ b/src/cmd/bit/symbolic_ref.mbt @@ -9,7 +9,7 @@ async fn handle_symbolic_ref(args : Array[String]) -> Unit raise Error { match arg { "-d" | "--delete" => delete_mode = true "--short" => short_mode = true - _ if !(arg.has_prefix("-")) => positional.push(arg) + _ if !arg.has_prefix("-") => positional.push(arg) _ if arg.has_prefix("-") => warn_unimplemented_arg("symbolic-ref", arg) _ => () } @@ -29,7 +29,7 @@ async fn handle_symbolic_ref(args : Array[String]) -> Unit raise Error { } if positional.length() == 1 { // Read mode - if !(fs.is_file(ref_path)) { + if !fs.is_file(ref_path) { raise @bitcore.GitError::InvalidObject("ref \{name} not found") } let content = decode_bytes(fs.read_file(ref_path)) diff --git a/src/cmd/bit/tag.mbt b/src/cmd/bit/tag.mbt index 0323a3aa..8f1c0631 100644 --- a/src/cmd/bit/tag.mbt +++ b/src/cmd/bit/tag.mbt @@ -168,7 +168,7 @@ async fn handle_tag(args : Array[String]) -> Unit raise Error { String::unsafe_substring(arg, start=12, end=arg.length()), ) "--points-at" => { - if i + 1 < args.length() && !(args[i + 1].has_prefix("-")) { + if i + 1 < args.length() && !args[i + 1].has_prefix("-") { points_at.push(args[i + 1]) i += 2 continue @@ -178,7 +178,7 @@ async fn handle_tag(args : Array[String]) -> Unit raise Error { _ if arg.has_prefix("--merged=") => merged = Some(String::unsafe_substring(arg, start=9, end=arg.length())) "--merged" => { - if i + 1 < args.length() && !(args[i + 1].has_prefix("-")) { + if i + 1 < args.length() && !args[i + 1].has_prefix("-") { merged = Some(args[i + 1]) i += 2 continue @@ -190,7 +190,7 @@ async fn handle_tag(args : Array[String]) -> Unit raise Error { String::unsafe_substring(arg, start=12, end=arg.length()), ) "--no-merged" => { - if i + 1 < args.length() && !(args[i + 1].has_prefix("-")) { + if i + 1 < args.length() && !args[i + 1].has_prefix("-") { no_merged = Some(args[i + 1]) i += 2 continue @@ -202,7 +202,7 @@ async fn handle_tag(args : Array[String]) -> Unit raise Error { "--color=auto" => color_mode = "auto" "--no-color" | "--color=never" => color_mode = "never" "--column" => { - if i + 1 < args.length() && !(args[i + 1].has_prefix("-")) { + if i + 1 < args.length() && !args[i + 1].has_prefix("-") { column_mode = Some(args[i + 1]) i += 2 continue @@ -214,7 +214,7 @@ async fn handle_tag(args : Array[String]) -> Unit raise Error { column_mode = Some( String::unsafe_substring(arg, start=9, end=arg.length()), ) - _ if !(arg.has_prefix("-")) => + _ if !arg.has_prefix("-") => if delete_mode { delete_tags.push(arg) } else if explicit_list { @@ -269,12 +269,12 @@ async fn handle_tag(args : Array[String]) -> Unit raise Error { ) } // Determine list mode: if no create/delete args, default to list - if !(delete_mode) && - !(annotated) && + if !delete_mode && + !annotated && message is None && message_file is None && - !(force) && - !(verify_mode) { + !force && + !verify_mode { if tag_name is None { list_mode = true } else if explicit_list || list_like { @@ -355,7 +355,7 @@ async fn handle_tag(args : Array[String]) -> Unit raise Error { break } } - if !(matched) { + if !matched { continue } } @@ -375,7 +375,7 @@ async fn handle_tag(args : Array[String]) -> Unit raise Error { None => () } } - if !(matches) { + if !matches { continue } } @@ -492,7 +492,7 @@ async fn handle_tag(args : Array[String]) -> Unit raise Error { @sys.exit(128) return } - if !(tag_is_valid_name(name)) { + if !tag_is_valid_name(name) { raise @bitcore.GitError::InvalidObject("invalid tag name: " + name) } // Resolve target (default to HEAD) @@ -501,8 +501,7 @@ async fn handle_tag(args : Array[String]) -> Unit raise Error { guard resolved_target is Some(id) else { raise @bitcore.GitError::InvalidObject("unknown revision: \{target_ref}") } - if !(force) && - @bitlib.resolve_ref(fs, git_dir, "refs/tags/" + name) is Some(_) { + if !force && @bitlib.resolve_ref(fs, git_dir, "refs/tags/" + name) is Some(_) { raise @bitcore.GitError::InvalidObject("tag '\{name}' already exists") } let (tag_message, edit_path) = tag_resolve_message( @@ -609,7 +608,7 @@ fn tag_expand_short_bundles(args : Array[String]) -> Array[String] { ///| fn tag_expand_short_bundle_arg(arg : String) -> Array[String]? { - if arg.length() <= 2 || !(arg.has_prefix("-")) || arg.has_prefix("--") { + if arg.length() <= 2 || !arg.has_prefix("-") || arg.has_prefix("--") { return None } let chars = arg.to_array() @@ -730,7 +729,7 @@ fn tag_apply_column_mode( raise @bitcore.GitError::InvalidObject("unsupported option '\{token}'") } } - if saw_layout && !(saw_enable) { + if saw_layout && !saw_enable { next_enabled_state = "enabled" } (next_enabled_state, next_layout, next_dense) @@ -915,7 +914,7 @@ fn tag_format_columns_with_layout( } else { idx + rows >= items.length() } - if !(newline) { + if !newline { let cell_width = widths[x] + padding line += " ".repeat(cell_width - lengths[idx]) } @@ -966,13 +965,13 @@ fn tag_apply_trailers(message : String, trailers : Array[String]) -> String { last_nonblank -= 1 } let need_blank = if last_nonblank >= 0 { - !(commit_is_trailer_line(lines[last_nonblank])) + !commit_is_trailer_line(lines[last_nonblank]) } else { true } let result = StringBuilder::new() result.write_string(message) - if !(message.has_suffix("\n")) { + if !message.has_suffix("\n") { result.write_char('\n') } if need_blank { @@ -1292,7 +1291,7 @@ fn tag_edit_buffer_template(initial_message : String?) -> String { Some(message) => if message.length() > 0 { sb.write_string(message) - if !(message.has_suffix("\n")) { + if !message.has_suffix("\n") { sb.write_string("\n") } sb.write_string("\n") @@ -1362,7 +1361,7 @@ fn tag_cleanup_message(raw : String) -> String { for line in lines { let blank = line.trim().to_string().length() == 0 if blank { - if !(previous_blank) { + if !previous_blank { compact.push("") } previous_blank = true @@ -1560,9 +1559,7 @@ fn tag_maybe_append_reflog( if create_reflog { @bitrepo.create_reflog(wfs, rfs, git_dir, refname) } - if !(create_reflog) && - !(always) && - !(@bitrepo.reflog_exists(rfs, git_dir, refname)) { + if !create_reflog && !always && !@bitrepo.reflog_exists(rfs, git_dir, refname) { return } let name_end = tagger.find(" <").unwrap_or(tagger.length()) @@ -1733,7 +1730,7 @@ fn tag_apply_list_filters( let commit_id = tag_peel_to_commit(fs, db, ref_id) guard commit_id is Some(cid) else { continue } match merged_id { - Some(mid) => if !(tag_is_ancestor(fs, db, cid, mid)) { continue } + Some(mid) => if !tag_is_ancestor(fs, db, cid, mid) { continue } None => () } match no_merged_id { @@ -1741,10 +1738,7 @@ fn tag_apply_list_filters( None => () } match contains_id { - Some(ancestor) => - if !(tag_is_ancestor(fs, db, ancestor, cid)) { - continue - } + Some(ancestor) => if !tag_is_ancestor(fs, db, ancestor, cid) { continue } None => () } match no_contains_id { @@ -1809,7 +1803,7 @@ fn tag_validate_sort_keys(sort_keys : Array[String]) -> Unit raise Error { } else { key } - if !(tag_is_valid_sort_field(sort_field)) { + if !tag_is_valid_sort_field(sort_field) { raise @bitcore.GitError::InvalidObject( "unsupported sort specification: " + sort_field, ) @@ -1951,8 +1945,8 @@ fn tag_versionsort_parse_config_text( in_versionsort = section.to_lower() == "versionsort" } else if in_versionsort && trimmed.length() > 0 && - !(trimmed.has_prefix("#")) && - !(trimmed.has_prefix(";")) { + !trimmed.has_prefix("#") && + !trimmed.has_prefix(";") { match trimmed.find("=") { Some(idx) => { let key = trim_string( @@ -2141,7 +2135,7 @@ fn tag_version_compare_with_suffixes( 2 => diff 3 => { while tag_version_is_digit(tag_version_char_at(a_chars, i1)) { - if !(tag_version_is_digit(tag_version_char_at(b_chars, i2))) { + if !tag_version_is_digit(tag_version_char_at(b_chars, i2)) { return 1 } i1 += 1 diff --git a/src/cmd/bit/tag_wbtest.mbt b/src/cmd/bit/tag_wbtest.mbt index 177ccb46..70e7551b 100644 --- a/src/cmd/bit/tag_wbtest.mbt +++ b/src/cmd/bit/tag_wbtest.mbt @@ -153,10 +153,10 @@ test "tag: sort field aliases normalize to refname variants" { ///| test "tag: validate tag name rejects invalid forms" { assert_true(tag_is_valid_name("release/v1.0")) - assert_true(!(tag_is_valid_name(".othertag"))) - assert_true(!(tag_is_valid_name("other tag"))) - assert_true(!(tag_is_valid_name("othertag^"))) - assert_true(!(tag_is_valid_name("other~tag"))) + assert_true(!tag_is_valid_name(".othertag")) + assert_true(!tag_is_valid_name("other tag")) + assert_true(!tag_is_valid_name("othertag^")) + assert_true(!tag_is_valid_name("other~tag")) } ///| diff --git a/src/cmd/bit/unpack_objects.mbt b/src/cmd/bit/unpack_objects.mbt index aeba5614..689c1b4b 100644 --- a/src/cmd/bit/unpack_objects.mbt +++ b/src/cmd/bit/unpack_objects.mbt @@ -21,7 +21,7 @@ async fn handle_unpack_objects(args : Array[String]) -> Unit raise Error { } // Parse the packfile let objects = @pack.parse_packfile(data) - if !(quiet) { + if !quiet { print_line( "Unpacking objects: 100% (\{objects.length()}/\{objects.length()}), done.", ) diff --git a/src/cmd/bit/update_index.mbt b/src/cmd/bit/update_index.mbt index a17a7717..3cfb9853 100644 --- a/src/cmd/bit/update_index.mbt +++ b/src/cmd/bit/update_index.mbt @@ -133,7 +133,7 @@ async fn handle_update_index(args : Array[String]) -> Unit raise Error { } break } - _ if !(arg.has_prefix("-")) => + _ if !arg.has_prefix("-") => match current_chmod { Some(mode) => chmod_updates.push((arg, mode)) None => paths.push(arg) @@ -212,7 +212,7 @@ async fn handle_update_index(args : Array[String]) -> Unit raise Error { } } // Check D/F conflicts for --cacheinfo entries - if direct_updates.length() > 0 && !(replace) { + if direct_updates.length() > 0 && !replace { let existing_entries_for_df = @bitlib.read_index_entries(fs, git_dir) let existing_paths : Map[String, Bool] = {} for entry in existing_entries_for_df { @@ -418,7 +418,7 @@ fn parse_update_index_info_line( } } 4 => - if !(is_update_index_object_type(fields[1])) { + if !is_update_index_object_type(fields[1]) { None } else { match parse_update_index_stage(fields[3]) { @@ -717,16 +717,14 @@ fn parse_update_index_version(value : String) -> Int? { ///| fn update_index_read_header_version(fs : OsFs, git_dir : String) -> Int { let index_path = git_dir + "/index" - if !(fs.is_file(index_path)) { + if !fs.is_file(index_path) { return 2 } let data = fs.read_file(index_path) catch { _ => return 2 } if data.length() < 12 { return 2 } - if !( - data[0] == b'D' && data[1] == b'I' && data[2] == b'R' && data[3] == b'C', - ) { + if !(data[0] == b'D' && data[1] == b'I' && data[2] == b'R' && data[3] == b'C') { return 2 } (data[4].to_int() << 24) | @@ -743,7 +741,7 @@ fn update_index_write_header_version( ) -> Unit raise Error { let index_path = git_dir + "/index" let hash_size = update_index_repo_hash_size(fs, git_dir) - if !(fs.is_file(index_path)) { + if !fs.is_file(index_path) { update_index_write_entries(fs, git_dir, []) } let data = fs.read_file(index_path) @@ -785,7 +783,7 @@ async fn update_index_apply_chmod( for op in ops { let (raw_path, _) = op let normalized = normalize_update_index_path(raw_path) - if !(seen.contains(normalized)) { + if !seen.contains(normalized) { stage_paths.push(normalized) seen[normalized] = true } @@ -798,7 +796,7 @@ async fn update_index_apply_chmod( } let filtered_entries : Array[@bitlib.IndexEntry] = [] for entry in existing_entries { - if !(stage_set.contains(normalize_update_index_path(entry.path))) { + if !stage_set.contains(normalize_update_index_path(entry.path)) { filtered_entries.push(entry) } } @@ -1084,7 +1082,7 @@ async fn update_index_stage_paths( } let filtered_entries : Array[@bitlib.IndexEntry] = [] for e in existing_entries { - if !(add_set.contains(normalize_update_index_path(e.path))) { + if !add_set.contains(normalize_update_index_path(e.path)) { filtered_entries.push(e) } } @@ -1135,7 +1133,7 @@ fn update_index_remove_paths( } let filtered : Array[@bitlib.IndexEntry] = [] for e in entries { - if !(remove_set.contains(normalize_update_index_path(e.path))) { + if !remove_set.contains(normalize_update_index_path(e.path)) { filtered.push(e) } } @@ -1169,7 +1167,7 @@ async fn handle_update_index_paths( let exists = @bitio.lstat_entry_meta(full_path) is Some(_) || update_index_read_gitlink_entry(fs, root, normalized_path) is Some(_) let tracked_path = tracked.contains(normalized_path) - if force_remove || (remove_requested && (tracked_path || !(exists))) { + if force_remove || (remove_requested && (tracked_path || !exists)) { remove_paths.push(normalized_path) } else if exists { if add_requested || tracked_path { @@ -1184,7 +1182,7 @@ async fn handle_update_index_paths( } } if errors.length() > 0 { - if !(quiet) { + if !quiet { for path in errors { eprint_line("error: " + path + ": does not exist") } @@ -1245,7 +1243,7 @@ async fn handle_update_index_refresh( deleted[path] = true } let unmerged_paths = @bitlib.read_unmerged_paths(fs, git_dir) - if !(allow_unmerged) { + if !allow_unmerged { let selected_unmerged_paths : Map[String, Bool] = {} for item in stage_entries { let normalized_path = normalize_update_index_path(item.entry.path) @@ -1255,7 +1253,7 @@ async fn handle_update_index_refresh( } } if selected_unmerged_paths.length() > 0 { - if !(quiet) { + if !quiet { for item in selected_unmerged_paths.to_array() { let (path, _) = item print_line(path) @@ -1277,7 +1275,7 @@ async fn handle_update_index_refresh( let mut force_write = false for entry in entries { let normalized_path = normalize_update_index_path(entry.path) - if requested.length() > 0 && !(requested.contains(normalized_path)) { + if requested.length() > 0 && !requested.contains(normalized_path) { refreshed.push(entry) continue } @@ -1291,7 +1289,7 @@ async fn handle_update_index_refresh( } if update_index_gitlink_is_modified(fs, root, normalized_path, entry.id) { has_error = true - if !(quiet) { + if !quiet { print_line(normalized_path) } } @@ -1299,9 +1297,9 @@ async fn handle_update_index_refresh( } if deleted.contains(normalized_path) { refreshed.push(entry) - if !(ignore_missing) { + if !ignore_missing { has_error = true - if !(quiet) { + if !quiet { print_line(normalized_path) } } @@ -1310,7 +1308,7 @@ async fn handle_update_index_refresh( if modified.contains(normalized_path) { refreshed.push(entry) has_error = true - if !(quiet) { + if !quiet { print_line(normalized_path) } continue @@ -1328,7 +1326,7 @@ async fn handle_update_index_refresh( } else { refreshed.push(entry) has_error = true - if !(quiet) { + if !quiet { print_line(normalized_path) } } @@ -1353,9 +1351,9 @@ async fn handle_update_index_refresh( } None => { refreshed.push(entry) - if !(ignore_missing) { + if !ignore_missing { has_error = true - if !(quiet) { + if !quiet { print_line(normalized_path) } } @@ -1369,7 +1367,7 @@ async fn handle_update_index_refresh( } merged_stage_entries.append(preserved_unmerged_stage_entries) update_index_write_stage_entries(fs, git_dir, merged_stage_entries) - } else if force_write || !(update_index_entries_equal(entries, refreshed)) { + } else if force_write || !update_index_entries_equal(entries, refreshed) { update_index_write_entries_preserving_flags(fs, git_dir, refreshed) } if has_error { @@ -1414,7 +1412,7 @@ async fn handle_update_index_again( deleted_paths.push(path) } } - if deleted_paths.length() > 0 && !(remove_missing) { + if deleted_paths.length() > 0 && !remove_missing { @sys.exit(1) } if modified_paths.length() > 0 { @@ -1425,7 +1423,7 @@ async fn handle_update_index_again( } let filtered_entries : Array[@bitlib.IndexEntry] = [] for entry in existing_entries { - if !(add_set.contains(normalize_update_index_path(entry.path))) { + if !add_set.contains(normalize_update_index_path(entry.path)) { filtered_entries.push(entry) } } @@ -1440,7 +1438,7 @@ async fn handle_update_index_again( } let filtered : Array[@bitlib.IndexEntry] = [] for entry in entries { - if !(deleted_set.contains(normalize_update_index_path(entry.path))) { + if !deleted_set.contains(normalize_update_index_path(entry.path)) { filtered.push(entry) } } diff --git a/src/cmd/bit/update_index_wbtest.mbt b/src/cmd/bit/update_index_wbtest.mbt index 231553b4..f2c5976d 100644 --- a/src/cmd/bit/update_index_wbtest.mbt +++ b/src/cmd/bit/update_index_wbtest.mbt @@ -95,7 +95,7 @@ async fn update_index_wbtest_run_sparse_checkout_shim( // Build the native binary first so exit codes propagate correctly // (moon run swallows non-zero exit codes) let bit_exe = repo_root + "/_build/native/release/build/cmd/bit/bit.exe" - if !(fs.is_file(bit_exe)) { + if !fs.is_file(bit_exe) { let build_code = @process.run( "moon", ["build", "--target", "native", "--release"], diff --git a/src/cmd/bit/update_ref.mbt b/src/cmd/bit/update_ref.mbt index f0c4a6d6..43ea1f45 100644 --- a/src/cmd/bit/update_ref.mbt +++ b/src/cmd/bit/update_ref.mbt @@ -42,10 +42,10 @@ fn update_ref_storage_runtime_delegate_args( let normalized_refname = @bitlib.normalize_repo_path(parsed.refname) catch { _ => return None } - if !(parsed.refname.has_prefix("refs/")) { + if !parsed.refname.has_prefix("refs/") { return None } - if !(normalized_refname.has_prefix("refs/")) { + if !normalized_refname.has_prefix("refs/") { return None } if resolve_symbolic_ref_target(fs, git_dir, normalized_refname) is Some(_) { @@ -108,7 +108,7 @@ async fn handle_update_ref(args : Array[String]) -> Unit raise Error { message = Some(args[i + 1]) i += 1 } - _ if !(arg.has_prefix("-")) => positional.push(arg) + _ if !arg.has_prefix("-") => positional.push(arg) _ if arg.has_prefix("-") => warn_unimplemented_arg("update-ref", arg) _ => () } @@ -218,7 +218,7 @@ async fn handle_update_ref(args : Array[String]) -> Unit raise Error { } } } - if !(ok) { + if !ok { eprint_line("fatal: update-ref: verify failed for " + tokens[1]) @sys.exit(1) } @@ -241,8 +241,7 @@ async fn handle_update_ref(args : Array[String]) -> Unit raise Error { let refname = resolve_update_target_ref( fs, actual_git_dir, input_refname, no_deref, ) - if !(no_deref) && - has_symbolic_ref_cycle(fs, actual_git_dir, input_refname) { + if !no_deref && has_symbolic_ref_cycle(fs, actual_git_dir, input_refname) { @stdio.stderr.write( "error: cannot lock ref '\{input_refname}': unable to resolve reference '\{input_refname}'", ) @@ -336,7 +335,7 @@ async fn handle_update_ref(args : Array[String]) -> Unit raise Error { let refname = resolve_update_target_ref( fs, actual_git_dir, input_refname, no_deref, ) - if !(no_deref) && has_symbolic_ref_cycle(fs, actual_git_dir, input_refname) { + if !no_deref && has_symbolic_ref_cycle(fs, actual_git_dir, input_refname) { @stdio.stderr.write( "error: cannot lock ref '\{input_refname}': unable to resolve reference '\{input_refname}'", ) @@ -389,7 +388,7 @@ async fn handle_update_ref(args : Array[String]) -> Unit raise Error { None => "" Some(i) => String::unsafe_substring(ref_path, start=0, end=i) } - if dir.length() > 0 && !(fs.is_dir(dir)) { + if dir.length() > 0 && !fs.is_dir(dir) { fs.mkdir_p(dir) } // Write the ref @@ -469,14 +468,14 @@ fn resolve_symbolic_ref_target( let mut depth = 0 while depth < 8 { let ref_path = git_dir + "/" + current - if !(fs.is_file(ref_path)) { + if !fs.is_file(ref_path) { return if current == refname { None } else { Some(current) } } let content = decode_bytes(fs.read_file(ref_path)) catch { _ => return if current == refname { None } else { Some(current) } } let line = trim_chars(content, " \t\r\n") - if !(line.has_prefix("ref: ")) { + if !line.has_prefix("ref: ") { return if current == refname { None } else { Some(current) } } current = String::unsafe_substring(line, start=5, end=line.length()) @@ -518,7 +517,7 @@ fn delete_packed_ref_entry( refname : String, ) -> Unit raise Error { let packed_refs_path = git_dir + "/packed-refs" - if !(fs.is_file(packed_refs_path)) { + if !fs.is_file(packed_refs_path) { return () } let content = decode_bytes(fs.read_file(packed_refs_path)) catch { @@ -535,9 +534,7 @@ fn delete_packed_ref_entry( continue } skip_peeled = false - if line.length() > 0 && - !(line.has_prefix("#")) && - !(line.has_prefix("^")) { + if line.length() > 0 && !line.has_prefix("#") && !line.has_prefix("^") { let space_idx = line.find(" ") match space_idx { Some(i) => { @@ -579,14 +576,14 @@ fn has_symbolic_ref_cycle( } visited.push(current) let ref_path = git_dir + "/" + current - if !(fs.is_file(ref_path)) { + if !fs.is_file(ref_path) { return false } let content = decode_bytes(fs.read_file(ref_path)) catch { _ => return false } let line = trim_chars(content, " \t\r\n") - if !(line.has_prefix("ref: ")) { + if !line.has_prefix("ref: ") { return false } current = String::unsafe_substring(line, start=5, end=line.length()) @@ -750,7 +747,7 @@ async fn handle_update_ref_reftable( "-d" | "--delete" => delete_mode = true "--create-reflog" | "--no-deref" => () "-m" if i + 1 < args.length() => i += 1 - _ if !(arg.has_prefix("-")) => positional.push(arg) + _ if !arg.has_prefix("-") => positional.push(arg) _ => () } i += 1 @@ -772,7 +769,7 @@ async fn handle_update_ref_reftable( 0UL } let next_index = max_update_index + 1UL - if !(delete_mode) && positional.length() < 2 { + if !delete_mode && positional.length() < 2 { @stdio.stderr.write("fatal: update-ref requires a value argument\n") @sys.exit(1) } diff --git a/src/cmd/bit/upload_archive.mbt b/src/cmd/bit/upload_archive.mbt index 5f0ef30c..683a2198 100644 --- a/src/cmd/bit/upload_archive.mbt +++ b/src/cmd/bit/upload_archive.mbt @@ -12,7 +12,7 @@ async fn handle_upload_archive(args : Array[String]) -> Unit raise Error { // Parse repository path from args (last non-flag argument) let mut repo_path = "" for arg in args { - if !(arg.has_prefix("-")) { + if !arg.has_prefix("-") { repo_path = arg } } @@ -28,7 +28,7 @@ async fn handle_upload_archive(args : Array[String]) -> Unit raise Error { let fs = OsFs::new() let git_dir = if root.has_suffix(".git") && !root.has_suffix("/.git") { root - } else if fs.is_file(root + "/HEAD") && !(fs.is_dir(root + "/.git")) { + } else if fs.is_file(root + "/HEAD") && !fs.is_dir(root + "/.git") { root } else { root + "/.git" @@ -93,7 +93,7 @@ async fn handle_upload_archive(args : Array[String]) -> Unit raise Error { } else if arg.has_prefix("-") { // Skip other flags silently () - } else if !(tree_ish_set) { + } else if !tree_ish_set { tree_ish = arg tree_ish_set = true } else { diff --git a/src/cmd/bit/upload_pack.mbt b/src/cmd/bit/upload_pack.mbt index 6fc156f3..0f13a211 100644 --- a/src/cmd/bit/upload_pack.mbt +++ b/src/cmd/bit/upload_pack.mbt @@ -151,7 +151,7 @@ async fn upload_pack_fail( ) -> Unit { let _ : Int = protocol_version let msg = upload_pack_error_text(err) - if !(advertise) { + if !advertise { let line = upload_pack_first_line(msg) let pkt = @protocol.pktline_encode("ERR " + line + "\n") @stdio.stdout.write(pkt) diff --git a/src/cmd/bit/verify_commit.mbt b/src/cmd/bit/verify_commit.mbt index e35b5bc5..1e5e206f 100644 --- a/src/cmd/bit/verify_commit.mbt +++ b/src/cmd/bit/verify_commit.mbt @@ -73,7 +73,7 @@ async fn handle_verify_commit(args : Array[String]) -> Unit raise Error { continue } } - if not(verified) { + if !verified { had_error = true } } diff --git a/src/cmd/bit/verify_pack.mbt b/src/cmd/bit/verify_pack.mbt index 203aebfd..ae283a57 100644 --- a/src/cmd/bit/verify_pack.mbt +++ b/src/cmd/bit/verify_pack.mbt @@ -8,7 +8,7 @@ async fn handle_verify_pack(args : Array[String]) -> Unit raise Error { match arg { "-v" | "--verbose" => verbose = true "-s" | "--stat-only" => stat_only = true - _ if !(arg.has_prefix("-")) => pack_files.push(arg) + _ if !arg.has_prefix("-") => pack_files.push(arg) _ if arg.has_prefix("-") => warn_unimplemented_arg("verify-pack", arg) _ => () } @@ -40,7 +40,7 @@ async fn verify_single_pack( pack_path } let pack_file = base_path + ".pack" - if !(fs.is_file(pack_file)) { + if !fs.is_file(pack_file) { raise @bitcore.GitError::InvalidObject("pack file not found: " + pack_file) } let data = fs.read_file(pack_file) @@ -61,7 +61,7 @@ async fn verify_single_pack( } total_size += obj.data.length() } - if verbose && !(stat_only) { + if verbose && !stat_only { // Print each object for obj in objects { let id = @bitcore.hash_object_content(obj.obj_type, obj.data) diff --git a/src/cmd/bit/worktree.mbt b/src/cmd/bit/worktree.mbt index 0f474f3d..1710c1a1 100644 --- a/src/cmd/bit/worktree.mbt +++ b/src/cmd/bit/worktree.mbt @@ -57,7 +57,7 @@ fn worktree_resolve_common_git_dir( git_dir : String, ) -> String { let commondir_path = git_dir + "/commondir" - if !(fs.is_file(commondir_path)) { + if !fs.is_file(commondir_path) { return git_dir } let raw = decode_bytes( @@ -99,7 +99,7 @@ fn worktree_quote_path(path : String) -> String { break } } - if !(needs_quote) { + if !needs_quote { return path } let buf = StringBuilder::new() @@ -207,7 +207,7 @@ fn worktree_has_ref_files( fs : &@bitcore.RepoFileSystem, dir : String, ) -> Bool raise Error { - if !(fs.is_dir(dir)) { + if !fs.is_dir(dir) { return false } for entry in fs.readdir(dir) { @@ -364,7 +364,7 @@ async fn worktree_should_infer_orphan( match worktree_local_refs_status(fs, git_dir, common_git_dir) { WorktreeLocalRefsStatus::Available => return false WorktreeLocalRefsStatus::InvalidHead(path, contents) => { - if !(quiet) { + if !quiet { worktree_print_invalid_head_warning(path, contents) } return false @@ -378,14 +378,14 @@ async fn worktree_should_infer_orphan( if worktree_has_ref_files(fs, common_git_dir + "/refs/remotes") { return false } - if !(force) && @bitlib.list_remotes(fs, common_git_dir).length() > 0 { + if !force && @bitlib.list_remotes(fs, common_git_dir).length() > 0 { eprint_line( "fatal: No local or remote refs exist despite at least one remote present, stopping; use 'add -f' to override or fetch a remote first", ) @sys.exit(128) } } - if !(quiet) { + if !quiet { eprint_line("No possible source branch, inferring '--orphan'") } if track_requested { @@ -493,7 +493,7 @@ async fn handle_worktree_list(args : Array[String]) -> Unit raise Error { } } // -z requires --porcelain - if nul_terminated && !(porcelain) { + if nul_terminated && !porcelain { eprint_line("fatal: -z requires --porcelain") @sys.exit(1) } @@ -538,7 +538,7 @@ async fn handle_worktree_list(args : Array[String]) -> Unit raise Error { None => print_str("locked\{sep}") } } - if !(wt.is_main) { + if !wt.is_main { let prunable = @bitlib.get_worktree_prunable_reason(fs, root, wt.path) match prunable { Some(r) => print_str("prunable \{r}\{sep}") @@ -579,7 +579,7 @@ async fn handle_worktree_list(args : Array[String]) -> Unit raise Error { None => () } } - if !(wt.is_main) { + if !wt.is_main { let prunable = @bitlib.get_worktree_prunable_reason(fs, root, wt.path) match prunable { Some(r) => print_line("\tprunable: \{r}") @@ -604,7 +604,7 @@ async fn handle_worktree_list(args : Array[String]) -> Unit raise Error { if wt.locked { suffix = suffix + " locked" } - if !(wt.is_main) { + if !wt.is_main { let prunable = @bitlib.get_worktree_prunable_reason(fs, root, wt.path) if prunable is Some(_) { suffix = suffix + " prunable" @@ -761,7 +761,7 @@ async fn handle_worktree_add(args : Array[String]) -> Unit raise Error { eprint_line("usage: git worktree add [] []") @sys.exit(1) } - if lock_reason is Some(_) && !(lock) { + if lock_reason is Some(_) && !lock { eprint_line("fatal: --reason requires --lock") @sys.exit(1) } @@ -802,7 +802,7 @@ async fn handle_worktree_add(args : Array[String]) -> Unit raise Error { } else if detach { if branch == "HEAD" { match worktree_local_refs_status(fs, git_dir, common_git_dir) { - WorktreeLocalRefsStatus::InvalidHead(path, contents) if !(quiet) => + WorktreeLocalRefsStatus::InvalidHead(path, contents) if !quiet => worktree_print_invalid_head_warning(path, contents) _ => () } @@ -826,7 +826,7 @@ async fn handle_worktree_add(args : Array[String]) -> Unit raise Error { Some(remote_guess) => { branch = remote_guess.refname new_branch = Some(dwim_branch) - if !(no_track) { + if !no_track { tracking_remote = Some(remote_guess.remote_name) tracking_merge = Some("refs/heads/" + dwim_branch) } @@ -847,14 +847,14 @@ async fn handle_worktree_add(args : Array[String]) -> Unit raise Error { ) } } - } else if !(detach) { + } else if !detach { if branch != "-" && @bitlib.rev_parse(fs, common_git_dir, branch) is None { match worktree_guess_remote_branch(fs, common_git_dir, branch) { Some(remote_guess) => { let branch_name = branch new_branch = Some(branch_name) branch = remote_guess.refname - if !(no_track) { + if !no_track { tracking_remote = Some(remote_guess.remote_name) tracking_merge = Some("refs/heads/" + branch_name) } @@ -864,16 +864,16 @@ async fn handle_worktree_add(args : Array[String]) -> Unit raise Error { } if branch == "HEAD" { match worktree_local_refs_status(fs, git_dir, common_git_dir) { - WorktreeLocalRefsStatus::InvalidHead(path, contents) if !(quiet) => + WorktreeLocalRefsStatus::InvalidHead(path, contents) if !quiet => worktree_print_invalid_head_warning(path, contents) _ => () } } } - if !(orphan) && + if !orphan && branch != "-" && @bitlib.rev_parse(fs, common_git_dir, branch) is None { - if !(quiet) && commit_ish is None { + if !quiet && commit_ish is None { let hint_branch = if used_new_branch_options { new_branch } else { None } worktree_print_orphan_hint(wt_path, hint_branch) } @@ -918,7 +918,7 @@ async fn handle_worktree_add(args : Array[String]) -> Unit raise Error { _ => () } // Print success message - if !(quiet) { + if !quiet { match (new_branch, detach, commit_ish, branch) { (Some(b), _, _, _) => print_line("Preparing worktree (new branch '\{b}')") (None, true, _, _) => print_line("Preparing worktree (detached HEAD)") @@ -941,7 +941,7 @@ async fn handle_worktree_remove(args : Array[String]) -> Unit raise Error { for arg in args { match arg { "--force" | "-f" => force_count += 1 - _ if !(arg.has_prefix("-")) => path = Some(arg) + _ if !arg.has_prefix("-") => path = Some(arg) _ if arg.has_prefix("-") => warn_unimplemented_arg("worktree", arg) _ => () } @@ -976,7 +976,7 @@ async fn handle_worktree_prune(args : Array[String]) -> Unit raise Error { expire_before_sec = worktree_parse_expire_before_sec( String::unsafe_substring(arg, start=9, end=arg.length()), ) - _ if !(arg.has_prefix("-")) => { + _ if !arg.has_prefix("-") => { eprint_line("fatal: too many arguments") @sys.exit(128) } @@ -1035,7 +1035,7 @@ async fn handle_worktree_lock(args : Array[String]) -> Unit raise Error { } _ if arg.has_prefix("--reason=") => reason = Some(string_slice_from(arg, 9)) - _ if !(arg.has_prefix("-")) => path = Some(arg) + _ if !arg.has_prefix("-") => path = Some(arg) _ if arg.has_prefix("-") => warn_unimplemented_arg("worktree", arg) _ => () } @@ -1054,7 +1054,7 @@ async fn handle_worktree_unlock(args : Array[String]) -> Unit raise Error { let fs = OsFs::new() let mut path : String? = None for arg in args { - if !(arg.has_prefix("-")) { + if !arg.has_prefix("-") { path = Some(arg) } else { warn_unimplemented_arg("worktree", arg) @@ -1079,7 +1079,7 @@ async fn handle_worktree_move(args : Array[String]) -> Unit raise Error { "--force" | "-f" => force_count += 1 "--relative-paths" => relative_paths = Some(true) "--no-relative-paths" => relative_paths = Some(false) - _ if !(arg.has_prefix("-")) => positional.push(arg) + _ if !arg.has_prefix("-") => positional.push(arg) _ if arg.has_prefix("-") => warn_unimplemented_arg("worktree", arg) _ => () } @@ -1112,7 +1112,7 @@ async fn handle_worktree_repair(args : Array[String]) -> Unit raise Error { match arg { "--relative-paths" => relative_paths = Some(true) "--no-relative-paths" => relative_paths = Some(false) - _ if !(arg.has_prefix("-")) => paths.push(arg) + _ if !arg.has_prefix("-") => paths.push(arg) _ => warn_unimplemented_arg("worktree", arg) } } diff --git a/src/cmd/bit/worktree_wbtest.mbt b/src/cmd/bit/worktree_wbtest.mbt index 92f9e51c..18524a09 100644 --- a/src/cmd/bit/worktree_wbtest.mbt +++ b/src/cmd/bit/worktree_wbtest.mbt @@ -22,7 +22,7 @@ async fn worktree_wbtest_collect_shim_git( // Build the native binary first so exit codes propagate correctly // (moon run swallows non-zero exit codes) let bit_exe = repo_root + "/_build/native/release/build/cmd/bit/bit.exe" - if !(fs.is_file(bit_exe)) { + if !fs.is_file(bit_exe) { let build_code = @process.run( "moon", ["build", "--target", "native", "--release"], @@ -354,10 +354,8 @@ async fn worktree_wbtest_case_explicit_head_creates_detached_worktree() -> Unit expected_head, ) assert_true( - !( - decode_bytes( - fs.read_file(repo_dir + "/.git/worktrees/head-explicit/HEAD"), - ).has_prefix("ref: "), + !decode_bytes(fs.read_file(repo_dir + "/.git/worktrees/head-explicit/HEAD")).has_prefix( + "ref: ", ), ) diff --git a/src/cmd/git-bit/helpers_shared.mbt b/src/cmd/git-bit/helpers_shared.mbt index 00fe2f04..4260ff6c 100644 --- a/src/cmd/git-bit/helpers_shared.mbt +++ b/src/cmd/git-bit/helpers_shared.mbt @@ -68,7 +68,7 @@ fn normalize_path(path : String) -> String { } else if part == ".." { if parts.length() > 0 && parts[parts.length() - 1] != ".." { let _ = parts.pop() - } else if !(path.has_prefix("/")) { + } else if !path.has_prefix("/") { parts.push(part) } } else { diff --git a/src/cmd/git-bit/hub_helpers.mbt b/src/cmd/git-bit/hub_helpers.mbt index ffcb94e7..eb818dab 100644 --- a/src/cmd/git-bit/hub_helpers.mbt +++ b/src/cmd/git-bit/hub_helpers.mbt @@ -89,7 +89,7 @@ fn parse_hub_merge_policy_toml( in_merge_section = section_name == "merge" continue } - if !(in_merge_section) { + if !in_merge_section { continue } let eq_idx = line.find("=") @@ -168,7 +168,7 @@ fn load_hub_merge_policy( git_dir : String, ) -> @hub.PrMergePolicy raise @bitcore.GitError { let policy_path = hub_merge_policy_path(git_dir) - if !(fs.is_file(policy_path)) { + if !fs.is_file(policy_path) { return default_hub_merge_policy() } let content = decode_bytes(fs.read_file(policy_path)) diff --git a/src/cmd/git-bit/hub_issue.mbt b/src/cmd/git-bit/hub_issue.mbt index f20a686c..ae2237d6 100644 --- a/src/cmd/git-bit/hub_issue.mbt +++ b/src/cmd/git-bit/hub_issue.mbt @@ -120,7 +120,7 @@ fn parse_work_item_state_for_list( "Unknown \{unknown_state_label} state: \{value}", ) } - if !(allow_merged) && parsed == @hub.WorkItemState::Merged { + if !allow_merged && parsed == @hub.WorkItemState::Merged { raise @bitcore.GitError::InvalidObject( "Unknown \{unknown_state_label} state: \{value}", ) @@ -276,7 +276,7 @@ async fn handle_hub_issue_list(args : Array[String]) -> Unit raise Error { while j < args.length() { match args[j] { "--all" => show_all = true - "--relay" if j + 1 < args.length() && !(args[j + 1].has_prefix("-")) => { + "--relay" if j + 1 < args.length() && !args[j + 1].has_prefix("-") => { relay_url = Some(args[j + 1]) j += 1 } @@ -342,12 +342,12 @@ async fn handle_hub_issue_list(args : Array[String]) -> Unit raise Error { if filter_labels.length() > 0 { let mut has_all = true for label in filter_labels { - if !(issue.labels.contains(label)) { + if !issue.labels.contains(label) { has_all = false break } } - if !(has_all) { + if !has_all { continue } } diff --git a/src/cmd/git-bit/hub_libgit2_native.mbt b/src/cmd/git-bit/hub_libgit2_native.mbt index 1fa74d17..4f1155d6 100644 --- a/src/cmd/git-bit/hub_libgit2_native.mbt +++ b/src/cmd/git-bit/hub_libgit2_native.mbt @@ -29,7 +29,7 @@ fn hub_libgit2_available() -> Bool { ///| fn hub_git_repository_path(root : String) -> String? { - if !(hub_libgit2_available()) { + if !hub_libgit2_available() { return None } hub_libgit2_decode_nonempty(hub_libgit2_repo_path(str_to_bytes(root))) @@ -37,7 +37,7 @@ fn hub_git_repository_path(root : String) -> String? { ///| fn hub_git_head_ref_name(root : String) -> String? { - if !(hub_libgit2_available()) { + if !hub_libgit2_available() { return None } hub_libgit2_decode_nonempty(hub_libgit2_head_name(str_to_bytes(root))) diff --git a/src/cmd/git-bit/hub_pr.mbt b/src/cmd/git-bit/hub_pr.mbt index a3ffa652..2781f431 100644 --- a/src/cmd/git-bit/hub_pr.mbt +++ b/src/cmd/git-bit/hub_pr.mbt @@ -197,7 +197,7 @@ async fn handle_hub_pr_status(args : Array[String]) -> Unit raise Error { let author = get_author_string() let mut mine_count = 0 for pr in open_prs { - if pr.author() == author && !(branch_ids.contains(pr.id())) { + if pr.author() == author && !branch_ids.contains(pr.id()) { if mine_count == 0 { print_line("Open pull requests authored by \{author}:") } diff --git a/src/cmd/git-bit/hub_search.mbt b/src/cmd/git-bit/hub_search.mbt index e9620020..e59cb400 100644 --- a/src/cmd/git-bit/hub_search.mbt +++ b/src/cmd/git-bit/hub_search.mbt @@ -71,7 +71,7 @@ fn push_unique_search_type( types : Array[HubSearchType], t : HubSearchType, ) -> Unit { - if !(hub_search_has_type(types, t)) { + if !hub_search_has_type(types, t) { types.push(t) } } @@ -125,7 +125,7 @@ fn parse_hub_search_types(value : String) -> Array[HubSearchType]? { if token.length() == 0 { continue } - if !(append_hub_search_types_by_token(out, token)) { + if !append_hub_search_types_by_token(out, token) { return None } } @@ -172,7 +172,7 @@ fn parse_hub_search_options( "Unknown hub search type: \{value}", ) } - if !(type_filter_set) { + if !type_filter_set { types = [] type_filter_set = true } @@ -194,7 +194,7 @@ fn parse_hub_search_options( "Unknown hub search type: \{value}", ) } - if !(type_filter_set) { + if !type_filter_set { types = [] type_filter_set = true } @@ -350,7 +350,7 @@ fn matches_labels_filter( lower_labels.push(label.to_lower()) } for required in required_labels { - if !(lower_labels.contains(required.to_lower())) { + if !lower_labels.contains(required.to_lower()) { return false } } @@ -454,10 +454,10 @@ async fn handle_hub_search(args : Array[String]) -> Unit raise Error { if search_limit_reached(options.limit, results.length()) { break } - if !(matches_pr_state_filter(options.state, pr.state())) { + if !matches_pr_state_filter(options.state, pr.state()) { continue } - if !(matches_labels_filter(options.labels, pr.labels())) { + if !matches_labels_filter(options.labels, pr.labels()) { continue } if include_pr && @@ -477,7 +477,7 @@ async fn handle_hub_search(args : Array[String]) -> Unit raise Error { if search_limit_reached(options.limit, results.length()) { break } - if !(matches_author_filter(options.author, comment.author())) { + if !matches_author_filter(options.author, comment.author()) { continue } if matches_query_filter(options.query, [ @@ -498,7 +498,7 @@ async fn handle_hub_search(args : Array[String]) -> Unit raise Error { if search_limit_reached(options.limit, results.length()) { break } - if !(matches_author_filter(options.author, review.author())) { + if !matches_author_filter(options.author, review.author()) { continue } if matches_query_filter(options.query, [ @@ -523,10 +523,10 @@ async fn handle_hub_search(args : Array[String]) -> Unit raise Error { if search_limit_reached(options.limit, results.length()) { break } - if !(matches_issue_state_filter(options.state, issue.state())) { + if !matches_issue_state_filter(options.state, issue.state()) { continue } - if !(matches_labels_filter(options.labels, issue.labels())) { + if !matches_labels_filter(options.labels, issue.labels()) { continue } if include_issue && @@ -550,7 +550,7 @@ async fn handle_hub_search(args : Array[String]) -> Unit raise Error { if search_limit_reached(options.limit, results.length()) { break } - if !(matches_author_filter(options.author, comment.author())) { + if !matches_author_filter(options.author, comment.author()) { continue } if matches_query_filter(options.query, [ @@ -633,10 +633,10 @@ async fn handle_hub_search_with_defaults( if search_limit_reached(options.limit, results.length()) { break } - if !(matches_pr_state_filter(options.state, pr.state())) { + if !matches_pr_state_filter(options.state, pr.state()) { continue } - if !(matches_labels_filter(options.labels, pr.labels())) { + if !matches_labels_filter(options.labels, pr.labels()) { continue } if include_pr && @@ -656,7 +656,7 @@ async fn handle_hub_search_with_defaults( if search_limit_reached(options.limit, results.length()) { break } - if !(matches_author_filter(options.author, comment.author())) { + if !matches_author_filter(options.author, comment.author()) { continue } if matches_query_filter(options.query, [ @@ -677,7 +677,7 @@ async fn handle_hub_search_with_defaults( if search_limit_reached(options.limit, results.length()) { break } - if !(matches_author_filter(options.author, review.author())) { + if !matches_author_filter(options.author, review.author()) { continue } if matches_query_filter(options.query, [ @@ -702,10 +702,10 @@ async fn handle_hub_search_with_defaults( if search_limit_reached(options.limit, results.length()) { break } - if !(matches_issue_state_filter(options.state, issue.state())) { + if !matches_issue_state_filter(options.state, issue.state()) { continue } - if !(matches_labels_filter(options.labels, issue.labels())) { + if !matches_labels_filter(options.labels, issue.labels()) { continue } if include_issue && @@ -729,7 +729,7 @@ async fn handle_hub_search_with_defaults( if search_limit_reached(options.limit, results.length()) { break } - if !(matches_author_filter(options.author, comment.author())) { + if !matches_author_filter(options.author, comment.author()) { continue } if matches_query_filter(options.query, [ diff --git a/src/cmd/git-bit/hub_stores.mbt b/src/cmd/git-bit/hub_stores.mbt index 9ea0ca3e..4dbe2a58 100644 --- a/src/cmd/git-bit/hub_stores.mbt +++ b/src/cmd/git-bit/hub_stores.mbt @@ -192,7 +192,7 @@ fn resolve_hub_git_dir_with_bit_backend(root : String) -> String { ///| fn resolve_hub_git_dir_with_git_backend(root : String) -> String { - if !(can_use_hub_git_backend()) { + if !can_use_hub_git_backend() { return resolve_hub_git_dir_with_bit_backend(root) } match hub_git_repository_path(root) { @@ -219,7 +219,7 @@ impl HubRepoBackend for GitHubRepoBackend with resolve_git_dir(_self, root) { ///| impl HubRepoBackend for GitHubRepoBackend with current_branch_name(_self, root) { - if !(can_use_hub_git_backend()) { + if !can_use_hub_git_backend() { let fallback = BitHubRepoBackend::{ } return fallback.current_branch_name(root) } diff --git a/src/cmd/git-bit/hub_stores_wbtest.mbt b/src/cmd/git-bit/hub_stores_wbtest.mbt index 0caeba48..99271f12 100644 --- a/src/cmd/git-bit/hub_stores_wbtest.mbt +++ b/src/cmd/git-bit/hub_stores_wbtest.mbt @@ -59,7 +59,7 @@ test "hub backend: resolve shared git dir follows commondir file" { ///| async test "hub backend: git backend resolves git dir and current branch" { - if !(can_use_hub_git_backend()) { + if !can_use_hub_git_backend() { return () } let fs = OsFs::new() diff --git a/src/config_parse/config_parse.mbt b/src/config_parse/config_parse.mbt index d0872929..1bd9ae2f 100644 --- a/src/config_parse/config_parse.mbt +++ b/src/config_parse/config_parse.mbt @@ -107,7 +107,7 @@ fn config_is_continuation_context(line : String) -> Bool { start=ei + 1, end=line.length(), ) - !(config_has_unquoted_comment_before_backslash(after_eq)) + !config_has_unquoted_comment_before_backslash(after_eq) } } } @@ -119,10 +119,10 @@ fn config_has_unquoted_comment_before_backslash(value : String) -> Bool { for i, c in value { if c == '"' { let escaped = if i > 0 { value[i - 1] == '\\' } else { false } - if !(escaped) { - in_quote = !(in_quote) + if !escaped { + in_quote = !in_quote } - } else if !(in_quote) && (c == '#' || c == ';') { + } else if !in_quote && (c == '#' || c == ';') { last_comment_pos = i break } @@ -178,7 +178,7 @@ fn config_code_in_string(c : UInt16, s : String) -> Bool { pub fn parse_section_header_line( line : String, ) -> (String, String?, String, Bool)? { - if !(line.has_prefix("[")) { + if !line.has_prefix("[") { return None } match line.find("]") { @@ -233,12 +233,10 @@ pub fn is_valid_section_name(name : String) -> Bool { return false } for c in name { - if !( - (c >= 'a' && c <= 'z') || - (c >= 'A' && c <= 'Z') || - (c >= '0' && c <= '9') || - c == '-', - ) { + if !((c >= 'a' && c <= 'z') || + (c >= 'A' && c <= 'Z') || + (c >= '0' && c <= '9') || + c == '-') { return false } } @@ -367,10 +365,8 @@ pub fn find_config_key_line_from_content( } } None => { - if !( - config_section_header_matches( - current_section, current_subsection, sec_l, sub, - ), + if !config_section_header_matches( + current_section, current_subsection, sec_l, sub, ) { continue } @@ -676,7 +672,7 @@ pub fn parse_config_value(raw : String) -> String { trailing_ws = 0 continue } - if !(started) && config_is_horizontal_space(c) { + if !started && config_is_horizontal_space(c) { continue } if c == '"' { @@ -696,7 +692,7 @@ pub fn parse_config_value(raw : String) -> String { continue } if c == '#' || c == ';' { - if !(started) || trailing_ws > 0 { + if !started || trailing_ws > 0 { break } } @@ -824,7 +820,7 @@ fn config_value_pattern_matches(text : String, pattern : String) -> Bool { } let result = config_regex_matches(text, actual) if negate { - !(result) + !result } else { result } @@ -991,7 +987,7 @@ fn config_regex_char_class_matches( i += 1 } if negate { - !(matched) + !matched } else { matched } diff --git a/src/diff/diff_ops.mbt b/src/diff/diff_ops.mbt index 8ce03168..4beb16ae 100644 --- a/src/diff/diff_ops.mbt +++ b/src/diff/diff_ops.mbt @@ -58,9 +58,9 @@ pub async fn diff_worktree( if skip_worktree_paths.contains(path) { continue } - if cache_ready && !(cache_map.contains(path)) { + if cache_ready && !cache_map.contains(path) { let ignored = @bitlib.is_ignored_path(fs, root, path, false) - if !(ignored) { + if !ignored { let old = diff_read_blob(db, fs, entry.id) // Skip if blob not found (e.g., submodule) if old is Some(_) { @@ -117,7 +117,7 @@ pub async fn diff_worktree( } None => () } - if !(mode_changed) && stat_matches { + if !mode_changed && stat_matches { content_changed = false } else { let content = fs.read_file(abs) @@ -145,7 +145,7 @@ pub async fn diff_worktree( } None => () } - if !(mode_changed) && stat_matches { + if !mode_changed && stat_matches { content_changed = false } else { match @bitio.read_symlink_target_path(abs) { @@ -247,11 +247,11 @@ fn diff_worktree_gitlink_change( entry : @bitlib.IndexEntry, ) -> DiffFile? { let sub_root = @bit.join_path(root, entry.path) - if !(fs.is_dir(sub_root)) { + if !fs.is_dir(sub_root) { return None } let sub_git = @bit.join_path(sub_root, ".git") - if !(fs.is_file(sub_git)) && !(fs.is_dir(sub_git)) { + if !fs.is_file(sub_git) && !fs.is_dir(sub_git) { return None } let sub_git_dir = @bitlib.resolve_gitdir(fs, sub_git) @@ -332,7 +332,7 @@ pub fn diff_index( } for item in head_entries.to_array() { let (path, h) = item - if !(index_map.contains(path)) { + if !index_map.contains(path) { let old = diff_content_for_entry(db, fs, h.id, h.mode) // Skip if blob not found (e.g., submodule) if old is Some(_) { @@ -670,7 +670,7 @@ pub fn diff_trees( } // Deleted for path, entry in old_entries { - if !(new_entries.contains(path)) { + if !new_entries.contains(path) { let old_content = diff_content_for_entry(db, fs, entry.id, entry.mode) if old_content is Some(_) { out.push({ @@ -862,7 +862,7 @@ fn normalize_crlf_to_lf(content : Bytes) -> Bytes { out.push(content[i]) i += 1 } - if !(changed) { + if !changed { return content } Bytes::from_array(FixedArray::makei(out.length(), i => out[i])) @@ -891,7 +891,7 @@ fn profile_lap( label : String, start : @bench.Timestamp?, ) -> @bench.Timestamp? { - if !(enabled) { + if !enabled { return start } match start { diff --git a/src/diff_core/diff_core.mbt b/src/diff_core/diff_core.mbt index c9d2fb94..2afbf6bf 100644 --- a/src/diff_core/diff_core.mbt +++ b/src/diff_core/diff_core.mbt @@ -273,8 +273,7 @@ pub fn unified_hunks( last_ins_is_eof = false } out.push("-" + text) - last_del_is_eof = !(old_has_trailing_nl) && - oi == old_lines.length() - 1 + last_del_is_eof = !old_has_trailing_nl && oi == old_lines.length() - 1 } _ => { if last_del_is_eof { @@ -282,8 +281,7 @@ pub fn unified_hunks( last_del_is_eof = false } out.push("+" + text) - last_ins_is_eof = !(new_has_trailing_nl) && - ni == new_lines.length() - 1 + last_ins_is_eof = !new_has_trailing_nl && ni == new_lines.length() - 1 } } } diff --git a/src/fast_import/fast_import_parse.mbt b/src/fast_import/fast_import_parse.mbt index 3cb4f4f5..311c5908 100644 --- a/src/fast_import/fast_import_parse.mbt +++ b/src/fast_import/fast_import_parse.mbt @@ -18,7 +18,7 @@ pub fn fast_import_parse_data( return { content: Bytes::new(0), next_line: start } } let line = lines[start] - if !(line.has_prefix("data ")) { + if !line.has_prefix("data ") { return { content: Bytes::new(0), next_line: start + 1 } } let rest = String::unsafe_substring(line, start=5, end=line.length()) diff --git a/src/grep/pattern.mbt b/src/grep/pattern.mbt index 2ea8109c..becadc86 100644 --- a/src/grep/pattern.mbt +++ b/src/grep/pattern.mbt @@ -186,7 +186,7 @@ pub fn grep_eval_expr( ignore_case, word_regexp~, ) - { matched: !(result.matched), span: result.span } + { matched: !result.matched, span: result.span } } } } @@ -432,7 +432,7 @@ fn grep_fixed_first_match_span( Some(rel_idx) => { let start = offset + rel_idx let end_column = start + pattern_len - if !(word_regexp) || grep_is_word_match(chars, start, end_column) { + if !word_regexp || grep_is_word_match(chars, start, end_column) { return Some({ start_column: start + 1, end_column }) } offset = start + 1 @@ -459,7 +459,7 @@ fn grep_collect_fixed_match_spans( Some(rel_idx) => { let start = offset + rel_idx let end_column = start + pattern_len - if !(word_regexp) || grep_is_word_match(chars, start, end_column) { + if !word_regexp || grep_is_word_match(chars, start, end_column) { spans.push({ start_column: start + 1, end_column }) offset = if end_column > start { end_column } else { start + 1 } } else { @@ -488,7 +488,7 @@ fn grep_regex_like_first_match_span( text_chars, start, pattern_chars, pattern_type, ) { Some(end_column) => - if !(word_regexp) || grep_is_word_match(text_chars, start, end_column) { + if !word_regexp || grep_is_word_match(text_chars, start, end_column) { return Some({ start_column: start + 1, end_column }) } None => () @@ -515,7 +515,7 @@ fn grep_collect_regex_like_match_spans( text_chars, start, pattern_chars, pattern_type, ) { Some(end_column) => - if !(word_regexp) || grep_is_word_match(text_chars, start, end_column) { + if !word_regexp || grep_is_word_match(text_chars, start, end_column) { spans.push({ start_column: start + 1, end_column }) start = if end_column > start { end_column } else { start + 1 } } else { @@ -589,8 +589,7 @@ fn grep_regex_like_match_here( None } Some('+') => { - if ti >= text.length() || - !(grep_regex_like_atom_matches(atom, text[ti])) { + if ti >= text.length() || !grep_regex_like_atom_matches(atom, text[ti]) { return None } let mut max_ti = ti + 1 @@ -618,7 +617,7 @@ fn grep_regex_like_match_here( if ti >= text.length() { return None } - if !(grep_regex_like_atom_matches(atom, text[ti])) { + if !grep_regex_like_atom_matches(atom, text[ti]) { return None } grep_regex_like_match_here( @@ -834,7 +833,7 @@ fn grep_append_unique_spans( break } } - if !(inserted) { + if !inserted { out.push(span) } } @@ -856,7 +855,7 @@ fn grep_is_word_match( } else { grep_is_word_char(text[end_column]) } - !(before_is_word) && !(after_is_word) + !before_is_word && !after_is_word } ///| diff --git a/src/grep/search.mbt b/src/grep/search.mbt index ea93fd18..6f7e15ee 100644 --- a/src/grep/search.mbt +++ b/src/grep/search.mbt @@ -67,14 +67,14 @@ pub fn search_tracked_worktree_expr( let db = @bitlib.ObjectDb::load(fs, git_dir) let matches : Array[GrepFileMatch] = [] for entry in index_entries { - if !(grep_path_matches_filters(entry.path, paths, max_depth)) { + if !grep_path_matches_filters(entry.path, paths, max_depth) { continue } let abs_path = root + "/" + entry.path let has_worktree_file = fs.is_file(abs_path) let content = if assume_unchanged_paths.contains(entry.path) { if skip_worktree_paths.contains(entry.path) { - if !(has_worktree_file) { + if !has_worktree_file { continue } @utf8.decode_lossy(fs.read_file(abs_path)[:]) @@ -87,7 +87,7 @@ pub fn search_tracked_worktree_expr( @utf8.decode_lossy(blob.data[:]) } } else if skip_worktree_paths.contains(entry.path) { - if !(has_worktree_file) { + if !has_worktree_file { continue } @utf8.decode_lossy(fs.read_file(abs_path)[:]) @@ -95,7 +95,7 @@ pub fn search_tracked_worktree_expr( if entry.intent_to_add { continue } - if !(has_worktree_file) { + if !has_worktree_file { continue } @utf8.decode_lossy(fs.read_file(abs_path)[:]) @@ -121,7 +121,7 @@ pub fn list_tracked_worktree_candidate_paths( let assume_unchanged_paths = @bitlib.read_assume_unchanged_paths(fs, git_dir) let out : Array[String] = [] for entry in index_entries { - if !(grep_path_matches_filters(entry.path, paths, max_depth)) { + if !grep_path_matches_filters(entry.path, paths, max_depth) { continue } if entry.intent_to_add && assume_unchanged_paths.contains(entry.path) { @@ -393,7 +393,7 @@ fn search_worktree_paths( let matches : Array[GrepFileMatch] = [] for path in candidate_paths { let abs_path = root + "/" + path - if !(fs.is_file(abs_path)) { + if !fs.is_file(abs_path) { continue } let content = @utf8.decode_lossy(fs.read_file(abs_path)[:]) @@ -863,7 +863,7 @@ fn collect_line_matches( word_regexp~, ) let matched = result.matched - let should_output = if invert_match { !(matched) } else { matched } + let should_output = if invert_match { !matched } else { matched } if should_output { let column = match result.span { Some(value) => value.start_column diff --git a/src/hash/hex.mbt b/src/hash/hex.mbt index 9c70ed7d..839443e3 100644 --- a/src/hash/hex.mbt +++ b/src/hash/hex.mbt @@ -20,7 +20,7 @@ pub fn is_hex_string(s : String) -> Bool { return false } for c in s { - if !(is_hex_char(c)) { + if !is_hex_char(c) { return false } } diff --git a/src/ignore/ignore.mbt b/src/ignore/ignore.mbt index dea99d01..9986a965 100644 --- a/src/ignore/ignore.mbt +++ b/src/ignore/ignore.mbt @@ -162,7 +162,7 @@ pub fn Matcher::is_ignored( let mut ignored = false for rule in self.rules { if rule_applies(rule, rel_path, is_dir) { - ignored = !(rule.negated) + ignored = !rule.negated } } ignored @@ -203,11 +203,11 @@ pub fn Matcher::could_negate_under(self : Matcher, dir_rel : String) -> Bool { return false } for rule in self.rules { - if !(rule.negated) { + if !rule.negated { continue } // Non-path-specific rules (no slash, not anchored) could match anywhere - if !(rule.has_slash) && !(rule.anchored) { + if !rule.has_slash && !rule.anchored { return true } // Path-specific rule: compute target path and check prefix overlap diff --git a/src/ignore/ignore_test.mbt b/src/ignore/ignore_test.mbt index f6fa9f39..e3d1ab4e 100644 --- a/src/ignore/ignore_test.mbt +++ b/src/ignore/ignore_test.mbt @@ -132,7 +132,7 @@ test "git-aware glob filter" { "src/app.ts", "src/data.generated.js", "src/keep.generated.ts", "dist/bundle.js", "lib/build/out.o", "server.log", ] - let visible = files.filter(fn(p) { !(m.is_ignored(p, false)) }) + let visible = files.filter(fn(p) { !m.is_ignored(p, false) }) assert_eq(visible.length(), 2) assert_true(visible.contains("src/app.ts")) assert_true(visible.contains("src/keep.generated.ts")) diff --git a/src/io/native/upload_pack_process.mbt b/src/io/native/upload_pack_process.mbt index d3c86515..30f6cc55 100644 --- a/src/io/native/upload_pack_process.mbt +++ b/src/io/native/upload_pack_process.mbt @@ -283,7 +283,7 @@ fn parse_ssh_authority(authority : String) -> (String, String?) { ///| fn parse_ssh_url_endpoint(raw : String) -> SshEndpoint? { - if !(raw.has_prefix("ssh://")) { + if !raw.has_prefix("ssh://") { return None } let rest = String::unsafe_substring(raw, start=6, end=raw.length()) @@ -1092,7 +1092,7 @@ pub async fn discover_upload_refs_process( } let refs = @protocol.parse_refs(adv) let caps = @protocol.parse_v0_advertised_caps(adv) - let symrefs = parse_symrefs_from_capabilities(caps) + let symrefs = @protocol.parse_symrefs_from_capabilities(caps) (refs, caps, @protocol.ProtocolVersion::V0, symrefs) } @@ -1279,7 +1279,7 @@ fn write_pack_promisor_marker( match default_ref { Some((_, head_id)) => { let head_line = head_id.to_hex() + " HEAD" - if !(seen.contains(head_line)) { + if !seen.contains(head_line) { seen[head_line] = true marker_lines.push(head_line) } diff --git a/src/io/test_fs.mbt b/src/io/test_fs.mbt index 8b62e433..5dd65d0d 100644 --- a/src/io/test_fs.mbt +++ b/src/io/test_fs.mbt @@ -83,7 +83,7 @@ pub fn TestFs::remove_dir( self : TestFs, path : String, ) -> Unit raise @types.GitError { - if !(self.dirs.contains(path)) { + if !self.dirs.contains(path) { raise @types.GitError::IoError("Directory not found: \{path}") } // Check if directory is empty @@ -99,7 +99,7 @@ pub fn TestFs::readdir( self : TestFs, path : String, ) -> Array[String] raise @types.GitError { - if !(self.dirs.contains(path)) { + if !self.dirs.contains(path) { raise @types.GitError::IoError("Directory not found: \{path}") } let entries : Map[String, Bool] = {} diff --git a/src/lib/bench_index_diff_test.mbt b/src/lib/bench_index_diff_test.mbt index 1293a6fe..c85d6e05 100644 --- a/src/lib/bench_index_diff_test.mbt +++ b/src/lib/bench_index_diff_test.mbt @@ -24,7 +24,7 @@ fn bench_index_join_path(root : String, path : String) -> String { ///| fn bench_index_ensure_dir(path : String) -> Unit { - if !(@fs.path_exists(path)) { + if !@fs.path_exists(path) { @fs.create_dir(path) catch { _ => () } diff --git a/src/lib/bench_working_files_test.mbt b/src/lib/bench_working_files_test.mbt index b4fac56b..801482c5 100644 --- a/src/lib/bench_working_files_test.mbt +++ b/src/lib/bench_working_files_test.mbt @@ -30,7 +30,7 @@ let bench_large_root : String = join_path(bench_root_base, "large") ///| fn ensure_dir(path : String) -> Unit { - if !(@fs.path_exists(path)) { + if !@fs.path_exists(path) { @fs.create_dir(path) catch { _ => () } @@ -47,7 +47,7 @@ fn ensure_bench_repo(root : String, file_count : Int, dir_count : Int) -> Unit { ensure_dir(root) ensure_dir(join_path(root, ".git")) let ignore_path = join_path(root, ".gitignore") - if !(@fs.path_exists(ignore_path)) { + if !@fs.path_exists(ignore_path) { @fs.write_string_to_file(ignore_path, "ignore*\n") catch { _ => () } diff --git a/src/lib/bisect.mbt b/src/lib/bisect.mbt index 2df77e1a..d2ad4fd1 100644 --- a/src/lib/bisect.mbt +++ b/src/lib/bisect.mbt @@ -43,7 +43,7 @@ pub fn bisect_get_candidates( continue } visited[hex] = true - if !(skip_set.contains(hex)) && cid != bad { + if !skip_set.contains(hex) && cid != bad { candidates.push(cid) } let obj = db.get(rfs, cid) diff --git a/src/lib/branch.mbt b/src/lib/branch.mbt index c6e11af0..b283e66d 100644 --- a/src/lib/branch.mbt +++ b/src/lib/branch.mbt @@ -203,7 +203,7 @@ pub fn list_remote_branches( ) -> Array[String] { let lines : Array[String] = [] let refs_dir = join_path(git_dir, "refs/remotes") - if !(fs.is_dir(refs_dir)) { + if !fs.is_dir(refs_dir) { return lines } // Walk refs/remotes directory @@ -274,7 +274,7 @@ fn append_branch_creation_reflog( ) -> Unit raise @bit.GitError { let is_bare = branch_is_bare_repo(rfs, root, git_dir) let (should_log, _) = should_log_ref(rfs, git_dir, refname, is_bare) - if !(should_log) { + if !should_log { return } let source_label = branch_creation_source_label(rfs, git_dir, start_point) @@ -395,10 +395,10 @@ fn prune_empty_ref_parent_dirs( while current.length() > 0 && current != stop_dir && current.has_prefix(stop_dir + "/") { - if !(rfs.is_dir(current)) { + if !rfs.is_dir(current) { break } - if !(is_directory_empty(rfs, current)) { + if !is_directory_empty(rfs, current) { break } fs.remove_dir(current) catch { @@ -431,11 +431,11 @@ pub fn delete_branch( let exists = rfs.is_file(ref_path) || resolve_packed_ref(rfs, join_path(git_dir, "packed-refs"), refname) is Some(_) - if !(exists) { + if !exists { raise @bit.GitError::InvalidObject("branch '\{name}' not found") } // Check if branch is fully merged (unless force) - if !(force) { + if !force { let head_commit = resolve_head_commit(rfs, git_dir) let branch_id = match resolve_ref(rfs, git_dir, refname) { Some(id) => id @@ -443,7 +443,7 @@ pub fn delete_branch( } match head_commit { Some(head_id) => - if !(is_ancestor_of(rfs, git_dir, branch_id, head_id)) { + if !is_ancestor_of(rfs, git_dir, branch_id, head_id) { raise @bit.GitError::InvalidObject( "The branch '\{name}' is not fully merged.\nIf you are sure you want to delete it, run 'git branch -D \{name}'.", ) @@ -525,11 +525,11 @@ pub fn rename_branch( } let new_exists = ( rfs.is_file(new_path) && - !(branch_is_dangling_symref(rfs, git_dir, new_ref, new_path)) + !branch_is_dangling_symref(rfs, git_dir, new_ref, new_path) ) || new_packed_exists if new_exists { - if !(force) { + if !force { raise @bit.GitError::InvalidObject("branch '\{new_name}' already exists") } if rfs.is_file(new_path) { @@ -642,11 +642,11 @@ fn branch_is_dangling_symref( refname : String, ref_path : String, ) -> Bool raise @bit.GitError { - if !(rfs.is_file(ref_path)) { + if !rfs.is_file(ref_path) { return false } let line = read_ref_line(rfs, ref_path) - if !(line.has_prefix("ref: ")) { + if !line.has_prefix("ref: ") { return false } resolve_ref(rfs, git_dir, refname) is None @@ -672,7 +672,7 @@ fn validate_branch_rename_target_path( } } let new_path = join_path(git_dir, new_ref) - if rfs.is_dir(new_path) && !(old_ref.has_prefix(new_ref + "/")) { + if rfs.is_dir(new_path) && !old_ref.has_prefix(new_ref + "/") { raise @bit.GitError::InvalidObject("branch '\{new_ref}' already exists") } } @@ -735,7 +735,7 @@ pub fn switch_branch( let ref_path = join_path(git_dir, refname) if create { create_branch(fs, rfs, root, name) - } else if !(rfs.is_file(ref_path)) { + } else if !rfs.is_file(ref_path) { match resolve_ref(rfs, git_dir, refname) { None => raise @bit.GitError::InvalidObject("Invalid ref: \{name}") Some(_) => () @@ -776,7 +776,7 @@ fn resolve_ref_commondir( git_dir : String, ) -> String? { let commondir_path = join_path(git_dir, "commondir") - if !(fs.is_file(commondir_path)) { + if !fs.is_file(commondir_path) { return None } let rel = read_ref_line(fs, commondir_path) catch { _ => "" } @@ -877,7 +877,7 @@ fn collect_packed_heads( start=idx + 1, end=line.length(), ) - if !(refname.has_prefix("refs/heads/")) { + if !refname.has_prefix("refs/heads/") { continue } let name = String::unsafe_substring( @@ -885,7 +885,7 @@ fn collect_packed_heads( start=11, end=refname.length(), ) - if !(out.contains(name)) { + if !out.contains(name) { match parse_ref_object_id(id_hex) { Some(id) => out[name] = id None => () @@ -1020,7 +1020,7 @@ fn collect_tag_names( if fs.is_dir(path) { collect_tag_names(fs, path, name, out) } else if fs.is_file(path) { - if !(out.contains(name)) { + if !out.contains(name) { out.push(name) } } @@ -1056,7 +1056,7 @@ fn collect_packed_tags( start=10, end=refname.length(), ) - if !(out.contains(name)) { + if !out.contains(name) { out.push(name) } } @@ -1198,7 +1198,7 @@ fn has_packed_ref_path_conflict( packed_path : String, refname : String, ) -> Bool { - if !(fs.is_file(packed_path)) { + if !fs.is_file(packed_path) { return false } let text = @utf8.decode_lossy(fs.read_file(packed_path)[:]) catch { diff --git a/src/lib/branch_test.mbt b/src/lib/branch_test.mbt index 775faa0a..097880bb 100644 --- a/src/lib/branch_test.mbt +++ b/src/lib/branch_test.mbt @@ -74,7 +74,7 @@ test "branch: create branch in unborn repo does not create empty ref file" { let fs = setup_branch_fs() fs.write_string("/repo/.git/HEAD", "ref: refs/heads/main\n") create_branch(fs, fs, "/repo", "main") - assert_true(!(fs.is_file("/repo/.git/refs/heads/main"))) + assert_true(!fs.is_file("/repo/.git/refs/heads/main")) } ///| @@ -229,8 +229,8 @@ test "branch: delete_branch prunes empty parent directories for nested refs" { "/repo/.git/refs/heads/branch/conflict", "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\n", ) delete_branch(fs, fs, "/repo", "branch/conflict", force=true) - assert_true(!(fs.is_file("/repo/.git/refs/heads/branch/conflict"))) - assert_true(!(fs.is_dir("/repo/.git/refs/heads/branch"))) + assert_true(!fs.is_file("/repo/.git/refs/heads/branch/conflict")) + assert_true(!fs.is_dir("/repo/.git/refs/heads/branch")) } ///| @@ -266,7 +266,7 @@ test "branch: delete_branch removes reflog for deleted ref" { "/repo/.git/logs/refs/heads/topic", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb Test 0 +0000\tbranch: Created from main\n", ) delete_branch(fs, fs, "/repo", "topic", force=true) - assert_true(!(fs.is_file("/repo/.git/logs/refs/heads/topic"))) + assert_true(!fs.is_file("/repo/.git/logs/refs/heads/topic")) } ///| @@ -304,7 +304,7 @@ test "branch: rename_branch can move parent ref to nested child" { "/repo/.git/logs/refs/heads/m", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb Test 0 +0000\tbranch: Created from main\n", ) rename_branch(fs, fs, "/repo", "m", "m/m") - assert_true(!(fs.is_file("/repo/.git/refs/heads/m"))) + assert_true(!fs.is_file("/repo/.git/refs/heads/m")) assert_eq( fs.read_string("/repo/.git/refs/heads/m/m"), "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\n", @@ -349,7 +349,7 @@ test "branch: rename_branch from linked worktree root updates common refs" { fs.write_string("/repo/.git/worktrees/wt1/commondir", "../..\n") fs.write_string("/worktree/.git", "gitdir: /repo/.git/worktrees/wt1\n") rename_branch(fs, fs, "/worktree", "baz", "bam") - assert_true(!(fs.is_file("/repo/.git/refs/heads/baz"))) + assert_true(!fs.is_file("/repo/.git/refs/heads/baz")) assert_eq( fs.read_string("/repo/.git/refs/heads/bam"), "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\n", @@ -375,7 +375,7 @@ test "branch: rename_branch can move nested child to parent" { "/repo/.git/logs/refs/heads/n/n", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb Test 0 +0000\tbranch: Created from main\n", ) rename_branch(fs, fs, "/repo", "n/n", "n") - assert_true(!(fs.is_dir("/repo/.git/refs/heads/n/n"))) + assert_true(!fs.is_dir("/repo/.git/refs/heads/n/n")) assert_eq( fs.read_string("/repo/.git/refs/heads/n"), "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\n", @@ -401,7 +401,7 @@ test "branch: rename_branch replaces dangling symref target" { fs.read_string("/repo/.git/refs/heads/broken_symref"), "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\n", ) - assert_true(!(fs.is_file("/repo/.git/refs/heads/m"))) + assert_true(!fs.is_file("/repo/.git/refs/heads/m")) } ///| @@ -420,7 +420,7 @@ test "branch: create_lightweight_tag rejects conflicting parent ref path" { ) assert_true(result is Err(_)) assert_true(fs.is_file("/repo/.git/refs/tags/foo/bar")) - assert_true(!(fs.is_file("/repo/.git/refs/tags/foo"))) + assert_true(!fs.is_file("/repo/.git/refs/tags/foo")) } ///| @@ -437,7 +437,7 @@ test "branch: create_lightweight_tag rejects conflicting packed ref path" { @bit.ObjectId::from_hex("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"), ) assert_true(result is Err(_)) - assert_true(!(fs.is_file("/repo/.git/refs/tags/foo"))) + assert_true(!fs.is_file("/repo/.git/refs/tags/foo")) } ///| @@ -471,10 +471,10 @@ test "branch: delete_tag removes reflog and prunes empty parent directories" { delete_tag(fs, fs, "/repo/.git", "foo/bar") - assert_true(!(fs.exists("/repo/.git/refs/tags/foo/bar"))) - assert_true(!(fs.exists("/repo/.git/logs/refs/tags/foo/bar"))) - assert_true(!(fs.exists("/repo/.git/refs/tags/foo"))) - assert_true(!(fs.exists("/repo/.git/logs/refs/tags/foo"))) + assert_true(!fs.exists("/repo/.git/refs/tags/foo/bar")) + assert_true(!fs.exists("/repo/.git/logs/refs/tags/foo/bar")) + assert_true(!fs.exists("/repo/.git/refs/tags/foo")) + assert_true(!fs.exists("/repo/.git/logs/refs/tags/foo")) } ///| diff --git a/src/lib/checkout.mbt b/src/lib/checkout.mbt index 6d341376..0a6b24ad 100644 --- a/src/lib/checkout.mbt +++ b/src/lib/checkout.mbt @@ -82,7 +82,7 @@ pub fn checkout( let head_path = join_path(actual_git_dir, "HEAD") let mut target : @bit.ObjectId? = None let mut refname : String? = None - if !(detach) { + if !detach { let name = if spec.has_prefix("refs/") { spec } else { @@ -94,7 +94,7 @@ pub fn checkout( refname = Some(name) } None => - if !(spec.has_prefix("refs/")) { + if !spec.has_prefix("refs/") { let remote_ref = "refs/remotes/origin/" + spec match resolve_ref(rfs, actual_git_dir, remote_ref) { Some(id) => { @@ -187,7 +187,7 @@ fn resolve_checkout_common_git_dir( git_dir : String, ) -> String { let commondir_path = join_path(git_dir, "commondir") - if !(fs.is_file(commondir_path)) { + if !fs.is_file(commondir_path) { return git_dir } let raw = @utf8.decode_lossy( diff --git a/src/lib/cherry_pick.mbt b/src/lib/cherry_pick.mbt index 358d56c9..2906d4aa 100644 --- a/src/lib/cherry_pick.mbt +++ b/src/lib/cherry_pick.mbt @@ -112,7 +112,7 @@ pub fn cherry_pick( // Find deleted files for entry in parent_files.iter() { let (path, _) = entry - if !(commit_files.contains(path)) { + if !commit_files.contains(path) { deleted_files.push(path) } } diff --git a/src/lib/commit_graph_reader.mbt b/src/lib/commit_graph_reader.mbt index 1755cf3a..78273cba 100644 --- a/src/lib/commit_graph_reader.mbt +++ b/src/lib/commit_graph_reader.mbt @@ -17,7 +17,7 @@ pub fn CommitGraphFile::load( git_dir : String, ) -> CommitGraphFile? raise @bit.GitError { let graph_path = join_path(git_dir, "objects/info/commit-graph") - if !(rfs.is_file(graph_path)) { + if !rfs.is_file(graph_path) { return None } let data = rfs.read_file(graph_path) diff --git a/src/lib/commit_helpers.mbt b/src/lib/commit_helpers.mbt index 8e327e0b..93d580e0 100644 --- a/src/lib/commit_helpers.mbt +++ b/src/lib/commit_helpers.mbt @@ -70,12 +70,10 @@ pub fn commit_is_trailer_line(line : String) -> Bool { return false } for c in token { - if !( - (c >= 'a' && c <= 'z') || - (c >= 'A' && c <= 'Z') || - (c >= '0' && c <= '9') || - c == '-', - ) { + if !((c >= 'a' && c <= 'z') || + (c >= 'A' && c <= 'Z') || + (c >= '0' && c <= '9') || + c == '-') { return false } } @@ -108,7 +106,7 @@ pub fn commit_apply_signoff(msg : String, committer~ : String) -> String { // Determine if we need a blank line separator. // A blank line is needed if the last non-blank line is not a trailer. let need_blank = if last_nonblank >= 0 { - !(commit_is_trailer_line(lines[last_nonblank])) + !commit_is_trailer_line(lines[last_nonblank]) } else { true } diff --git a/src/lib/diff.mbt b/src/lib/diff.mbt index b6304c11..c0ed0e4a 100644 --- a/src/lib/diff.mbt +++ b/src/lib/diff.mbt @@ -51,9 +51,9 @@ pub async fn diff_worktree( if skip_worktree_paths.contains(path) { continue } - if cache_ready && !(cache_map.contains(path)) { + if cache_ready && !cache_map.contains(path) { let ignored = is_ignored_path(fs, root, path, false) - if !(ignored) { + if !ignored { let old = diff_read_blob(db, fs, entry.id) // Skip if blob not found (e.g., submodule) if old is Some(_) { @@ -110,7 +110,7 @@ pub async fn diff_worktree( } None => () } - if !(mode_changed) && stat_matches { + if !mode_changed && stat_matches { content_changed = false } else { let content = fs.read_file(abs) @@ -149,7 +149,7 @@ pub async fn diff_worktree( } None => () } - if !(mode_changed) && stat_matches { + if !mode_changed && stat_matches { content_changed = false } else { match @bitio.read_symlink_target_path(abs) { @@ -262,7 +262,7 @@ pub fn diff_index( } for item in head_entries.to_array() { let (path, h) = item - if !(index_map.contains(path)) { + if !index_map.contains(path) { let old = diff_read_blob(db, fs, h.id) // Skip if blob not found (e.g., submodule) if old is Some(_) { @@ -641,7 +641,7 @@ pub fn diff_trees( } // Deleted for path, entry in old_entries { - if !(new_entries.contains(path)) { + if !new_entries.contains(path) { let old_content = diff_read_blob(db, fs, entry.id) if old_content is Some(_) { out.push({ diff --git a/src/lib/fs_tree.mbt b/src/lib/fs_tree.mbt index e4e53f21..c6c0a187 100644 --- a/src/lib/fs_tree.mbt +++ b/src/lib/fs_tree.mbt @@ -87,7 +87,7 @@ pub fn move_tree_safe( src : String, dest : String, ) -> Unit raise @bit.GitError { - if !(rfs.is_dir(src)) { + if !rfs.is_dir(src) { return () } if dest.has_prefix(src + "/") { diff --git a/src/lib/fs_tree_test.mbt b/src/lib/fs_tree_test.mbt index f305859d..f4d1bc38 100644 --- a/src/lib/fs_tree_test.mbt +++ b/src/lib/fs_tree_test.mbt @@ -32,7 +32,7 @@ test "fs_tree: move_tree_safe handles nested destinations" { fs.write_string("/src/a.txt", "hello\n") move_tree_safe(fs, fs, "/src", "/src/nested") assert_true(fs.is_file("/src/nested/a.txt")) - assert_true(!(fs.is_file("/src/a.txt"))) + assert_true(!fs.is_file("/src/a.txt")) } ///| @@ -42,6 +42,6 @@ test "fs_tree: remove_ref_path removes file and directory" { fs.write_string("/refs/tags/v1/tag", "def") remove_ref_path(fs, fs, "/refs/heads/main") remove_ref_path(fs, fs, "/refs/tags") - assert_true(!(fs.is_file("/refs/heads/main"))) - assert_true(!(fs.is_dir("/refs/tags"))) + assert_true(!fs.is_file("/refs/heads/main")) + assert_true(!fs.is_dir("/refs/tags")) } diff --git a/src/lib/fsck.mbt b/src/lib/fsck.mbt index 0286320e..5cb8ed76 100644 --- a/src/lib/fsck.mbt +++ b/src/lib/fsck.mbt @@ -39,7 +39,7 @@ pub fn fsck_connectivity_check( reachable[hex] = true let obj = db.get(fs, current) catch { _ => { - if !(missing.contains(hex)) { + if !missing.contains(hex) { missing[hex] = true errors += 1 } @@ -48,7 +48,7 @@ pub fn fsck_connectivity_check( } match obj { None => - if !(missing.contains(hex)) { + if !missing.contains(hex) { missing[hex] = true errors += 1 } @@ -65,12 +65,12 @@ pub fn fsck_connectivity_check( root_commits.push(hex) } let tree_hex = info.tree.to_hex() - if !(reachable.contains(tree_hex)) { + if !reachable.contains(tree_hex) { queue.push(info.tree) } for parent in info.parents { let phex = parent.to_hex() - if !(reachable.contains(phex)) { + if !reachable.contains(phex) { queue.push(parent) } } @@ -84,7 +84,7 @@ pub fn fsck_connectivity_check( } for entry in entries { let ehex = entry.id.to_hex() - if !(reachable.contains(ehex)) { + if !reachable.contains(ehex) { queue.push(entry.id) } } @@ -121,7 +121,7 @@ fn fsck_walk_tag( end=line.length(), ) let target = @bit.ObjectId::from_hex(target_hex) catch { _ => return } - if !(reachable.contains(target.to_hex())) { + if !reachable.contains(target.to_hex()) { queue.push(target) } break @@ -135,14 +135,14 @@ pub fn fsck_enumerate_objects(db : ObjectDb) -> Array[String] { let all : Array[String] = [] let seen : Map[String, Bool] = {} for hex, _ in db.loose_paths { - if !(seen.contains(hex)) { + if !seen.contains(hex) { seen[hex] = true all.push(hex) } } for pack in db.packs { for id in pack.ids { - if !(seen.contains(id)) { + if !seen.contains(id) { seen[id] = true all.push(id) } diff --git a/src/lib/fsck_test.mbt b/src/lib/fsck_test.mbt index c4d0105c..0abec6ab 100644 --- a/src/lib/fsck_test.mbt +++ b/src/lib/fsck_test.mbt @@ -122,10 +122,8 @@ test "fsck_verify_loose_hash valid" { let expected = @bit.sha1(raw) assert_true(@lib.fsck_verify_loose_hash(raw, expected.to_hex())) assert_true( - !( - @lib.fsck_verify_loose_hash( - raw, "0000000000000000000000000000000000000000", - ), + !@lib.fsck_verify_loose_hash( + raw, "0000000000000000000000000000000000000000", ), ) } diff --git a/src/lib/gc.mbt b/src/lib/gc.mbt index e8fb2bb1..4d108e18 100644 --- a/src/lib/gc.mbt +++ b/src/lib/gc.mbt @@ -99,7 +99,7 @@ fn gc_git_dir( let unreachable_hex : Array[String] = [] for item in store.objects.to_array() { let (hex, _) = item - if !(reachable_hex.contains(hex)) { + if !reachable_hex.contains(hex) { unreachable_hex.push(hex) } } @@ -145,7 +145,7 @@ fn prune_git_dir( let loose_hex = list_loose_object_hex(rfs, git_dir) let pruned : Array[@bit.ObjectId] = [] for hex in loose_hex { - if !(reachable_hex.contains(hex)) { + if !reachable_hex.contains(hex) { pruned.push(@bit.ObjectId::from_hex(hex)) } } @@ -276,7 +276,7 @@ fn collect_packed_refs( matched = true } } - if matched && !(out.contains(refname)) { + if matched && !out.contains(refname) { out[refname] = @bit.ObjectId::from_hex(id_hex) } } @@ -335,7 +335,7 @@ fn collect_reflog_referenced_objects( let sub = collect_reachable_objects_from_commits(db, fs, [id]) for s in sub { let sh = @bit.hash_object_content(s.obj_type, s.data).to_hex() - if !(seen.contains(sh)) { + if !seen.contains(sh) { seen[sh] = true objects.push(s) } @@ -354,7 +354,7 @@ fn collect_all_reflog_ids( ) -> Array[@bit.ObjectId] raise @bit.GitError { let ids : Array[@bit.ObjectId] = [] let logs_dir = git_dir + "/logs" - if !(fs.is_dir(logs_dir)) { + if !fs.is_dir(logs_dir) { return ids } collect_reflog_ids_recursive(fs, logs_dir, ids) @@ -435,7 +435,7 @@ fn resolve_commit_roots( None => () Some(commit_id) => { let hex = commit_id.to_hex() - if !(seen.contains(hex)) { + if !seen.contains(hex) { seen[hex] = true roots.push(commit_id) } @@ -518,7 +518,7 @@ fn prune_loose_objects( remove_reachable : Bool, ) -> Unit raise @bit.GitError { let objects_dir = join_path(git_dir, "objects") - if !(rfs.is_dir(objects_dir)) { + if !rfs.is_dir(objects_dir) { return } let entries = rfs.readdir(objects_dir) @@ -530,7 +530,7 @@ fn prune_loose_objects( continue } let dir = join_path(objects_dir, entry) - if !(rfs.is_dir(dir)) { + if !rfs.is_dir(dir) { continue } let files = rfs.readdir(dir) @@ -539,11 +539,11 @@ fn prune_loose_objects( continue } let path = join_path(dir, name) - if !(rfs.is_file(path)) { + if !rfs.is_file(path) { continue } let hex = entry + name - if !(remove_reachable) && keep.contains(hex) { + if !remove_reachable && keep.contains(hex) { continue } fs.remove_file(path) @@ -558,7 +558,7 @@ fn list_loose_object_hex( ) -> Array[String] raise @bit.GitError { let out : Array[String] = [] let objects_dir = join_path(git_dir, "objects") - if !(fs.is_dir(objects_dir)) { + if !fs.is_dir(objects_dir) { return out } let entries = fs.readdir(objects_dir) @@ -570,7 +570,7 @@ fn list_loose_object_hex( continue } let dir = join_path(objects_dir, entry) - if !(fs.is_dir(dir)) { + if !fs.is_dir(dir) { continue } let files = fs.readdir(dir) @@ -579,7 +579,7 @@ fn list_loose_object_hex( continue } let path = join_path(dir, name) - if !(fs.is_file(path)) { + if !fs.is_file(path) { continue } out.push(entry + name) @@ -596,7 +596,7 @@ fn prune_packfiles( keep_pack_id : @bit.ObjectId, ) -> Unit raise @bit.GitError { let pack_dir = join_path(git_dir, "objects/pack") - if !(rfs.is_dir(pack_dir)) { + if !rfs.is_dir(pack_dir) { return } let base = "pack-" + keep_pack_id.to_hex() diff --git a/src/lib/gc_test.mbt b/src/lib/gc_test.mbt index 4d366d2a..a239160f 100644 --- a/src/lib/gc_test.mbt +++ b/src/lib/gc_test.mbt @@ -71,7 +71,7 @@ test "gc_repo reports unreachable objects" { String::unsafe_substring(hex, start=0, end=2) + "/" + String::unsafe_substring(hex, start=2, end=hex.length()) - assert_true(!(fs.is_file(orphan_path))) + assert_true(!fs.is_file(orphan_path)) match result.pack { None => fail("expected pack") Some(r) => assert_true(r.object_count == 3) diff --git a/src/lib/gitattributes.mbt b/src/lib/gitattributes.mbt index 22c24fbb..9c7079fb 100644 --- a/src/lib/gitattributes.mbt +++ b/src/lib/gitattributes.mbt @@ -55,7 +55,7 @@ pub fn resolve_diff_driver( if words.length() < 2 { continue } - if !(gitattr_pattern_matches(normalized, words[0])) { + if !gitattr_pattern_matches(normalized, words[0]) { continue } let mut j = 1 @@ -127,7 +127,7 @@ pub fn resolve_eol_attrs( path : String, ) -> FileEolAttrs { let attr_path = join_path(root, ".gitattributes") - if !(rfs.is_file(attr_path)) { + if !rfs.is_file(attr_path) { return { text: TextAttr::Unspecified, eol: EolAttr::Unspecified, @@ -156,7 +156,7 @@ pub fn resolve_eol_attrs( if words.length() < 2 { continue } - if !(gitattr_pattern_matches(normalized, words[0])) { + if !gitattr_pattern_matches(normalized, words[0]) { continue } let mut j = 1 @@ -331,7 +331,7 @@ pub fn check_unsupported_gitattributes( root : String, ) -> String? { let attr_path = join_path(root, ".gitattributes") - if !(rfs.is_file(attr_path)) { + if !rfs.is_file(attr_path) { return None } let content = @utf8.decode_lossy( @@ -416,7 +416,7 @@ pub fn has_any_filter_attributes( root : String, ) -> Bool { let attr_path = join_path(root, ".gitattributes") - if !(rfs.is_file(attr_path)) { + if !rfs.is_file(attr_path) { return false } let content = @utf8.decode_lossy( diff --git a/src/lib/ignore_worktree_test.mbt b/src/lib/ignore_worktree_test.mbt index 040988fe..11dadfa3 100644 --- a/src/lib/ignore_worktree_test.mbt +++ b/src/lib/ignore_worktree_test.mbt @@ -19,9 +19,9 @@ test "ignore: basic ignore and .git skip" { fs.write_string("/repo/.git/config", "[core]\n") let files = list_working_files(fs, "/repo") assert_true(files.contains("keep.txt")) - assert_true(!(files.contains("debug.log"))) - assert_true(!(files.contains("sub/info.log"))) - assert_true(!(files.contains(".git/config"))) + assert_true(!files.contains("debug.log")) + assert_true(!files.contains("sub/info.log")) + assert_true(!files.contains(".git/config")) } ///| @@ -34,8 +34,8 @@ test "ignore: negation and dir ignore" { fs.write_string("/repo/other.log", "ng") let files = list_working_files(fs, "/repo") assert_true(files.contains("important.log")) - assert_true(!(files.contains("other.log"))) - assert_true(!(files.contains("build/out.txt"))) + assert_true(!files.contains("other.log")) + assert_true(!files.contains("build/out.txt")) } ///| @@ -48,7 +48,7 @@ test "ignore: nested gitignore" { fs.write_string("/repo/src/drop.tmp", "ng") let files = list_working_files(fs, "/repo") assert_true(files.contains("src/keep.tmp")) - assert_true(!(files.contains("src/drop.tmp"))) + assert_true(!files.contains("src/drop.tmp")) } ///| @@ -56,5 +56,5 @@ test "ignore: is_ignored_path" { let fs = setup_repo_fs() fs.write_string("/repo/.gitignore", "*.log\n") assert_true(is_ignored_path(fs, "/repo", "a.log", false)) - assert_true(!(is_ignored_path(fs, "/repo", "a.txt", false))) + assert_true(!is_ignored_path(fs, "/repo", "a.txt", false)) } diff --git a/src/lib/index.mbt b/src/lib/index.mbt index e4980cfe..807c3175 100644 --- a/src/lib/index.mbt +++ b/src/lib/index.mbt @@ -228,7 +228,7 @@ pub fn expand_sparse_index_entries( entries : Array[IndexEntry], ) -> Array[IndexEntry] raise @bit.GitError { let has_sparse_dir = entries.any(index_entry_is_sparse_dir) - if !(has_sparse_dir) { + if !has_sparse_dir { return entries } let db = ObjectDb::load(fs, git_dir) @@ -257,7 +257,7 @@ pub fn expand_sparse_skip_worktree_paths( skip_worktree_paths : Map[String, Bool], ) -> Map[String, Bool] raise @bit.GitError { let has_sparse_dir = entries.any(index_entry_is_sparse_dir) - if !(has_sparse_dir) { + if !has_sparse_dir { return skip_worktree_paths } let db = ObjectDb::load(fs, git_dir) @@ -267,7 +267,7 @@ pub fn expand_sparse_skip_worktree_paths( expanded[path] = true } for entry in entries { - if !(skip_worktree_paths.contains(entry.path)) { + if !skip_worktree_paths.contains(entry.path) { continue } if index_entry_is_sparse_dir(entry) { @@ -294,7 +294,7 @@ pub fn read_index_stage_entries( git_dir : String, ) -> Array[IndexStageEntry] raise @bit.GitError { let path = join_path(git_dir, "index") - if !(fs.is_file(path)) { + if !fs.is_file(path) { return [] } let data = fs.read_file(path) @@ -310,7 +310,7 @@ pub fn read_resolve_undo_entries( git_dir : String, ) -> Array[ResolveUndoEntry] raise @bit.GitError { let path = join_path(git_dir, "index") - if !(fs.is_file(path)) { + if !fs.is_file(path) { return [] } let data = fs.read_file(path) @@ -328,9 +328,7 @@ fn index_read_stage_entries_from_bytes( if data.length() < 32 { raise @bit.GitError::InvalidObject("Index file too short") } - if !( - data[0] == b'D' && data[1] == b'I' && data[2] == b'R' && data[3] == b'C', - ) { + if !(data[0] == b'D' && data[1] == b'I' && data[2] == b'R' && data[3] == b'C') { raise @bit.GitError::InvalidObject("Invalid index header") } let version = index_read_u32_be(data, 4) @@ -419,9 +417,7 @@ fn index_read_resolve_undo_entries_from_bytes( if data.length() < 32 { return [] } - if !( - data[0] == b'D' && data[1] == b'I' && data[2] == b'R' && data[3] == b'C', - ) { + if !(data[0] == b'D' && data[1] == b'I' && data[2] == b'R' && data[3] == b'C') { raise @bit.GitError::InvalidObject("Invalid index header") } let version = index_read_u32_be(data, 4) @@ -799,7 +795,7 @@ fn index_collect_changed_paths( match new_by_path.get(path) { Some(new_sig) if new_sig == old_sig => () _ => - if !(seen.contains(path)) { + if !seen.contains(path) { seen[path] = true changed.push(path) } @@ -807,7 +803,7 @@ fn index_collect_changed_paths( } for item in new_by_path.to_array() { let (path, _) = item - if !(old_by_path.contains(path)) && !(seen.contains(path)) { + if !old_by_path.contains(path) && !seen.contains(path) { seen[path] = true changed.push(path) } @@ -1004,16 +1000,14 @@ pub fn read_skip_worktree_paths( } } let index_path = join_path(git_dir, "index") - if !(fs.is_file(index_path)) { + if !fs.is_file(index_path) { return out } let data = fs.read_file(index_path) catch { _ => return out } if data.length() < 32 { return out } - if !( - data[0] == b'D' && data[1] == b'I' && data[2] == b'R' && data[3] == b'C', - ) { + if !(data[0] == b'D' && data[1] == b'I' && data[2] == b'R' && data[3] == b'C') { return out } let count = index_read_u32_be(data, 8) catch { _ => return out } @@ -1069,16 +1063,14 @@ pub fn read_assume_unchanged_paths( } let out : Map[String, Bool] = {} let index_path = join_path(git_dir, "index") - if !(fs.is_file(index_path)) { + if !fs.is_file(index_path) { return out } let data = fs.read_file(index_path) catch { _ => return out } if data.length() < 32 { return out } - if !( - data[0] == b'D' && data[1] == b'I' && data[2] == b'R' && data[3] == b'C', - ) { + if !(data[0] == b'D' && data[1] == b'I' && data[2] == b'R' && data[3] == b'C') { return out } let count = index_read_u32_be(data, 8) catch { _ => return out } diff --git a/src/lib/init.mbt b/src/lib/init.mbt index dc0f2e3d..dc43df75 100644 --- a/src/lib/init.mbt +++ b/src/lib/init.mbt @@ -70,7 +70,7 @@ pub fn init_repo_with_options( } let use_default_template_files = opts.template_dir is None let head_path = join_path(git_dir, "HEAD") - if opts.separate_git_dir is Some(_) && !(bare) { + if opts.separate_git_dir is Some(_) && !bare { fs.mkdir_p(root) } fs.mkdir_p(git_dir) @@ -83,7 +83,7 @@ pub fn init_repo_with_options( fs.mkdir_p(join_path(git_dir, "hooks")) fs.mkdir_p(join_path(git_dir, "info")) } - if opts.separate_git_dir is Some(_) && !(bare) { + if opts.separate_git_dir is Some(_) && !bare { let gitfile_path = join_path(root, ".git") fs.remove_dir(gitfile_path) catch { _ => () @@ -93,7 +93,7 @@ pub fn init_repo_with_options( } fs.write_string(gitfile_path, "gitdir: " + git_dir + "\n") } - if !(opts.is_reinit) { + if !opts.is_reinit { fs.write_string(head_path, "ref: refs/heads/" + opts.default_branch + "\n") } let bare_str = if bare { "true" } else { "false" } @@ -110,7 +110,7 @@ pub fn init_repo_with_options( Some(wt) => config = config + "\tworktree = " + wt + "\n" None => () } - if !(bare) { + if !bare { config = config + "\tlogallrefupdates = true\n" } if opts.ref_format == "reftable" { @@ -161,7 +161,7 @@ pub fn init_repo_with_options_with_repo_fs( let use_default_template_files = opts.template_dir is None let head_path = join_path(git_dir, "HEAD") // Create work tree directory if needed (for --separate-git-dir) - if opts.separate_git_dir is Some(_) && !(bare) { + if opts.separate_git_dir is Some(_) && !bare { fs.mkdir_p(root) } // Create git directory structure @@ -176,7 +176,7 @@ pub fn init_repo_with_options_with_repo_fs( fs.mkdir_p(join_path(git_dir, "info")) } // If separate-git-dir, create .git file pointing to actual git dir - if opts.separate_git_dir is Some(_) && !(bare) { + if opts.separate_git_dir is Some(_) && !bare { let gitfile_path = join_path(root, ".git") let existing_git_dir = if rfs.is_dir(gitfile_path) { Some(gitfile_path) @@ -203,7 +203,7 @@ pub fn init_repo_with_options_with_repo_fs( fs.write_string(gitfile_path, "gitdir: " + git_dir + "\n") } // Write HEAD only on fresh init (not re-init) - if !(opts.is_reinit) { + if !opts.is_reinit { fs.write_string(head_path, "ref: refs/heads/" + opts.default_branch + "\n") } // Create/update config file with appropriate bare setting @@ -223,7 +223,7 @@ pub fn init_repo_with_options_with_repo_fs( None => () } // Write core.logallrefupdates for non-bare repos - if !(bare) { + if !bare { config = config + "\tlogallrefupdates = true\n" } if opts.ref_format == "reftable" { @@ -278,7 +278,7 @@ fn copy_dir_recursive( src : String, dst : String, ) -> Unit raise @bit.GitError { - if !(rfs.is_dir(src)) { + if !rfs.is_dir(src) { return } wfs.mkdir_p(dst) @@ -293,7 +293,7 @@ fn copy_dir_recursive( copy_dir_recursive(wfs, rfs, src_path, dst_path) } else if rfs.is_file(src_path) { // Don't overwrite existing files - if !(rfs.is_file(dst_path)) { + if !rfs.is_file(dst_path) { let content = rfs.read_file(src_path) wfs.write_file(dst_path, content) } diff --git a/src/lib/js_api_exports.mbt b/src/lib/js_api_exports.mbt index 329524fd..f8b8730b 100644 --- a/src/lib/js_api_exports.mbt +++ b/src/lib/js_api_exports.mbt @@ -377,7 +377,7 @@ pub fn js_status(host_id : Int, root : String) -> Result[Status, String] { continue } let abs_path = join_path(root, entry.path) - if !(fs.is_file(abs_path)) { + if !fs.is_file(abs_path) { unstaged_deleted.push(entry.path) } } @@ -1615,8 +1615,8 @@ pub async fn js_push_remote( js_transport_get(transport_id, url, headers) }) let old_id = js_find_remote_ref(refs, target_ref) - if !(force) && old_id != @bit.ObjectId::zero() { - if !(js_is_ancestor(fs, git_dir, old_id, head_id)) { + if !force && old_id != @bit.ObjectId::zero() { + if !js_is_ancestor(fs, git_dir, old_id, head_id) { raise @bit.GitError::InvalidObject( "Updates were rejected because the tip of your current branch is behind its remote counterpart. Use force to override.", ) diff --git a/src/lib/log.mbt b/src/lib/log.mbt index b065d6c5..4ffd91bc 100644 --- a/src/lib/log.mbt +++ b/src/lib/log.mbt @@ -182,7 +182,7 @@ fn log_read_graft_parents( log_resolve_common_git_dir(fs, git_dir), "info/grafts", ) - if !(fs.is_file(graft_path)) { + if !fs.is_file(graft_path) { return None } let content = decode_bytes_lossy( @@ -227,7 +227,7 @@ fn log_resolve_common_git_dir( git_dir : String, ) -> String { let commondir_path = join_path(git_dir, "commondir") - if !(fs.is_file(commondir_path)) { + if !fs.is_file(commondir_path) { return git_dir } let raw = @utf8.decode_lossy( diff --git a/src/lib/merge.mbt b/src/lib/merge.mbt index 27f29ea6..c5dce289 100644 --- a/src/lib/merge.mbt +++ b/src/lib/merge.mbt @@ -36,12 +36,12 @@ fn merge_preserve_removed_gitlinks( let backup_root = ".bit-merge-preserve" let mut backup_index = 0 for entry in entries { - if files.contains(entry.path) || !(is_gitlink_mode_int(entry.mode)) { + if files.contains(entry.path) || !is_gitlink_mode_int(entry.mode) { continue } let full_path = join_path(root, entry.path) let git_marker = join_path(full_path, ".git") - if !(rfs.is_dir(full_path)) { + if !rfs.is_dir(full_path) { continue } if !(rfs.is_file(git_marker) || rfs.is_dir(git_marker)) { @@ -76,7 +76,7 @@ fn merge_restore_preserved_gitlinks( continue } let backup_abs = join_path(root, item.backup_path) - if !(rfs.is_dir(backup_abs)) { + if !rfs.is_dir(backup_abs) { continue } mv_copy_directory_recursive(fs, rfs, backup_abs, full_path) @@ -203,7 +203,7 @@ pub fn merge( if @diff3.is_binary_content(ours_data) || @diff3.is_binary_content(theirs_data) { conflicts.push(candidate.path) - if !(all_conflict_types.contains(candidate.path)) { + if !all_conflict_types.contains(candidate.path) { all_conflict_types[candidate.path] = "content" } continue @@ -225,7 +225,7 @@ pub fn merge( fs.mkdir_p(dir) fs.write_string(full_path, result.content) conflicts.push(candidate.path) - if !(all_conflict_types.contains(candidate.path)) { + if !all_conflict_types.contains(candidate.path) { all_conflict_types[candidate.path] = "content" } } else { @@ -713,7 +713,7 @@ fn merge_files( } } // Check for rename/add-dest: theirs independently added a file at new_path - if !(base.contains(new_path)) { + if !base.contains(new_path) { match theirs.get(new_path) { Some(_) => { // Theirs added a file at same path as our rename target @@ -726,7 +726,7 @@ fn merge_files( handled_paths[old_path] = true handled_paths[new_path] = true // Only mark old_path for removal if it's a clean rename (no conflict, no add-source) - if !(is_add_source) && !(conflict_types.contains(new_path)) { + if !is_add_source && !conflict_types.contains(new_path) { removed_paths.push(old_path) } } @@ -782,7 +782,7 @@ fn merge_files( } } // Check for rename/add-dest: ours independently added a file at new_path - if !(base.contains(new_path)) { + if !base.contains(new_path) { match ours.get(new_path) { Some(_) => { conflicts.push(new_path) @@ -793,24 +793,24 @@ fn merge_files( } handled_paths[old_path] = true handled_paths[new_path] = true - if !(is_add_source) && !(conflict_types.contains(new_path)) { + if !is_add_source && !conflict_types.contains(new_path) { removed_paths.push(old_path) } } // Step 4: Process remaining paths with standard logic let all_paths : Map[String, Bool] = {} for path, _ in base { - if !(handled_paths.contains(path)) { + if !handled_paths.contains(path) { all_paths[path] = true } } for path, _ in ours { - if !(handled_paths.contains(path)) { + if !handled_paths.contains(path) { all_paths[path] = true } } for path, _ in theirs { - if !(handled_paths.contains(path)) { + if !handled_paths.contains(path) { all_paths[path] = true } } @@ -1011,7 +1011,7 @@ fn merge_conflicted_index_entries_with_renames( } let merged_entries = tree_files_to_index(db, fs, merged) for entry in merged_entries { - if !(conflict_set.contains(entry.path)) { + if !conflict_set.contains(entry.path) { out.push({ entry, stage: 0 }) } } diff --git a/src/lib/merge_base.mbt b/src/lib/merge_base.mbt index 26207dcb..829c711f 100644 --- a/src/lib/merge_base.mbt +++ b/src/lib/merge_base.mbt @@ -84,7 +84,7 @@ pub fn merge_base_all( } seen[hex] = true if ancestors_a.contains(hex) { - if !(common_set.contains(hex)) { + if !common_set.contains(hex) { common.push(current) common_set[hex] = true } @@ -151,7 +151,7 @@ pub fn merge_base_all( break } } - if !(is_ancestor_of_another) { + if !is_ancestor_of_another { result.push(candidate) } } @@ -178,7 +178,7 @@ pub fn merge_base_independent( break } } - if !(reachable) { + if !reachable { result.push(candidate) } } diff --git a/src/lib/native/bench_worktree_entry_wbtest.mbt b/src/lib/native/bench_worktree_entry_wbtest.mbt index f804f19c..72551d7e 100644 --- a/src/lib/native/bench_worktree_entry_wbtest.mbt +++ b/src/lib/native/bench_worktree_entry_wbtest.mbt @@ -24,7 +24,7 @@ fn bench_wt_join_path(root : String, path : String) -> String { ///| fn bench_wt_ensure_dir(path : String) -> Unit { - if !(@fs.path_exists(path)) { + if !@fs.path_exists(path) { @fs.create_dir(path) catch { _ => () } diff --git a/src/lib/native/ignore_async_test.mbt b/src/lib/native/ignore_async_test.mbt index 9659a3a2..5ed31031 100644 --- a/src/lib/native/ignore_async_test.mbt +++ b/src/lib/native/ignore_async_test.mbt @@ -33,5 +33,5 @@ async test "ignore async: symlink dir is not traversed" { let files = @bitlib.list_working_files_async(fs, root) assert_true(files.contains("real/file.txt")) assert_true(files.contains("link")) - assert_true(!(files.contains("link/file.txt"))) + assert_true(!files.contains("link/file.txt")) } diff --git a/src/lib/native/sync_http.mbt b/src/lib/native/sync_http.mbt index e7e20614..60ad9456 100644 --- a/src/lib/native/sync_http.mbt +++ b/src/lib/native/sync_http.mbt @@ -125,8 +125,8 @@ pub async fn push_http( let refs = @bitnative.discover_receive_refs_http(remote) let old_id = sync_find_ref(refs, refname) // Check fast-forward unless force - if !(force) && old_id != @bit.ObjectId::zero() { - if !(sync_is_ancestor(rfs, actual_git_dir, old_id, head_id)) { + if !force && old_id != @bit.ObjectId::zero() { + if !sync_is_ancestor(rfs, actual_git_dir, old_id, head_id) { raise @bit.GitError::InvalidObject( "Updates were rejected because the tip of your current branch is behind\nits remote counterpart. If you want to force the update, use 'git push --force'.", ) diff --git a/src/lib/native/worktree_modes.mbt b/src/lib/native/worktree_modes.mbt index a0ac650d..4899fd9d 100644 --- a/src/lib/native/worktree_modes.mbt +++ b/src/lib/native/worktree_modes.mbt @@ -117,7 +117,7 @@ fn detect_case_insensitive_collision_skips( paths : Array[String], ) -> Map[String, Bool] raise @bit.GitError { let skip : Map[String, Bool] = {} - if !(worktree_is_case_insensitive(fs, rfs, git_dir)) { + if !worktree_is_case_insensitive(fs, rfs, git_dir) { return skip } let mut i = 0 @@ -170,7 +170,7 @@ async fn remove_path_if_exists(path : String) -> Unit raise @bit.GitError { err if @async.is_cancellation_error(err) => abort("cancelled") _ => false } - if !(exists) { + if !exists { return } let kind_result : Result[@afs.FileKind, Error] = try? @afs.kind( diff --git a/src/lib/object_db.mbt b/src/lib/object_db.mbt index 962edcd9..94907018 100644 --- a/src/lib/object_db.mbt +++ b/src/lib/object_db.mbt @@ -1,5 +1,11 @@ ///| Git object database loader (loose + pack + idx) +///| +#warnings("-deprecated") +fn object_db_parse_int(value : StringView) -> Int raise { + @strconv.parse_int(value) +} + ///| pub struct PackIndex { pack_path : String @@ -117,7 +123,7 @@ pub struct ObjectDb { fn pack_cache_limit_from_env() -> Int { match @bitio.env_get("BIT_PACK_CACHE_LIMIT") { Some(v) => - try @string.parse_int(v) catch { + try object_db_parse_int(v) catch { _ => 2 } noraise { n => if n < 0 { 0 } else { n } @@ -274,7 +280,7 @@ pub fn ObjectDb::get( ) -> @bit.PackObject? raise @bit.GitError { let hex = id.to_hex() // Fast path: try loose object first without allocating seen set - if !(self.prefer_packed) { + if !self.prefer_packed { match get_loose_by_hex(self, fs, hex) { Some(obj) => return Some(obj) None => () @@ -327,7 +333,7 @@ pub fn ObjectDb::find_delta_base( id : @bit.ObjectId, ) -> @bit.ObjectId? raise @bit.GitError { let hex = id.to_hex() - if !(self.prefer_packed) { + if !self.prefer_packed { if get_loose_by_hex(self, fs, hex) is Some(_) { return None } @@ -466,7 +472,7 @@ fn get_loose_by_hex( e => raise @bit.GitError::InvalidObject("Zlib error: \{e}") } let obj = parse_loose_object(raw) - if !(db.skip_verify) { + if !db.skip_verify { let verify_algo : @object.HashAlgorithm = if hex.length() == 64 { @object.HashAlgorithm::Sha256 } else { @@ -527,7 +533,7 @@ fn get_from_packs( try { let data = get_pack_bytes(db, fs, pack.pack_path) let obj = read_pack_object_at(data, pack, offset, db, fs, seen) - if !(db.skip_verify) { + if !db.skip_verify { let computed = obj.id.to_hex() if computed != hex { if pack.version == 1 { @@ -552,7 +558,7 @@ fn get_from_packs( let pack = lazy_pack.get(fs) // ensure loaded let data = get_pack_bytes(db, fs, pack.pack_path) let obj = read_pack_object_at(data, pack, offset, db, fs, seen) - if !(db.skip_verify) { + if !db.skip_verify { let computed = obj.id.to_hex() if computed != hex { if pack.version == 1 { @@ -681,7 +687,7 @@ fn get_by_hex( e => raise @bit.GitError::InvalidObject("Zlib error: \{e}") } let obj = parse_loose_object(raw) - if !(db.skip_verify) { + if !db.skip_verify { let verify_algo : @object.HashAlgorithm = if hex.length() == 64 { @object.HashAlgorithm::Sha256 } else { @@ -772,7 +778,7 @@ fn collect_loose_paths( continue } let dir = join_path(objects_dir, entry) - if !(fs.is_dir(dir)) { + if !fs.is_dir(dir) { continue } let files = fs.readdir(dir) @@ -781,7 +787,7 @@ fn collect_loose_paths( continue } let path = join_path(dir, name) - if !(fs.is_file(path)) { + if !fs.is_file(path) { continue } let hex = entry + name @@ -818,16 +824,16 @@ fn load_pack_indexes( let result : Array[PackIndex] = [] let entries = fs.readdir(pack_dir) for entry in entries { - if !(entry.has_suffix(".idx")) { + if !entry.has_suffix(".idx") { continue } let idx_path = join_path(pack_dir, entry) - if !(fs.is_file(idx_path)) { + if !fs.is_file(idx_path) { continue } let base = String::unsafe_substring(entry, start=0, end=entry.length() - 4) let pack_path = join_path(pack_dir, base + ".pack") - if !(fs.is_file(pack_path)) { + if !fs.is_file(pack_path) { continue } let data = fs.read_file(idx_path) @@ -846,16 +852,16 @@ fn collect_lazy_pack_indexes( let result : Array[LazyPackIndex] = [] let entries = fs.readdir(pack_dir) for entry in entries { - if !(entry.has_suffix(".idx")) { + if !entry.has_suffix(".idx") { continue } let idx_path = join_path(pack_dir, entry) - if !(fs.is_file(idx_path)) { + if !fs.is_file(idx_path) { continue } let base = String::unsafe_substring(entry, start=0, end=entry.length() - 4) let pack_path = join_path(pack_dir, base + ".pack") - if !(fs.is_file(pack_path)) { + if !fs.is_file(pack_path) { continue } result.push(LazyPackIndex::new(idx_path, pack_path)) @@ -871,11 +877,11 @@ fn load_pack_objects( let result : Array[@bit.PackObject] = [] let entries = fs.readdir(pack_dir) for entry in entries { - if !(entry.has_suffix(".pack")) { + if !entry.has_suffix(".pack") { continue } let path = join_path(pack_dir, entry) - if !(fs.is_file(path)) { + if !fs.is_file(path) { continue } let data = fs.read_file(path) diff --git a/src/lib/profile.mbt b/src/lib/profile.mbt index 167755d1..0781bbe3 100644 --- a/src/lib/profile.mbt +++ b/src/lib/profile.mbt @@ -23,7 +23,7 @@ fn profile_lap( label : String, start : @bench.Timestamp?, ) -> @bench.Timestamp? { - if !(enabled) { + if !enabled { return start } match start { diff --git a/src/lib/promisor.mbt b/src/lib/promisor.mbt index dafb9a36..03266c25 100644 --- a/src/lib/promisor.mbt +++ b/src/lib/promisor.mbt @@ -7,7 +7,7 @@ pub fn read_promisor_remote( git_dir : String, ) -> String? { let promisor_path = promisor_join_path(git_dir, "objects/info/promisor") - if !(fs.is_file(promisor_path)) { + if !fs.is_file(promisor_path) { return None } let content = fs.read_file(promisor_path) catch { _ => return None } @@ -108,7 +108,7 @@ pub async fn PromisorDb::fetch_missing( let to_fetch : Array[@bit.ObjectId] = [] for id in ids { let hex = id.to_hex() - if !(self.fetched.contains(hex)) { + if !self.fetched.contains(hex) { to_fetch.push(id) self.fetched.set(hex, true) } diff --git a/src/lib/prune_test.mbt b/src/lib/prune_test.mbt index 84f3440d..556e49cb 100644 --- a/src/lib/prune_test.mbt +++ b/src/lib/prune_test.mbt @@ -39,5 +39,5 @@ test "prune: removes unreachable loose objects" { assert_true(fs.is_file(obj_path)) let result = prune_repo(fs, fs, "/repo") assert_true(result.pruned.contains(orphan)) - assert_true(!(fs.is_file(obj_path))) + assert_true(!fs.is_file(obj_path)) } diff --git a/src/lib/rebase.mbt b/src/lib/rebase.mbt index d555b0b7..21bd5715 100644 --- a/src/lib/rebase.mbt +++ b/src/lib/rebase.mbt @@ -870,7 +870,7 @@ pub fn load_rebase_state( git_dir : String, ) -> RebaseState? raise @bit.GitError { let state_dir = join_path(git_dir, "rebase-merge") - if !(fs.is_dir(state_dir)) { + if !fs.is_dir(state_dir) { return None } let onto_hex = read_file_trimmed(fs, join_path(state_dir, "onto")) @@ -926,7 +926,7 @@ fn parse_todo_file( path : String, ) -> Array[@bit.ObjectId] { let result : Array[@bit.ObjectId] = [] - if !(fs.is_file(path)) { + if !fs.is_file(path) { return result } let content = @utf8.decode_lossy( @@ -959,7 +959,7 @@ pub fn clear_rebase_state( git_dir : String, ) -> Unit raise @bit.GitError { let state_dir = join_path(git_dir, "rebase-merge") - if !(rfs.is_dir(state_dir)) { + if !rfs.is_dir(state_dir) { return () } // Remove all files in state_dir @@ -1021,7 +1021,7 @@ pub fn rebase_start_with_onto( } } Some(h) => { - if !(force_rebase) && h == onto && h == upstream { + if !force_rebase && h == onto && h == upstream { return { status: RebaseStatus::NothingToRebase, commit_id: Some(h), @@ -1031,7 +1031,7 @@ pub fn rebase_start_with_onto( let db = ObjectDb::load(rfs, git_dir) let chain = rebase_collect_chain(db, rfs, h, upstream) if chain.length() == 0 { - if !(force_rebase) { + if !force_rebase { if h != onto { fast_forward_to(fs, rfs, root, onto) return { @@ -1346,7 +1346,7 @@ fn rebase_compute_patch_tree_diff( } for item in parent { let (path, _) = item - if !(current_map.contains(path)) { + if !current_map.contains(path) { diff.push((path, "D")) } } @@ -1427,8 +1427,7 @@ fn rebase_change_already_applied( target_content, @diff3.ContentMergeOptions::default(), ) - !(merge_result.has_conflicts) && - merge_result.content == base_content + !merge_result.has_conflicts && merge_result.content == base_content } _ => false } @@ -1447,7 +1446,7 @@ fn rebase_changes_already_applied( return false } for ch in changes { - if !(rebase_change_already_applied(db, rfs, base, parent_map, ch)) { + if !rebase_change_already_applied(db, rfs, base, parent_map, ch) { return false } } diff --git a/src/lib/receive_pack.mbt b/src/lib/receive_pack.mbt index 970e57a7..c827990d 100644 --- a/src/lib/receive_pack.mbt +++ b/src/lib/receive_pack.mbt @@ -92,7 +92,7 @@ fn normalize_receive_refname(refname : String) -> String raise @bit.GitError { _ => raise @bit.GitError::ProtocolError("Invalid receive-pack ref: " + refname) } - if !(normalized.has_prefix("refs/")) { + if !normalized.has_prefix("refs/") { raise @bit.GitError::ProtocolError("Invalid receive-pack ref: " + refname) } normalized @@ -241,7 +241,7 @@ fn receive_parse_cert_content( if in_sig { continue } - if !(in_body) { + if !in_body { if cert_line.length() == 0 { in_body = true continue @@ -318,7 +318,7 @@ pub fn apply_receive_pack( pack_objects = @pack.parse_packfile(req.pack) } // Connectivity check BEFORE writing pack to disk - if !(skip_connectivity_check) && pack_objects.length() > 0 { + if !skip_connectivity_check && pack_objects.length() > 0 { let fail_oid = receive_connectivity_check(rfs, git_dir, pack_objects) if fail_oid is Some(oid) { return { @@ -358,14 +358,14 @@ pub fn apply_receive_pack( let ff = receive_is_ancestor_commit(db, rfs, current_id, upd.new_id) catch { _ => false } - if !(ff) { + if !ff { rejected.push((refname, "non-fast-forward")) continue } } } if upd.new_id == @bit.ObjectId::zero() { - if !(receive_delete_ref(fs, rfs, git_dir, refname)) { + if !receive_delete_ref(fs, rfs, git_dir, refname) { rejected.push((refname, "ref not found")) continue } @@ -570,7 +570,7 @@ fn receive_delete_ref( return true } let packed = join_path(git_dir, "packed-refs") - if !(rfs.is_file(packed)) { + if !rfs.is_file(packed) { return false } let data = rfs.read_file(packed) @@ -753,16 +753,16 @@ fn receive_connectivity_check( // Check parents exist for parent in info.parents { let p_hex = parent.to_hex() - if !(pack_ids.contains(p_hex)) { - if !(receive_object_exists(rfs, db, repo_cache, parent)) { + if !pack_ids.contains(p_hex) { + if !receive_object_exists(rfs, db, repo_cache, parent) { return Some(obj.id.to_hex()) } } } // Check tree exists let t_hex = info.tree.to_hex() - if !(pack_ids.contains(t_hex)) { - if !(receive_object_exists(rfs, db, repo_cache, info.tree)) { + if !pack_ids.contains(t_hex) { + if !receive_object_exists(rfs, db, repo_cache, info.tree) { return Some(obj.id.to_hex()) } } diff --git a/src/lib/reflog.mbt b/src/lib/reflog.mbt index 14756369..62080d93 100644 --- a/src/lib/reflog.mbt +++ b/src/lib/reflog.mbt @@ -1,5 +1,11 @@ ///| Git reflog implementation +///| +#warnings("-deprecated") +fn reflog_parse_int64(value : StringView) -> Int64 raise { + @strconv.parse_int64(value) +} + ///| pub struct ReflogEntry { old_id : @bit.ObjectId @@ -40,7 +46,7 @@ pub fn read_reflog( refname : String, ) -> Array[ReflogEntry] raise @bit.GitError { let reflog_path = get_reflog_path(git_dir, refname) - if !(fs.is_file(reflog_path)) { + if !fs.is_file(reflog_path) { return [] } let content = @utf8.decode_lossy(fs.read_file(reflog_path)[:]) @@ -104,7 +110,7 @@ fn parse_reflog_line(line : String) -> ReflogEntry? { } // Next should be timestamp and timezone if i < parts.length() { - timestamp = @string.parse_int64(parts[i]) catch { _ => 0L } + timestamp = reflog_parse_int64(parts[i]) catch { _ => 0L } i += 1 } if i < parts.length() { @@ -134,7 +140,7 @@ pub fn append_reflog( None => "" Some(i) => String::unsafe_substring(reflog_path, start=0, end=i) } - if parent_dir.length() > 0 && !(rfs.is_dir(parent_dir)) { + if parent_dir.length() > 0 && !rfs.is_dir(parent_dir) { wfs.mkdir_p(parent_dir) } // Format: <> \t\n @@ -161,10 +167,10 @@ pub fn create_reflog( None => "" Some(i) => String::unsafe_substring(reflog_path, start=0, end=i) } - if parent_dir.length() > 0 && !(rfs.is_dir(parent_dir)) { + if parent_dir.length() > 0 && !rfs.is_dir(parent_dir) { wfs.mkdir_p(parent_dir) } - if !(rfs.is_file(reflog_path)) { + if !rfs.is_file(reflog_path) { wfs.write_string(reflog_path, "") } } @@ -239,7 +245,7 @@ pub fn should_log_ref( ( refname.has_prefix("refs/heads/") || refname.has_prefix("refs/remotes/") || - (!(is_bare) && refname == "HEAD"), + (!is_bare && refname == "HEAD"), false, ) Some("false") | Some("0") => (false, false) diff --git a/src/lib/remote_config.mbt b/src/lib/remote_config.mbt index 924901ea..ba44e50b 100644 --- a/src/lib/remote_config.mbt +++ b/src/lib/remote_config.mbt @@ -164,7 +164,7 @@ pub fn render_config_blocks(blocks : Array[ConfigBlock]) -> String { } } let mut content = lines.join("\n") - if content.length() > 0 && !(content.has_suffix("\n")) { + if content.length() > 0 && !content.has_suffix("\n") { content = content + "\n" } content @@ -300,7 +300,7 @@ pub fn split_config_key( section : String, ) -> (String, String)? { let prefix = section + "." - if !(full_key.has_prefix(prefix)) { + if !full_key.has_prefix(prefix) { return None } let rest = String::unsafe_substring( @@ -457,7 +457,7 @@ pub fn read_repo_config( git_dir : String, ) -> (Map[String, RemoteConfig], Map[String, BranchConfig]) { let config_path = git_dir + "/config" - if !(fs.is_file(config_path)) { + if !fs.is_file(config_path) { return ({}, {}) } let content = decode_bytes_lossy( @@ -530,7 +530,7 @@ pub fn get_remote_url( name : String, ) -> String? { let config_path = git_dir + "/config" - if !(fs.is_file(config_path)) { + if !fs.is_file(config_path) { return None } let content = decode_bytes_lossy( @@ -730,7 +730,7 @@ pub fn is_mirror_fetch_config(rc : RemoteConfig) -> Bool { if dst == "refs/*" { return true } - if dst.has_prefix("refs/") && !(dst.has_prefix("refs/remotes/")) { + if dst.has_prefix("refs/") && !dst.has_prefix("refs/remotes/") { return true } } @@ -747,7 +747,7 @@ pub fn remote_set_branches( add : Bool, ) -> Unit raise @bit.GitError { let config_path = git_dir + "/config" - if !(rfs.is_file(config_path)) { + if !rfs.is_file(config_path) { raise @bit.GitError::InvalidObject("No such remote '\{name}'") } let content = decode_bytes_lossy(rfs.read_file(config_path)) @@ -779,7 +779,7 @@ pub fn remote_set_branches( break } } - if !(exists) { + if !exists { updated_specs.push(spec) } } @@ -810,7 +810,7 @@ pub fn remote_set_branches( new_blocks.push(block) } } - if !(found) { + if !found { raise @bit.GitError::InvalidObject("No such remote '\{name}'") } fs.write_string(config_path, render_config_blocks(new_blocks)) @@ -847,7 +847,7 @@ pub fn set_config_key( continue } if in_section && trimmed.has_prefix("[") { - if !(key_set) { + if !key_set { lines.push("\t\{key} = \{value}") key_set = true } @@ -861,7 +861,7 @@ pub fn set_config_key( lines.push(line) } if found_section { - if in_section && !(key_set) { + if in_section && !key_set { lines.push("\t\{key} = \{value}") } } else { diff --git a/src/lib/remote_helpers.mbt b/src/lib/remote_helpers.mbt index f03a698a..65f13d2c 100644 --- a/src/lib/remote_helpers.mbt +++ b/src/lib/remote_helpers.mbt @@ -212,7 +212,7 @@ pub fn read_local_remote_head_state( head_path : String, remote_name : String, ) -> RemoteHeadState { - if !(fs.is_file(head_path)) { + if !fs.is_file(head_path) { return RemoteHeadState::Missing } let content = try? fs.read_file(head_path) @@ -246,7 +246,7 @@ pub fn read_remote_head_branch( remote_git_dir : String, ) -> String? { let head_path = remote_git_dir + "/HEAD" - if !(fs.is_file(head_path)) { + if !fs.is_file(head_path) { return None } let content = try? fs.read_file(head_path) @@ -371,7 +371,7 @@ pub fn match_url_pattern(pattern : String, value : String) -> Bool { matched = true vi += 1 } - if !(matched) { + if !matched { return false } } else { diff --git a/src/lib/rename_detect.mbt b/src/lib/rename_detect.mbt index 0f4f3c92..1869e1e2 100644 --- a/src/lib/rename_detect.mbt +++ b/src/lib/rename_detect.mbt @@ -26,7 +26,7 @@ fn merge_detect_renames( let sources : Array[(String, TreeFileEntry)] = [] let replaced_paths : Map[String, Bool] = {} for path, entry in base { - if !(side.contains(path)) { + if !side.contains(path) { sources.push((path, entry)) } else { match side.get(path) { @@ -42,7 +42,7 @@ fn merge_detect_renames( // Added paths: in side but not in base let added : Array[(String, TreeFileEntry)] = [] for path, entry in side { - if !(base.contains(path)) { + if !base.contains(path) { added.push((path, entry)) } } @@ -69,7 +69,7 @@ fn merge_detect_renames( match source_by_oid.get(hex) { Some(candidates) => for old_path in candidates { - if !(matched_source.contains(old_path)) { + if !matched_source.contains(old_path) { old_to_new[old_path] = new_path matched_source[old_path] = true matched_added[new_path] = true @@ -87,14 +87,14 @@ fn merge_detect_renames( let unmatched_sources : Array[(String, TreeFileEntry)] = [] for item in sources { let (path, _) = item - if !(matched_source.contains(path)) { + if !matched_source.contains(path) { unmatched_sources.push(item) } } let unmatched_added : Array[(String, TreeFileEntry)] = [] for item in added { let (path, _) = item - if !(matched_added.contains(path)) { + if !matched_added.contains(path) { unmatched_added.push(item) } } diff --git a/src/lib/reset.mbt b/src/lib/reset.mbt index 6ba1e970..22980bf5 100644 --- a/src/lib/reset.mbt +++ b/src/lib/reset.mbt @@ -94,7 +94,7 @@ fn reset_resolve_common_git_dir( git_dir : String, ) -> String { let commondir_path = join_path(git_dir, "commondir") - if !(fs.is_file(commondir_path)) { + if !fs.is_file(commondir_path) { return git_dir } let raw = @utf8.decode_lossy( diff --git a/src/lib/revparse.mbt b/src/lib/revparse.mbt index edeffad2..6c0aff72 100644 --- a/src/lib/revparse.mbt +++ b/src/lib/revparse.mbt @@ -110,7 +110,7 @@ fn resolve_commit_message_search_all_refs( for item in refs { let (_, id) = item let hex = id.to_hex() - if !(seen_start.contains(hex)) { + if !seen_start.contains(hex) { seen_start[hex] = true starts.push(id) } @@ -118,7 +118,7 @@ fn resolve_commit_message_search_all_refs( match resolve_head_commit(fs, git_dir) { Some(id) => { let hex = id.to_hex() - if !(seen_start.contains(hex)) { + if !seen_start.contains(hex) { seen_start[hex] = true starts.push(id) } @@ -165,7 +165,7 @@ fn find_reachable_commit_by_message_from_many( } let info = @bit.parse_commit(obj.data) for parent in info.parents { - if !(seen.contains(parent.to_hex())) { + if !seen.contains(parent.to_hex()) { queue.push(parent) } } @@ -412,7 +412,7 @@ fn apply_rev_suffix( steps = steps * 10 + (chars[i].to_int() - '0'.to_int()) i += 1 } - if !(has_digits) { + if !has_digits { steps = 1 } for _ in 0.. @bit.ObjectId? raise @bit.GitError { - if spec.length() < 4 || - spec.length() >= 40 || - !(@bithash.is_hex_string(spec)) { + if spec.length() < 4 || spec.length() >= 40 || !@bithash.is_hex_string(spec) { return None } let needle = @bithash.lower_hex_string(spec) @@ -692,7 +690,7 @@ fn ref_collect_packed( start=idx + 1, end=line.length(), ) - if !(out.contains(name)) { + if !out.contains(name) { out[name] = @bit.ObjectId::from_hex(id_hex) } } @@ -882,7 +880,7 @@ pub fn rev_parse_normalize_glob_pattern(pattern : String) -> String { pub fn rev_parse_glob_match(text : String, pattern : String) -> Bool { let has_star = pattern.find("*") is Some(_) let has_question = pattern.find("?") is Some(_) - if !(has_star) && !(has_question) { + if !has_star && !has_question { text == pattern || ( text.has_prefix(pattern) && @@ -1092,7 +1090,7 @@ pub fn rev_parse_apply_prefix_to_colon_path( start=colon_idx + 1, end=spec.length(), ) - if !(path_part.has_prefix("./")) && !(path_part.has_prefix("../")) { + if !path_part.has_prefix("./") && !path_part.has_prefix("../") { return spec } let rev_part = String::unsafe_substring(spec, start=0, end=colon_idx) @@ -1104,7 +1102,7 @@ pub fn rev_parse_apply_prefix_to_colon_path( ///| /// Parse index pathspec like `:0:path` or `:path`. pub fn parse_index_pathspec(spec : String) -> (Int, String?) { - if !(spec.has_prefix(":")) || spec.length() <= 1 { + if !spec.has_prefix(":") || spec.length() <= 1 { return (0, None) } let rest = String::unsafe_substring(spec, start=1, end=spec.length()) diff --git a/src/lib/smart_http.mbt b/src/lib/smart_http.mbt index 5b685fa4..65dec0e1 100644 --- a/src/lib/smart_http.mbt +++ b/src/lib/smart_http.mbt @@ -15,7 +15,7 @@ pub fn receive_pack_info_refs_response( token : String, agent? : String = "git/moonbit", ) -> HttpResponse raise @bit.GitError { - if !(check_bearer_token(auth_header, token)) { + if !check_bearer_token(auth_header, token) { return { status: 401, headers: { "Content-Type": "text/plain", "WWW-Authenticate": "Bearer" }, @@ -44,7 +44,7 @@ pub fn receive_pack_response( token : String, body : Bytes, ) -> HttpResponse raise @bit.GitError { - if !(check_bearer_token(auth_header, token)) { + if !check_bearer_token(auth_header, token) { return { status: 401, headers: { "Content-Type": "text/plain", "WWW-Authenticate": "Bearer" }, @@ -84,7 +84,7 @@ fn check_bearer_token(auth_header : String?, token : String) -> Bool { match auth_header { None => false Some(value) => { - if !(value.has_prefix("Bearer ")) { + if !value.has_prefix("Bearer ") { return false } let received = String::unsafe_substring( diff --git a/src/lib/sparse.mbt b/src/lib/sparse.mbt index d477d07c..839b1be8 100644 --- a/src/lib/sparse.mbt +++ b/src/lib/sparse.mbt @@ -41,7 +41,7 @@ fn sparse_upsert_section_value( continue } if in_section && trimmed.has_prefix("[") { - if !(key_set) { + if !key_set { lines.push("\t\{name} = \{value_text}") key_set = true } @@ -55,7 +55,7 @@ fn sparse_upsert_section_value( lines.push(line) } if found_section { - if in_section && !(key_set) { + if in_section && !key_set { lines.push("\t\{name} = \{value_text}") } } else { @@ -109,7 +109,7 @@ fn sparse_is_section_bool_enabled( join_path(git_dir, "config.worktree"), ] for config_path in config_paths { - if !(rfs.is_file(config_path)) { + if !rfs.is_file(config_path) { continue } let content = @utf8.decode_lossy( @@ -290,7 +290,7 @@ fn sparse_canonicalize_cone_patterns(patterns : Array[String]) -> Array[String] for existing in kept { canonical.push(existing) } - if !(covered) { + if !covered { canonical.push(normalized) } } @@ -335,17 +335,17 @@ fn sparse_encode_cone_patterns(patterns : Array[String]) -> Array[String] { current + "/" + parts[i] } let parent = "/" + current + "/" - if !(out.contains(parent)) { + if !out.contains(parent) { out.push(parent) } let exclude_children = "!/" + current + "/*/" - if !(out.contains(exclude_children)) { + if !out.contains(exclude_children) { out.push(exclude_children) } } } let stored = "/" + relative + "/" - if !(out.contains(stored)) { + if !out.contains(stored) { out.push(stored) } } @@ -376,7 +376,7 @@ pub fn read_sparse_patterns( git_dir : String, ) -> Array[String] raise @bit.GitError { let sparse_path = join_path(git_dir, "info/sparse-checkout") - if !(rfs.is_file(sparse_path)) { + if !rfs.is_file(sparse_path) { return [] } let content = rfs.read_file(sparse_path) @@ -384,7 +384,7 @@ pub fn read_sparse_patterns( let patterns : Array[String] = [] for line_view in text.split("\n") { let line = sparse_trim(line_view.to_string()) - if line.length() > 0 && !(line.has_prefix("#")) { + if line.length() > 0 && !line.has_prefix("#") { patterns.push(line) } } @@ -397,7 +397,7 @@ pub fn read_sparse_display_patterns( git_dir : String, ) -> Array[String] raise @bit.GitError { let patterns = read_sparse_patterns(rfs, git_dir) - if !(is_sparse_checkout_cone_enabled(rfs, git_dir)) { + if !is_sparse_checkout_cone_enabled(rfs, git_dir) { return patterns } let positive : Array[String] = [] @@ -421,7 +421,7 @@ pub fn read_sparse_display_patterns( continue } match sparse_normalize_cone_pattern(pattern) { - Some(normalized) if !(positive.contains(normalized)) => + Some(normalized) if !positive.contains(normalized) => positive.push(normalized) _ => () } @@ -437,7 +437,7 @@ pub fn read_sparse_display_patterns( } } } - if !(intermediate) { + if !intermediate { display.push(candidate) } } @@ -493,7 +493,7 @@ pub fn sparse_checkout_init( fs.write_string(config_path, updated) sparse_set_cone_config(fs, rfs, git_dir, cone) let sparse_path = join_path(git_dir, "info/sparse-checkout") - if !(rfs.is_file(sparse_path)) { + if !rfs.is_file(sparse_path) { write_sparse_patterns(fs, rfs, git_dir, sparse_default_patterns()) } sparse_update_worktree(fs, rfs, root) @@ -509,7 +509,7 @@ pub fn sparse_checkout_set( ) -> Unit raise @bit.GitError { let git_dir = join_path(root, ".git") // Ensure sparse checkout is initialized - if !(is_sparse_checkout_enabled(rfs, git_dir)) { + if !is_sparse_checkout_enabled(rfs, git_dir) { sparse_checkout_init(fs, rfs, root) } sparse_enable_worktree_config(fs, rfs, git_dir) @@ -533,13 +533,13 @@ pub fn sparse_checkout_add( ) -> Unit raise @bit.GitError { let git_dir = join_path(root, ".git") // Ensure sparse checkout is initialized - if !(is_sparse_checkout_enabled(rfs, git_dir)) { + if !is_sparse_checkout_enabled(rfs, git_dir) { sparse_checkout_init(fs, rfs, root) } sparse_enable_worktree_config(fs, rfs, git_dir) let cone_mode = is_sparse_checkout_cone_enabled(rfs, git_dir) let existing = read_sparse_patterns(rfs, git_dir) - if cone_mode && !(sparse_patterns_use_cone_mode(existing)) { + if cone_mode && !sparse_patterns_use_cone_mode(existing) { raise @bit.GitError::InvalidObject( "existing sparse-checkout patterns do not use cone mode", ) @@ -547,14 +547,14 @@ pub fn sparse_checkout_add( let next_patterns = if cone_mode { let display = read_sparse_display_patterns(rfs, git_dir) for p in new_patterns { - if !(display.contains(p)) { + if !display.contains(p) { display.push(p) } } sparse_encode_cone_patterns(display) } else { for p in new_patterns { - if !(existing.contains(p)) { + if !existing.contains(p) { existing.push(p) } } @@ -621,7 +621,7 @@ pub fn sparse_checkout_reapply( root : String, ) -> Unit raise @bit.GitError { let git_dir = join_path(root, ".git") - if !(is_sparse_checkout_enabled(rfs, git_dir)) { + if !is_sparse_checkout_enabled(rfs, git_dir) { sparse_checkout_init(fs, rfs, root) } sparse_enable_worktree_config(fs, rfs, git_dir) @@ -672,7 +672,7 @@ fn sparse_path_matches(path : String, pattern : String) -> Bool { // "*.txt" - match files ending in .txt if normalized_pattern == "/*" { // Match files in root (no slash in path) - return !(path.contains("/")) + return !path.contains("/") } if normalized_pattern == "/*/" { // Used by the default negation pattern "!/*/" to exclude root directories. @@ -726,7 +726,7 @@ fn sparse_path_matches(path : String, pattern : String) -> Bool { start=dir.length() + 1, end=path.length(), ) - return !(rest.contains("/")) + return !rest.contains("/") } return false } @@ -832,7 +832,7 @@ fn sparse_parent_dirs(path : String) -> Array[String] { break } current = String::unsafe_substring(current, start=0, end=slash) - if current.length() > 0 && !(out.contains(current)) { + if current.length() > 0 && !out.contains(current) { out.push(current) } } @@ -879,7 +879,7 @@ fn sparse_build_sparse_index_entries( let candidate_dirs : Array[String] = [] for path in skip_paths { for dir in sparse_parent_dirs(path) { - if !(candidate_dirs.contains(dir)) { + if !candidate_dirs.contains(dir) { candidate_dirs.push(dir) } } @@ -900,16 +900,16 @@ fn sparse_build_sparse_index_entries( let mut fully_skipped = true for item in all_files.to_array() { let (path, _) = item - if !(sparse_is_under_dir(path, dir)) { + if !sparse_is_under_dir(path, dir) { continue } has_files = true - if !(skip_paths.contains(path)) { + if !skip_paths.contains(path) { fully_skipped = false break } } - if !(has_files) || !(fully_skipped) { + if !has_files || !fully_skipped { continue } let mut shadowed = false @@ -919,7 +919,7 @@ fn sparse_build_sparse_index_entries( break } } - if !(shadowed) { + if !shadowed { sparse_dirs.push(dir) } } @@ -971,7 +971,7 @@ fn sparse_update_worktree( preserve_index? : Bool = false, ) -> Unit raise @bit.GitError { let git_dir = join_path(root, ".git") - if !(rfs.is_file(join_path(git_dir, "index"))) { + if !rfs.is_file(join_path(git_dir, "index")) { return } let patterns = read_sparse_patterns(rfs, git_dir) @@ -993,7 +993,7 @@ fn sparse_update_worktree( // Reapply should still prune root-level skipped files back to the // current sparse patterns, while preserving dirty paths inside skipped // directories that may coexist with user files. - if preserve_index && !(entry.path.contains("/")) { + if preserve_index && !entry.path.contains("/") { continue } if sparse_worktree_matches_index_entry( @@ -1030,7 +1030,7 @@ fn sparse_update_worktree( // Remove files not in sparse set for item in all_files.to_array() { let (path, _) = item - if !(matches_sparse_pattern(path, patterns)) { + if !matches_sparse_pattern(path, patterns) { if protected_skip_paths.contains(path) { continue } @@ -1111,7 +1111,7 @@ fn sparse_prune_empty_dirs( if path != root && path.has_prefix(join_path(root, ".git")) { return false } - if !(rfs.is_dir(path)) { + if !rfs.is_dir(path) { return false } let entries = rfs.readdir(path) catch { _ => return false } @@ -1132,7 +1132,7 @@ fn sparse_prune_empty_dirs( break } } - if path != root && !(has_entries) { + if path != root && !has_entries { fs.remove_dir(path) catch { _ => () } diff --git a/src/lib/stash.mbt b/src/lib/stash.mbt index 7ce8f4b3..ed7372b5 100644 --- a/src/lib/stash.mbt +++ b/src/lib/stash.mbt @@ -13,12 +13,12 @@ pub fn stash_list( git_dir : String, ) -> Array[StashEntry] raise @bit.GitError { let stash_ref_path = git_dir + "/refs/stash" - if !(fs.is_file(stash_ref_path)) { + if !fs.is_file(stash_ref_path) { return [] } // Read reflog for stash let reflog_path = git_dir + "/logs/refs/stash" - if !(fs.is_file(reflog_path)) { + if !fs.is_file(reflog_path) { // Just return the current stash let content = @utf8.decode_lossy(fs.read_file(stash_ref_path)[:]) let hex = content.trim_end(chars="\n\r ").to_string() @@ -271,7 +271,7 @@ fn stash_drop_at( } // Rebuild reflog without the entry let reflog_path = git_dir + "/logs/refs/stash" - if !(rfs.is_file(reflog_path)) { + if !rfs.is_file(reflog_path) { // Only one entry, just remove refs/stash let stash_ref = git_dir + "/refs/stash" fs.remove_file(stash_ref) diff --git a/src/lib/status_text.mbt b/src/lib/status_text.mbt index 084f58de..2ac21945 100644 --- a/src/lib/status_text.mbt +++ b/src/lib/status_text.mbt @@ -63,7 +63,7 @@ pub async fn status_text( sb.write_string(" " + path + "\n") } } - if !(has_staged) && !(has_unstaged) && st.untracked.length() == 0 { + if !has_staged && !has_unstaged && st.untracked.length() == 0 { sb.write_string("\nnothing to commit, working tree clean\n") } sb.to_string() diff --git a/src/lib/status_walk.mbt b/src/lib/status_walk.mbt index 995b241a..28c1b5c6 100644 --- a/src/lib/status_walk.mbt +++ b/src/lib/status_walk.mbt @@ -107,8 +107,8 @@ async fn index_guided_status_walk( ) // Post-walk sweep: any unvisited, non-skip-worktree entries are deleted for i, entry in index_entries { - if !(visited[i]) && !(skip_worktree.contains(entry.path)) { - if !(is_gitlink_mode_int(entry.mode)) { + if !visited[i] && !skip_worktree.contains(entry.path) { + if !is_gitlink_mode_int(entry.mode) { unstaged_deleted.push(entry.path) } } @@ -156,7 +156,7 @@ async fn walk_dir_guided( break } } - if !(has_git) { + if !has_git { for entry in disk_dirs { if entry == ".git" || entry == ".bit" { has_git = true @@ -201,7 +201,7 @@ async fn walk_dir_guided( let idx_pos = sorted_idx[ii].0 let entry = index_entries[idx_pos] visited[idx_pos] = true - if !(is_gitlink_mode_int(entry.mode)) { + if !is_gitlink_mode_int(entry.mode) { check_file_against_index( fs, root, @@ -224,7 +224,7 @@ async fn walk_dir_guided( name != ".jj" && name != ".gitignore" { let child_rel = if rel == "" { name } else { rel + "/" + name } - if !(matcher.is_ignored(child_rel, false)) { + if !matcher.is_ignored(child_rel, false) { untracked.push(child_rel) } } @@ -239,7 +239,7 @@ async fn walk_dir_guided( // Let the post-walk sweep handle it. But we need to avoid double-counting. // Actually: mark visited and add to deleted directly here. let entry = index_entries[idx_pos] - if !(is_gitlink_mode_int(entry.mode)) { + if !is_gitlink_mode_int(entry.mode) { unstaged_deleted.push(entry.path) } ii += 1 @@ -252,7 +252,7 @@ async fn walk_dir_guided( name != ".jj" && name != ".gitignore" { let child_rel = if rel == "" { name } else { rel + "/" + name } - if !(matcher.is_ignored(child_rel, false)) { + if !matcher.is_ignored(child_rel, false) { untracked.push(child_rel) } } @@ -262,7 +262,7 @@ async fn walk_dir_guided( let idx_pos = sorted_idx[ii].0 visited[idx_pos] = true let entry = index_entries[idx_pos] - if !(is_gitlink_mode_int(entry.mode)) { + if !is_gitlink_mode_int(entry.mode) { unstaged_deleted.push(entry.path) } ii += 1 @@ -477,7 +477,7 @@ async fn check_file_against_index( match info.mtime_nsec { Some(mn) => if entry.mtime_sec != 0 || entry.mtime_nsec != 0 { - stat_matches = !(size_mismatch) && + stat_matches = !size_mismatch && ms == entry.mtime_sec && mn == entry.mtime_nsec } @@ -492,7 +492,7 @@ async fn check_file_against_index( unstaged_modified.push(path) } else if size_mismatch { unstaged_modified.push(path) - } else if !(stat_matches) { + } else if !stat_matches { let content = fs.read_file(abs) let attrs = resolve_eol_attrs(fs, root, path) let content = match (attrs.filter, run_filter_cmd) { @@ -547,7 +547,7 @@ async fn check_file_against_index( } if mode_changed { unstaged_modified.push(path) - } else if !(stat_matches) { + } else if !stat_matches { match @bitio.read_symlink_target_path(abs) { Some(target) => { let id = target |> @utf8.encode |> @bit.hash_blob diff --git a/src/lib/subdir.mbt b/src/lib/subdir.mbt index 65e34036..f29fbcb5 100644 --- a/src/lib/subdir.mbt +++ b/src/lib/subdir.mbt @@ -175,7 +175,7 @@ fn find_subtree( break } } - if !(found) { + if !found { return None } } @@ -310,7 +310,7 @@ fn read_remote_url_from_config( git_dir : String, ) -> String? { let config_path = git_dir + "/config" - if !(fs.is_file(config_path)) { + if !fs.is_file(config_path) { return None } let config_content = @string_utils.decode_bytes( diff --git a/src/lib/tree_ops.mbt b/src/lib/tree_ops.mbt index 70654ca5..fc546938 100644 --- a/src/lib/tree_ops.mbt +++ b/src/lib/tree_ops.mbt @@ -36,7 +36,7 @@ fn detect_case_insensitive_collision_skips( paths : Array[String], ) -> Map[String, Bool] raise @bit.GitError { let skip : Map[String, Bool] = {} - if !(worktree_is_case_insensitive(fs, rfs, git_dir)) { + if !worktree_is_case_insensitive(fs, rfs, git_dir) { return skip } let mut i = 0 @@ -75,7 +75,7 @@ fn remove_worktree_path_recursive( fs.remove_file(path) return () } - if !(rfs.is_dir(path)) { + if !rfs.is_dir(path) { return () } let entries = rfs.readdir(path) @@ -113,7 +113,7 @@ fn tree_ops_get_rel_path(from : String, to : String) -> String { result = result + "../" } for i in common.. 0 && !(result.has_suffix("/")) { + if result.length() > 0 && !result.has_suffix("/") { result = result + "/" } result = result + to_parts[i] @@ -178,7 +178,7 @@ fn tree_ops_find_submodule_name_by_path( tree_ops_find_submodule_name_in_content(content, path).unwrap_or(path) None => { let gitmodules_path = join_path(root, ".gitmodules") - if !(rfs.is_file(gitmodules_path)) { + if !rfs.is_file(gitmodules_path) { return path } let content = decode_bytes_lossy( @@ -211,7 +211,7 @@ fn tree_ops_set_core_config_value( continue } if in_core && trimmed.has_prefix("[") { - if !(key_set) { + if !key_set { lines.push("\t\{key} = \{value}") key_set = true } @@ -230,7 +230,7 @@ fn tree_ops_set_core_config_value( lines.push(line) } if found_section { - if in_core && !(key_set) { + if in_core && !key_set { lines.push("\t\{key} = \{value}") } } else { @@ -288,7 +288,7 @@ fn restore_gitlink_worktree( ) let modules_dir = join_path(join_path(git_dir, "modules"), submodule_name) fs.mkdir_p(full_path) - if !(rfs.is_dir(modules_dir)) { + if !rfs.is_dir(modules_dir) { return () } let rel_path = tree_ops_get_rel_path(full_path, modules_dir) @@ -307,7 +307,7 @@ fn restore_gitlink_worktree( fs.write_string(config_path, with_bare) if rfs.is_file(worktree_git_path) { fs.write_string(worktree_git_path, "gitdir: \{rel_path}\n") - } else if !(has_existing_worktree) { + } else if !has_existing_worktree { fs.write_string(worktree_git_path, "gitdir: \{rel_path}\n") } if has_existing_worktree { @@ -449,7 +449,7 @@ fn tree_ops_prepare_blob_path( full_path : String, path : String, ) -> Unit raise @bit.GitError { - if !(rfs.is_dir(full_path)) { + if !rfs.is_dir(full_path) { return } let bit_marker = join_path(full_path, ".git") @@ -578,7 +578,7 @@ pub fn write_worktree_and_build_index( let (path, info) = item let skip_write = skip_paths.contains(path) if is_gitlink_mode_int(info.mode) { - if !(skip_write) { + if !skip_write { restore_gitlink_worktree( fs, rfs, @@ -604,7 +604,7 @@ pub fn write_worktree_and_build_index( }) continue } - if !(skip_write) { + if !skip_write { let full_path = join_path(root, path) tree_ops_prepare_blob_path(fs, rfs, full_path, path) } @@ -619,7 +619,7 @@ pub fn write_worktree_and_build_index( raise @bit.GitError::InvalidObject("Object is not a blob") } let full_path = join_path(root, path) - if !(skip_write) { + if !skip_write { let dir = parent_dir(full_path) fs.mkdir_p(dir) let attrs = resolve_eol_attrs(rfs, root, path) diff --git a/src/lib/tree_path.mbt b/src/lib/tree_path.mbt index 2757336f..4c375849 100644 --- a/src/lib/tree_path.mbt +++ b/src/lib/tree_path.mbt @@ -8,7 +8,7 @@ fn normalize_repo_path_internal(path : String) -> String { } else if part == ".." { if parts.length() > 0 && parts[parts.length() - 1] != ".." { let _ = parts.pop() - } else if !(path.has_prefix("/")) { + } else if !path.has_prefix("/") { parts.push(part) } } else { @@ -84,7 +84,7 @@ pub fn find_tree_entry( return Some(entry) } else { let is_tree = entry.mode == "40000" || entry.mode == "040000" - if !(is_tree) { + if !is_tree { return None } current = entry.id diff --git a/src/lib/upload_pack.mbt b/src/lib/upload_pack.mbt index a4f3bf89..1bee649e 100644 --- a/src/lib/upload_pack.mbt +++ b/src/lib/upload_pack.mbt @@ -1,5 +1,17 @@ ///| Upload-pack (server-side) implementation +///| +#warnings("-deprecated") +fn upload_pack_parse_int(value : StringView) -> Int raise { + @strconv.parse_int(value) +} + +///| +#warnings("-deprecated") +fn upload_pack_parse_int64(value : StringView) -> Int64 raise { + @strconv.parse_int64(value) +} + ///| pub struct UploadPackRequest { wants : Array[@bit.ObjectId] @@ -120,7 +132,7 @@ pub fn parse_upload_pack_request_v2( let line = upload_bytes_to_string_range(data, i + 4, i + len) let line = upload_trim_line(line) i += len - if !(in_args) { + if !in_args { // Command section if line.has_prefix("command=") { command = String::unsafe_substring(line, start=8, end=line.length()) @@ -347,7 +359,7 @@ pub fn parse_upload_pack_request( } else if line.has_prefix("deepen ") { let depth_str = String::unsafe_substring(line, start=7, end=line.length()) let depth_str = upload_trim_line(depth_str) - let depth = @string.parse_int(depth_str) catch { _ => -1 } + let depth = upload_pack_parse_int(depth_str) catch { _ => -1 } if depth >= 0 { deepen = Some(depth) } @@ -381,7 +393,7 @@ pub fn upload_pack( } // Stateless clients may terminate after wants; respond with flush only - if !(req.done) && req.haves.length() == 0 { + if !req.done && req.haves.length() == 0 { return @protocol.pktline_flush() } @@ -391,7 +403,7 @@ pub fn upload_pack( // Collect have ACKs (v0 allows duplicates) let ack_ids = collect_have_acks_v0(db, fs, req.haves) - if !(req.done) { + if !req.done { return build_upload_pack_ack_response(ack_ids) } @@ -416,7 +428,7 @@ pub fn upload_pack( let filtered : Array[@bit.PackObject] = [] for obj in objects { let id = @bit.hash_object_content(obj.obj_type, obj.data) - if !(have_set.contains(id.to_hex())) { + if !have_set.contains(id.to_hex()) { filtered.push(obj) } } @@ -551,7 +563,7 @@ fn upload_pack_error_message( ProtocolError(msg) => msg IoError(msg) => msg } - if include_pack_objects_died && !(base.contains("pack-objects died")) { + if include_pack_objects_died && !base.contains("pack-objects died") { base + "\npack-objects died" } else { base @@ -697,7 +709,7 @@ pub fn upload_pack_v2( config : UploadPackConfig, ) -> Bytes raise @bit.GitError { // Validate request against config - if req.filter is Some(_) && !(config.allow_filter) { + if req.filter is Some(_) && !config.allow_filter { raise @bit.GitError::ProtocolError( "unexpected line: 'filter " + req.filter.unwrap() + "'", ) @@ -728,7 +740,7 @@ pub fn upload_pack_v2( } let wanted_refs : Array[(String, @bit.ObjectId)] = [] if req.want_refs.length() > 0 { - if !(config.allow_ref_in_want) { + if !config.allow_ref_in_want { raise @bit.GitError::ProtocolError("unknown command 'want-ref'") } for name in req.want_refs { @@ -745,13 +757,13 @@ pub fn upload_pack_v2( let wants : Array[@bit.ObjectId] = [] for id in all_wants { let hex = id.to_hex() - if !(seen_wants.contains(hex)) { + if !seen_wants.contains(hex) { seen_wants[hex] = true wants.push(id) } } let ack_ids = collect_have_acks_v2(db, fs, req.haves) - if !(req.done) { + if !req.done { return build_upload_pack_response_v2_ack(ack_ids, wanted_refs) } @@ -779,7 +791,7 @@ pub fn upload_pack_v2( let filtered : Array[@bit.PackObject] = [] for obj in objects { let id = @bit.hash_object_content(obj.obj_type, obj.data) - if !(have_set.contains(id.to_hex())) { + if !have_set.contains(id.to_hex()) { filtered.push(obj) } } @@ -799,11 +811,11 @@ fn parse_filter_spec(spec : String) -> @protocol.FilterSpec { @protocol.FilterSpec::BlobNone } else if spec.has_prefix("blob:limit=") { let limit_str = String::unsafe_substring(spec, start=11, end=spec.length()) - let limit = @string.parse_int64(limit_str) catch { _ => 0L } + let limit = upload_pack_parse_int64(limit_str) catch { _ => 0L } @protocol.FilterSpec::BlobLimit(limit) } else if spec.has_prefix("tree:") { let depth_str = String::unsafe_substring(spec, start=5, end=spec.length()) - let depth = @string.parse_int(depth_str) catch { _ => 0 } + let depth = upload_pack_parse_int(depth_str) catch { _ => 0 } @protocol.FilterSpec::TreeDepth(depth) } else { @protocol.FilterSpec::NoFilter diff --git a/src/lib/worktree.mbt b/src/lib/worktree.mbt index 84415733..de86f4f1 100644 --- a/src/lib/worktree.mbt +++ b/src/lib/worktree.mbt @@ -264,7 +264,7 @@ pub async fn add_paths_async( (existing.mtime_sec != 0 || existing.mtime_nsec != 0) && ms == existing.mtime_sec && mn == existing.mtime_nsec && - (!(core_filemode) || info.mode == existing.mode) + (!core_filemode || info.mode == existing.mode) _ => false } if stat_matches { @@ -293,7 +293,7 @@ pub async fn add_paths_async( // Collect CRLF conversion warnings match warnings { Some(warns) => - if !(is_binary_bytes(content)) { + if !is_binary_bytes(content) { collect_crlf_warnings( warns, path, content, normalized, attrs, autocrlf, ) @@ -413,7 +413,7 @@ pub fn commit( let parent = resolve_head_commit(rfs, actual_git_dir) let entries = read_index_entries(rfs, actual_git_dir) let tree_id = if entries.length() == 0 { - if !(allow_empty) { + if !allow_empty { raise @bit.GitError::InvalidObject("Empty index") } match parent { @@ -840,7 +840,7 @@ fn read_core_filemode_setting( git_dir : String, ) -> Bool { let local_path = join_path(git_dir, "config") - if !(fs.is_file(local_path)) { + if !fs.is_file(local_path) { return true } match read_core_filemode_from_config(fs, local_path) { @@ -981,7 +981,7 @@ fn collect_crlf_warnings( "warning: in the working copy of '\{path}', CRLF will be replaced by LF", ) } - } else if !(has_crlf_in_original) && bytes_contains_lf(original) { + } else if !has_crlf_in_original && bytes_contains_lf(original) { // File has LF only. Check if smudge would add CRLF let would_crlf = match attrs.text { Unset => false @@ -1039,7 +1039,7 @@ pub fn normalize_crlf_to_lf(content : Bytes) -> Bytes { out.push(content[i]) i += 1 } - if !(changed) { + if !changed { return content } Bytes::from_array(FixedArray::makei(out.length(), i => out[i])) @@ -1323,7 +1323,7 @@ fn write_tree_from_entries( if worktree_is_zero_object_id(e.id) { continue } - if !(is_gitlink_mode_int(e.mode)) { + if !is_gitlink_mode_int(e.mode) { match object_db { Some(db) => match db.get(rfs, e.id) { @@ -1479,7 +1479,7 @@ fn resolve_worktree_common_git_dir( git_dir : String, ) -> String { let commondir_path = join_path(git_dir, "commondir") - if !(fs.is_file(commondir_path)) { + if !fs.is_file(commondir_path) { return git_dir } let raw = @utf8.decode_lossy( @@ -1766,7 +1766,7 @@ pub fn rm_paths( // Remove from index map.remove(norm_path) // Remove from working tree unless --cached - if !(cached) { + if !cached { let abs = join_path(root, norm_path) if rfs.is_file(abs) { fs.remove_file(abs) @@ -1797,7 +1797,7 @@ pub fn rm_paths( write_index_entries_with_skip_worktree( fs, actual_git_dir, out, remaining_skip_worktree_paths, ) - if !(cached) { + if !cached { rm_update_gitmodules_after_submodule_removal( fs, rfs, root, removed_submodule_paths, ) @@ -1815,7 +1815,7 @@ fn rm_update_gitmodules_after_submodule_removal( return } let gitmodules_path = join_path(root, ".gitmodules") - if !(rfs.is_file(gitmodules_path)) { + if !rfs.is_file(gitmodules_path) { return } let removed_paths : Map[String, Bool] = {} @@ -1842,7 +1842,7 @@ fn rm_remove_gitmodules_sections_by_path( let mut current_path : String? = None let mut have_section = false let flush_section = fn() { - if !(have_section) { + if !have_section { return } if in_submodule && @@ -1866,7 +1866,7 @@ fn rm_remove_gitmodules_sections_by_path( current_path = None continue } - if !(have_section) { + if !have_section { out.push(line) continue } @@ -1894,7 +1894,7 @@ fn rm_prune_empty_parent_dirs( } while current.length() > 0 { let abs = join_path(root, current) - if !(rfs.is_dir(abs)) { + if !rfs.is_dir(abs) { return } let entries = rfs.readdir(abs) catch { _ => return } @@ -1970,7 +1970,7 @@ pub fn mv_path( let src_abs = join_path(root, src_norm) let mut dst_abs = join_path(root, dst_norm) // Check source exists - if !(rfs.is_file(src_abs)) && !(rfs.is_dir(src_abs)) { + if !rfs.is_file(src_abs) && !rfs.is_dir(src_abs) { raise @bit.GitError::InvalidObject("source '\{source}' does not exist") } // If dest is a directory, move source into it (like `mv file dir/`) @@ -1984,7 +1984,7 @@ pub fn mv_path( dst_abs = join_path(root, dst_norm) } // Check dest doesn't exist (unless force) - if (rfs.is_file(dst_abs) || rfs.is_dir(dst_abs)) && !(force) { + if (rfs.is_file(dst_abs) || rfs.is_dir(dst_abs)) && !force { raise @bit.GitError::InvalidObject("destination '\{dest}' already exists") } // Read index @@ -2133,7 +2133,7 @@ fn mv_rewrite_gitfile_after_directory_move( let content = trim_worktree_text( @string_utils.decode_bytes(rfs.read_file(dst_gitfile)), ) - if !(content.has_prefix("gitdir: ")) { + if !content.has_prefix("gitdir: ") { return () } let rel_gitdir = String::unsafe_substring( @@ -2163,7 +2163,7 @@ pub fn convert_lf_to_crlf(content : Bytes) -> Bytes { } i += 1 } - if !(changed) { + if !changed { return content } Bytes::from_array(FixedArray::makei(out.length(), fn(i) { out[i] })) diff --git a/src/lib/worktree_admin.mbt b/src/lib/worktree_admin.mbt index 6f5f2198..3dbc23ff 100644 --- a/src/lib/worktree_admin.mbt +++ b/src/lib/worktree_admin.mbt @@ -32,7 +32,7 @@ pub fn list_worktrees( result.push(main_info) // Scan .git/worktrees/ for linked worktrees let worktrees_dir = join_path(git_dir, "worktrees") - if !(fs.is_dir(worktrees_dir)) { + if !fs.is_dir(worktrees_dir) { return result } let entries = fs.readdir(worktrees_dir) @@ -41,7 +41,7 @@ pub fn list_worktrees( continue } let admin_dir = join_path(worktrees_dir, entry) - if !(fs.is_dir(admin_dir)) { + if !fs.is_dir(admin_dir) { continue } match get_linked_worktree_info(fs, admin_dir) { @@ -132,7 +132,7 @@ pub fn create_worktree( "a branch named '\{b}' already exists", ) } - if !(force) { + if !force { match is_branch_checked_out(rfs, root, b) { Some(path) => raise @bit.GitError::InvalidObject( @@ -306,7 +306,7 @@ pub fn prune_worktrees_detailed( let git_dir = resolve_git_dir(rfs, root) let worktrees_dir = join_path(git_dir, "worktrees") let pruned : Array[PrunedWorktreeEntry] = [] - if !(rfs.is_dir(worktrees_dir)) { + if !rfs.is_dir(worktrees_dir) { return pruned } let seen_worktree_roots : Map[String, Bool] = {} @@ -318,7 +318,7 @@ pub fn prune_worktrees_detailed( continue } let admin_dir = join_path(worktrees_dir, entry) - if !(rfs.is_dir(admin_dir)) { + if !rfs.is_dir(admin_dir) { prune_record( fs, rfs, worktrees_dir, admin_dir, entry, "not a valid directory", pruned, dry_run, @@ -332,7 +332,7 @@ pub fn prune_worktrees_detailed( continue } let gitdir_path = join_path(admin_dir, "gitdir") - if !(rfs.is_file(gitdir_path)) { + if !rfs.is_file(gitdir_path) { prune_record( fs, rfs, worktrees_dir, admin_dir, entry, "gitdir file does not exist", pruned, dry_run, @@ -363,7 +363,7 @@ pub fn prune_worktrees_detailed( ) continue } - if !(rfs.is_file(resolved_gitdir)) && !(rfs.is_dir(resolved_gitdir)) { + if !rfs.is_file(resolved_gitdir) && !rfs.is_dir(resolved_gitdir) { prune_record( fs, rfs, worktrees_dir, admin_dir, entry, "gitdir file points to non-existent location", pruned, dry_run, @@ -394,7 +394,7 @@ fn prune_record( pruned : Array[PrunedWorktreeEntry], dry_run : Bool, ) -> Unit raise @bit.GitError { - if !(dry_run) { + if !dry_run { if rfs.is_dir(admin_path) { remove_dir_recursive(fs, rfs, admin_path) } else if rfs.is_file(admin_path) { @@ -412,7 +412,7 @@ fn prune_cleanup_worktrees_dir( worktrees_dir : String, dry_run : Bool, ) -> Unit raise @bit.GitError { - if dry_run || !(rfs.is_dir(worktrees_dir)) { + if dry_run || !rfs.is_dir(worktrees_dir) { return } let mut has_entries = false @@ -422,7 +422,7 @@ fn prune_cleanup_worktrees_dir( break } } - if !(has_entries) { + if !has_entries { fs.remove_dir(worktrees_dir) catch { _ => () } @@ -528,7 +528,7 @@ pub fn unlock_worktree( } // Check if locked let locked_path = join_path(admin, "locked") - if !(rfs.is_file(locked_path)) { + if !rfs.is_file(locked_path) { raise @bit.GitError::InvalidObject("'\{worktree_path}' is not locked") } // Remove lock file @@ -551,7 +551,7 @@ pub fn get_worktree_lock_reason( let admin_dir = find_worktree_admin_dir(rfs, git_dir, abs_wt_path) guard admin_dir is Some(admin) else { return None } let locked_path = join_path(admin, "locked") - if !(rfs.is_file(locked_path)) { + if !rfs.is_file(locked_path) { return None } let content = read_trimmed_file(rfs, locked_path) @@ -711,11 +711,11 @@ fn worktree_repair_gitfile_target( worktree_path : String, ) -> String? raise @bit.GitError { let git_file = join_path(worktree_path, ".git") - if !(fs.is_file(git_file)) { + if !fs.is_file(git_file) { return None } let content = read_trimmed_file(fs, git_file) - if !(content.has_prefix("gitdir: ")) { + if !content.has_prefix("gitdir: ") { return None } let raw = String::unsafe_substring(content, start=8, end=content.length()) @@ -733,10 +733,10 @@ fn worktree_repair_target_is_repository( fs : &@bit.RepoFileSystem, target : String, ) -> Bool { - if !(fs.is_dir(target)) { + if !fs.is_dir(target) { return false } - if !(fs.is_file(join_path(target, "HEAD"))) { + if !fs.is_file(join_path(target, "HEAD")) { return false } let common = (try? resolve_commondir(fs, target)).unwrap_or(target) @@ -799,7 +799,7 @@ fn worktree_repair_collect_paths( } let admin_dir = join_path(worktrees_dir, entry) let gitdir_path = join_path(admin_dir, "gitdir") - if !(fs.is_file(gitdir_path)) { + if !fs.is_file(gitdir_path) { continue } let content = read_trimmed_file(fs, gitdir_path) @@ -807,9 +807,7 @@ fn worktree_repair_collect_paths( } } let current_git_file = join_path(root, ".git") - if fs.is_dir(root) && - fs.is_file(current_git_file) && - !(paths.contains(root)) { + if fs.is_dir(root) && fs.is_file(current_git_file) && !paths.contains(root) { paths.push(root) } paths @@ -875,7 +873,7 @@ pub fn repair_worktree_detailed( let warnings : Array[String] = [] let worktrees_dir = join_path(git_dir, "worktrees") let explicit_paths = worktree_paths.length() > 0 - if !(rfs.is_dir(worktrees_dir)) && !(explicit_paths) { + if !rfs.is_dir(worktrees_dir) && !explicit_paths { return { repaired, warnings } } let paths_to_check = worktree_repair_collect_paths( @@ -893,7 +891,7 @@ pub fn repair_worktree_detailed( if wt_is_file { raise @bit.GitError::InvalidObject("'\{wt_path}' is not a directory") } - if !(wt_exists) { + if !wt_exists { raise @bit.GitError::InvalidObject("'\{wt_path}' is not a valid path") } if rfs.is_dir(wt_git_file) { @@ -923,7 +921,7 @@ pub fn repair_worktree_detailed( Some(target) => if target != admin && worktree_repair_target_exists(rfs, target) && - !(worktree_repair_target_is_repository(rfs, target)) { + !worktree_repair_target_is_repository(rfs, target) { raise @bit.GitError::InvalidObject( ".git file does not reference a repository", ) @@ -934,7 +932,7 @@ pub fn repair_worktree_detailed( admin, wt_path, use_relative_paths, ) let gitdir_path = join_path(admin, "gitdir") - if !(rfs.is_file(gitdir_path)) { + if !rfs.is_file(gitdir_path) { fs.write_string(gitdir_path, expected_gitdir) warnings.push("gitdir unreadable: \{gitdir_path}") repaired.push("gitdir: \{wt_path}") @@ -949,7 +947,7 @@ pub fn repair_worktree_detailed( let expected_gitfile = worktree_repair_expected_gitfile_content( admin, wt_path, use_relative_paths, ) - if !(rfs.is_file(wt_git_file)) { + if !rfs.is_file(wt_git_file) { fs.write_string(wt_git_file, expected_gitfile) warnings.push(".git file broken: \{wt_path}") repaired.push(".git: \{wt_path}") @@ -984,7 +982,7 @@ pub fn repair_worktree_detailed( if wt_is_file { raise @bit.GitError::InvalidObject("'\{wt_path}' is not a directory") } - if !(wt_exists) { + if !wt_exists { continue } if rfs.is_dir(wt_git_file) { @@ -995,7 +993,7 @@ pub fn repair_worktree_detailed( admin, wt_path, use_relative_paths, ) let gitdir_path = join_path(admin, "gitdir") - if !(rfs.is_file(gitdir_path)) { + if !rfs.is_file(gitdir_path) { fs.write_string(gitdir_path, expected_gitdir) warnings.push("gitdir unreadable: \{gitdir_path}") repaired.push("gitdir: \{wt_path}") @@ -1010,7 +1008,7 @@ pub fn repair_worktree_detailed( let expected_gitfile = worktree_repair_expected_gitfile_content( admin, wt_path, use_relative_paths, ) - if !(rfs.is_file(wt_git_file)) { + if !rfs.is_file(wt_git_file) { fs.write_string(wt_git_file, expected_gitfile) warnings.push(".git file broken: \{wt_path}") repaired.push(".git: \{wt_path}") @@ -1077,12 +1075,12 @@ pub fn get_worktree_prunable_reason( } // Check if gitdir file points to non-existent location let gitdir_path = join_path(admin, "gitdir") - if !(rfs.is_file(gitdir_path)) { + if !rfs.is_file(gitdir_path) { return Some("gitdir file is missing") } let gitdir_content = read_trimmed_file(rfs, gitdir_path) let wt_git_dir = parent_dir(gitdir_content) - if !(rfs.is_dir(wt_git_dir)) { + if !rfs.is_dir(wt_git_dir) { return Some("gitdir file points to non-existent location") } None @@ -1150,15 +1148,13 @@ fn copy_worktree_config( ) -> Unit raise @bit.GitError { let common_git_dir = resolve_commondir(rfs, source_git_dir) let config_path = join_path(common_git_dir, "config") - if !( - read_config_bool(rfs, config_path, "extensions", "worktreeconfig").unwrap_or( - false, - ), + if !read_config_bool(rfs, config_path, "extensions", "worktreeconfig").unwrap_or( + false, ) { return } let source_path = join_path(source_git_dir, "config.worktree") - if !(rfs.is_file(source_path)) { + if !rfs.is_file(source_path) { return } let content = decode_bytes_lossy(rfs.read_file(source_path)) @@ -1268,7 +1264,7 @@ fn get_linked_worktree_info( ) -> WorktreeInfo? raise @bit.GitError { // Read gitdir to find worktree path let gitdir_path = join_path(admin_dir, "gitdir") - if !(fs.is_file(gitdir_path)) { + if !fs.is_file(gitdir_path) { return None } let gitdir_content = read_trimmed_file(fs, gitdir_path) @@ -1338,7 +1334,7 @@ fn worktree_dir_has_entries( fs : &@bit.RepoFileSystem, path : String, ) -> Bool raise @bit.GitError { - if !(fs.is_dir(path)) { + if !fs.is_dir(path) { return false } for entry in fs.readdir(path) { @@ -1384,7 +1380,7 @@ fn worktree_admin_is_forbidden_ref_char(ch : Char) -> Bool { fn worktree_strip_lock_suffixes(name : String) -> String { let mut current = name let mut done = false - while !(done) { + while !done { match current.strip_suffix(".lock") { Some(stripped) => current = stripped.to_string() None => done = true @@ -1524,7 +1520,7 @@ fn resolve_worktree_target( } } // Try to resolve as branch first - if !(detach) { + if !detach { let branch_ref = "refs/heads/" + spec match resolve_ref(rfs, git_dir, branch_ref) { Some(id) => return (Some(spec), Some(id)) @@ -1544,7 +1540,7 @@ fn load_previous_checkout_location( git_dir : String, ) -> String? raise @bit.GitError { let path = join_path(git_dir, "bit-prev-checkout") - if !(fs.is_file(path)) { + if !fs.is_file(path) { return None } let prev = worktree_trim_whitespace(read_trimmed_file(fs, path)) @@ -1603,7 +1599,7 @@ fn find_worktree_admin_dir( worktree_path : String, ) -> String? raise @bit.GitError { let worktrees_dir = join_path(git_dir, "worktrees") - if !(fs.is_dir(worktrees_dir)) { + if !fs.is_dir(worktrees_dir) { return None } let normalized_worktree_path = normalize_path(worktree_path) @@ -1613,11 +1609,11 @@ fn find_worktree_admin_dir( continue } let admin_dir = join_path(worktrees_dir, entry) - if !(fs.is_dir(admin_dir)) { + if !fs.is_dir(admin_dir) { continue } let gitdir_path = join_path(admin_dir, "gitdir") - if !(fs.is_file(gitdir_path)) { + if !fs.is_file(gitdir_path) { continue } let gitdir_content = read_trimmed_file(fs, gitdir_path) @@ -1745,7 +1741,7 @@ fn worktree_upsert_top_level_config_key( _ => lines.push(line) } } - if !(found_key) { + if !found_key { lines.push("\t\{key} = \{value}") } updated.push({ @@ -1758,7 +1754,7 @@ fn worktree_upsert_top_level_config_key( updated.push(block) } } - if !(found_section) { + if !found_section { updated.push({ header: Some("[\{section}]"), section: Some(section), @@ -1775,7 +1771,7 @@ fn worktree_contains_nested_git( path : String, is_root? : Bool = true, ) -> Bool raise @bit.GitError { - if !(fs.is_dir(path)) { + if !fs.is_dir(path) { return false } for entry in fs.readdir(path) { @@ -1784,7 +1780,7 @@ fn worktree_contains_nested_git( } let child_path = join_path(path, entry) if entry == ".git" { - if !(is_root) && (fs.is_file(child_path) || fs.is_dir(child_path)) { + if !is_root && (fs.is_file(child_path) || fs.is_dir(child_path)) { return true } continue @@ -1815,7 +1811,7 @@ fn worktree_has_local_changes( continue } let file_path = join_path(worktree_path, entry.path) - if !(fs.is_file(file_path)) { + if !fs.is_file(file_path) { return true } let file_bytes = fs.read_file(file_path) @@ -1845,7 +1841,7 @@ fn worktree_has_untracked_files( } else { join_path(worktree_path, rel_path) } - if !(fs.is_dir(abs_path)) { + if !fs.is_dir(abs_path) { return false } for entry in fs.readdir(abs_path) { @@ -1880,7 +1876,7 @@ fn worktree_has_untracked_files( } else { return true } - } else if fs.is_file(child_abs) && !(tracked_paths.contains(child_rel)) { + } else if fs.is_file(child_abs) && !tracked_paths.contains(child_rel) { return true } } @@ -1921,7 +1917,7 @@ fn remove_dir_recursive( rfs : &@bit.RepoFileSystem, path : String, ) -> Unit raise @bit.GitError { - if !(rfs.is_dir(path)) { + if !rfs.is_dir(path) { if rfs.is_file(path) { fs.remove_file(path) } @@ -2003,7 +1999,7 @@ fn normalize_path(path : String) -> String { } else if part == ".." { if parts.length() > 0 && parts[parts.length() - 1] != ".." { let _ = parts.pop() - } else if !(path.has_prefix("/")) { + } else if !path.has_prefix("/") { parts.push(part) } } else { diff --git a/src/lib/worktree_admin_test.mbt b/src/lib/worktree_admin_test.mbt index f161092c..e7e3ed17 100644 --- a/src/lib/worktree_admin_test.mbt +++ b/src/lib/worktree_admin_test.mbt @@ -388,7 +388,7 @@ test "worktree admin: create_worktree resolves HEAD to detached commit" { ) let linked_head = fs.read_string("/repo/.git/worktrees/head-detached/HEAD") - assert_true(!(linked_head.has_prefix("ref: "))) + assert_true(!linked_head.has_prefix("ref: ")) assert_eq(fs.read_string("/repo/head-detached/init.t"), "main\n") } diff --git a/src/object/object.mbt b/src/object/object.mbt index 28a67204..57d11d9f 100644 --- a/src/object/object.mbt +++ b/src/object/object.mbt @@ -98,8 +98,7 @@ fn object_serialize_commit_content_array(commit : Commit) -> Array[Byte] { object_append_utf8_string(content, " ") object_append_utf8_string(content, commit.committer_tz) content.push(b'\n') - if commit.encoding.length() > 0 && - !(object_is_utf8_encoding(commit.encoding)) { + if commit.encoding.length() > 0 && !object_is_utf8_encoding(commit.encoding) { object_append_utf8_string(content, "encoding ") object_append_utf8_string(content, commit.encoding) content.push(b'\n') @@ -109,7 +108,7 @@ fn object_serialize_commit_content_array(commit : Commit) -> Array[Byte] { content.append(msg_bytes) // For verbatim mode (commit-tree), store message exactly as given. // Otherwise, ensure trailing newline (git commit behavior). - if !(commit.verbatim_message) { + if !commit.verbatim_message { if msg_bytes.length() == 0 || msg_bytes[msg_bytes.length() - 1] != b'\n' { content.push(b'\n') } diff --git a/src/osfs/osfs.mbt b/src/osfs/osfs.mbt index d4034442..9267cc49 100644 --- a/src/osfs/osfs.mbt +++ b/src/osfs/osfs.mbt @@ -36,7 +36,7 @@ fn ensure_dir(path : String) -> Unit raise @bit.GitError { current + "/" + part } let exists = @fs.is_dir(current) catch { _ => false } - if !(exists) { + if !exists { @fs.create_dir(current) catch { err => raise io_error(err) } diff --git a/src/pack/bit_oracle_pack_test.mbt b/src/pack/bit_oracle_pack_test.mbt index f40ec42b..fefdeaff 100644 --- a/src/pack/bit_oracle_pack_test.mbt +++ b/src/pack/bit_oracle_pack_test.mbt @@ -163,7 +163,7 @@ async test "git oracle: index-pack accepts blob packfile" { remove_dir_recursive(temp_dir) return () } - if !(@fs.path_exists(idx_path)) { + if !@fs.path_exists(idx_path) { println("idx file not created") remove_dir_recursive(temp_dir) return () @@ -268,9 +268,9 @@ async test "git oracle: parse pack-objects output" { return () } // Check if packfile contains expected objects (skip if not) - if !(contains_string(parsed_ids, commit_hex)) || - !(contains_string(parsed_ids, tree_hex)) || - !(contains_string(parsed_ids, blob_hex)) { + if !contains_string(parsed_ids, commit_hex) || + !contains_string(parsed_ids, tree_hex) || + !contains_string(parsed_ids, blob_hex) { // Pack might not contain all objects in some cases remove_dir_recursive(repo_dir) return () @@ -384,7 +384,7 @@ async test "git oracle: parse delta packfile from git" { } } // Skip if we didn't find both blobs - if !(found_base) || !(found_modified) { + if !found_base || !found_modified { remove_dir_recursive(repo_dir) return () } @@ -554,7 +554,7 @@ async test "git oracle: pack index verified by git" { let hello_hash = @bit.hash_blob(blob1).to_hex() let world_hash = @bit.hash_blob(blob2).to_hex() // These should be in the output, but don't fail test if not - if !(out_str.contains(hello_hash)) || !(out_str.contains(world_hash)) { + if !out_str.contains(hello_hash) || !out_str.contains(world_hash) { println("Warning: blob hashes not found in verify-pack output") } } @@ -722,7 +722,7 @@ async test "git oracle: parse tree with subdirectory" { found_dir = true } } - if !(found_dir) { + if !found_dir { remove_dir_recursive(repo_dir) return () } @@ -1142,7 +1142,7 @@ async test "git oracle: executable file mode 100755" { let lstree_str = bytes_to_string_lossy(lstree_out) // Check if git recorded the file as executable // ls-tree output: "100755 blob \tscript.sh" - if !(lstree_str.contains("100755")) { + if !lstree_str.contains("100755") { // Git might not have recorded it as executable (depends on config) remove_dir_recursive(repo_dir) return () @@ -1245,7 +1245,7 @@ async test "git oracle: symlink mode 120000" { } // If symlink wasn't found, it's not necessarily an error // (some systems don't support symlinks or git didn't track it) - if !(found_link) { + if !found_link { remove_dir_recursive(repo_dir) return () } @@ -1974,7 +1974,7 @@ async test "git oracle: git rm removes file from index" { assert_true(status.contains("D")) assert_true(status.contains("to_remove.txt")) // File should not exist on disk - assert_true(!(@fs.path_exists("\{repo_dir}/to_remove.txt"))) + assert_true(!@fs.path_exists("\{repo_dir}/to_remove.txt")) remove_dir_recursive(repo_dir) } @@ -2033,7 +2033,7 @@ async test "git oracle: git mv renames file" { (status.contains("old_name") && status.contains("new_name")), ) // Old file should not exist, new file should exist - assert_true(!(@fs.path_exists("\{repo_dir}/old_name.txt"))) + assert_true(!@fs.path_exists("\{repo_dir}/old_name.txt")) assert_true(@fs.path_exists("\{repo_dir}/new_name.txt")) remove_dir_recursive(repo_dir) } @@ -2496,7 +2496,7 @@ async test "git oracle: git clean removes untracked files" { return () } // Untracked file should be removed - assert_true(!(@fs.path_exists("\{repo_dir}/untracked.txt"))) + assert_true(!@fs.path_exists("\{repo_dir}/untracked.txt")) // Tracked file should still exist assert_true(@fs.path_exists("\{repo_dir}/tracked.txt")) remove_dir_recursive(repo_dir) diff --git a/src/pack/pack_index_write_test.mbt b/src/pack/pack_index_write_test.mbt index f1c1bcee..4f634b32 100644 --- a/src/pack/pack_index_write_test.mbt +++ b/src/pack/pack_index_write_test.mbt @@ -9,7 +9,7 @@ fn read_fixture_bytes(path : String) -> Bytes raise { ///| fn assert_bytes_equal(actual : Bytes, expected : Bytes) -> Unit raise { - if !(Bytes::equal(actual, expected)) { + if !Bytes::equal(actual, expected) { fail( "bytes mismatch: actual=\{actual.length()} expected=\{expected.length()}", ) diff --git a/src/pack/packfile.mbt b/src/pack/packfile.mbt index fee17306..ac265606 100644 --- a/src/pack/packfile.mbt +++ b/src/pack/packfile.mbt @@ -442,7 +442,7 @@ fn pack_object_with_delta( None => false } } - if !(try_delta) { + if !try_delta { let compressed = compress_pack_data(data, compression) let normal_len = type_and_size_len(data.length()) + compressed.length() encode_type_and_size(obj_type, data.length(), result) diff --git a/src/pack/packfile_parse.mbt b/src/pack/packfile_parse.mbt index 1001120a..6e0aef25 100644 --- a/src/pack/packfile_parse.mbt +++ b/src/pack/packfile_parse.mbt @@ -28,9 +28,7 @@ pub fn max_delta_chain_length( if data.length() < 32 { raise @bit.GitError::PackfileError("Packfile too short") } - if !( - data[0] == b'P' && data[1] == b'A' && data[2] == b'C' && data[3] == b'K', - ) { + if !(data[0] == b'P' && data[1] == b'A' && data[2] == b'C' && data[3] == b'K') { raise @bit.GitError::PackfileError("Invalid packfile magic") } let version = read_u32_be(data, 4) @@ -393,7 +391,7 @@ fn insert_pack_object_by_id( match by_id.get(obj.id) { Some(existing) => if existing.obj_type != obj.obj_type || - !(Bytes::equal(existing.data, obj.data)) { + !Bytes::equal(existing.data, obj.data) { raise @bit.GitError::PackfileError("SHA1 COLLISION FOUND") } None => () @@ -434,9 +432,7 @@ fn parse_packfile_internal( } // Magic: "PACK" - if !( - data[0] == b'P' && data[1] == b'A' && data[2] == b'C' && data[3] == b'K', - ) { + if !(data[0] == b'P' && data[1] == b'A' && data[2] == b'C' && data[3] == b'K') { raise @bit.GitError::PackfileError("Invalid packfile magic") } let version = read_u32_be(data, 4) @@ -698,9 +694,7 @@ fn parse_packfile_stream_internal( if data.length() < 32 { raise @bit.GitError::PackfileError("Packfile too short") } - if !( - data[0] == b'P' && data[1] == b'A' && data[2] == b'C' && data[3] == b'K', - ) { + if !(data[0] == b'P' && data[1] == b'A' && data[2] == b'C' && data[3] == b'K') { raise @bit.GitError::PackfileError("Invalid packfile magic") } let version = read_u32_be(data, 4) @@ -881,7 +875,7 @@ fn parse_packfile_stream_internal( } } } - if !(progress) { + if !progress { break } pending_list = next_pending diff --git a/src/protocol/pkg.generated.mbti b/src/protocol/pkg.generated.mbti index 157a2c0c..40ffd8cb 100644 --- a/src/protocol/pkg.generated.mbti +++ b/src/protocol/pkg.generated.mbti @@ -49,6 +49,8 @@ pub fn parse_remote(String) -> RemoteSpec pub fn parse_sideband(Bytes) -> (Int, Bytes) +pub fn parse_symrefs_from_capabilities(Array[String]) -> Map[String, String] + pub fn parse_v0_advertised_caps(Bytes) -> Array[String] raise @object.GitError pub fn parse_v2_advertised_caps(Bytes) -> Array[String] raise @object.GitError @@ -97,8 +99,7 @@ pub struct LsRefsResult { pub(all) enum ProtocolVersion { V0 V2 -} -pub impl Eq for ProtocolVersion +} derive(Eq) pub struct PushRequest { old_id : @object.ObjectId @@ -119,8 +120,7 @@ pub(all) enum RemoteKind { Http Ssh File -} -pub impl Eq for RemoteKind +} derive(Eq) pub struct RemoteSpec { kind : RemoteKind diff --git a/src/protocol/remote_common.mbt b/src/protocol/remote_common.mbt index 4720e59b..4a4cbbac 100644 --- a/src/protocol/remote_common.mbt +++ b/src/protocol/remote_common.mbt @@ -286,7 +286,7 @@ pub async fn push_with_http( ) -> String raise @bit.GitError { let (_, caps) = discover_refs_with_http(remote, http_get) let has_report_status = caps.contains("report-status") - if !(has_report_status) { + if !has_report_status { raise @bit.GitError::ProtocolError("Server does not support report-status") } let url = remote.receive_pack_url() diff --git a/src/protocol/remote_test.mbt b/src/protocol/remote_test.mbt index c9ef5b45..5c95ed47 100644 --- a/src/protocol/remote_test.mbt +++ b/src/protocol/remote_test.mbt @@ -145,6 +145,26 @@ test "extract_capabilities" { assert_true(caps.contains("side-band-64k")) } +///| +test "parse_symrefs_from_capabilities parses symref pairs" { + let symrefs = parse_symrefs_from_capabilities([ + "report-status", "symref=HEAD:refs/heads/main", "symref=refs/remotes/origin/HEAD:refs/remotes/origin/main", + ]) + assert_eq(symrefs.get("HEAD"), Some("refs/heads/main")) + assert_eq( + symrefs.get("refs/remotes/origin/HEAD"), + Some("refs/remotes/origin/main"), + ) +} + +///| +test "parse_symrefs_from_capabilities accepts symref-target capability" { + let symrefs = parse_symrefs_from_capabilities([ + "ls-refs=unborn", "symref-target:refs/heads/main", + ]) + assert_eq(symrefs.get("HEAD"), Some("refs/heads/main")) +} + ///| test "ssh_remote_to_https converts scp-style ssh remote" { inspect( diff --git a/src/protocol/transport.mbt b/src/protocol/transport.mbt index 726463bf..2e960028 100644 --- a/src/protocol/transport.mbt +++ b/src/protocol/transport.mbt @@ -50,7 +50,7 @@ pub fn parse_remote(remote : String) -> RemoteSpec { start=idx + 2, end=remote.length(), ) - if host.length() > 0 && path.length() > 0 && !(host.contains("/")) { + if host.length() > 0 && path.length() > 0 && !host.contains("/") { return { kind: RemoteKind::Ssh, raw: remote, @@ -65,14 +65,14 @@ pub fn parse_remote(remote : String) -> RemoteSpec { } // scp-style: [user@]host:path let colon = remote.find(":") - if colon is Some(idx) && !(remote.has_prefix("/")) { + if colon is Some(idx) && !remote.has_prefix("/") { let host = String::unsafe_substring(remote, start=0, end=idx) let path = String::unsafe_substring( remote, start=idx + 1, end=remote.length(), ) - if host.length() > 0 && path.length() > 0 && !(host.contains("/")) { + if host.length() > 0 && path.length() > 0 && !host.contains("/") { return { kind: RemoteKind::Ssh, raw: remote, diff --git a/src/protocol/upload_pack_common.mbt b/src/protocol/upload_pack_common.mbt index 703d883e..24a49277 100644 --- a/src/protocol/upload_pack_common.mbt +++ b/src/protocol/upload_pack_common.mbt @@ -76,6 +76,37 @@ pub fn parse_v0_advertised_caps( result } +///| +pub fn parse_symrefs_from_capabilities( + caps : Array[String], +) -> Map[String, String] { + let symrefs : Map[String, String] = {} + for cap in caps { + if cap.has_prefix("symref=") { + let raw = String::unsafe_substring(cap, start=7, end=cap.length()) + match raw.find(":") { + None => () + Some(idx) => { + let source = String::unsafe_substring(raw, start=0, end=idx) + let target = String::unsafe_substring( + raw, + start=idx + 1, + end=raw.length(), + ) + symrefs[source] = target + } + } + continue + } + if cap.has_prefix("symref-target:") { + let target = String::unsafe_substring(cap, start=14, end=cap.length()) + symrefs["HEAD"] = target + continue + } + } + symrefs +} + ///| pub fn build_ls_refs_request(agent : String, prefixes : Array[String]) -> Bytes { let chunks : Array[Bytes] = [] @@ -298,7 +329,7 @@ pub fn extract_pack_from_v2_response(data : Bytes) -> Bytes raise @bit.GitError if line_bytes.length() == 0 { continue } - if !(in_pack) { + if !in_pack { let line = line_bytes |> bytes_to_string |> trim_newline if line == "packfile" { in_pack = true diff --git a/src/protocol/upload_pack_http_common.mbt b/src/protocol/upload_pack_http_common.mbt index 48d0a09d..0d96fa37 100644 --- a/src/protocol/upload_pack_http_common.mbt +++ b/src/protocol/upload_pack_http_common.mbt @@ -97,35 +97,6 @@ pub async fn discover_upload_refs_with_http( (refs, caps, ProtocolVersion::V0, symrefs) } -///| -fn parse_symrefs_from_capabilities(caps : Array[String]) -> Map[String, String] { - let symrefs : Map[String, String] = {} - for cap in caps { - if cap.has_prefix("symref=") { - let raw = String::unsafe_substring(cap, start=7, end=cap.length()) - match raw.find(":") { - None => () - Some(idx) => { - let source = String::unsafe_substring(raw, start=0, end=idx) - let target = String::unsafe_substring( - raw, - start=idx + 1, - end=raw.length(), - ) - symrefs[source] = target - } - } - continue - } - if cap.has_prefix("symref-target:") { - let target = String::unsafe_substring(cap, start=14, end=cap.length()) - symrefs["HEAD"] = target - continue - } - } - symrefs -} - ///| fn normalize_remote_for_http_transport( remote : String, @@ -346,7 +317,7 @@ fn write_pack_promisor_marker_http( match default_ref { Some((_, head_id)) => { let head_line = head_id.to_hex() + " HEAD" - if not(seen.contains(head_line)) { + if !seen.contains(head_line) { seen[head_line] = true marker_lines.push(head_line) } diff --git a/src/refs/refs_store.mbt b/src/refs/refs_store.mbt index 38ff701d..69e14581 100644 --- a/src/refs/refs_store.mbt +++ b/src/refs/refs_store.mbt @@ -40,7 +40,7 @@ pub fn collect_loose_ref_ids( out : Map[String, @bit.ObjectId], filter_prefix : String?, ) -> Unit { - if !(fs.is_dir(dir)) { + if !fs.is_dir(dir) { return () } let entries = fs.readdir(dir) catch { _ => [] } @@ -53,7 +53,7 @@ pub fn collect_loose_ref_ids( if fs.is_dir(path) { collect_loose_ref_ids(fs, path, name, out, filter_prefix) } else if fs.is_file(path) { - if filter_prefix is Some(pfx) && !(name.has_prefix(pfx)) { + if filter_prefix is Some(pfx) && !name.has_prefix(pfx) { continue } let content = decode_bytes_lossy_refs( @@ -79,7 +79,7 @@ pub fn collect_packed_ref_ids( filter_prefix : String?, ) -> Unit { let packed_path = git_dir + "/packed-refs" - if !(fs.is_file(packed_path)) { + if !fs.is_file(packed_path) { return () } let packed = fs.read_file(packed_path) catch { _ => Bytes::default() } @@ -105,7 +105,7 @@ pub fn collect_packed_ref_ids( start=idx + 1, end=line.length(), ) - if filter_prefix is Some(pfx) && !(refname.has_prefix(pfx)) { + if filter_prefix is Some(pfx) && !refname.has_prefix(pfx) { continue } if out.contains(refname) { @@ -155,7 +155,7 @@ pub fn rewrite_packed_refs( transform : (String) -> String?, ) -> Unit raise @bit.GitError { let packed_path = git_dir + "/packed-refs" - if !(rfs.is_file(packed_path)) { + if !rfs.is_file(packed_path) { return () } let data = rfs.read_file(packed_path) catch { _ => Bytes::default() } @@ -173,7 +173,7 @@ pub fn rewrite_packed_refs( continue } if line.has_prefix("^") { - if !(skip_peeled) { + if !skip_peeled { lines.push(line) } continue @@ -284,7 +284,7 @@ pub fn list_remote_tracking_refs( let refs = list_refs_with_ids(fs, git_dir, Some(prefix)) let out : Map[String, @bit.ObjectId] = {} for refname, id in refs { - if !(refname.has_prefix(prefix)) { + if !refname.has_prefix(prefix) { continue } let name = String::unsafe_substring( diff --git a/src/reftable/stack.mbt b/src/reftable/stack.mbt index 50ef674f..50ec33fb 100644 --- a/src/reftable/stack.mbt +++ b/src/reftable/stack.mbt @@ -8,7 +8,7 @@ pub fn read_tables_list( git_dir : String, ) -> Array[String] raise @object.GitError { let path = git_dir + "/reftable/tables.list" - if !(fs.is_file(path)) { + if !fs.is_file(path) { return [] } let data = fs.read_file(path) diff --git a/src/remote/remote_path.mbt b/src/remote/remote_path.mbt index 070380f2..81ee0d19 100644 --- a/src/remote/remote_path.mbt +++ b/src/remote/remote_path.mbt @@ -85,7 +85,7 @@ fn normalize_local_path(path : String) -> String { } else if part == ".." { if parts.length() > 0 && parts[parts.length() - 1] != ".." { let _ = parts.pop() - } else if !(path.has_prefix("/")) { + } else if !path.has_prefix("/") { parts.push(part) } } else { @@ -211,7 +211,7 @@ pub fn resolve_gitdir(fs : &@bit.RepoFileSystem, bit_path : String) -> String { end=trimmed.length(), ) // If relative path, resolve relative to parent of .git file - if !(target.has_prefix("/")) { + if !target.has_prefix("/") { let parent = match bit_path.rev_find("/") { Some(i) => String::unsafe_substring(bit_path, start=0, end=i) None => "." diff --git a/src/repo/core.mbt b/src/repo/core.mbt index f84ff28a..ec0a9899 100644 --- a/src/repo/core.mbt +++ b/src/repo/core.mbt @@ -112,7 +112,7 @@ fn parse_tree_with_hash_size( raise @object.GitError::InvalidObject("Truncated tree entry mode") } let mode = mode_buf.to_string() - if !(parse_tree_mode_is_octal(mode)) { + if !parse_tree_mode_is_octal(mode) { raise @object.GitError::InvalidObject("Invalid tree entry mode") } i += 1 // skip space diff --git a/src/repo_ops/revparse_ops.mbt b/src/repo_ops/revparse_ops.mbt index 53b68d1d..00533e7e 100644 --- a/src/repo_ops/revparse_ops.mbt +++ b/src/repo_ops/revparse_ops.mbt @@ -12,7 +12,7 @@ pub fn rev_parse( } // :N:path — index stage entry lookup (e.g. :0:file, :2:file) // :path — shorthand for :0:path - if spec.has_prefix(":") && !(spec.has_prefix(":/")) { + if spec.has_prefix(":") && !spec.has_prefix(":/") { let rest = substring_revparse(spec, 1, spec.length()) let (target_stage, path) = if rest.length() >= 2 { let ch = rest[0] @@ -178,7 +178,7 @@ fn resolve_commit_message_search_all_refs( for item in refs { let (_, id) = item let hex = id.to_hex() - if !(seen_start.contains(hex)) { + if !seen_start.contains(hex) { seen_start[hex] = true starts.push(id) } @@ -186,7 +186,7 @@ fn resolve_commit_message_search_all_refs( match @bitlib.resolve_head_commit(fs, git_dir) { Some(id) => { let hex = id.to_hex() - if !(seen_start.contains(hex)) { + if !seen_start.contains(hex) { seen_start[hex] = true starts.push(id) } @@ -237,7 +237,7 @@ fn find_reachable_commit_by_message_from_many( Some(obj) => if obj.obj_type == @object.ObjectType::Commit { let contains = commit_message_contains(obj.data, needle) - let matches = if negate { !(contains) } else { contains } + let matches = if negate { !contains } else { contains } if matches { let ts = parse_commit_committer_timestamp(obj.data) if best_id is None || ts > best_time { @@ -247,7 +247,7 @@ fn find_reachable_commit_by_message_from_many( } let info = @repo.parse_commit(obj.data) for parent in info.parents { - if !(seen.contains(parent.to_hex())) { + if !seen.contains(parent.to_hex()) { queue.push(parent) } } @@ -556,7 +556,7 @@ fn apply_rev_suffix( steps = steps * 10 + (chars[i].to_int() - '0'.to_int()) i += 1 } - if !(has_digits) { + if !has_digits { steps = 1 } for _ in 0.. @object.ObjectId? raise @object.GitError { let index_path = git_dir + "/index" - if !(fs.is_file(index_path)) { + if !fs.is_file(index_path) { return None } let data = fs.read_file(index_path) @@ -716,9 +716,7 @@ fn resolve_abbrev_ref_id( git_dir : String, spec : String, ) -> @object.ObjectId? raise @object.GitError { - if spec.length() < 4 || - spec.length() >= 64 || - !(@bithash.is_hex_string(spec)) { + if spec.length() < 4 || spec.length() >= 64 || !@bithash.is_hex_string(spec) { return None } let needle = @bithash.lower_hex_string(spec) @@ -847,7 +845,7 @@ pub fn resolve_upstream_ref( Some(_) => true None => false } - if !(branch_exists) { + if !branch_exists { raise @object.GitError::InvalidObject( "no such branch: '" + branch_name + "'", ) @@ -900,7 +898,7 @@ pub fn resolve_upstream_ref( break } } - if !(mapped) { + if !mapped { raise @object.GitError::InvalidObject( "upstream branch '" + merge + @@ -1302,7 +1300,7 @@ fn ref_collect_packed( start=idx + 1, end=line.length(), ) - if !(out.contains(name)) { + if !out.contains(name) { out[name] = @object.ObjectId::from_hex(id_hex) } } diff --git a/src/runtime/storage_runtime.mbt b/src/runtime/storage_runtime.mbt index 5565d2c3..1be3ecc3 100644 --- a/src/runtime/storage_runtime.mbt +++ b/src/runtime/storage_runtime.mbt @@ -115,7 +115,7 @@ fn storage_normalize_path(path : String) -> String { } else if part == ".." { if parts.length() > 0 && parts[parts.length() - 1] != ".." { let _ = parts.pop() - } else if !(path.has_prefix("/")) { + } else if !path.has_prefix("/") { parts.push(part) } } else { @@ -352,13 +352,13 @@ fn storage_hash_object_validate_content( match obj_type { @bit.ObjectType::Commit => { let text = @utf8.decode_lossy(content[:]) - if !(text.has_prefix("tree ")) { + if !text.has_prefix("tree ") { raise @bit.GitError::InvalidObject("corrupt commit") } } @bit.ObjectType::Tag => { let text = @utf8.decode_lossy(content[:]) - if !(text.has_prefix("object ")) { + if !text.has_prefix("object ") { raise @bit.GitError::InvalidObject("corrupt tag") } } @@ -506,7 +506,7 @@ fn storage_handle_init( shared: None, } @bitrepo.init_repo_with_options_with_repo_fs(fs, rfs, root, opts) - if !(args.quiet) { + if !args.quiet { let git_dir = storage_resolve_git_dir(rfs, root) storage_print_line("Initialized empty Git repository in " + git_dir + "/") } @@ -613,7 +613,7 @@ fn storage_handle_commit( committer_timezone=Some(timezone), algo~, ) - if !(args.quiet) { + if !args.quiet { let short_id = String::unsafe_substring(commit_id.to_hex(), start=0, end=7) let first_line = match args.message.find("\n") { Some(idx) => String::unsafe_substring(args.message, start=0, end=idx) @@ -656,7 +656,7 @@ fn storage_resolve_common_git_dir( git_dir : String, ) -> String { let commondir_path = git_dir + "/commondir" - if !(rfs.is_file(commondir_path)) { + if !rfs.is_file(commondir_path) { return git_dir } let raw = storage_decode_bytes( @@ -797,7 +797,7 @@ fn storage_collect_status_snapshot( continue } let abs_path = root + "/" + entry.path - if !(rfs.is_file(abs_path)) { + if !rfs.is_file(abs_path) { unstaged_deleted.push(entry.path) } } @@ -962,7 +962,7 @@ fn storage_status_text_lines( out.push(" " + path) } } - if !(has_staged) && !(has_unstaged) && status.untracked.length() == 0 { + if !has_staged && !has_unstaged && status.untracked.length() == 0 { out.push("") out.push("nothing to commit, working tree clean") } @@ -1034,7 +1034,7 @@ fn storage_handle_hash_object( let algo = storage_resolve_hash_algorithm(rfs, git_dir, args.object_format) if args.stdin_mode { let content = storage_read_all_stdin() - if !(args.literally) { + if !args.literally { storage_hash_object_validate_content(args.obj_type, content) } let id = @object.hash_object_content_with_algo(algo, args.obj_type, content) @@ -1047,7 +1047,7 @@ fn storage_handle_hash_object( @bitlib.write_object_bytes(fs, git_dir, id, compressed) } storage_print_line(id.to_hex()) - if args.paths.length() == 0 && !(args.stdin_paths) { + if args.paths.length() == 0 && !args.stdin_paths { return } } @@ -1128,7 +1128,7 @@ fn storage_handle_hash_object( } else { @bitlib.clean_for_storage(content, attrs, autocrlf) } - if !(args.literally) { + if !args.literally { storage_hash_object_validate_content(args.obj_type, normalized) } let id = @object.hash_object_content_with_algo( @@ -1247,7 +1247,7 @@ fn storage_handle_update_ref( let new_id = storage_resolve_object_id(rfs, git_dir, new_value) let ref_path = git_dir + "/" + args.refname let dir = storage_parent_dir(ref_path) - if dir.length() > 0 && !(rfs.is_dir(dir)) { + if dir.length() > 0 && !rfs.is_dir(dir) { fs.mkdir_p(dir) } fs.write_string(ref_path, new_id.to_hex() + "\n") diff --git a/src/tar/tar.mbt b/src/tar/tar.mbt index 41e19952..ea00c9f8 100644 --- a/src/tar/tar.mbt +++ b/src/tar/tar.mbt @@ -230,7 +230,7 @@ pub fn tar_emit_parent_dirs( let mut di = dirs.length() - 1 while di >= 0 { let dir = dirs[di] - if !(emitted.contains(dir)) { + if !emitted.contains(dir) { emitted[dir] = true let hdr = tar_make_header(dir, 0o40755, 0, mtime, b'5', "") for b in hdr { diff --git a/src/trailers/trailers.mbt b/src/trailers/trailers.mbt index bb8556a6..9fad1576 100644 --- a/src/trailers/trailers.mbt +++ b/src/trailers/trailers.mbt @@ -213,7 +213,7 @@ pub fn add_trailer(message : String, key : String, value : String) -> String { let result = StringBuilder::new() result.write_string(body) // Ensure blank line before trailers if body doesn't end with one - if body.length() > 0 && !(body.has_suffix("\n\n")) { + if body.length() > 0 && !body.has_suffix("\n\n") { if body.has_suffix("\n") { result.write_char('\n') } else { diff --git a/src/x/bitconfig/load.mbt b/src/x/bitconfig/load.mbt index 5753eefd..d759d89d 100644 --- a/src/x/bitconfig/load.mbt +++ b/src/x/bitconfig/load.mbt @@ -131,7 +131,7 @@ pub fn load_and_inject() -> Unit { Some(p) => p None => return } - if !(@fs.path_exists(path)) { + if !@fs.path_exists(path) { return } let content = @fs.read_file_to_string(path) catch { _ => return } diff --git a/src/x/doc/doc.mbt b/src/x/doc/doc.mbt index 8357b949..8b5d74cf 100644 --- a/src/x/doc/doc.mbt +++ b/src/x/doc/doc.mbt @@ -62,7 +62,7 @@ pub fn list_pages( break } } - if !(inserted) { + if !inserted { sorted.push(page) } } @@ -80,7 +80,7 @@ pub fn read_page( Some(path) => path None => return Err(InvalidPageName(page_name)) } - if !(rfs.is_file(path)) { + if !rfs.is_file(path) { return Err(PageNotFound(page)) } Ok(decode_bytes(rfs.read_file(path))) @@ -129,7 +129,7 @@ pub fn append_page( } else { "" } - if content.length() > 0 && !(content.has_suffix("\n")) { + if content.length() > 0 && !content.has_suffix("\n") { content = content + "\n" } content = content + "- [\{timestamp}] \{message}\n" @@ -149,7 +149,7 @@ pub fn remove_page( Some(path) => path None => return Err(InvalidPageName(page_name)) } - if !(rfs.is_file(path)) { + if !rfs.is_file(path) { return Err(PageNotFound(page)) } wfs.remove_file(path) @@ -159,7 +159,7 @@ pub fn remove_page( ///| fn resolve_page_path(root : String, page_name : String) -> String? { let page = normalize_page_name(page_name) - if !(is_valid_page_name(page)) { + if !is_valid_page_name(page) { return None } Some(docs_dir(root) + "/" + page + ".md") @@ -173,7 +173,7 @@ fn collect_pages( prefix : String?, out : Array[String], ) -> Unit { - if !(rfs.is_dir(abs_dir)) { + if !rfs.is_dir(abs_dir) { return } let entries = rfs.readdir(abs_dir) catch { _ => [] } @@ -191,7 +191,7 @@ fn collect_pages( collect_pages(rfs, abs_path, rel_path, prefix, out) continue } - if !(entry.has_suffix(".md")) { + if !entry.has_suffix(".md") { continue } let page = String::unsafe_substring( @@ -200,7 +200,7 @@ fn collect_pages( end=rel_path.length() - 3, ) match prefix { - Some(p) if !(page.has_prefix(p)) => continue + Some(p) if !page.has_prefix(p) => continue _ => () } out.push(page) diff --git a/src/x/fingerprint/fingerprint.mbt b/src/x/fingerprint/fingerprint.mbt index 5a4d5936..8808c635 100644 --- a/src/x/fingerprint/fingerprint.mbt +++ b/src/x/fingerprint/fingerprint.mbt @@ -66,7 +66,7 @@ pub fn fast_directory_fingerprint( root : String, ignore_entries? : Array[String] = [".", "..", ".git", ".bit"], ) -> String { - if !(fs.is_dir(root)) { + if !fs.is_dir(root) { return @bit.hash_blob_string("missing").to_hex() } let files : Array[String] = [] @@ -140,7 +140,7 @@ fn resolve_git_dir(fs : &@bit.RepoFileSystem, root : String) -> String { let text = decode_bytes(bytes) for line_view in text.split("\n") { let line = trim_string(line_view.to_string()) - if !(line.has_prefix("gitdir:")) { + if !line.has_prefix("gitdir:") { continue } let raw = trim_string( @@ -333,7 +333,7 @@ pub fn bit_compat_directory_fingerprint( root : String, ignore_entries? : Array[String] = [".", "..", ".git", ".bit"], ) -> String { - if !(fs.is_dir(root)) { + if !fs.is_dir(root) { return @bit.hash_blob_string("missing").to_hex() } let entries = index_entries_after_add_all(fs, root, ignore_entries) diff --git a/src/x/fs/bench_real_test.mbt b/src/x/fs/bench_real_test.mbt index 5f33c383..a4c8201a 100644 --- a/src/x/fs/bench_real_test.mbt +++ b/src/x/fs/bench_real_test.mbt @@ -68,7 +68,7 @@ fn bench_git_dir_exists() -> Bool { ///| /// Simple test to verify real git reading works test "real_git: can read HEAD" { - if !(bench_git_dir_exists()) { + if !bench_git_dir_exists() { println("Skipping: bench git dir not found") return } @@ -81,7 +81,7 @@ test "real_git: can read HEAD" { ///| /// Simple test to verify Fs from real git works test "real_git: can create Fs from HEAD" { - if !(bench_git_dir_exists()) { + if !bench_git_dir_exists() { println("Skipping: bench git dir not found") return } @@ -95,7 +95,7 @@ test "real_git: can create Fs from HEAD" { ///| /// Test reading files from real git test "real_git: can read files" { - if !(bench_git_dir_exists()) { + if !bench_git_dir_exists() { println("Skipping: bench git dir not found") return } @@ -116,7 +116,7 @@ let bench_real_git_dir : String = get_bench_git_dir() ///| fn with_real_commit(f : (@bit.ObjectId) -> Unit) -> Unit { - if !(bench_git_dir_exists()) { + if !bench_git_dir_exists() { println("Skipping: bench git dir not found") return } diff --git a/src/x/fs/fs.mbt b/src/x/fs/fs.mbt index 0c8805f4..cbc03b06 100644 --- a/src/x/fs/fs.mbt +++ b/src/x/fs/fs.mbt @@ -126,7 +126,7 @@ pub fn Fs::get_promisor_db( self : Fs, backing_fs : &@bit.RepoFileSystem, ) -> @lib.PromisorDb? raise @bit.GitError { - if !(self.config.enable_promisor) { + if !self.config.enable_promisor { return None } match self.cached_promisor_db { @@ -147,7 +147,7 @@ pub fn Fs::get_promisor_db( ///| /// Check if this Fs is backed by a partial clone with promisor remote pub fn Fs::has_promisor(self : Fs, backing_fs : &@bit.RepoFileSystem) -> Bool { - if !(self.config.enable_promisor) { + if !self.config.enable_promisor { return false } @lib.is_partial_clone(backing_fs, self.git_dir) @@ -159,7 +159,7 @@ pub fn Fs::get_promisor_remote( self : Fs, backing_fs : &@bit.RepoFileSystem, ) -> String? { - if !(self.config.enable_promisor) { + if !self.config.enable_promisor { return None } @lib.read_promisor_remote(backing_fs, self.git_dir) diff --git a/src/x/fs/integration_test.mbt b/src/x/fs/integration_test.mbt index 68167534..5b6d4cef 100644 --- a/src/x/fs/integration_test.mbt +++ b/src/x/fs/integration_test.mbt @@ -36,7 +36,7 @@ test "integration: mount helix repo (lazy)" { let git_dir = get_helix_git_dir() // Skip if helix repo not available - if !(osfs.is_dir(git_dir)) { + if !osfs.is_dir(git_dir) { return } let commit_id = get_helix_head() @@ -68,7 +68,7 @@ test "integration: mount helix repo (eager)" { let git_dir = get_helix_git_dir() // Skip if helix repo not available - if !(osfs.is_dir(git_dir)) { + if !osfs.is_dir(git_dir) { return } let commit_id = get_helix_head() @@ -91,7 +91,7 @@ test "integration: mount helix repo (eager)" { test "integration: mount, modify, get changes" { let osfs = @osfs.OsFs::new() let git_dir = get_helix_git_dir() - if !(osfs.is_dir(git_dir)) { + if !osfs.is_dir(git_dir) { return } let commit_id = get_helix_head() @@ -146,7 +146,7 @@ test "integration: mount, modify, get changes" { test "integration: generate diff" { let osfs = @osfs.OsFs::new() let git_dir = get_helix_git_dir() - if !(osfs.is_dir(git_dir)) { + if !osfs.is_dir(git_dir) { return } let commit_id = get_helix_head() @@ -202,7 +202,7 @@ fn collect_changes( for path in working_files { let content = bitfs.read_file(osfs, path) catch { _ => Bytes::new(0) } // Check if file existed before - let is_new = !(file_exists_in_base(bitfs, osfs, path)) + let is_new = !file_exists_in_base(bitfs, osfs, path) let change_type = if is_new { "added" } else { "modified" } changes.push({ path, change_type, _content: Some(content) }) } @@ -249,7 +249,7 @@ fn format_changes(changes : Array[FileChange]) -> String { test "integration: demo workflow output" { let osfs = @osfs.OsFs::new() let git_dir = get_helix_git_dir() - if !(osfs.is_dir(git_dir)) { + if !osfs.is_dir(git_dir) { println("Skipping: helix repo not found") return } @@ -284,7 +284,7 @@ test "integration: demo workflow output" { test "bench_integration: helix lazy mount" (b : @bench.T) { let osfs = @osfs.OsFs::new() let git_dir = get_helix_git_dir() - if !(osfs.is_dir(git_dir)) { + if !osfs.is_dir(git_dir) { return } let commit_id = try! get_helix_head() @@ -296,7 +296,7 @@ test "bench_integration: helix lazy mount" (b : @bench.T) { test "bench_integration: helix read files" (b : @bench.T) { let osfs = @osfs.OsFs::new() let git_dir = get_helix_git_dir() - if !(osfs.is_dir(git_dir)) { + if !osfs.is_dir(git_dir) { return } let commit_id = try! get_helix_head() @@ -316,7 +316,7 @@ test "bench_integration: helix read files" (b : @bench.T) { test "bench_integration: helix full workflow" (b : @bench.T) { let osfs = @osfs.OsFs::new() let git_dir = get_helix_git_dir() - if !(osfs.is_dir(git_dir)) { + if !osfs.is_dir(git_dir) { return } let commit_id = try! get_helix_head() diff --git a/src/x/fs/layer.mbt b/src/x/fs/layer.mbt index 0deb3034..f31523c3 100644 --- a/src/x/fs/layer.mbt +++ b/src/x/fs/layer.mbt @@ -64,7 +64,7 @@ pub fn Fs::flatten_layers( backing_fs : &@bit.FileSystem, rfs : &@bit.RepoFileSystem, ) -> @bit.ObjectId raise @bit.GitError { - if self.layers.length() == 0 && !(self.working.is_dirty()) { + if self.layers.length() == 0 && !self.working.is_dirty() { return self.base_tree } let root = TreeNode::new_dir() diff --git a/src/x/fs/partial_clone_test.mbt b/src/x/fs/partial_clone_test.mbt index 027311b2..a4ad04cf 100644 --- a/src/x/fs/partial_clone_test.mbt +++ b/src/x/fs/partial_clone_test.mbt @@ -6,14 +6,14 @@ test "partial_clone: mount and list files" { let git_dir = "/tmp/partial-clone-test/tree-sitter-nickel/.git" // Skip if test repo not available - if !(osfs.is_dir(git_dir)) { + if !osfs.is_dir(git_dir) { println("Skipping: partial clone test repo not found") println( "Run: moongit clone --filter=blob:none https://github.com/nickel-lang/tree-sitter-nickel /tmp/partial-clone-test/tree-sitter-nickel", ) return } - if !(@lib.is_partial_clone(osfs, git_dir)) { + if !@lib.is_partial_clone(osfs, git_dir) { println("Skipping: repo is not a partial clone") return } @@ -21,7 +21,7 @@ test "partial_clone: mount and list files" { // Check if it's a partial clone let is_partial = @lib.is_partial_clone(osfs, git_dir) println("Is partial clone: \{is_partial}") - if !(is_partial) { + if !is_partial { println("Skipping: repo is not a partial clone") return } @@ -81,11 +81,11 @@ test "partial_clone: mount and list files" { async test "partial_clone: on-demand fetch" { let osfs = @osfs.OsFs::new() let git_dir = "/tmp/partial-clone-test/tree-sitter-nickel/.git" - if !(osfs.is_dir(git_dir)) { + if !osfs.is_dir(git_dir) { println("Skipping: partial clone test repo not found") return } - if !(@lib.is_partial_clone(osfs, git_dir)) { + if !@lib.is_partial_clone(osfs, git_dir) { println("Skipping: repo is not a partial clone") return } @@ -147,11 +147,11 @@ test "partial_clone: glob pattern matching" { // Test glob_match function via prefetch_glob behavior let osfs = @osfs.OsFs::new() let git_dir = "/tmp/partial-clone-test/tree-sitter-nickel/.git" - if !(osfs.is_dir(git_dir)) { + if !osfs.is_dir(git_dir) { println("Skipping: partial clone test repo not found") return } - if !(@lib.is_partial_clone(osfs, git_dir)) { + if !@lib.is_partial_clone(osfs, git_dir) { println("Skipping: repo is not a partial clone") return } @@ -210,11 +210,11 @@ test "partial_clone: glob pattern matching" { async test "partial_clone: prefetch with glob" { let osfs = @osfs.OsFs::new() let git_dir = "/tmp/partial-clone-test/tree-sitter-nickel/.git" - if !(osfs.is_dir(git_dir)) { + if !osfs.is_dir(git_dir) { println("Skipping: partial clone test repo not found") return } - if !(@lib.is_partial_clone(osfs, git_dir)) { + if !@lib.is_partial_clone(osfs, git_dir) { println("Skipping: repo is not a partial clone") return } @@ -252,11 +252,11 @@ async test "partial_clone: prefetch with glob" { async test "partial_clone: prefetch BFS" { let osfs = @osfs.OsFs::new() let git_dir = "/tmp/partial-clone-test/tree-sitter-nickel/.git" - if !(osfs.is_dir(git_dir)) { + if !osfs.is_dir(git_dir) { println("Skipping: partial clone test repo not found") return } - if !(@lib.is_partial_clone(osfs, git_dir)) { + if !@lib.is_partial_clone(osfs, git_dir) { println("Skipping: repo is not a partial clone") return } @@ -300,11 +300,11 @@ async test "partial_clone: prefetch BFS" { async test "partial_clone: prefetch multiple files" { let osfs = @osfs.OsFs::new() let git_dir = "/tmp/partial-clone-test/tree-sitter-nickel/.git" - if !(osfs.is_dir(git_dir)) { + if !osfs.is_dir(git_dir) { println("Skipping: partial clone test repo not found") return } - if !(@lib.is_partial_clone(osfs, git_dir)) { + if !@lib.is_partial_clone(osfs, git_dir) { println("Skipping: repo is not a partial clone") return } diff --git a/src/x/fs/perf_partial_clone_test.mbt b/src/x/fs/perf_partial_clone_test.mbt index 7817bec5..8d501ba8 100644 --- a/src/x/fs/perf_partial_clone_test.mbt +++ b/src/x/fs/perf_partial_clone_test.mbt @@ -9,14 +9,14 @@ test "perf: partial clone access pattern verification" { let git_dir = "/tmp/partial-clone-test/tree-sitter-nickel/.git" // Skip if test repo not available - if !(osfs.is_dir(git_dir)) { + if !osfs.is_dir(git_dir) { println("Skipping: partial clone test repo not found") println( "Run: moongit clone --filter=blob:none https://github.com/nickel-lang/tree-sitter-nickel /tmp/partial-clone-test/tree-sitter-nickel", ) return } - if !(@lib.is_partial_clone(osfs, git_dir)) { + if !@lib.is_partial_clone(osfs, git_dir) { println("Skipping: repo is not a partial clone") return } @@ -120,11 +120,11 @@ test "perf: partial clone access pattern verification" { test "perf: verify lazy vs eager difference" { let osfs = @osfs.OsFs::new() let git_dir = "/tmp/partial-clone-test/tree-sitter-nickel/.git" - if !(osfs.is_dir(git_dir)) { + if !osfs.is_dir(git_dir) { println("Skipping: partial clone test repo not found") return } - if !(@lib.is_partial_clone(osfs, git_dir)) { + if !@lib.is_partial_clone(osfs, git_dir) { println("Skipping: repo is not a partial clone") return } diff --git a/src/x/fs/read_ops.mbt b/src/x/fs/read_ops.mbt index 824592c4..ab0c66bc 100644 --- a/src/x/fs/read_ops.mbt +++ b/src/x/fs/read_ops.mbt @@ -84,7 +84,7 @@ pub fn Fs::readdir( for item in self.working.deleted.to_array() { let (del_path, _) = item if parent_dir(del_path) == norm || - (norm.length() == 0 && !(del_path.contains("/"))) { + (norm.length() == 0 && !del_path.contains("/")) { entries.remove(basename(del_path)) } } @@ -145,7 +145,7 @@ fn Fs::readdir_from_tree( } } } - if !(found) { + if !found { return } } @@ -225,7 +225,7 @@ fn Fs::check_dir_in_tree( } } } - if !(found) { + if !found { return false } } @@ -342,7 +342,7 @@ fn Fs::find_in_tree( } } } - if !(found) { + if !found { return None } } @@ -455,7 +455,7 @@ pub async fn Fs::prefetch( ) -> Int raise @bit.GitError { let promisor_db = self.get_promisor_db(read_fs) guard promisor_db is Some(pdb) else { return 0 } - if !(pdb.has_promisor()) { + if !pdb.has_promisor() { return 0 } // Collect object IDs that need fetching @@ -475,7 +475,7 @@ pub async fn Fs::prefetch( // Check if not already cached if self.cache.get_blob(norm) is None { // Check if not locally available - if !(pdb.has_local(read_fs, id)) { + if !pdb.has_local(read_fs, id) { ids.push(id) } } @@ -512,7 +512,7 @@ pub fn Fs::needs_fetch( // Check if object exists locally let promisor_db = self.get_promisor_db(read_fs) match promisor_db { - Some(pdb) => !(pdb.has_local(read_fs, id)) + Some(pdb) => !pdb.has_local(read_fs, id) None => { let db = self.get_db(read_fs) db.get(read_fs, id) is None diff --git a/src/x/fs/snapshot.mbt b/src/x/fs/snapshot.mbt index 259c7211..06343e23 100644 --- a/src/x/fs/snapshot.mbt +++ b/src/x/fs/snapshot.mbt @@ -9,7 +9,7 @@ pub fn Fs::snapshot( author : String, timestamp : Int64, ) -> Snapshot raise @bit.GitError { - if !(self.working.is_dirty()) { + if !self.working.is_dirty() { raise @bit.GitError::InvalidObject("No changes to commit") } let tree_id = build_tree_from_working( diff --git a/src/x/fs/tree_builder.mbt b/src/x/fs/tree_builder.mbt index c51516d3..d28dc238 100644 --- a/src/x/fs/tree_builder.mbt +++ b/src/x/fs/tree_builder.mbt @@ -264,7 +264,7 @@ fn write_tree_recursive( git_dir : String, node : TreeNode, ) -> @bit.ObjectId raise @bit.GitError { - if !(node.dirty) { + if !node.dirty { if node.base_tree_id is Some(base_tree_id) { return base_tree_id } diff --git a/src/x/fs/verify_lazy_test.mbt b/src/x/fs/verify_lazy_test.mbt index e8efcecd..2e97637b 100644 --- a/src/x/fs/verify_lazy_test.mbt +++ b/src/x/fs/verify_lazy_test.mbt @@ -4,7 +4,7 @@ test "verify: lazy loading on helix repo" { let osfs = @osfs.OsFs::new() let git_dir = "/Users/mz/ghq/github.com/helix-editor/helix/.git" - if !(osfs.is_dir(git_dir)) { + if !osfs.is_dir(git_dir) { println("Skipping: helix repo not found") return } @@ -85,7 +85,7 @@ test "verify: lazy loading on helix repo" { test "verify: lazy loading on this repo" { let osfs = @osfs.OsFs::new() let git_dir = "/Users/mz/ghq/github.com/mizchi/git/.git" - if !(osfs.is_dir(git_dir)) { + if !osfs.is_dir(git_dir) { println("Skipping: this repo .git not found") return } diff --git a/src/x/hq/config.mbt b/src/x/hq/config.mbt index c924b3ab..a19b23fc 100644 --- a/src/x/hq/config.mbt +++ b/src/x/hq/config.mbt @@ -17,13 +17,13 @@ pub fn load_config( let home = env_get("HOME").unwrap_or("/home/user") // Check BHQ_ROOT environment variable first match env_get("BHQ_ROOT") { - Some(root) if !(root.is_empty()) => + Some(root) if !root.is_empty() => HqConfig::new(expand_home_with(root, home)) _ => // If ghq_compat mode, check ghq.root if ghq_compat { match bit_config_get("ghq.root") { - Some(root) if !(root.is_empty()) => + Some(root) if !root.is_empty() => HqConfig::new(expand_home_with(root, home), ghq_compat=true) _ => HqConfig::new(expand_home_with(default_bhq_root, home)) } diff --git a/src/x/hq/list.mbt b/src/x/hq/list.mbt index ac35dd0f..bba92e2a 100644 --- a/src/x/hq/list.mbt +++ b/src/x/hq/list.mbt @@ -39,7 +39,7 @@ fn scan_repos( let entries = list_dir(current_path) for entry in entries { let (name, is_dir) = entry - if is_dir && !(name.has_prefix(".")) { + if is_dir && !name.has_prefix(".") { let new_rel = if rel_path.is_empty() { name } else { diff --git a/src/x/hq/root.mbt b/src/x/hq/root.mbt index 2e799ba5..3f0bb8ec 100644 --- a/src/x/hq/root.mbt +++ b/src/x/hq/root.mbt @@ -13,14 +13,14 @@ pub fn hq_roots( let roots : Array[String] = [] // Check BHQ_ROOT first match env_get("BHQ_ROOT") { - Some(root) if !(root.is_empty()) => roots.push(expand_home(root)) + Some(root) if !root.is_empty() => roots.push(expand_home(root)) _ => () } // Add ghq.root values let ghq_roots = bit_config_get_all("ghq.root") for root in ghq_roots { let expanded = expand_home(root) - if !(roots.contains(expanded)) { + if !roots.contains(expanded) { roots.push(expanded) } } diff --git a/src/x/hub/crypto/relay_sign.mbt b/src/x/hub/crypto/relay_sign.mbt index 3c8a2f61..4258cf74 100644 --- a/src/x/hub/crypto/relay_sign.mbt +++ b/src/x/hub/crypto/relay_sign.mbt @@ -77,7 +77,7 @@ pub fn relay_extract_sha256_hex(output : String) -> String? { if token.length() == 64 { let mut ok = true for c in token.to_array() { - if !(relay_is_hex_char(c)) { + if !relay_is_hex_char(c) { ok = false break } diff --git a/src/x/hub/issue.mbt b/src/x/hub/issue.mbt index a6567711..9a0f6622 100644 --- a/src/x/hub/issue.mbt +++ b/src/x/hub/issue.mbt @@ -342,7 +342,7 @@ pub fn Hub::link_pr_to_issue( raise @bit.GitError::InvalidObject("Issue not found: \{issue_id}") } let linked = existing.linked_prs - if !(linked.contains(pr_id)) { + if !linked.contains(pr_id) { linked.push(pr_id) } let updated = Issue::new( diff --git a/src/x/hub/merge.mbt b/src/x/hub/merge.mbt index 45c8b44d..a5896bfb 100644 --- a/src/x/hub/merge.mbt +++ b/src/x/hub/merge.mbt @@ -156,7 +156,7 @@ pub fn Hub::check_merge_policy( let (approved_count, has_request_changes) = summarize_latest_review_state( reviews, ) - if !(policy.allow_request_changes) && has_request_changes { + if !policy.allow_request_changes && has_request_changes { raise @bit.GitError::InvalidObject( "Merge blocked by policy: request-changes review is present", ) @@ -618,7 +618,7 @@ fn create_tree_from_files( String::unsafe_substring(path, start=idx + 1, end=path.length()), ) } - if !(tree_map.contains(dir)) { + if !tree_map.contains(dir) { tree_map[dir] = [] } let arr = tree_map.get(dir) diff --git a/src/x/hub/native/sync_native.mbt b/src/x/hub/native/sync_native.mbt index 769e17fd..f89cbb34 100644 --- a/src/x/hub/native/sync_native.mbt +++ b/src/x/hub/native/sync_native.mbt @@ -204,11 +204,11 @@ fn relay_is_valid_room_name(room : String) -> Bool { let mut first = true for c in room { if first { - if !(relay_room_leading_char(c)) { + if !relay_room_leading_char(c) { return false } first = false - } else if !(relay_room_safe_char(c)) { + } else if !relay_room_safe_char(c) { return false } } @@ -314,7 +314,7 @@ fn parse_relay_base_url(remote_url : String) -> String? { /// Matches: http(s)://host/git/ where session_id is 6-16 alphanumeric chars. /// Returns the base URL (everything before /git/). fn detect_relay_proxied_git_base(url : String) -> String? { - if !(is_http_url(url)) { + if !is_http_url(url) { return None } let git_path = "/git/" @@ -343,11 +343,9 @@ fn detect_relay_proxied_git_base(url : String) -> String? { return None } for c in session { - if !( - (c >= 'A' && c <= 'Z') || - (c >= 'a' && c <= 'z') || - (c >= '0' && c <= '9'), - ) { + if !((c >= 'A' && c <= 'Z') || + (c >= 'a' && c <= 'z') || + (c >= '0' && c <= '9')) { return None } } @@ -434,7 +432,7 @@ fn relay_resolve_control_endpoint( } None => "main" } - if !(relay_is_valid_room_name(room)) { + if !relay_is_valid_room_name(room) { raise @bit.GitError::InvalidObject("invalid relay room: \{room}") } let room_token = relay_normalize_optional_text( @@ -445,7 +443,7 @@ fn relay_resolve_control_endpoint( ///| fn should_fallback_to_relay(err : @bit.GitError, remote_url : String) -> Bool { - if !(is_http_url(remote_url)) { + if !is_http_url(remote_url) { return false } match err { @@ -566,7 +564,7 @@ fn parse_relay_poll_clone_peers( if sender.length() == 0 { continue } - if !(include_self) && sender == self_sender { + if !include_self && sender == self_sender { continue } guard envelope_obj.get("payload") is Some(Json::Object(payload_obj)) else { @@ -680,9 +678,9 @@ fn relay_record_matches_signing_policy( match record.signature { Some(signature) => signature == relay_compute_record_signature(record, key) - None => !(require_signed) + None => !require_signed } - None => !(require_signed) + None => !require_signed } } @@ -730,12 +728,10 @@ fn apply_relay_record( record : @hub.HubRecord, conflict_policy : @hub.RecordMergePolicy, ) -> Bool raise @bit.GitError { - if !( - relay_record_matches_signing_policy( - record, - store.signing_key(), - store.require_signed(), - ), + if !relay_record_matches_signing_policy( + record, + store.signing_key(), + store.require_signed(), ) { return false } @@ -816,7 +812,7 @@ fn read_relay_cursor( remote_url : String, ) -> Int { let path = relay_cursor_path(git_dir, remote_url) - if !(rfs.is_file(path)) { + if !rfs.is_file(path) { return 0 } let content = rfs.read_file(path) catch { _ => return 0 } diff --git a/src/x/hub/notes.mbt b/src/x/hub/notes.mbt index bd5cbd6a..1ae7a5da 100644 --- a/src/x/hub/notes.mbt +++ b/src/x/hub/notes.mbt @@ -225,7 +225,7 @@ fn update_notes_tree( new_entries.push(entry) } } - if !(found) { + if !found { new_entries.push(@bit.TreeEntry::new("100644", commit_hex, blob_id)) } new_entries.sort_by((a, b) => String::compare(a.name, b.name)) @@ -278,7 +278,7 @@ fn remove_notes_tree_entry( } new_entries.push(entry) } - if !(found) { + if !found { return () } new_entries.sort_by((a, b) => String::compare(a.name, b.name)) diff --git a/src/x/hub/proposal.mbt b/src/x/hub/proposal.mbt index 2d8f50cb..c230feb3 100644 --- a/src/x/hub/proposal.mbt +++ b/src/x/hub/proposal.mbt @@ -271,7 +271,7 @@ pub fn Hub::list_pr_proposals( let result : Array[PullRequest] = [] let records = self.store.list_records(objects, pr_proposal_prefix()) for record in records { - if !(record.key.has_suffix("/meta")) || record.kind != "pr-proposal" { + if !record.key.has_suffix("/meta") || record.kind != "pr-proposal" { continue } let pr = parse_legacy_pull_request(record.payload) catch { _ => continue } diff --git a/src/x/hub/store.mbt b/src/x/hub/store.mbt index 64c68ffb..2310456f 100644 --- a/src/x/hub/store.mbt +++ b/src/x/hub/store.mbt @@ -326,9 +326,9 @@ fn compare_clock(a : Map[String, Int64], b : Map[String, Int64]) -> Int { b_gt = true } } - if a_gt && !(b_gt) { + if a_gt && !b_gt { 1 - } else if b_gt && !(a_gt) { + } else if b_gt && !a_gt { -1 } else { 0 @@ -528,9 +528,9 @@ fn verify_record_by_policy(store : HubStore, record : HubRecord) -> Bool { Some(key) => match record.signature { Some(_) => verify_record_signature(record, key) - None => !(store.require_signed) + None => !store.require_signed } - None => !(store.require_signed) + None => !store.require_signed } } @@ -563,7 +563,7 @@ pub fn HubStore::get_record( Some(blob_obj) => { let text = @utf8.decode_lossy(blob_obj.data[:]) let record = parse_hub_record(text) - if !(verify_record_by_policy(self, record)) { + if !verify_record_by_policy(self, record) { None } else if record.deleted { None @@ -682,13 +682,13 @@ pub fn HubStore::list_records( Some(blob_obj) => { let text = @utf8.decode_lossy(blob_obj.data[:]) let record = parse_hub_record(text) - if !(verify_record_by_policy(self, record)) { + if !verify_record_by_policy(self, record) { continue } - if !(record.key.has_prefix(prefix)) { + if !record.key.has_prefix(prefix) { continue } - if !(include_deleted_val) && record.deleted { + if !include_deleted_val && record.deleted { continue } result.push(record) diff --git a/src/x/hub/work_item.mbt b/src/x/hub/work_item.mbt index 329c6e8e..5b126076 100644 --- a/src/x/hub/work_item.mbt +++ b/src/x/hub/work_item.mbt @@ -26,7 +26,7 @@ pub fn Hub::get_work_item( match record { None => None Some(r) => { - if !(is_work_item_record_kind(r.kind)) { + if !is_work_item_record_kind(r.kind) { return None } let result : Result[WorkItem, PrError] = try? parse_work_item(r.payload) @@ -48,20 +48,20 @@ pub fn Hub::list_work_items( let result : Array[WorkItem] = [] let records = self.store.list_records(objects, work_item_meta_prefix()) for record in records { - if !(record.key.has_suffix("/meta")) { + if !record.key.has_suffix("/meta") { continue } - if !(is_work_item_record_kind(record.kind)) { + if !is_work_item_record_kind(record.kind) { continue } let parsed : Result[WorkItem, PrError] = try? parse_work_item( record.payload, ) guard parsed is Ok(item) else { continue } - if !(include_kind(item.kind(), kind)) { + if !include_kind(item.kind(), kind) { continue } - if !(include_state(item.state(), state)) { + if !include_state(item.state(), state) { continue } result.push(item) diff --git a/src/x/kv/bench_test.mbt b/src/x/kv/bench_test.mbt index dfa96143..76587706 100644 --- a/src/x/kv/bench_test.mbt +++ b/src/x/kv/bench_test.mbt @@ -49,7 +49,7 @@ fn bench_join_path(root : String, path : String) -> String { ///| fn bench_ensure_dir(path : String) -> Unit { - if !(@nfs.path_exists(path)) { + if !@nfs.path_exists(path) { @nfs.create_dir(path) catch { _ => () } diff --git a/src/x/kv/gossip.mbt b/src/x/kv/gossip.mbt index ec220ef8..34913be6 100644 --- a/src/x/kv/gossip.mbt +++ b/src/x/kv/gossip.mbt @@ -266,7 +266,7 @@ fn Kv::find_missing_objects( } // Find objects we have that they don't for entry in our_objects { - if !(their_objects.contains(entry.0)) { + if !their_objects.contains(entry.0) { let id = @bit.ObjectId::from_hex(entry.0) catch { _ => continue } let obj = store.get(id) catch { _ => continue } guard obj is Some(o) else { continue } diff --git a/src/x/kv/merge.mbt b/src/x/kv/merge.mbt index b3ed00a4..864995ca 100644 --- a/src/x/kv/merge.mbt +++ b/src/x/kv/merge.mbt @@ -176,9 +176,9 @@ fn Kv::do_merge( resolve_conflict(self, store, path, our_content, their_hash, strategy) } } - } else if in_theirs && !(in_ours) { + } else if in_theirs && !in_ours { // They added, we don't have - if !(in_base) { + if !in_base { // New file from them let their_hash = their_id.unwrap_or(@bit.ObjectId::zero()) let content = get_blob_content(store, their_hash) @@ -188,7 +188,7 @@ fn Kv::do_merge( } } // If in base but not in ours, we deleted it - keep deleted - } else if in_ours && !(in_theirs) { + } else if in_ours && !in_theirs { // We have, they don't if in_base { // They deleted, we still have diff --git a/src/x/kv/native/sync_native.mbt b/src/x/kv/native/sync_native.mbt index 21e0b973..32b987ea 100644 --- a/src/x/kv/native/sync_native.mbt +++ b/src/x/kv/native/sync_native.mbt @@ -378,11 +378,11 @@ async fn exchange_http_peer( msg : @kv.GossipMessage, headers : Map[String, String], ) -> Result[@kv.GossipMessage?, String] { - if !(is_http_endpoint(peer.endpoint)) { + if !is_http_endpoint(peer.endpoint) { return Err("peer endpoint is not http(s): \{peer.endpoint}") } let request_headers = headers.copy() - if !(request_headers.contains("Content-Type")) { + if !request_headers.contains("Content-Type") { request_headers["Content-Type"] = "application/json" } let payload = encode_gossip_message(msg) @@ -406,7 +406,7 @@ async fn exchange_websocket_peer( msg : @kv.GossipMessage, headers : Map[String, String], ) -> Result[@kv.GossipMessage?, String] { - if !(is_websocket_endpoint(peer.endpoint)) { + if !is_websocket_endpoint(peer.endpoint) { return Err("peer endpoint is not ws(s): \{peer.endpoint}") } let conn = @xws.Conn::connect(peer.endpoint, headers~) catch { diff --git a/src/x/kv/sync_engine.mbt b/src/x/kv/sync_engine.mbt index b60b5c22..dfbf2544 100644 --- a/src/x/kv/sync_engine.mbt +++ b/src/x/kv/sync_engine.mbt @@ -179,7 +179,7 @@ fn select_random_unique( while selected.length() < count && used.length() < peers.length() { current_seed = (current_seed * 1103515245L + 12345L) % 2147483648L let idx = (current_seed % peers.length().to_int64()).to_int() - if !(used.contains(idx)) { + if !used.contains(idx) { used[idx] = true selected.push(peers[idx]) } diff --git a/src/x/rebase-ai/rebase_ai.mbt b/src/x/rebase-ai/rebase_ai.mbt index cc8dff37..d6b029c1 100644 --- a/src/x/rebase-ai/rebase_ai.mbt +++ b/src/x/rebase-ai/rebase_ai.mbt @@ -226,7 +226,7 @@ fn extract_fenced_code_block(text : String) -> String? { let mut in_fence = false for line in lines { if line.has_prefix("```") { - if !(started) { + if !started { started = true in_fence = true continue @@ -355,7 +355,7 @@ fn build_repo_scoped_rw_registry( return "error: invalid path (repository scope only)" } let abs_path = root + "/" + rel_path - if !(rfs.is_file(abs_path)) { + if !rfs.is_file(abs_path) { return "error: file not found" } let bytes = rfs.read_file(abs_path) catch { @@ -405,7 +405,7 @@ fn build_repo_scoped_read_tools( guard resolve_repo_scoped_path(root, raw_path) is Some(path) else { return "error: invalid path" } - if !(rfs.is_file(root + "/" + path)) { + if !rfs.is_file(root + "/" + path) { return "error: file not found" } let abs_path = root + "/" + path @@ -436,7 +436,7 @@ fn build_repo_scoped_read_tools( } else { root + "/" + target_path } - if !(rfs.is_dir(abs_path)) { + if !rfs.is_dir(abs_path) { return "error: invalid path" } let entries = rfs.readdir(abs_path) catch { @@ -502,7 +502,7 @@ fn resolve_conflict_file_with_agent_loop( let abs_path = root + "/" + rel_path let bytes = rfs.read_file(abs_path) catch { _ => return false } let conflicted = decode_bytes(bytes) - if !(has_conflict_markers(conflicted)) { + if !has_conflict_markers(conflicted) { return false } let (registry, touched_paths) = build_repo_scoped_rw_registry(fs, rfs, root) @@ -551,7 +551,7 @@ fn resolve_conflict_file_with_provider( let abs_path = root + "/" + rel_path let bytes = rfs.read_file(abs_path) catch { _ => return false } let conflicted = decode_bytes(bytes) - if !(has_conflict_markers(conflicted)) { + if !has_conflict_markers(conflicted) { return false } let prompt = build_resolve_prompt_with_context(rel_path, conflicted, context) diff --git a/src/x/subdir/commit.mbt b/src/x/subdir/commit.mbt index e34ce04d..24e7759b 100644 --- a/src/x/subdir/commit.mbt +++ b/src/x/subdir/commit.mbt @@ -17,7 +17,7 @@ pub fn SubdirRepo::commit( timestamp? : Int64 = 0L, ) -> @bit.ObjectId raise SubdirError { // 変更がなければエラー - if !(self.is_dirty()) { + if !self.is_dirty() { raise IoError("nothing to commit") } // 親コミットを取得 diff --git a/src/x/subdir/history.mbt b/src/x/subdir/history.mbt index d0056ee3..44bf054c 100644 --- a/src/x/subdir/history.mbt +++ b/src/x/subdir/history.mbt @@ -200,7 +200,7 @@ fn filter_subdir_history( prev_tree = subdir_tree // 親コミットをキューに追加 for parent in commit_info.parents { - if !(visited.contains(parent.to_hex())) { + if !visited.contains(parent.to_hex()) { queue.push(parent) } } diff --git a/src/x/subdir/module.mbt b/src/x/subdir/module.mbt index f7ed174a..033c1fc4 100644 --- a/src/x/subdir/module.mbt +++ b/src/x/subdir/module.mbt @@ -143,7 +143,7 @@ fn setup_filter_config( if content.contains(section_header) { return () } - if content.length() > 0 && !(content.has_suffix("\n")) { + if content.length() > 0 && !content.has_suffix("\n") { content = content + "\n" } content = content + section_header + "\n" @@ -173,7 +173,7 @@ fn setup_gitattributes_filter( if content.contains(pattern) { return () } - if content.length() > 0 && !(content.has_suffix("\n")) { + if content.length() > 0 && !content.has_suffix("\n") { content = content + "\n" } content = content + "# moongit subdir: " + subdir_path + "\n" @@ -208,7 +208,7 @@ fn setup_precommit_hook( return () } // hook スクリプトを追加 - if !(content.has_suffix("\n")) { + if !content.has_suffix("\n") { content = content + "\n" } content = content + "\n" + marker + "\n" @@ -241,7 +241,7 @@ fn remove_precommit_hook( ) -> Unit raise SubdirError { let hooks_dir = git_dir + "/hooks" let hook_path = hooks_dir + "/pre-commit" - if !(rfs.is_file(hook_path)) { + if !rfs.is_file(hook_path) { return () } let content = bytes_to_string_mod( @@ -250,7 +250,7 @@ fn remove_precommit_hook( }, ) let marker = "# moongit-subdir-check: " + subdir_path - if !(content.contains(marker)) { + if !content.contains(marker) { return () } // マーカーから fi までを削除 @@ -338,7 +338,7 @@ fn add_filter_to_config( } // filter セクションを追加 let filter_section = StringBuilder::new() - if config.length() > 0 && !(config.has_suffix("\n")) { + if config.length() > 0 && !config.has_suffix("\n") { filter_section.write_string("\n") } filter_section.write_string("[filter \"") @@ -379,7 +379,7 @@ fn add_filter_to_gitattributes( return () } // パターンを追加 - if content.length() > 0 && !(content.has_suffix("\n")) { + if content.length() > 0 && !content.has_suffix("\n") { content = content + "\n" } // コメントを追加して分かりやすく @@ -438,7 +438,7 @@ fn remove_filter_from_config( filter_name : String, ) -> Unit raise SubdirError { let config_path = git_dir + "/config" - if !(rfs.is_file(config_path)) { + if !rfs.is_file(config_path) { return () } let content = bytes_to_string_mod( @@ -447,7 +447,7 @@ fn remove_filter_from_config( }, ) let section_header = "[filter \"" + filter_name + "\"]" - if !(content.contains(section_header)) { + if !content.contains(section_header) { return () } // セクションを削除 @@ -531,7 +531,7 @@ fn remove_filter_from_gitattributes( subdir_path : String, ) -> Unit raise SubdirError { let gitattributes_path = repo_root + "/.gitattributes" - if !(rfs.is_file(gitattributes_path)) { + if !rfs.is_file(gitattributes_path) { return () } let content = bytes_to_string_mod( @@ -541,7 +541,7 @@ fn remove_filter_from_gitattributes( ) let pattern_line = subdir_path + "/** filter=" + filter_name let comment_line = "# moongit subdir: " + subdir_path - if !(content.contains(pattern_line)) { + if !content.contains(pattern_line) { return () } // パターンとコメントを削除 @@ -615,7 +615,7 @@ fn _add_to_gitmodules( } // 新しいエントリを追加 let entry = StringBuilder::new() - if content.length() > 0 && !(content.has_suffix("\n")) { + if content.length() > 0 && !content.has_suffix("\n") { entry.write_string("\n") } entry.write_string("[submodule \"") @@ -640,7 +640,7 @@ fn _remove_from_gitmodules( subdir_path : String, ) -> Unit raise SubdirError { let gitmodules_path = repo_root + "/.gitmodules" - if !(rfs.is_file(gitmodules_path)) { + if !rfs.is_file(gitmodules_path) { return () } let content = bytes_to_string_mod( @@ -649,7 +649,7 @@ fn _remove_from_gitmodules( }, ) let section_header = "[submodule \"" + subdir_path + "\"]" - if !(content.contains(section_header)) { + if !content.contains(section_header) { return () } // セクションを削除 @@ -847,7 +847,7 @@ pub fn list_modules( git_dir : String, ) -> Array[String] { let modules_dir = git_dir + "/modules" - if !(rfs.is_dir(modules_dir)) { + if !rfs.is_dir(modules_dir) { return [] } let entries = rfs.readdir(modules_dir) catch { _ => return [] } diff --git a/src/x/subdir/sparse.mbt b/src/x/subdir/sparse.mbt index e4160bdc..751bad06 100644 --- a/src/x/subdir/sparse.mbt +++ b/src/x/subdir/sparse.mbt @@ -15,7 +15,7 @@ pub fn is_module_sparse_enabled( let module_name = path_to_module_name(normalized_path) let module_dir = git_dir + "/modules/" + module_name let config_path = module_dir + "/config" - if !(rfs.is_file(config_path)) { + if !rfs.is_file(config_path) { return false } let content = rfs.read_file(config_path) catch { _ => return false } @@ -51,7 +51,7 @@ pub fn read_module_sparse_patterns( let module_name = path_to_module_name(normalized_path) let module_dir = git_dir + "/modules/" + module_name let sparse_path = module_dir + "/info/sparse-checkout" - if !(rfs.is_file(sparse_path)) { + if !rfs.is_file(sparse_path) { return [] } let content = rfs.read_file(sparse_path) catch { _ => return [] } @@ -59,7 +59,7 @@ pub fn read_module_sparse_patterns( let patterns : Array[String] = [] for line_view in text.split("\n") { let line = sparse_trim(line_view.to_string()) - if line.length() > 0 && !(line.has_prefix("#")) { + if line.length() > 0 && !line.has_prefix("#") { patterns.push(line) } } @@ -101,7 +101,7 @@ pub fn init_module_sparse( let module_name = path_to_module_name(normalized_path) let module_dir = git_dir + "/modules/" + module_name // モジュールが初期化済みかチェック - if !(rfs.is_dir(module_dir)) { + if !rfs.is_dir(module_dir) { raise IoError("module not initialized: " + subdir_path) } // config に sparseCheckout = true を追加 @@ -112,7 +112,7 @@ pub fn init_module_sparse( "[core]\n" } // sparseCheckout = true を追加 - if !(config.contains("sparseCheckout")) { + if !config.contains("sparseCheckout") { if config.contains("[core]") { config = config.replace( old="[core]", @@ -123,7 +123,7 @@ pub fn init_module_sparse( } } // cone mode を追加 - if cone && !(config.contains("sparseCheckoutCone")) { + if cone && !config.contains("sparseCheckoutCone") { if config.contains("[core]") { config = config.replace( old="sparseCheckout = true", @@ -140,7 +140,7 @@ pub fn init_module_sparse( _ => () } let sparse_path = module_dir + "/info/sparse-checkout" - if !(rfs.is_file(sparse_path)) { + if !rfs.is_file(sparse_path) { fs.write_file(sparse_path, string_to_bytes_sparse("/*\n!/*/\n")) catch { _ => raise IoError("failed to write initial sparse-checkout") } @@ -157,7 +157,7 @@ pub fn set_module_sparse_patterns( patterns : Array[String], ) -> Unit raise SubdirError { // sparse checkout が初期化されていなければ初期化 - if !(is_module_sparse_enabled(rfs, git_dir, subdir_path)) { + if !is_module_sparse_enabled(rfs, git_dir, subdir_path) { init_module_sparse(fs, rfs, git_dir, subdir_path) catch { e => raise e } @@ -177,14 +177,14 @@ pub fn add_module_sparse_patterns( new_patterns : Array[String], ) -> Unit raise SubdirError { // sparse checkout が初期化されていなければ初期化 - if !(is_module_sparse_enabled(rfs, git_dir, subdir_path)) { + if !is_module_sparse_enabled(rfs, git_dir, subdir_path) { init_module_sparse(fs, rfs, git_dir, subdir_path) catch { e => raise e } } let existing = read_module_sparse_patterns(rfs, git_dir, subdir_path) for p in new_patterns { - if !(existing.contains(p)) { + if !existing.contains(p) { existing.push(p) } } @@ -261,7 +261,7 @@ fn sparse_path_matches(path : String, pattern : String) -> Bool { } // "/*" - ルート直下のファイル if normalized_pattern == "/*" { - return !(path.contains("/")) + return !path.contains("/") } // "!/*/" - ルート直下のディレクトリを除外 if normalized_pattern == "!/*/" { @@ -293,7 +293,7 @@ fn sparse_path_matches(path : String, pattern : String) -> Bool { start=dir.length() + 1, end=path.length(), ) - return !(rest.contains("/")) + return !rest.contains("/") } return false } @@ -333,7 +333,7 @@ fn match_double_star(path : String, pattern : String) -> Bool { let prefix = parts_arr[0] let suffix = parts_arr[1] // プレフィックスチェック - if prefix.length() > 0 && !(path.has_prefix(prefix)) { + if prefix.length() > 0 && !path.has_prefix(prefix) { return false } // サフィックスのパス部分を取得(ファイル名のみ) diff --git a/src/x/subdir/subdir.mbt b/src/x/subdir/subdir.mbt index 02c4a081..b94f22f8 100644 --- a/src/x/subdir/subdir.mbt +++ b/src/x/subdir/subdir.mbt @@ -146,7 +146,7 @@ pub fn extract_subdir_tree( } } } - if !(found) { + if !found { raise SubdirNotFound(subdir_path) } } diff --git a/src/x/workspace/workspace.mbt b/src/x/workspace/workspace.mbt index fa1b3354..d0ea9a5b 100644 --- a/src/x/workspace/workspace.mbt +++ b/src/x/workspace/workspace.mbt @@ -83,7 +83,7 @@ fn normalize_path(path : String) -> String { } else if part == ".." { if parts.length() > 0 && parts[parts.length() - 1] != ".." { let _ = parts.pop() - } else if !(path.has_prefix("/")) { + } else if !path.has_prefix("/") { parts.push(part) } } else { @@ -538,10 +538,10 @@ fn strip_workspace_comment(raw : String) -> String { continue } if ch == '"' { - in_string = !(in_string) + in_string = !in_string continue } - if ch == '#' && !(in_string) { + if ch == '#' && !in_string { return String::unsafe_substring(raw, start=0, end=i) } } @@ -554,7 +554,7 @@ fn parse_toml_string(raw : String) -> String? { if text.length() < 2 { return None } - if !(text.has_prefix("\"")) || !(text.has_suffix("\"")) { + if !text.has_prefix("\"") || !text.has_suffix("\"") { return None } let inner = String::unsafe_substring(text, start=1, end=text.length() - 1) @@ -579,7 +579,7 @@ fn parse_toml_bool(raw : String, default : Bool) -> Bool { ///| fn parse_toml_string_array(raw : String) -> Array[String] { let text = trim_string(raw) - if text.length() < 2 || !(text.has_prefix("[")) || !(text.has_suffix("]")) { + if text.length() < 2 || !text.has_prefix("[") || !text.has_suffix("]") { return [] } let inner = String::unsafe_substring(text, start=1, end=text.length() - 1) @@ -901,12 +901,12 @@ fn workspace_manifest_issues( let issues : Array[String] = [] for node in manifest.nodes { let node_root = workspace_node_abs_path(workspace_root, node.path) - if !(path_is_within_workspace_root(workspace_root, node_root)) { + if !path_is_within_workspace_root(workspace_root, node_root) { issues.push("node '\{node.id}' path escapes workspace root: \{node.path}") continue } if include_repo_checks { - if !(fs.is_dir(node_root)) { + if !fs.is_dir(node_root) { issues.push("node '\{node.id}' path does not exist: \{node.path}") } if workspace_node_git_dir(fs, node_root) is None { @@ -943,7 +943,7 @@ fn workspace_node_git_dir(fs : @osfs.OsFs, node_root : String) -> String? { let marker_exists = fs.is_dir(marker) || fs.is_file(marker) || is_bare_repo_dir(node_root) - if !(marker_exists) { + if !marker_exists { return None } let git_dir = resolve_git_dir(fs, node_root) @@ -1062,7 +1062,7 @@ fn workspace_collect_nested_repo_paths( relative_root + "/" + entry } let child_root = node_root + "/" + relative_path - if !(fs.is_dir(child_root)) { + if !fs.is_dir(child_root) { continue } let marker = default_repo_marker_path(fs, child_root) @@ -1134,7 +1134,7 @@ fn read_workspace_lock_commits( workspace_root : String, ) -> Map[String, String] { let path = workspace_lock_path(fs, workspace_root) - if !(fs.is_file(path)) { + if !fs.is_file(path) { return {} } let text = decode_bytes(fs.read_file(path)) catch { _ => return {} } @@ -1159,7 +1159,7 @@ fn read_workspace_lock_signatures( workspace_root : String, ) -> Map[String, String] { let path = workspace_lock_path(fs, workspace_root) - if !(fs.is_file(path)) { + if !fs.is_file(path) { return {} } let text = decode_bytes(fs.read_file(path)) catch { _ => return {} } @@ -1189,7 +1189,7 @@ fn read_workspace_flow_cache( workspace_root : String, ) -> Map[String, String] { let path = workspace_flow_cache_path(fs, workspace_root) - if !(fs.is_file(path)) { + if !fs.is_file(path) { return {} } let text = decode_bytes(fs.read_file(path)) catch { _ => return {} } @@ -1278,7 +1278,7 @@ fn read_successful_push_nodes( txn_id : String, ) -> Map[String, Bool] { let path = workspace_txn_path(fs, workspace_root, txn_id) - if !(fs.is_file(path)) { + if !fs.is_file(path) { return {} } let text = decode_bytes(fs.read_file(path)) catch { _ => return {} } @@ -1560,7 +1560,7 @@ pub fn workspace_translate_implicit_command( if cmd == "workspace" || cmd == "ws" || cmd == "repo" { return (cmd, rest) } - if !(is_workspace_subcommand_name(cmd)) { + if !is_workspace_subcommand_name(cmd) { return (cmd, rest) } let probe = resolve_workspace_probe_dir(cwd) @@ -1627,7 +1627,7 @@ fn workspace_slug(raw : String) -> String { fn workspace_bitflow_fs_adapter(fs : @osfs.OsFs) -> @bitflow.FsAdapter { @bitflow.FsAdapter::new( fn(path : String) { - if !(fs.is_file(path)) { + if !fs.is_file(path) { return None } let content : Result[Bytes, Error] = try? fs.read_file(path) @@ -1743,7 +1743,7 @@ fn workspace_parse_star_flow_ir( } else { normalize_path(workspace_root + "/" + star_path) } - if !(fs.is_file(absolute_star_path)) { + if !fs.is_file(absolute_star_path) { raise @bit.GitError::InvalidObject( "workspace flow: star file not found: " + absolute_star_path, ) @@ -1768,7 +1768,7 @@ fn workspace_parse_star_flow_ir( break } } - if !(found) { + if !found { raise @bit.GitError::InvalidObject( "workspace flow: star target task not found: " + task_id, ) @@ -1815,7 +1815,7 @@ async fn handle_workspace_init(args : Array[String]) -> Unit raise Error { } let start = resolve_workspace_probe_dir(None) match find_workspace_root_from(start) { - Some(existing_root) if !(force) => { + Some(existing_root) if !force => { println("workspace already initialized at " + existing_root) return } @@ -1928,7 +1928,7 @@ async fn handle_workspace_commit( for node in ordered { let node_root = workspace_node_abs_path(workspace_root, node.path) let repo_exists = workspace_node_git_dir(fs, node_root) is Some(_) - if !(repo_exists) { + if !repo_exists { workspace_record_step( steps, node, "commit", "failed", "repository marker not found", ) @@ -1938,7 +1938,7 @@ async fn handle_workspace_commit( continue } let dirty = workspace_is_node_dirty(fs, node_root) - if !(dirty) && !(allow_empty) { + if !dirty && !allow_empty { workspace_record_step(steps, node, "commit", "skipped", "clean") continue } @@ -2030,7 +2030,7 @@ async fn handle_workspace_push( } let node_root = workspace_node_abs_path(workspace_root, node.path) let repo_exists = workspace_node_git_dir(fs, node_root) is Some(_) - if !(repo_exists) { + if !repo_exists { workspace_record_step( steps, node, "push", "failed", "repository marker not found", ) @@ -2209,7 +2209,7 @@ async fn handle_workspace_flow( "--config" => { if i + 1 < args.length() { let value = args[i + 1] - if !(value.has_prefix("-")) { + if !value.has_prefix("-") { star_path = Some(value) i += 2 continue @@ -2227,7 +2227,7 @@ async fn handle_workspace_flow( "-c" => { if i + 1 < args.length() { let value = args[i + 1] - if !(value.has_prefix("-")) { + if !value.has_prefix("-") { star_path = Some(value) i += 2 continue @@ -2251,7 +2251,7 @@ async fn handle_workspace_flow( star_var_cli_args.push("--var") if i + 1 < args.length() { let value = args[i + 1] - if !(value.has_prefix("-")) { + if !value.has_prefix("-") { star_var_cli_args.push(value) i += 2 continue @@ -2458,7 +2458,7 @@ async fn handle_workspace_flow( guard task_map.get(task_id) is Some(task_spec) else { continue } let blocked_deps : Array[String] = [] for dep in task_spec.needs { - if !(task_success.get(dep).unwrap_or(false)) { + if !task_success.get(dep).unwrap_or(false) { blocked_deps.push(dep) } } @@ -2503,7 +2503,7 @@ async fn handle_workspace_flow( break } } - if !(no_cache) && !(dep_ran) { + if !no_cache && !dep_ran { match decision { Some(value) if value.hit => { workspace_record_step_raw( @@ -2551,7 +2551,7 @@ async fn handle_workspace_flow( task_spec.id, ) task_success[task_spec.id] = true - if !(no_cache) && fingerprint.length() > 0 { + if !no_cache && fingerprint.length() > 0 { flow_cache[cache_key] = fingerprint } } else { @@ -2565,7 +2565,7 @@ async fn handle_workspace_flow( "task '\{task_spec.id}' failed with exit \{code}", ) task_success[task_spec.id] = false - if !(no_cache) { + if !no_cache { flow_cache.remove(cache_key) } if task_spec.required { @@ -2574,7 +2574,7 @@ async fn handle_workspace_flow( } } let _ = ensure_workspace_meta_dir(fs, workspace_root) - if !(no_cache) { + if !no_cache { write_workspace_flow_cache(fs, workspace_root, flow_cache) } let state = if required_failed { "partial_failed" } else { "completed" } @@ -2708,7 +2708,7 @@ async fn handle_workspace_flow( continue } let dep_ok = node_success.get(dep).unwrap_or(false) - if !(dep_ok) { + if !dep_ok { blocked_deps.push(dep) } } @@ -2728,7 +2728,7 @@ async fn handle_workspace_flow( } let node_root = workspace_node_abs_path(workspace_root, node.path) let repo_exists = node_repo_exists.get(node.id).unwrap_or(false) - if !(repo_exists) { + if !repo_exists { workspace_record_step( steps, node, "flow", "failed", "repository marker not found", ) @@ -2758,8 +2758,8 @@ async fn handle_workspace_flow( break } } - if !(no_cache) && - !(dep_ran) && + if !no_cache && + !dep_ran && cache_hit_by_node.get(node.id).unwrap_or(false) { workspace_record_step(steps, node, "flow", "cached", task) node_success[node.id] = true @@ -2787,7 +2787,7 @@ async fn handle_workspace_flow( workspace_record_step(steps, node, "flow", "success", task) node_success[node.id] = true node_ran[node.id] = true - if !(no_cache) { + if !no_cache { flow_cache[cache_key] = fingerprint } } else { @@ -2800,7 +2800,7 @@ async fn handle_workspace_flow( ) node_success[node.id] = false node_ran[node.id] = true - if !(no_cache) { + if !no_cache { flow_cache.remove(cache_key) } if node.required { @@ -2822,7 +2822,7 @@ async fn handle_workspace_flow( } } let _ = ensure_workspace_meta_dir(fs, workspace_root) - if !(no_cache) { + if !no_cache { write_workspace_flow_cache(fs, workspace_root, flow_cache) } let state = if required_failed { "partial_failed" } else { "completed" } diff --git a/tools/flaker-affected-rules.mjs b/tools/flaker-affected-rules.mjs new file mode 100644 index 00000000..7f45dbc7 --- /dev/null +++ b/tools/flaker-affected-rules.mjs @@ -0,0 +1,341 @@ +import { pathToFileURL } from "node:url"; + +export const GIT_COMPAT_AFFECTED_RULES = [ + { + reason: "infrastructure", + changed: [ + "moon.mod.json", + "src/top.mbt", + "src/cmd/bit/main*.mbt", + "src/cmd/bit/helpers*.mbt", + "src/cmd/bit/fallback*.mbt", + "tools/git-shim/**", + "tools/run-git-test.sh", + "tools/apply-git-test-patches.sh", + "tools/select-git-tests.sh", + "tools/flaker-run-git-compat-tests.mjs", + ], + select: ["third_party/git/t/*.sh"], + }, + { + reason: "command:setup", + changed: [ + "src/cmd/bit/init*.mbt", + "src/cmd/bit/config*.mbt", + "src/cmd/bit/gitconfig*.mbt", + "src/cmd/bit/show_ref.mbt", + "src/cmd/bit/symbolic_ref.mbt", + "src/cmd/bit/rev_parse*.mbt", + "src/cmd/bit/hash_object*.mbt", + "src/cmd/bit/cat_file*.mbt", + "src/object/**", + "src/hash/**", + "src/refs/**", + "src/repo_ops/revparse_ops.mbt", + ], + select: [ + "third_party/git/t/t0000-basic.sh", + "third_party/git/t/t0001-init.sh", + "third_party/git/t/t0012-help.sh", + "third_party/git/t/t0450-txt-doc-vs-help.sh", + "third_party/git/t/t1006-cat-file.sh", + "third_party/git/t/t1007-hash-object.sh", + "third_party/git/t/t1300-config.sh", + "third_party/git/t/t1401-symbolic-ref.sh", + "third_party/git/t/t1403-show-ref.sh", + "third_party/git/t/t1500-rev-parse.sh", + ], + }, + { + reason: "command:checkout", + changed: [ + "src/cmd/bit/checkout*.mbt", + "src/cmd/bit/switch*.mbt", + "src/cmd/bit/restore*.mbt", + "src/cmd/bit/checkout_index.mbt", + "src/lib/checkout*.mbt", + "src/lib/path.mbt", + "src/worktree/**", + ], + select: [ + "third_party/git/t/t2006-checkout-index-basic.sh", + "third_party/git/t/t2014-checkout-switch.sh", + "third_party/git/t/t2060-switch.sh", + "third_party/git/t/t7201-co.sh", + ], + }, + { + reason: "command:index", + changed: [ + "src/cmd/bit/ls_files*.mbt", + "src/cmd/bit/ls_tree.mbt", + "src/cmd/bit/read_tree.mbt", + "src/cmd/bit/update_index*.mbt", + "src/cmd/bit/sparse_checkout*.mbt", + "src/cmd/bit/check_attr.mbt", + "src/cmd/bit/check_ignore.mbt", + "src/lib/gitattributes.mbt", + "src/lib/tree_ops.mbt", + "src/worktree/**", + ], + select: [ + "third_party/git/t/t300*.sh", + "third_party/git/t/t310*.sh", + "third_party/git/t/t613*.sh", + "third_party/git/t/t7011-skip-worktree-reading.sh", + "third_party/git/t/t7012-skip-worktree-writing.sh", + ], + }, + { + reason: "command:branch", + changed: [ + "src/cmd/bit/branch*.mbt", + "src/cmd/bit/check_ref_format.mbt", + "src/cmd/bit/show_branches.mbt", + "src/cmd/bit/for_each_ref.mbt", + "src/cmd/bit/show_ref.mbt", + "src/refs/**", + ], + select: [ + "third_party/git/t/t320*.sh", + "third_party/git/t/t630*.sh", + "third_party/git/t/t7419-submodule-set-branch.sh", + ], + }, + { + reason: "command:diff", + changed: [ + "src/cmd/bit/diff*.mbt", + "src/cmd/bit/difftool.mbt", + "src/diff/**", + "src/diff_core/**", + ], + select: [ + "third_party/git/t/t400*.sh", + "third_party/git/t/t6427-diff3-conflict-markers.sh", + ], + }, + { + reason: "command:history", + changed: [ + "src/cmd/bit/log*.mbt", + "src/cmd/bit/rev_list*.mbt", + "src/cmd/bit/merge_base.mbt", + "src/cmd/bit/name_rev.mbt", + "src/cmd/bit/describe.mbt", + "src/cmd/bit/bisect*.mbt", + "src/cmd/bit/bundle.mbt", + "src/cmd/bit/fmt_merge_msg.mbt", + "src/lib/merge_base.mbt", + "src/repo/**", + "src/repo_ops/**", + ], + select: [ + "third_party/git/t/t60*.sh", + "third_party/git/t/t610*.sh", + "third_party/git/t/t611*.sh", + "third_party/git/t/t6120-describe.sh", + "third_party/git/t/t6200-fmt-merge-msg.sh", + ], + }, + { + reason: "command:merge", + changed: [ + "src/cmd/bit/merge*.mbt", + "src/cmd/bit/cherry_pick*.mbt", + "src/cmd/bit/rebase*.mbt", + "src/cmd/bit/revert.mbt", + "src/lib/cherry_pick.mbt", + "src/lib/rebase.mbt", + "src/lib/merge*.mbt", + ], + select: [ + "third_party/git/t/t640*.sh", + "third_party/git/t/t641*.sh", + "third_party/git/t/t642*.sh", + "third_party/git/t/t643*.sh", + "third_party/git/t/t7402-submodule-rebase.sh", + "third_party/git/t/t760*.sh", + "third_party/git/t/t761*.sh", + ], + }, + { + reason: "command:pack", + changed: [ + "src/cmd/bit/pack*.mbt", + "src/cmd/bit/index_pack.mbt", + "src/cmd/bit/unpack_objects.mbt", + "src/cmd/bit/verify_pack.mbt", + "src/cmd/bit/multi_pack_index*.mbt", + "src/cmd/bit/commit_graph*.mbt", + "src/pack/**", + "src/pack_ops/**", + ], + select: [ + "third_party/git/t/t530*.sh", + "third_party/git/t/t531*.sh", + "third_party/git/t/t532*.sh", + "third_party/git/t/t533*.sh", + "third_party/git/t/t5351-unpack-large-objects.sh", + "third_party/git/t/t6113-rev-list-bitmap-filters.sh", + "third_party/git/t/t6114-keep-packs.sh", + ], + }, + { + reason: "command:transport", + changed: [ + "src/cmd/bit/fetch*.mbt", + "src/cmd/bit/pull.mbt", + "src/cmd/bit/push.mbt", + "src/cmd/bit/clone*.mbt", + "src/cmd/bit/remote*.mbt", + "src/cmd/bit/receive_pack.mbt", + "src/cmd/bit/upload_pack.mbt", + "src/cmd/bit/fetch_pack.mbt", + "src/cmd/bit/send_pack.mbt", + "src/cmd/bit/http_fetch.mbt", + "src/cmd/bit/http_serve_*.mbt", + "src/cmd/bit/fetch_serve_*.mbt", + "src/lib/remote*.mbt", + "src/protocol/**", + "src/io/http_client.mbt", + "src/io/native/http_client_native.mbt", + "src/io/native/upload_pack*.mbt", + "src/io/native/remote.mbt", + "src/remote/**", + ], + select: [ + "third_party/git/t/t550*.sh", + "third_party/git/t/t551*.sh", + "third_party/git/t/t552*.sh", + "third_party/git/t/t553*.sh", + "third_party/git/t/t570*.sh", + "third_party/git/t/t5710-promisor-remote-capability.sh", + "third_party/git/t/t573*.sh", + "third_party/git/t/t5750-bundle-uri-parse.sh", + ], + }, + { + reason: "command:porcelain", + changed: [ + "src/cmd/bit/add*.mbt", + "src/cmd/bit/commit*.mbt", + "src/cmd/bit/reset*.mbt", + "src/cmd/bit/status*.mbt", + "src/cmd/bit/show*.mbt", + "src/cmd/bit/rm*.mbt", + "src/cmd/bit/mv.mbt", + "src/cmd/bit/stash.mbt", + "src/cmd/bit/clean.mbt", + "src/lib/reset.mbt", + ], + select: [ + "third_party/git/t/t7001-mv.sh", + "third_party/git/t/t7002-mv-sparse-checkout.sh", + "third_party/git/t/t7007-show.sh", + "third_party/git/t/t706*.sh", + "third_party/git/t/t710*.sh", + "third_party/git/t/t711*.sh", + "third_party/git/t/t730*.sh", + "third_party/git/t/t750*.sh", + "third_party/git/t/t751*.sh", + "third_party/git/t/t752*.sh", + ], + }, + { + reason: "command:tag", + changed: [ + "src/cmd/bit/mktag_cmd.mbt", + "src/cmd/bit/tag*.mbt", + "src/cmd/bit/verify_tag.mbt", + ], + select: [ + "third_party/git/t/t7004-tag.sh", + "third_party/git/t/t7030-verify-tag.sh", + "third_party/git/t/t7031-verify-tag-signed-ssh.sh", + ], + }, + { + reason: "command:submodule", + changed: [ + "src/cmd/bit/submodule*.mbt", + "src/cmd/bit/worktree*.mbt", + "src/cmd/bit/sparse_checkout*.mbt", + "src/x/subdir/**", + ], + select: [ + "third_party/git/t/t6437-submodule-merge.sh", + "third_party/git/t/t6438-submodule-directory-file-conflicts.sh", + "third_party/git/t/t740*.sh", + "third_party/git/t/t741*.sh", + "third_party/git/t/t742*.sh", + "third_party/git/t/t7450-bad-git-dotfiles.sh", + ], + }, +]; + +function escapeRegex(value) { + return value.replace(/[.+^${}()|[\]\\]/g, "\\$&"); +} + +function compileGlob(glob) { + const escaped = glob + .replaceAll("\\", "/") + .replaceAll("**", "\u0000") + .replaceAll("*", "[^/]*") + .replaceAll("?", "[^/]") + .replaceAll("\u0000", ".*"); + return new RegExp(`^${escapeRegex(escaped).replace(/\\\[\\\^\/\\\]\\\*/g, "[^/]*").replace(/\\\[\\\^\/\\\]/g, "[^/]")}$`); +} + +function compileRule(rule) { + return { + ...rule, + changedPatterns: rule.changed.map(compileGlob), + selectPatterns: rule.select.map(compileGlob), + }; +} + +function quoteTomlString(value) { + return JSON.stringify(value); +} + +function renderTomlArray(values) { + return `[${values.map(quoteTomlString).join(", ")}]`; +} + +export function renderAffectedRulesToml(rules) { + return `${rules.map((rule) => [ + "[[rules]]", + `changed = ${renderTomlArray(rule.changed)}`, + `select = ${renderTomlArray(rule.select)}`, + `reason = ${quoteTomlString(rule.reason)}`, + ].join("\n")).join("\n\n")}\n`; +} + +export function selectSuitesForChanges(changedFiles, suites, rules) { + const compiledRules = rules.map(compileRule); + const selected = new Set(); + + for (const file of changedFiles.map((value) => value.replaceAll("\\", "/"))) { + const matchingRules = compiledRules.filter((rule) => + rule.changedPatterns.some((pattern) => pattern.test(file)), + ); + if (matchingRules.length === 0) continue; + + for (const suite of suites) { + const normalizedSuite = suite.replaceAll("\\", "/"); + if (matchingRules.some((rule) => + rule.selectPatterns.some((pattern) => pattern.test(normalizedSuite)) + )) { + selected.add(suite); + } + } + } + + return suites.filter((suite) => selected.has(suite)); +} + +if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) { + process.stdout.write(renderAffectedRulesToml(GIT_COMPAT_AFFECTED_RULES)); +} diff --git a/tools/flaker-affected-rules.test.mjs b/tools/flaker-affected-rules.test.mjs new file mode 100644 index 00000000..a79e0b2c --- /dev/null +++ b/tools/flaker-affected-rules.test.mjs @@ -0,0 +1,84 @@ +import assert from "node:assert/strict"; +import test from "node:test"; +import { readFileSync } from "node:fs"; + +import { + GIT_COMPAT_AFFECTED_RULES, + renderAffectedRulesToml, + selectSuitesForChanges, +} from "./flaker-affected-rules.mjs"; + +test("renderAffectedRulesToml stays in sync with committed config", () => { + const committed = readFileSync("tools/flaker-affected-rules.toml", "utf8"); + assert.equal(renderAffectedRulesToml(GIT_COMPAT_AFFECTED_RULES), committed); +}); + +test("merge-related changes select merge-focused git compat suites", () => { + const selected = selectSuitesForChanges( + ["src/cmd/bit/merge.mbt"], + [ + "third_party/git/t/t6400-merge-df.sh", + "third_party/git/t/t7600-merge.sh", + "third_party/git/t/t7508-status.sh", + ], + GIT_COMPAT_AFFECTED_RULES, + ); + + assert.deepEqual(selected, [ + "third_party/git/t/t6400-merge-df.sh", + "third_party/git/t/t7600-merge.sh", + ]); +}); + +test("fetch and protocol changes include transport suites", () => { + const selected = selectSuitesForChanges( + ["src/cmd/bit/fetch.mbt", "src/protocol/transport.mbt"], + [ + "third_party/git/t/t5500-fetch-pack.sh", + "third_party/git/t/t5700-protocol-v1.sh", + "third_party/git/t/t1300-config.sh", + ], + GIT_COMPAT_AFFECTED_RULES, + ); + + assert.deepEqual(selected, [ + "third_party/git/t/t5500-fetch-pack.sh", + "third_party/git/t/t5700-protocol-v1.sh", + ]); +}); + +test("refname validation changes include branch-oriented suites", () => { + const selected = selectSuitesForChanges( + ["src/cmd/bit/check_ref_format.mbt"], + [ + "third_party/git/t/t3204-branch-name-interpretation.sh", + "third_party/git/t/t7419-submodule-set-branch.sh", + "third_party/git/t/t7004-tag.sh", + ], + GIT_COMPAT_AFFECTED_RULES, + ); + + assert.deepEqual(selected, [ + "third_party/git/t/t3204-branch-name-interpretation.sh", + "third_party/git/t/t7419-submodule-set-branch.sh", + ]); +}); + +test("tag verification changes include tag suites", () => { + const selected = selectSuitesForChanges( + ["src/cmd/bit/verify_tag.mbt", "src/cmd/bit/mktag_cmd.mbt"], + [ + "third_party/git/t/t7004-tag.sh", + "third_party/git/t/t7030-verify-tag.sh", + "third_party/git/t/t7031-verify-tag-signed-ssh.sh", + "third_party/git/t/t7508-status.sh", + ], + GIT_COMPAT_AFFECTED_RULES, + ); + + assert.deepEqual(selected, [ + "third_party/git/t/t7004-tag.sh", + "third_party/git/t/t7030-verify-tag.sh", + "third_party/git/t/t7031-verify-tag-signed-ssh.sh", + ]); +}); diff --git a/tools/flaker-affected-rules.toml b/tools/flaker-affected-rules.toml new file mode 100644 index 00000000..49346028 --- /dev/null +++ b/tools/flaker-affected-rules.toml @@ -0,0 +1,64 @@ +[[rules]] +changed = ["moon.mod.json", "src/top.mbt", "src/cmd/bit/main*.mbt", "src/cmd/bit/helpers*.mbt", "src/cmd/bit/fallback*.mbt", "tools/git-shim/**", "tools/run-git-test.sh", "tools/apply-git-test-patches.sh", "tools/select-git-tests.sh", "tools/flaker-run-git-compat-tests.mjs"] +select = ["third_party/git/t/*.sh"] +reason = "infrastructure" + +[[rules]] +changed = ["src/cmd/bit/init*.mbt", "src/cmd/bit/config*.mbt", "src/cmd/bit/gitconfig*.mbt", "src/cmd/bit/show_ref.mbt", "src/cmd/bit/symbolic_ref.mbt", "src/cmd/bit/rev_parse*.mbt", "src/cmd/bit/hash_object*.mbt", "src/cmd/bit/cat_file*.mbt", "src/object/**", "src/hash/**", "src/refs/**", "src/repo_ops/revparse_ops.mbt"] +select = ["third_party/git/t/t0000-basic.sh", "third_party/git/t/t0001-init.sh", "third_party/git/t/t0012-help.sh", "third_party/git/t/t0450-txt-doc-vs-help.sh", "third_party/git/t/t1006-cat-file.sh", "third_party/git/t/t1007-hash-object.sh", "third_party/git/t/t1300-config.sh", "third_party/git/t/t1401-symbolic-ref.sh", "third_party/git/t/t1403-show-ref.sh", "third_party/git/t/t1500-rev-parse.sh"] +reason = "command:setup" + +[[rules]] +changed = ["src/cmd/bit/checkout*.mbt", "src/cmd/bit/switch*.mbt", "src/cmd/bit/restore*.mbt", "src/cmd/bit/checkout_index.mbt", "src/lib/checkout*.mbt", "src/lib/path.mbt", "src/worktree/**"] +select = ["third_party/git/t/t2006-checkout-index-basic.sh", "third_party/git/t/t2014-checkout-switch.sh", "third_party/git/t/t2060-switch.sh", "third_party/git/t/t7201-co.sh"] +reason = "command:checkout" + +[[rules]] +changed = ["src/cmd/bit/ls_files*.mbt", "src/cmd/bit/ls_tree.mbt", "src/cmd/bit/read_tree.mbt", "src/cmd/bit/update_index*.mbt", "src/cmd/bit/sparse_checkout*.mbt", "src/cmd/bit/check_attr.mbt", "src/cmd/bit/check_ignore.mbt", "src/lib/gitattributes.mbt", "src/lib/tree_ops.mbt", "src/worktree/**"] +select = ["third_party/git/t/t300*.sh", "third_party/git/t/t310*.sh", "third_party/git/t/t613*.sh", "third_party/git/t/t7011-skip-worktree-reading.sh", "third_party/git/t/t7012-skip-worktree-writing.sh"] +reason = "command:index" + +[[rules]] +changed = ["src/cmd/bit/branch*.mbt", "src/cmd/bit/check_ref_format.mbt", "src/cmd/bit/show_branches.mbt", "src/cmd/bit/for_each_ref.mbt", "src/cmd/bit/show_ref.mbt", "src/refs/**"] +select = ["third_party/git/t/t320*.sh", "third_party/git/t/t630*.sh", "third_party/git/t/t7419-submodule-set-branch.sh"] +reason = "command:branch" + +[[rules]] +changed = ["src/cmd/bit/diff*.mbt", "src/cmd/bit/difftool.mbt", "src/diff/**", "src/diff_core/**"] +select = ["third_party/git/t/t400*.sh", "third_party/git/t/t6427-diff3-conflict-markers.sh"] +reason = "command:diff" + +[[rules]] +changed = ["src/cmd/bit/log*.mbt", "src/cmd/bit/rev_list*.mbt", "src/cmd/bit/merge_base.mbt", "src/cmd/bit/name_rev.mbt", "src/cmd/bit/describe.mbt", "src/cmd/bit/bisect*.mbt", "src/cmd/bit/bundle.mbt", "src/cmd/bit/fmt_merge_msg.mbt", "src/lib/merge_base.mbt", "src/repo/**", "src/repo_ops/**"] +select = ["third_party/git/t/t60*.sh", "third_party/git/t/t610*.sh", "third_party/git/t/t611*.sh", "third_party/git/t/t6120-describe.sh", "third_party/git/t/t6200-fmt-merge-msg.sh"] +reason = "command:history" + +[[rules]] +changed = ["src/cmd/bit/merge*.mbt", "src/cmd/bit/cherry_pick*.mbt", "src/cmd/bit/rebase*.mbt", "src/cmd/bit/revert.mbt", "src/lib/cherry_pick.mbt", "src/lib/rebase.mbt", "src/lib/merge*.mbt"] +select = ["third_party/git/t/t640*.sh", "third_party/git/t/t641*.sh", "third_party/git/t/t642*.sh", "third_party/git/t/t643*.sh", "third_party/git/t/t7402-submodule-rebase.sh", "third_party/git/t/t760*.sh", "third_party/git/t/t761*.sh"] +reason = "command:merge" + +[[rules]] +changed = ["src/cmd/bit/pack*.mbt", "src/cmd/bit/index_pack.mbt", "src/cmd/bit/unpack_objects.mbt", "src/cmd/bit/verify_pack.mbt", "src/cmd/bit/multi_pack_index*.mbt", "src/cmd/bit/commit_graph*.mbt", "src/pack/**", "src/pack_ops/**"] +select = ["third_party/git/t/t530*.sh", "third_party/git/t/t531*.sh", "third_party/git/t/t532*.sh", "third_party/git/t/t533*.sh", "third_party/git/t/t5351-unpack-large-objects.sh", "third_party/git/t/t6113-rev-list-bitmap-filters.sh", "third_party/git/t/t6114-keep-packs.sh"] +reason = "command:pack" + +[[rules]] +changed = ["src/cmd/bit/fetch*.mbt", "src/cmd/bit/pull.mbt", "src/cmd/bit/push.mbt", "src/cmd/bit/clone*.mbt", "src/cmd/bit/remote*.mbt", "src/cmd/bit/receive_pack.mbt", "src/cmd/bit/upload_pack.mbt", "src/cmd/bit/fetch_pack.mbt", "src/cmd/bit/send_pack.mbt", "src/cmd/bit/http_fetch.mbt", "src/cmd/bit/http_serve_*.mbt", "src/cmd/bit/fetch_serve_*.mbt", "src/lib/remote*.mbt", "src/protocol/**", "src/io/http_client.mbt", "src/io/native/http_client_native.mbt", "src/io/native/upload_pack*.mbt", "src/io/native/remote.mbt", "src/remote/**"] +select = ["third_party/git/t/t550*.sh", "third_party/git/t/t551*.sh", "third_party/git/t/t552*.sh", "third_party/git/t/t553*.sh", "third_party/git/t/t570*.sh", "third_party/git/t/t5710-promisor-remote-capability.sh", "third_party/git/t/t573*.sh", "third_party/git/t/t5750-bundle-uri-parse.sh"] +reason = "command:transport" + +[[rules]] +changed = ["src/cmd/bit/add*.mbt", "src/cmd/bit/commit*.mbt", "src/cmd/bit/reset*.mbt", "src/cmd/bit/status*.mbt", "src/cmd/bit/show*.mbt", "src/cmd/bit/rm*.mbt", "src/cmd/bit/mv.mbt", "src/cmd/bit/stash.mbt", "src/cmd/bit/clean.mbt", "src/lib/reset.mbt"] +select = ["third_party/git/t/t7001-mv.sh", "third_party/git/t/t7002-mv-sparse-checkout.sh", "third_party/git/t/t7007-show.sh", "third_party/git/t/t706*.sh", "third_party/git/t/t710*.sh", "third_party/git/t/t711*.sh", "third_party/git/t/t730*.sh", "third_party/git/t/t750*.sh", "third_party/git/t/t751*.sh", "third_party/git/t/t752*.sh"] +reason = "command:porcelain" + +[[rules]] +changed = ["src/cmd/bit/mktag_cmd.mbt", "src/cmd/bit/tag*.mbt", "src/cmd/bit/verify_tag.mbt"] +select = ["third_party/git/t/t7004-tag.sh", "third_party/git/t/t7030-verify-tag.sh", "third_party/git/t/t7031-verify-tag-signed-ssh.sh"] +reason = "command:tag" + +[[rules]] +changed = ["src/cmd/bit/submodule*.mbt", "src/cmd/bit/worktree*.mbt", "src/cmd/bit/sparse_checkout*.mbt", "src/x/subdir/**"] +select = ["third_party/git/t/t6437-submodule-merge.sh", "third_party/git/t/t6438-submodule-directory-file-conflicts.sh", "third_party/git/t/t740*.sh", "third_party/git/t/t741*.sh", "third_party/git/t/t742*.sh", "third_party/git/t/t7450-bad-git-dotfiles.sh"] +reason = "command:submodule" diff --git a/tools/flaker-cli-wrapper.mjs b/tools/flaker-cli-wrapper.mjs new file mode 100644 index 00000000..73fa0b0b --- /dev/null +++ b/tools/flaker-cli-wrapper.mjs @@ -0,0 +1,54 @@ +#!/usr/bin/env node + +import { spawnSync } from "node:child_process"; + +export function isGlobResolverFailure(stderr) { + return String(stderr ?? "").includes("Unknown resolver: glob"); +} + +export function formatFlakerFailure(stderr, flakerCommand) { + if (!isGlobResolverFailure(stderr)) { + return String(stderr ?? "").trim(); + } + + return [ + `This workflow requires flaker with glob resolver support, but \`${flakerCommand}\` does not have it.`, + "Use mizchi/flaker PR #14 or newer, or point FLAKER_CMD to a local flaker build that includes the glob resolver.", + "Example: FLAKER_CMD='node /path/to/flaker/dist/cli.js' just flaker-git-compat-affected changed=src/cmd/bit/merge.mbt", + ].join("\n"); +} + +function runFlaker(args, flakerCommand) { + return spawnSync(`${flakerCommand} ${args.map((arg) => JSON.stringify(arg)).join(" ")}`, { + shell: true, + stdio: ["inherit", "pipe", "pipe"], + encoding: "utf8", + }); +} + +function main() { + const args = process.argv.slice(2); + const flakerCommand = process.env.FLAKER_CMD?.trim() || "flaker"; + const result = runFlaker(args, flakerCommand); + + if (result.stdout) { + process.stdout.write(result.stdout); + } + + if (result.status === 0) { + if (result.stderr) { + process.stderr.write(result.stderr); + } + return; + } + + const message = formatFlakerFailure(result.stderr, flakerCommand); + if (message) { + process.stderr.write(`${message}\n`); + } + process.exit(result.status ?? 1); +} + +if (import.meta.url === `file://${process.argv[1]}`) { + main(); +} diff --git a/tools/flaker-cli-wrapper.test.mjs b/tools/flaker-cli-wrapper.test.mjs new file mode 100644 index 00000000..c494c30a --- /dev/null +++ b/tools/flaker-cli-wrapper.test.mjs @@ -0,0 +1,36 @@ +import assert from "node:assert/strict"; +import test from "node:test"; + +import { + formatFlakerFailure, + isGlobResolverFailure, +} from "./flaker-cli-wrapper.mjs"; + +test("isGlobResolverFailure detects unsupported glob resolver errors", () => { + assert.equal( + isGlobResolverFailure("Error: Unknown resolver: glob"), + true, + ); + assert.equal( + isGlobResolverFailure("something else failed"), + false, + ); +}); + +test("formatFlakerFailure rewrites glob resolver failures with guidance", () => { + const message = formatFlakerFailure( + "Error: Unknown resolver: glob", + "flaker", + ); + + assert.match(message, /glob resolver support/i); + assert.match(message, /FLAKER_CMD/); + assert.match(message, /PR #14 or newer/); +}); + +test("formatFlakerFailure preserves other failures", () => { + assert.equal( + formatFlakerFailure("plain failure", "flaker"), + "plain failure", + ); +}); diff --git a/tools/flaker-git-compat-lib.mjs b/tools/flaker-git-compat-lib.mjs new file mode 100644 index 00000000..22c43909 --- /dev/null +++ b/tools/flaker-git-compat-lib.mjs @@ -0,0 +1,98 @@ +import { basename } from "node:path"; +import { readFileSync } from "node:fs"; + +export const GIT_COMPAT_TASK_ID = "git-compat"; +export const GIT_TEST_SUITE_PREFIX = "third_party/git/t/"; + +export function parseAllowlistEntries(text) { + return text + .split(/\r?\n/) + .map((line) => line.trim()) + .filter((line) => line.length > 0 && !line.startsWith("#")); +} + +export function readAllowlistEntries(path = "tools/git-test-allowlist.txt") { + return parseAllowlistEntries(readFileSync(path, "utf8")); +} + +export function toGitCompatSuite(scriptName) { + return `${GIT_TEST_SUITE_PREFIX}${scriptName}`; +} + +export function toFlakerTest(scriptName) { + return { + suite: toGitCompatSuite(scriptName), + testName: scriptName, + taskId: GIT_COMPAT_TASK_ID, + }; +} + +export function listFlakerGitCompatTests(path = "tools/git-test-allowlist.txt") { + return readAllowlistEntries(path).map(toFlakerTest); +} + +function normalizeCandidate(value) { + if (!value) return null; + let candidate = String(value).trim(); + if (!candidate) return null; + if (candidate.startsWith(GIT_TEST_SUITE_PREFIX)) { + candidate = candidate.slice(GIT_TEST_SUITE_PREFIX.length); + } + if (candidate.startsWith("t/")) { + candidate = candidate.slice(2); + } + return basename(candidate); +} + +export function normalizeSelectedScript(test, allowlistSet) { + const candidates = [ + normalizeCandidate(test?.testName), + normalizeCandidate(test?.suite), + ].filter(Boolean); + + for (const candidate of candidates) { + if (allowlistSet.has(candidate)) { + return candidate; + } + } + + throw new Error( + `Selected test is not in git compat allowlist: ${JSON.stringify(test)}`, + ); +} + +export function normalizeSelectedScripts(tests, allowlistEntries) { + const allowlistSet = new Set(allowlistEntries); + const selected = []; + const seen = new Set(); + + for (const test of tests) { + const script = normalizeSelectedScript(test, allowlistSet); + if (seen.has(script)) continue; + seen.add(script); + selected.push(script); + } + + return selected; +} + +export function resolveShimRefreshAction({ + shimExists, + builtBitExists, + shimMtimeMs, + builtBitMtimeMs, +}) { + if (!builtBitExists) { + return "build"; + } + + if (!shimExists) { + return "copy"; + } + + if ((builtBitMtimeMs ?? 0) > (shimMtimeMs ?? 0)) { + return "copy"; + } + + return "keep"; +} diff --git a/tools/flaker-git-compat.test.mjs b/tools/flaker-git-compat.test.mjs new file mode 100644 index 00000000..bd00143a --- /dev/null +++ b/tools/flaker-git-compat.test.mjs @@ -0,0 +1,94 @@ +import assert from "node:assert/strict"; +import test from "node:test"; + +import { + GIT_COMPAT_TASK_ID, + parseAllowlistEntries, + listFlakerGitCompatTests, + normalizeSelectedScripts, + resolveShimRefreshAction, + toFlakerTest, +} from "./flaker-git-compat-lib.mjs"; + +test("parseAllowlistEntries skips comments and blank lines", () => { + const entries = parseAllowlistEntries(` +# comment +t1300-config.sh + + t3200-branch.sh +`); + + assert.deepEqual(entries, ["t1300-config.sh", "t3200-branch.sh"]); +}); + +test("toFlakerTest maps allowlist entries to flaker inventory", () => { + assert.deepEqual(toFlakerTest("t1300-config.sh"), { + suite: "third_party/git/t/t1300-config.sh", + testName: "t1300-config.sh", + taskId: GIT_COMPAT_TASK_ID, + }); +}); + +test("listFlakerGitCompatTests preserves allowlist order", () => { + const tests = listFlakerGitCompatTests("tools/git-test-allowlist.txt"); + assert.equal(tests.length > 100, true); + assert.equal(tests[0].suite.startsWith("third_party/git/t/"), true); +}); + +test("normalizeSelectedScripts accepts suite paths and de-duplicates", () => { + const selected = normalizeSelectedScripts( + [ + { + suite: "third_party/git/t/t1300-config.sh", + testName: "t1300-config.sh", + }, + { + suite: "third_party/git/t/t1300-config.sh", + testName: "t1300-config.sh", + }, + { + suite: "third_party/git/t/t3200-branch.sh", + testName: "ignored", + }, + ], + ["t1300-config.sh", "t3200-branch.sh"], + ); + + assert.deepEqual(selected, ["t1300-config.sh", "t3200-branch.sh"]); +}); + +test("resolveShimRefreshAction rebuilds when no built binary exists", () => { + assert.equal( + resolveShimRefreshAction({ + shimExists: true, + builtBitExists: false, + shimMtimeMs: 10, + builtBitMtimeMs: null, + }), + "build", + ); +}); + +test("resolveShimRefreshAction copies when built binary is newer than shim", () => { + assert.equal( + resolveShimRefreshAction({ + shimExists: true, + builtBitExists: true, + shimMtimeMs: 10, + builtBitMtimeMs: 20, + }), + "copy", + ); +}); + +test("resolveShimRefreshAction keeps shim when it is already up to date", () => { + assert.equal( + resolveShimRefreshAction({ + shimExists: true, + builtBitExists: true, + shimMtimeMs: 20, + builtBitMtimeMs: 10, + }), + "keep", + ); +}); diff --git a/tools/flaker-list-git-compat-tests.mjs b/tools/flaker-list-git-compat-tests.mjs new file mode 100644 index 00000000..064cfd5f --- /dev/null +++ b/tools/flaker-list-git-compat-tests.mjs @@ -0,0 +1,5 @@ +#!/usr/bin/env node + +import { listFlakerGitCompatTests } from "./flaker-git-compat-lib.mjs"; + +console.log(JSON.stringify(listFlakerGitCompatTests(), null, 2)); diff --git a/tools/flaker-run-git-compat-tests.mjs b/tools/flaker-run-git-compat-tests.mjs new file mode 100644 index 00000000..33e72883 --- /dev/null +++ b/tools/flaker-run-git-compat-tests.mjs @@ -0,0 +1,250 @@ +#!/usr/bin/env node + +import { cpSync, chmodSync, existsSync, mkdirSync, statSync, writeFileSync } from "node:fs"; +import { basename, dirname, join } from "node:path"; +import { fileURLToPath } from "node:url"; +import { spawnSync } from "node:child_process"; +import { + GIT_COMPAT_TASK_ID, + normalizeSelectedScripts, + readAllowlistEntries, + resolveShimRefreshAction, + toGitCompatSuite, +} from "./flaker-git-compat-lib.mjs"; + +const root = dirname(dirname(fileURLToPath(import.meta.url))); +const CI_SHIM_COMMANDS = [ + "init", "add", "diff", "diff-files", "diff-index", "ls-files", "tag", + "branch", "checkout", "switch", "commit", "log", "show", "reflog", + "reset", "update-ref", "update-index", "status", "merge", "rebase", + "clone", "push", "fetch", "pull", "mv", "notes", "stash", "rm", + "submodule", "worktree", "config", "show-ref", "for-each-ref", + "rev-parse", "symbolic-ref", "cherry-pick", "remote", "cat-file", + "hash-object", "ls-tree", "write-tree", "commit-tree", "receive-pack", + "upload-pack", "pack-objects", "index-pack", "format-patch", "describe", + "gc", "clean", "sparse-checkout", "restore", "blame", "grep", "shell", + "rev-list", "bisect", "diff-tree", "read-tree", "fsck", "am", "apply", + "bundle", "cherry", "revert", "prune", "pack-refs", "mktree", + "shortlog", "verify-pack", "unpack-objects", "maintenance", + "range-diff", "show-branch", "repack", "multi-pack-index", + "pack-redundant", "send-pack", "request-pull", "merge-base", "var", + "stripspace", "ls-remote", "fmt-merge-msg", "patch-id", "count-objects", + "name-rev", "update-server-info", "check-ref-format", "mktag", + "interpret-trailers", "column", "merge-tree", "merge-file", "fast-import", + "fast-export", "verify-tag", "fetch-pack", "difftool", "rerere", + "mailinfo", "archive", "check-attr", "check-ignore", "show-index", + "get-tar-commit-id", "verify-commit", "annotate", +].join(" "); + +function fail(message, exitCode = 1) { + console.error(message); + process.exit(exitCode); +} + +function run(command, args, opts = {}) { + return spawnSync(command, args, { + cwd: opts.cwd ?? root, + env: { ...process.env, ...(opts.env ?? {}) }, + encoding: "utf8", + timeout: opts.timeout, + }); +} + +function ensureOk(result, label) { + if (result.error) { + throw result.error; + } + if (typeof result.status === "number" && result.status !== 0) { + const stderr = result.stderr?.trim(); + throw new Error(`${label} failed${stderr ? `: ${stderr}` : ""}`); + } +} + +function maybeGettextEnv() { + const brew = run("brew", ["--prefix", "gettext"]); + if (brew.error || brew.status !== 0) { + return {}; + } + const prefix = brew.stdout.trim(); + if (!prefix) return {}; + return { + CPATH: `${prefix}/include`, + LDFLAGS: `-L${prefix}/lib`, + LIBRARY_PATH: `${prefix}/lib`, + }; +} + +function ensurePrepared() { + const patch = run("bash", ["tools/apply-git-test-patches.sh"]); + ensureOk(patch, "apply-git-test-patches"); + + const shimMoon = join(root, "tools/git-shim/moon"); + const builtBit = join( + root, + "_build/native/release/build/cmd/bit/bit.exe", + ); + const action = resolveShimRefreshAction({ + shimExists: existsSync(shimMoon), + builtBitExists: existsSync(builtBit), + shimMtimeMs: existsSync(shimMoon) ? statSync(shimMoon).mtimeMs : null, + builtBitMtimeMs: existsSync(builtBit) ? statSync(builtBit).mtimeMs : null, + }); + + if (action === "build") { + const build = run("moon", ["build", "--target", "native", "--release"]); + ensureOk(build, "moon build"); + } + + if (!existsSync(builtBit)) { + throw new Error(`bit binary not found after prepare step: ${builtBit}`); + } + + if (action !== "keep") { + mkdirSync(dirname(shimMoon), { recursive: true }); + cpSync(builtBit, shimMoon); + chmodSync(shimMoon, 0o755); + } +} + +function resolveRealGit() { + const bundled = join(root, "third_party/git/git"); + if (existsSync(bundled)) { + const whichGit = run("/usr/bin/which", ["git"]); + const fallbackRealGit = + whichGit.status === 0 && whichGit.stdout.trim() !== bundled + ? whichGit.stdout.trim() + : ""; + return { + realGit: bundled, + execPath: join(root, "third_party/git"), + fallbackRealGit, + }; + } + + const whichGit = run("/usr/bin/which", ["git"]); + ensureOk(whichGit, "which git"); + const realGit = whichGit.stdout.trim(); + const execPathResult = run(realGit, ["--exec-path"]); + ensureOk(execPathResult, "git --exec-path"); + return { + realGit, + execPath: execPathResult.stdout.trim(), + fallbackRealGit: "", + }; +} + +function buildCompatEnv() { + ensurePrepared(); + const { realGit, execPath, fallbackRealGit } = resolveRealGit(); + writeFileSync(join(root, "tools/git-shim/real-git-path"), `${realGit}\n`); + return { + ...maybeGettextEnv(), + SHIM_REAL_GIT: realGit, + SHIM_REAL_GIT_FALLBACK: fallbackRealGit, + SHIM_EXEC_PATH: execPath, + SHIM_MOON: join(root, "tools/git-shim/moon"), + SHIM_CMDS: CI_SHIM_COMMANDS, + SHIM_STRICT: "1", + GIT_TEST_INSTALLED: join(root, "tools/git-shim/bin"), + GIT_TEST_EXEC_PATH: execPath, + GIT_TEST_DEFAULT_HASH: "sha1", + }; +} + +function summarizeFailure(scriptName, stdout, stderr, exitCode) { + const lines = `${stdout}\n${stderr}` + .split(/\r?\n/) + .map((line) => line.trimEnd()) + .filter(Boolean); + const tail = lines.slice(-20).join("\n"); + return tail || `${scriptName} failed with exit code ${exitCode}`; +} + +async function parseInput() { + let raw = ""; + for await (const chunk of process.stdin) { + raw += chunk; + } + return raw ? JSON.parse(raw) : { tests: [], opts: {} }; +} + +function executeSelectedTests(selectedScripts, timeout) { + if (selectedScripts.length === 0) { + return { + exitCode: 0, + results: [], + durationMs: 0, + stdout: "", + stderr: "", + }; + } + + const env = buildCompatEnv(); + const results = []; + const stdoutChunks = []; + const stderrChunks = []; + let hasFailure = false; + const startedAt = Date.now(); + + for (const scriptName of selectedScripts) { + const suite = toGitCompatSuite(scriptName); + const testName = basename(scriptName); + const testStartedAt = Date.now(); + const command = run( + "bash", + ["tools/run-git-test.sh", `T=${scriptName}`], + { env, timeout }, + ); + const durationMs = Date.now() - testStartedAt; + const stdout = command.stdout ?? ""; + const stderr = command.stderr ?? ""; + const exitCode = command.status ?? 1; + + stdoutChunks.push(`## ${scriptName}\n${stdout}`); + if (stderr.trim()) { + stderrChunks.push(`## ${scriptName}\n${stderr}`); + } + + if (exitCode !== 0) { + hasFailure = true; + } + + results.push({ + suite, + testName, + taskId: GIT_COMPAT_TASK_ID, + status: exitCode === 0 ? "passed" : "failed", + durationMs, + retryCount: 0, + ...(exitCode === 0 + ? {} + : { + errorMessage: summarizeFailure(scriptName, stdout, stderr, exitCode), + }), + }); + } + + return { + exitCode: hasFailure ? 1 : 0, + results, + durationMs: Date.now() - startedAt, + stdout: stdoutChunks.join("\n"), + stderr: stderrChunks.join("\n"), + }; +} + +try { + const payload = await parseInput(); + const allowlistEntries = readAllowlistEntries(); + const selectedScripts = normalizeSelectedScripts( + payload.tests ?? [], + allowlistEntries, + ); + const executeResult = executeSelectedTests( + selectedScripts, + payload.opts?.timeout, + ); + process.stdout.write(JSON.stringify(executeResult, null, 2)); +} catch (error) { + fail(error instanceof Error ? error.message : String(error)); +}