worktree lock/unlock
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v5 Latest6 patches 0 repliesNew
- v46 patches 4 repliesSuperseded
- v36 patches 18 repliesSuperseded
Earlier versions · 1
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v2 | 5 patches | 17 replies | Superseded |
Patches in v5 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/6 | worktree.c: add find_worktree()worktree.c worktree.h | +23 | 0 replies | |
| 2/6 | worktree.c: add is_main_worktree()worktree.c worktree.h | +10 | 0 replies | |
| 3/6 | worktree.c: add is_worktree_locked()worktree.c worktree.h | +36 | 0 replies | |
| 4/6 | worktree: add "lock" commandDocumentation/ builtin/ contrib/ +1 more | +110 | 0 replies | |
| 5/6 | worktree: add "unlock" commandDocumentation/ builtin/ contrib/ +1 more | +48 | 0 replies | |
| 6/6 | worktree.c: find_worktree() search by path suffixDocumentation/ worktree.c | +34 | 0 replies |
Reviews trailers per patch
None of the 6 patches has a Reviewed-by or Acked-by.
| Patch | Eric Sunshine |
|---|---|
| 1/6 | Helped-by |
| 2/6 | |
| 3/6 | |
| 4/6 | Helped-by |
| 5/6 | |
| 6/6 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH v5 0/6] worktree lock/unlock
v5 fixes some error messages mentioning "working directory" instead of "working tree" and split the double use of "lock_reason" field in "struct worktree". This series depends on nd/worktree-cleanup-post-head-protection.
Diff from v4
-- 8< --
builtin/worktree.c +4 -4
@@ -478,9 +478,9 @@ static int lock_worktree(int ac, const char **av, const char *prefix) worktrees =get_worktrees (); wt =find_worktree (worktrees, prefix, av[0 ]);if (!wt) -die (_ ("'%s' is not a working directory" ), av[0 ]); +die (_ ("'%s' is not a working tree" ), av[0 ]);if (is_main_worktree (wt)) -die (_ ("'%s' is a main working directory" ), av[0 ]); +die (_ ("The main working tree cannot be locked or unlocked" )); old_reason =is_worktree_locked (wt);if (old_reason) {
@@ -511,9 +511,9 @@ static int unlock_worktree(int ac, const char **av, const char *prefix) worktrees =get_worktrees (); wt =find_worktree (worktrees, prefix, av[0 ]);if (!wt) -die (_ ("'%s' is not a working directory" ), av[0 ]); +die (_ ("'%s' is not a working tree" ), av[0 ]);if (is_main_worktree (wt)) -die (_ ("'%s' is a main working directory" ), av[0 ]); +die (_ ("The main working tree cannot be locked or unlocked" ));if (!is_worktree_locked (wt))die (_ ("'%s' is not locked" ), av[0 ]); ret =unlink_or_warn (git_common_path ("worktrees/%s/locked" , wt->id));
worktree.c +9 -7
@@ -5,8 +5,6 @@#include "dir.h" #include "wt-status.h" -static const char *lock_field_uninitialized ="value is not important" ; -void free_worktrees (struct worktree **worktrees) {int i =0 ;
@@ -15,8 +13,7 @@ void free_worktrees(struct worktree **worktrees)free (worktrees[i]->path);free (worktrees[i]->id);free (worktrees[i]->head_ref); -if (worktrees[i]->lock_reason != lock_field_uninitialized) -free (worktrees[i]->lock_reason); +free (worktrees[i]->lock_reason);free (worktrees[i]); }free (worktrees);
@@ -102,7 +99,8 @@ static struct worktree *get_main_worktree(void) worktree->is_detached = is_detached; worktree->is_current =0 ;add_head_info (&head_ref, worktree); - worktree->lock_reason = (char *)lock_field_uninitialized; + worktree->lock_reason =NULL ; + worktree->lock_reason_valid =0 ; done:strbuf_release (&path);
@@ -148,7 +146,8 @@ static struct worktree *get_linked_worktree(const char *id) worktree->is_detached = is_detached; worktree->is_current =0 ;add_head_info (&head_ref, worktree); - worktree->lock_reason = (char *)lock_field_uninitialized; + worktree->lock_reason =NULL ; + worktree->lock_reason_valid =0 ; done:strbuf_release (&path);
@@ -271,7 +270,9 @@ int is_main_worktree(const struct worktree *wt)const char *is_worktree_locked (struct worktree *wt) { -if (wt->lock_reason == lock_field_uninitialized) { +assert (!is_main_worktree (wt)); + +if (!wt->lock_reason_valid) {struct strbuf path =STRBUF_INIT ;strbuf_addstr (&path,worktree_git_path (wt,"locked" ));
@@ -283,6 +284,7 @@ const char *is_worktree_locked(struct worktree *wt) wt->lock_reason =strbuf_detach (&lock_reason,NULL ); }else wt->lock_reason =NULL ; + wt->lock_reason_valid =1 ;strbuf_release (&path); }
worktree.h +1 -0
@@ -10,6 +10,7 @@ struct worktree {int is_detached;int is_bare;int is_current; +int lock_reason_valid; };/* Functions for acting on the information about worktrees. */
-- >8 --
Nguyễn Thái Ngọc Duy (6):
worktree.c: add find_worktree() worktree.c: add is_main_worktree() worktree.c: add is_worktree_locked()
worktree: add "lock" command
worktree: add "unlock" command worktree.c: find_worktree() search by path suffix
Documentation/git-worktree.txt | 36 +++++++++++++--- builtin/worktree.c | 66 +++++++++++++++++++++++++++++ contrib/completion/git-completion.bash | 5 ++- t/t2028-worktree-move.sh (new +x) | 62 +++++++++++++++++++++++++++ worktree.c | 77 ++++++++++++++++++++++++++++++++++ worktree.h | 21 ++++++++++ 6 files changed, 260 insertions(+), 7 deletions(-) create mode 100755 t/t2028-worktree-move.sh
Signature · 1 line
2.8.2.524.g6ff3d78