3
3
///
4
4
pub mod create_tree {
5
5
use bstr:: BString ;
6
+ use but_graph:: VirtualBranchesTomlMetadata ;
7
+ use std:: collections:: BTreeSet ;
6
8
7
9
/// A way to determine what should be included in the snapshot when calling [create_tree()](function::create_tree).
8
- pub struct State < ' a > {
10
+ #[ derive( Debug , Clone ) ]
11
+ pub struct State {
9
12
/// The result of a previous worktree changes call.
10
13
///
11
14
/// It contains detailed information about the complete set of possible changes to become part of the worktree.
12
- pub changes : & ' a but_core:: WorktreeChanges ,
15
+ pub changes : but_core:: WorktreeChanges ,
13
16
/// Repository-relative and slash-separated paths that match any change in the [`changes`](State::changes) field.
14
17
/// **It's an error if there is no match.** as there is not supposed to be a snapshot without a change to the working tree.
15
- pub selection : Vec < BString > ,
18
+ pub selection : BTreeSet < BString > ,
16
19
/// If `true`, store the current `HEAD` reference, i.e. its target, as well as the targets of all refs it's pointing to by symbolic link.
17
20
pub head : bool ,
18
21
}
@@ -40,11 +43,21 @@ pub mod create_tree {
40
43
pub metadata : Option < gix:: ObjectId > ,
41
44
}
42
45
46
+ /// A utility to more easily use *no* workspace or metadata.
47
+ pub fn no_workspace_and_meta ( ) -> Option < (
48
+ & ' static but_graph:: projection:: Workspace < ' static > ,
49
+ & ' static VirtualBranchesTomlMetadata ,
50
+ ) > {
51
+ None
52
+ }
53
+
43
54
pub ( super ) mod function {
44
55
use super :: { Outcome , State } ;
45
56
use but_core:: RefMetadata ;
57
+
46
58
/// Create a tree that represents the snapshot for the given `selection`, with the basis for everything
47
59
/// being the `head_tree_id` (i.e. the tree to which `HEAD` is ultimately pointing to).
60
+ /// Make this an empty tree if the `HEAD` is unborn.
48
61
///
49
62
/// If `workspace_and_meta` is not `None`, the workspace and metadata to store in the snapshot.
50
63
/// We will only store reference positions, and assume that their commits are safely stored in the reflog to not
@@ -53,10 +66,17 @@ pub mod create_tree {
53
66
/// Note that objects will be written into the repository behind `head_tree_id` unless it's configured
54
67
/// to keep everything in memory.
55
68
pub fn create_tree (
56
- _head_tree_id : gix:: Id < ' _ > ,
57
- _selection : State ,
69
+ head_tree_id : gix:: Id < ' _ > ,
70
+ State {
71
+ changes : _,
72
+ selection : _,
73
+ head : _,
74
+ } : State ,
58
75
_workspace_and_meta : Option < ( & but_graph:: projection:: Workspace , & impl RefMetadata ) > ,
59
76
) -> anyhow:: Result < Outcome > {
77
+ let repo = head_tree_id. repo ;
78
+ // TODO: refactor tree-creation to not assume commits anymore.
79
+ // commit_engine::tree::create_tree(repo, )
60
80
todo ! ( )
61
81
}
62
82
}
@@ -91,6 +111,7 @@ pub mod resolve_tree {
91
111
92
112
pub ( super ) mod function {
93
113
use super :: Outcome ;
114
+ use crate :: commit_engine;
94
115
95
116
/// Given the `snapshot_tree` as previously returned via [super::create_tree::Outcome::snapshot_tree], extract data and…
96
117
///
0 commit comments