hook: add sign-off using "interpret-trailers"
[gitweb.git] / builtin / worktree.c
index 11f90d6e45f44f96f637cc976163075181c78fac..c98e2ce5f57c1f41ccaf90041a1a22233ae75551 100644 (file)
@@ -1,4 +1,5 @@
 #include "cache.h"
+#include "config.h"
 #include "builtin.h"
 #include "dir.h"
 #include "parse-options.h"
@@ -299,10 +300,8 @@ static int add_worktree(const char *path, const char *refname,
        }
 
        is_junk = 0;
-       free(junk_work_tree);
-       free(junk_git_dir);
-       junk_work_tree = NULL;
-       junk_git_dir = NULL;
+       FREE_AND_NULL(junk_work_tree);
+       FREE_AND_NULL(junk_git_dir);
 
 done:
        if (ret || !opts->keep_locked) {
@@ -414,9 +413,11 @@ static void show_worktree(struct worktree *wt, int path_maxlen, int abbrev_len)
                                find_unique_abbrev(wt->head_sha1, DEFAULT_ABBREV));
                if (wt->is_detached)
                        strbuf_addstr(&sb, "(detached HEAD)");
-               else if (wt->head_ref)
-                       strbuf_addf(&sb, "[%s]", shorten_unambiguous_ref(wt->head_ref, 0));
-               else
+               else if (wt->head_ref) {
+                       char *ref = shorten_unambiguous_ref(wt->head_ref, 0);
+                       strbuf_addf(&sb, "[%s]", ref);
+                       free(ref);
+               } else
                        strbuf_addstr(&sb, "(error)");
        }
        printf("%s\n", sb.buf);