diff options
Diffstat (limited to 'src/cli/create_command.zig')
-rw-r--r-- | src/cli/create_command.zig | 206 |
1 files changed, 0 insertions, 206 deletions
diff --git a/src/cli/create_command.zig b/src/cli/create_command.zig index a96d48624..ab2a23039 100644 --- a/src/cli/create_command.zig +++ b/src/cli/create_command.zig @@ -35,30 +35,6 @@ const Lock = @import("../lock.zig").Lock; const CopyFile = @import("../copy_file.zig"); var bun_path_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined; -const libgit2_basename = switch (std.builtin.os.tag) { - .linux => "libgit2.so.26", - .macos => "libgit2.dylib", - .windows => "libgit2.dll", - else => "libgit2.so", -}; - -const global_libgit2_paths = switch (std.builtin.os.tag) { - .macos => if (Environment.isAarch64) - &[][:0]const u8{ - "/opt/homebrew/lib/libgit2.dylib", - "/opt/homebrew/libgit2/lib/libgit2.dylib", - "/usr/local/lib/libgit2.dylib", - "/usr/local/opt/libgit2/lib/libgit2.dylib", - } - else - &[_][:0]const u8{ - "/usr/local/lib/libgit2.dylib", - "/usr/local/opt/libgit2/lib/libgit2.dylib", - }, - - else => &[_][:0]const u8{}, -}; - // the standard library function for this returns false when statically linking fn getSelfExeSharedLibPaths(allocator: *std.mem.Allocator) error{OutOfMemory}![][:0]u8 { const List = std.ArrayList([:0]u8); @@ -1379,188 +1355,6 @@ const GitHandler = struct { // [481.00ms] git // [89.00ms] git // if (comptime FeatureFlags.use_libgit2) { - // try_to_use_libgit2: { - // if (comptime Environment.isWindows) @compileError("TODO win32"); - - // // since we link libc, it always goes through dlopen unless windows - // const DlDynlib = std.DynLib; - // var libgit2_dylib: std.DynLib = brk: { - // for (global_libgit2_paths) |lib_path| { - // break :brk DlDynlib.openZ(lib_path) catch continue; - // } - - // var lib_paths = getSelfExeSharedLibPaths(default_allocator) catch break :try_to_use_libgit2; - - // // this is a list of every dynamically loaded library on the user's computer? - // for (lib_paths) |lib_path| { - // const basename = std.fs.path.basename(std.mem.span(lib_path)); - // if (basename.len == (comptime libgit2_basename.len) and - // std.hash.Wyhash.hash(10, basename) == comptime std.hash.Wyhash.hash(10, libgit2_basename)) - // { - // break :brk DlDynlib.openZ(lib_path) catch continue; - // } - // } - // break :try_to_use_libgit2; - // }; - - // const libgit2 = @import("../deps/libgit2.zig"); - // var repo: ?*libgit2.git_repository = null; - // // https://libgit2.org/docs/examples/init/ - // // Note: git_threads_init was renamed to git_libgit2_init - // // https://mail.gnome.org/archives/commits-list/2015-January/msg03703.html - // // ...in 2015 and that doc is still out of date - - // const git_repository_init = libgit2_dylib.lookup(libgit2.git_repository_init, "git_repository_init") orelse break :try_to_use_libgit2; - // const git_repository_free = libgit2_dylib.lookup(libgit2.git_repository_free, "git_repository_free") orelse break :try_to_use_libgit2; - // const git_signature_free = libgit2_dylib.lookup(libgit2.git_signature_free, "git_signature_free") orelse break :try_to_use_libgit2; - // const git_signature_default = libgit2_dylib.lookup(libgit2.git_signature_default, "git_signature_default") orelse break :try_to_use_libgit2; - // const git_repository_index = libgit2_dylib.lookup(libgit2.git_repository_index, "git_repository_index") orelse break :try_to_use_libgit2; - // const git_index_read_tree = libgit2_dylib.lookup(libgit2.git_index_read_tree, "git_index_read_tree") orelse break :try_to_use_libgit2; - // const git_index_write_tree = libgit2_dylib.lookup(libgit2.git_index_write_tree, "git_index_write_tree") orelse break :try_to_use_libgit2; - // const git_index_write = libgit2_dylib.lookup(libgit2.git_index_write, "git_index_write") orelse break :try_to_use_libgit2; - - // const git_index_add_all = libgit2_dylib.lookup(libgit2.git_index_add_all, "git_index_add_all") orelse break :try_to_use_libgit2; - // const git_tree_lookup = libgit2_dylib.lookup(libgit2.git_tree_lookup, "git_tree_lookup") orelse break :try_to_use_libgit2; - // const git_commit_create_v = libgit2_dylib.lookup(libgit2.git_commit_create_v, "git_commit_create_v") orelse break :try_to_use_libgit2; - // const git_index_free = libgit2_dylib.lookup(libgit2.git_index_free, "git_index_free") orelse break :try_to_use_libgit2; - // const git_tree_free = libgit2_dylib.lookup(libgit2.git_tree_free, "git_tree_free") orelse break :try_to_use_libgit2; - // const git_index_add_bypath = libgit2_dylib.lookup(libgit2.git_index_add_bypath, "git_index_add_bypath") orelse break :try_to_use_libgit2; - // const git_status_should_ignore = libgit2_dylib.lookup(libgit2.git_status_should_ignore, "git_status_should_ignore") orelse break :try_to_use_libgit2; - - // var sig: ?*libgit2.git_signature = null; - // // var destination_z = destination.ptr[0..destination.len :0]; - // // const original_cwd = std.os.getcwd(&bun_path_buf) catch break :try_to_use_libgit2; - // // bun_path_buf[original_cwd.len] = 0; - // // std.os.chdirZ(destination_z) catch {}; - // // var origin_z = bun_path_buf[0..original_cwd.len :0]; - // // defer std.os.chdirZ(origin_z) catch {}; - - // if (libgit2_dylib.lookup(libgit2.git_libgit2_init, "git_libgit2_init")) |git_libgit2_init| { - // std.debug.assert(git_libgit2_init() > -1); - // } - - // var rc: c_int = 0; - // rc = git_repository_init(&repo, destination.ptr, 0); - // if (rc < 0) break :try_to_use_libgit2; - // var repo_ = repo orelse break :try_to_use_libgit2; - // // defer git_repository_free(repo_); - - // rc = git_signature_default(&sig, repo_); - // // this fails if they never ran git config - // // the child process will fail too, so we just skip - // if (rc < 0) { - // return false; - // } - // // defer git_signature_free(sig.?); - - // var index: ?*libgit2.git_index = null; - // var tree_id: libgit2.git_oid = undefined; - // var commit_id: libgit2.git_oid = undefined; - // var second_commit_id: libgit2.git_oid = undefined; - // var git_tree: *libgit2.git_tree = undefined; - - // rc = git_repository_index(&index, repo_); - // if (rc < 0) break :try_to_use_libgit2; - - // // // add gitignore file first - // // // technically, we should add every gitignore first but i'll leave that as a future TODO - // // if (files_list.containsAdapted(comptime std.hash.Wyhash.hash(0, "gitignore"), Archive.Context.U64Context{})) { - // // rc = git_index_add_bypath(index.?, ".gitignore"); - // // if (rc < 0) break :try_to_use_libgit2; - // // } else if (files_list.containsAdapted(comptime std.hash.Wyhash.hash(0, ".gitignore"), Archive.Context.U64Context{})) { - // // rc = git_index_add_bypath(index.?, ".gitignore"); - // // if (rc < 0) break :try_to_use_libgit2; - // // } - - // var files = files_list.values(); - - // // without git - // // [6.00ms] bun create /Users/jarred/.bun-create/react2 - - // // with git: - // // [44.00ms] bun create /Users/jarred/.bun-create/react2 - - // var strs = std.mem.zeroes(libgit2.git_strarray); - // // var star = [_]u8{ '*', 0 }; - // // var star_ptr: [*c]u8 = ☆ - // strs.strings = files.ptr; - // strs.count = files.len; - // rc = git_index_add_all(index, &strs, libgit2.GIT_INDEX_ADD_DISABLE_PATHSPEC_MATCH, null, null); - // if (rc < 0) break :try_to_use_libgit2; - - // // if (comptime verbose) { - // // for (files) |file| { - // // var ignored: c_int = 0; - // // rc = git_status_should_ignore(&ignored, repo_, file); - // // if (rc < 0) break :try_to_use_libgit2; - // // if (ignored > 0) { - // // Output.prettyErrorln("[libgit2]: ignored {s}", .{std.mem.sliceTo(file, 0)}); - // // continue; - // // } - - // // // this can fail for a variety of reasons - // // // if it does, better to get most of the files than stop - // // rc = git_index_add_bypath(index.?, file); - // // switch (rc) { - // // libgit2.GIT_OK => { - // // Output.prettyErrorln("[libgit2]: Added {s}", .{std.mem.sliceTo(file, 0)}); - // // }, - // // libgit2.GIT_ENOTFOUND => { - // // Output.prettyErrorln("[libgit2]: not found {s}", .{std.mem.sliceTo(file, 0)}); - // // }, - // // else => { - // // Output.prettyErrorln("[libgit2]: error {d} for {s}", .{ rc, std.mem.sliceTo(file, 0) }); - // // }, - // // } - // // } - // // } else { - // // for (files) |file| { - // // var ignored: c_int = 0; - // // rc = git_status_should_ignore(&ignored, repo_, file); - // // if (rc < 0) break :try_to_use_libgit2; - // // if (ignored > 0) continue; - - // // // this can fail for a variety of reasons - // // // if it does, better to get most of the files than stop - // // _ = git_index_add_bypath(index.?, file); - // // } - // // } - - // // if you don't call git_index_write, git status will look very strange. - // rc = git_index_write(index.?); - // if (rc < 0) break :try_to_use_libgit2; - - // rc = git_index_write_tree(&tree_id, index); - // if (rc < 0) break :try_to_use_libgit2; - - // rc = git_tree_lookup(&git_tree, repo_, &tree_id); - // if (rc < 0) break :try_to_use_libgit2; - // // defer git_tree_free(git_tree); - - // rc = git_commit_create_v( - // &commit_id, - // repo_, - // "HEAD", - // sig.?, - // sig.?, - // null, - // "Initial commit (via bun create)", - // git_tree, - // 0, - // ); - // if (rc < 0) break :try_to_use_libgit2; - - // if (comptime verbose) { - // Output.prettyErrorln("git backend: libgit2", .{}); - // } - - // Output.prettyError("\n", .{}); - // Output.printStartEnd(git_start, std.time.nanoTimestamp()); - // Output.prettyError(" <d>git<r>\n", .{}); - - // // success! - // return true; - // } // } if (which(&bun_path_buf, PATH, destination, "git")) |git| { |