git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Michael Haggerty <mhagger@alum.mit.edu>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>,
	Michael Haggerty <mhagger@alum.mit.edu>
Subject: [RFC 08/11] string_list_append_list(): new function
Date: Wed,  4 Dec 2013 06:44:47 +0100	[thread overview]
Message-ID: <1386135890-13954-9-git-send-email-mhagger@alum.mit.edu> (raw)
In-Reply-To: <1386135890-13954-1-git-send-email-mhagger@alum.mit.edu>

Add a new function that appends the strings from one string_list onto
another string_list.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
---
 Documentation/technical/api-string-list.txt | 10 ++++++++--
 string-list.c                               |  9 +++++++++
 string-list.h                               |  8 ++++++++
 3 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/Documentation/technical/api-string-list.txt b/Documentation/technical/api-string-list.txt
index 20be348..2072cf7 100644
--- a/Documentation/technical/api-string-list.txt
+++ b/Documentation/technical/api-string-list.txt
@@ -22,8 +22,9 @@ member (you need this if you add things later) and you should set the
 `nr` and `alloc` members in that case, too.
 
 . Adds new items to the list, using `string_list_append`,
-  `string_list_append_nodup`, `string_list_insert`,
-  `string_list_split`, and/or `string_list_split_in_place`.
+  `string_list_append_nodup`, `string_list_append_list`,
+  `string_list_insert`, `string_list_split`, and/or
+  `string_list_split_in_place`.
 
 . Can check if a string is in the list using `string_list_has_string` or
   `unsorted_string_list_has_string` and get it from the list using
@@ -141,6 +142,11 @@ write `string_list_insert(...)->util = ...;`.
 	ownership of a malloc()ed string to a `string_list` that has
 	`strdup_string` set.
 
+`string_list_append_list`::
+
+	Append the strings from one string_list to the end of another
+	one.
+
 `sort_string_list`::
 
 	Sort the list's entries by string value in `strcmp()` order.
diff --git a/string-list.c b/string-list.c
index aabb25e..803acd1 100644
--- a/string-list.c
+++ b/string-list.c
@@ -212,6 +212,15 @@ struct string_list_item *string_list_append(struct string_list *list,
 			list->strdup_strings ? xstrdup(string) : (char *)string);
 }
 
+void string_list_append_list(struct string_list *dst, struct string_list *src)
+{
+	struct string_list_item *item;
+
+	ALLOC_GROW(dst->items, dst->nr + src->nr, dst->alloc);
+	for_each_string_list_item(item, src)
+		string_list_append(dst, item->string);
+}
+
 /* Yuck */
 static compare_strings_fn compare_for_qsort;
 
diff --git a/string-list.h b/string-list.h
index de6769c..7b0ae86 100644
--- a/string-list.h
+++ b/string-list.h
@@ -76,6 +76,14 @@ void string_list_remove_duplicates(struct string_list *sorted_list, int free_uti
 struct string_list_item *string_list_append(struct string_list *list, const char *string);
 
 /*
+ * Add all strings from src to the end of dst.  If dst->strdup_string
+ * is set, then the strings are copied; otherwise the new
+ * string_list_entries refer to the input strings.  src is left
+ * unchanged.
+ */
+void string_list_append_list(struct string_list *dst, struct string_list *src);
+
+/*
  * Like string_list_append(), except string is never copied.  When
  * list->strdup_strings is set, this function can be used to hand
  * ownership of a malloc()ed string to list without making an extra
-- 
1.8.4.3

  parent reply	other threads:[~2013-12-04  5:53 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-04  5:44 [RFC 00/11] Make reference pruning more configurable Michael Haggerty
2013-12-04  5:44 ` [RFC 01/11] get_stale_heads(): allow limiting to refname patterns Michael Haggerty
2013-12-04  5:44 ` [RFC 02/11] remote.c: add infrastructure for parsing --prune options Michael Haggerty
2013-12-04 12:57   ` Duy Nguyen
2013-12-04 17:04     ` Michael Haggerty
2013-12-04  5:44 ` [RFC 03/11] fetch: use the new functions for handling " Michael Haggerty
2013-12-04  5:44 ` [RFC 04/11] remote: " Michael Haggerty
2013-12-04  5:44 ` [RFC 05/11] remote.c: add infrastructure to handle --prune=<pattern> Michael Haggerty
2013-12-04  5:44 ` [RFC 06/11] fetch --prune: allow refname patterns to be specified Michael Haggerty
2013-12-04  5:44 ` [RFC 07/11] remote update " Michael Haggerty
2013-12-04  5:44 ` Michael Haggerty [this message]
2013-12-04  5:44 ` [RFC 09/11] remote prune: allow --prune=<pattern> options Michael Haggerty
2013-12-04  5:44 ` [RFC 10/11] remote show: " Michael Haggerty
2013-12-04  5:44 ` [RFC 11/11] remote: allow prune patterns to be configured Michael Haggerty
2013-12-04 20:25 ` [RFC 00/11] Make reference pruning more configurable Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1386135890-13954-9-git-send-email-mhagger@alum.mit.edu \
    --to=mhagger@alum.mit.edu \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).