exclude_existing(): set existing_refs.strdup_strings
authorMichael Haggerty <mhagger@alum.mit.edu>
Sat, 25 May 2013 09:08:22 +0000 (11:08 +0200)
committerJunio C Hamano <gitster@pobox.com>
Sun, 2 Jun 2013 22:28:47 +0000 (15:28 -0700)
The each_ref_fn add_existing() adds refnames to the existing_refs
list. But the lifetimes of these refnames is not guaranteed by the
refs API, so configure the string_list to make copies as it adds them.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/show-ref.c
index 8d9b76a02fd115c0285216c27c5232f345d0582d..4a0310da371cfc851bf1d9b763a927764be68476 100644 (file)
@@ -103,7 +103,7 @@ static int add_existing(const char *refname, const unsigned char *sha1, int flag
  */
 static int exclude_existing(const char *match)
 {
-       static struct string_list existing_refs = STRING_LIST_INIT_NODUP;
+       static struct string_list existing_refs = STRING_LIST_INIT_DUP;
        char buf[1024];
        int matchlen = match ? strlen(match) : 0;