@@ -6,6 +6,8 @@ use anyhow::Result;
6
6
use clap:: ArgMatches ;
7
7
8
8
use crate :: {
9
+ argset,
10
+ branchloc:: BranchLocator ,
9
11
ext:: RepositoryExtended ,
10
12
stack:: { InitializationPolicy , Stack } ,
11
13
} ;
@@ -19,25 +21,36 @@ pub(super) const STGIT_COMMAND: super::StGitCommand = super::StGitCommand {
19
21
20
22
fn make ( ) -> clap:: Command {
21
23
clap:: Command :: new ( STGIT_COMMAND . name )
22
- . about ( "Initialize a StGit stack on current branch" )
24
+ . about ( "Initialize a StGit stack on a branch" )
23
25
. long_about (
24
- "Initialize a StGit stack on the current branch.\n \
26
+ "Initialize a StGit stack on a branch.\n \
25
27
\n \
26
- A branch must be initialized with a StGit stack before patches may be \
27
- created with 'stg new', imported with 'stg import', or picked with 'stg \
28
- pick'.\n \
28
+ Initializing a branch with a StGit stack commits initial, empty stack \
29
+ state for the branch to the repository. Theses stack metadata commits are \
30
+ tracked by the `refs/stacks/<branch>` reference. Updated stack state is \
31
+ committed by each StGit command that modifies the stack. StGit users do \
32
+ not have to do anything with the `refs/stacks/<branch>` ref directly.\n \
29
33
\n \
30
- The branch and its git repository must already exist and contain at least \
31
- one commit before initializing a StGit stack. Branches created with `stg \
32
- branch --create` are automatically initialized.\n \
34
+ Some StGit commands, such as `stg new` and `stg uncommit`, will \
35
+ automatically initialize the stack, so it is often not necessary to \
36
+ explicitly initialize the stack on a branch. Also, branches created with \
37
+ `stg branch --create` are automatically initialized.\n \
38
+ \n \
39
+ The branch must already exist and point to a commit before initializing a \
40
+ StGit stack.\n \
33
41
\n \
34
42
StGit stack metadata can be deinitialized from a branch using `stg branch \
35
43
--cleanup`. See 'stg branch' for more details.",
36
44
)
45
+ . arg ( argset:: branch_arg ( ) )
37
46
}
38
47
39
- fn run ( _ : & ArgMatches ) -> Result < ( ) > {
48
+ fn run ( matches : & ArgMatches ) -> Result < ( ) > {
40
49
let repo = gix:: Repository :: open ( ) ?;
41
- Stack :: current ( & repo, InitializationPolicy :: MustInitialize ) ?;
50
+ Stack :: from_branch_locator (
51
+ & repo,
52
+ matches. get_one :: < BranchLocator > ( "branch" ) ,
53
+ InitializationPolicy :: MustInitialize ,
54
+ ) ?;
42
55
Ok ( ( ) )
43
56
}
0 commit comments