Subject: [PATCH v2 0/6] nd/worktree-cleanup-post-head-protection update

From: Nguyễn Thái Ngọc Duy <[email-masked]>
Date: Sun, 22 May 2016 16:33:50 +0700

This is mostly commit message update plus

 - dropping "--force" from the completion patch (a comment from Szeder
   Gabor in a previous attempt of worktree completion support).
 
 - the removal of clear_worktree() patch.

I keep the completion patch anyway even though two versions of it were
posted by Eric and Szeder (and didn't get discussed much) because I
needed this for new commands and because I didn't aim high. It's meant
to provide very basic completion support. Fancy stuff like ref
completion can be added later by people who are more experienced in
bash completion stuff.

Anyway, interdiff

-- 8< --
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index d3ac391..951a186 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2604,7 +2604,7 @@ _git_worktree ()
 	else
 		case "$subcommand,$cur" in
 		add,--*)
-			__gitcomp "--detach --force"
+			__gitcomp "--detach"
 			;;
 		list,--*)
 			__gitcomp "--porcelain"
diff --git a/worktree.c b/worktree.c
index 335c58f..f4a4f38 100644
--- a/worktree.c
+++ b/worktree.c
@@ -5,22 +5,14 @@
 #include "dir.h"
 #include "wt-status.h"
 
-void clear_worktree(struct worktree *wt)
-{
-	if (!wt)
-		return;
-	free(wt->path);
-	free(wt->id);
-	free(wt->head_ref);
-	memset(wt, 0, sizeof(*wt));
-}
-
 void free_worktrees(struct worktree **worktrees)
 {
 	int i = 0;
 
 	for (i = 0; worktrees[i]; i++) {
-		clear_worktree(worktrees[i]);
+		free(worktrees[i]->path);
+		free(worktrees[i]->id);
+		free(worktrees[i]->head_ref);
 		free(worktrees[i]);
 	}
 	free (worktrees);
diff --git a/worktree.h b/worktree.h
index 7430a4e..1394909 100644
--- a/worktree.h
+++ b/worktree.h
@@ -29,11 +29,6 @@ extern struct worktree **get_worktrees(void);
  */
 extern const char *get_worktree_git_dir(const struct worktree *wt);
 
-/*
- * Free up the memory for worktree
- */
-extern void clear_worktree(struct worktree *);
-
 /*
  * Free up the memory for worktree(s)
  */
-- 8< --

Nguyễn Thái Ngọc Duy (6):
  completion: support git-worktree
  worktree.c: rewrite mark_current_worktree() to avoid strbuf
  git-worktree.txt: keep subcommand listing in alphabetical order
  worktree.c: use is_dot_or_dotdot()
  worktree: avoid 0{40}, too many zeroes, hard to read
  worktree: simplify prefixing paths

 Documentation/git-worktree.txt         | 10 +++++-----
 builtin/worktree.c                     | 10 ++++++----
 contrib/completion/git-completion.bash | 23 +++++++++++++++++++++++
 worktree.c                             | 18 ++++++++----------
 4 files changed, 42 insertions(+), 19 deletions(-)

-- 
2.8.2.524.g6ff3d78