worktree: teach "add" to check out existing branches
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v9 Latest4 patches 3 repliesIn review
- v84 patches 3 repliesSuperseded
- v74 patches 5 repliesSuperseded
Earlier versions · 7
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v6 posting 2/2 | 1 patch | 3 replies | Superseded | |
| v6 posting 1/2 | 6 patches | 18 replies | Superseded | |
| v5 | 6 patches | 9 replies | Superseded | |
| v4 | 4 patches | 10 replies | Superseded | |
| v3 | 4 patches | 1 reply | Superseded | |
| v2 | 3 patches | 12 replies | Superseded | |
| v1 | 1 patch | 3 replies | Superseded |
Patches in v9 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/4 | worktree: remove extra members from struct add_optsbuiltin/ | +16 | 0 replies | |
| 2/4 | worktree: improve message when creating a new worktreebuiltin/ | +36 | 0 replies | |
| 3/4 | worktree: factor out dwim_branch functionbuiltin/ | +18 | 0 replies | |
| 4/4 | worktree: teach "add" to check out existing branchesDocumentation/ builtin/ t/ | +37 | 0 replies |
Reviews trailers per patch
None of the 4 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.
| Patch | Eric Sunshine |
|---|---|
| Series | R-b |
| 1/4 | |
| 2/4 | Helped-by |
| 3/4 | |
| 4/4 | Helped-by |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH v9 0/4] worktree: teach "add" to check out existing branches
Previous rounds are at <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]> and <[email protected]>.
Thanks Eric for the review and the suggestions on the previous round.
Changes since the previous round:
- UNLEAK new_branch after it was xstrndup'd
- update the commit message of 2/4 according to Eric's suggestions
- make force_new_branch a boolean flag in print_preparing_worktree_line, instead of using it as the branch name. Instead use new_branch as the new branch name everywhere in that function.
- get rid of the ckeckout_existing_branch flag
Interdiff below:
builtin/worktree.c +9 -17
@@ -356,18 +356,15 @@ static int add_worktree(const char *path, const char *refname,static void print_preparing_worktree_line (int detach,const char *branch,const char *new_branch, -const char *new_branch_force, -int checkout_existing_branch) +int force_new_branch) { -if (checkout_existing_branch) { -printf_ln (_ ("Preparing worktree (checking out '%s')" ), branch); - }else if (new_branch_force) { -struct commit *commit =lookup_commit_reference_by_name (new_branch_force); +if (force_new_branch) { +struct commit *commit =lookup_commit_reference_by_name (new_branch);if (!commit) -printf_ln (_ ("Preparing worktree (new branch '%s')" ), new_branch_force); +printf_ln (_ ("Preparing worktree (new branch '%s')" ), new_branch);else printf_ln (_ ("Preparing worktree (resetting branch '%s'; was at %s)" ), - new_branch_force, + new_branch,find_unique_abbrev (commit->object.oid.hash,DEFAULT_ABBREV )); }else if (new_branch) {
@@ -390,19 +387,17 @@ static void print_preparing_worktree_line(int detach, } } -static const char *dwim_branch (const char *path,const char **new_branch, -int *checkout_existing_branch) +static const char *dwim_branch (const char *path,const char **new_branch) {int n;const char *s =worktree_basename (path, &n);const char *branchname =xstrndup (s, n);struct strbuf ref =STRBUF_INIT ; +UNLEAK (branchname);if (!strbuf_check_branch_ref (&ref, branchname) &&ref_exists (ref.buf)) { - *checkout_existing_branch =1 ;strbuf_release (&ref); -UNLEAK (branchname);return branchname; }
@@ -421,7 +416,6 @@ static int add(int ac, const char **av, const char *prefix)struct add_opts opts;const char *new_branch_force =NULL ;char *path; -int checkout_existing_branch =0 ;const char *branch;const char *new_branch =NULL ;const char *opt_track =NULL ;
@@ -469,8 +463,7 @@ static int add(int ac, const char **av, const char *prefix) }if (ac <2 && !new_branch && !opts.detach) { -const char *s =dwim_branch (path, &new_branch, - &checkout_existing_branch); +const char *s =dwim_branch (path, &new_branch);if (s) branch = s; }
@@ -490,8 +483,7 @@ static int add(int ac, const char **av, const char *prefix) } } -print_preparing_worktree_line (opts.detach, branch, new_branch, new_branch_force, - checkout_existing_branch); +print_preparing_worktree_line (opts.detach, branch, new_branch, !!new_branch_force);if (new_branch) {struct child_process cp =CHILD_PROCESS_INIT ;
Thomas Gummerer (4):
worktree: remove extra members from struct add_opts
worktree: improve message when creating a new worktree
worktree: factor out dwim_branch function
worktree: teach "add" to check out existing branches
Documentation/git-worktree.txt | 9 +++- builtin/worktree.c | 103 ++++++++++++++++++++++++++++++----------- t/t2025-worktree-add.sh | 26 ++++++++--- 3 files changed, 102 insertions(+), 36 deletions(-)
Signature · 1 line
2.16.1.74.g7afd1c25cc.dirty