From 6b3fa3ee79fbac73ff8291ca32aa858dde227df1 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Tue, 29 Aug 2023 09:36:00 -0700 Subject: [PATCH] working_copy: avoid a nested `TreeBuilder` in a test It's just slightly simpler to not create a `TreeBuilder` to create a `TreeValue`; we can instead write to the outer builder. --- lib/tests/test_working_copy.rs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/lib/tests/test_working_copy.rs b/lib/tests/test_working_copy.rs index 49de12ece..a75987fa2 100644 --- a/lib/tests/test_working_copy.rs +++ b/lib/tests/test_working_copy.rs @@ -149,17 +149,14 @@ fn test_checkout_file_transitions(use_git: bool) { TreeValue::Symlink(id) } Kind::Tree => { - let mut sub_tree_builder = store.tree_builder(store.empty_tree_id().clone()); let file_path = path.join(&RepoPathComponent::from("file")); - write_path( - settings, - repo, - &mut sub_tree_builder, - Kind::Normal, - &file_path, - ); - let id = sub_tree_builder.write_tree(); - TreeValue::Tree(id) + let id = testutils::write_file(store, &file_path, "normal file contents"); + let value = TreeValue::File { + id, + executable: false, + }; + tree_builder.set(file_path, value); + return; } Kind::GitSubmodule => { let mut tx = repo.start_transaction(settings, "test");