@@ -88,6 +88,17 @@ struct checkout_opts {
88
88
struct tree * source_tree ;
89
89
};
90
90
91
+ struct branch_info {
92
+ const char * name ; /* The short name used */
93
+ const char * path ; /* The full name of a real branch */
94
+ struct commit * commit ; /* The named commit */
95
+ /*
96
+ * if not null the branch is detached because it's already
97
+ * checked out in this checkout
98
+ */
99
+ char * checkout ;
100
+ };
101
+
91
102
static int post_checkout_hook (struct commit * old_commit , struct commit * new_commit ,
92
103
int changed )
93
104
{
@@ -337,7 +348,8 @@ static void mark_ce_for_checkout_no_overlay(struct cache_entry *ce,
337
348
}
338
349
}
339
350
340
- static int checkout_worktree (const struct checkout_opts * opts )
351
+ static int checkout_worktree (const struct checkout_opts * opts ,
352
+ const struct branch_info * info )
341
353
{
342
354
struct checkout state = CHECKOUT_INIT ;
343
355
int nr_checkouts = 0 , nr_unmerged = 0 ;
@@ -396,7 +408,7 @@ static int checkout_worktree(const struct checkout_opts *opts)
396
408
}
397
409
398
410
static int checkout_paths (const struct checkout_opts * opts ,
399
- const char * revision )
411
+ const struct branch_info * new_branch_info )
400
412
{
401
413
int pos ;
402
414
static char * ps_matched ;
@@ -462,7 +474,7 @@ static int checkout_paths(const struct checkout_opts *opts,
462
474
else
463
475
BUG ("either flag must have been set, worktree=%d, index=%d" ,
464
476
opts -> checkout_worktree , opts -> checkout_index );
465
- return run_add_interactive (revision , patch_mode , & opts -> pathspec );
477
+ return run_add_interactive (new_branch_info -> name , patch_mode , & opts -> pathspec );
466
478
}
467
479
468
480
repo_hold_locked_index (the_repository , & lock_file , LOCK_DIE_ON_ERROR );
@@ -523,7 +535,7 @@ static int checkout_paths(const struct checkout_opts *opts,
523
535
524
536
/* Now we are committed to check them out */
525
537
if (opts -> checkout_worktree )
526
- errs |= checkout_worktree (opts );
538
+ errs |= checkout_worktree (opts , new_branch_info );
527
539
else
528
540
remove_marked_cache_entries (& the_index , 1 );
529
541
@@ -620,17 +632,6 @@ static int reset_tree(struct tree *tree, const struct checkout_opts *o,
620
632
}
621
633
}
622
634
623
- struct branch_info {
624
- const char * name ; /* The short name used */
625
- const char * path ; /* The full name of a real branch */
626
- struct commit * commit ; /* The named commit */
627
- /*
628
- * if not null the branch is detached because it's already
629
- * checked out in this checkout
630
- */
631
- char * checkout ;
632
- };
633
-
634
635
static void setup_branch_path (struct branch_info * branch )
635
636
{
636
637
struct strbuf buf = STRBUF_INIT ;
@@ -1710,7 +1711,7 @@ static int checkout_main(int argc, const char **argv, const char *prefix,
1710
1711
1711
1712
UNLEAK (opts );
1712
1713
if (opts -> patch_mode || opts -> pathspec .nr )
1713
- return checkout_paths (opts , new_branch_info . name );
1714
+ return checkout_paths (opts , & new_branch_info );
1714
1715
else
1715
1716
return checkout_branch (opts , & new_branch_info );
1716
1717
}
0 commit comments