Merge branch 'tf/string-list-init'
authorJunio C Hamano <gitster@pobox.com>
Wed, 18 Aug 2010 19:47:04 +0000 (12:47 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 18 Aug 2010 19:47:04 +0000 (12:47 -0700)
* tf/string-list-init:
string_list: Add STRING_LIST_INIT macro and make use of it.

1  2 
builtin/fetch.c
builtin/grep.c
builtin/rerere.c
merge-recursive.c
diff --combined builtin/fetch.c
index 680a8a97bd61cf3ce994ccaee1e89185600c84e8,88ff3575f81b234c1b916c2df4a27a01d84b9405..ea14d5dc6b00b475b8817768b7d35d0bb54d5236
@@@ -548,8 -548,8 +548,8 @@@ static void find_non_local_tags(struct 
                        struct ref **head,
                        struct ref ***tail)
  {
-       struct string_list existing_refs = { NULL, 0, 0, 0 };
-       struct string_list remote_refs = { NULL, 0, 0, 0 };
+       struct string_list existing_refs = STRING_LIST_INIT_NODUP;
+       struct string_list remote_refs = STRING_LIST_INIT_NODUP;
        const struct ref *ref;
        struct string_list_item *item = NULL;
  
@@@ -651,7 -651,7 +651,7 @@@ static int truncate_fetch_head(void
  static int do_fetch(struct transport *transport,
                    struct refspec *refs, int ref_count)
  {
-       struct string_list existing_refs = { NULL, 0, 0, 0 };
+       struct string_list existing_refs = STRING_LIST_INIT_NODUP;
        struct string_list_item *peer_item = NULL;
        struct ref *ref_map;
        struct ref *rm;
@@@ -829,8 -829,7 +829,8 @@@ static int fetch_one(struct remote *rem
        int exit_code;
  
        if (!remote)
 -              die("Where do you want to fetch from today?");
 +              die("No remote repository specified.  Please, specify either a URL or a\n"
 +                  "remote name from which new revisions should be fetched.");
  
        transport = transport_get(remote, NULL);
        transport_set_verbosity(transport, verbosity, progress);
  int cmd_fetch(int argc, const char **argv, const char *prefix)
  {
        int i;
-       struct string_list list = { NULL, 0, 0, 0 };
+       struct string_list list = STRING_LIST_INIT_NODUP;
        struct remote *remote;
        int result = 0;
  
diff --combined builtin/grep.c
index 597f76bc42f51e0fc1906c287981e3d37dc0f536,103f64a210b854b531b2b333fc567a7965c3e87d..cf6c29fa42d96f8bc8282e779617a60d40796166
@@@ -836,7 -836,7 +836,7 @@@ int cmd_grep(int argc, const char **arg
        struct grep_opt opt;
        struct object_array list = { 0, 0, NULL };
        const char **paths = NULL;
-       struct string_list path_list = { NULL, 0, 0, 0 };
+       struct string_list path_list = STRING_LIST_INIT_NODUP;
        int i;
        int dummy;
        int nongit = 0, use_index = 1;
        if (show_in_pager == default_pager)
                show_in_pager = git_pager(1);
        if (show_in_pager) {
 +              opt.color = 0;
                opt.name_only = 1;
                opt.null_following_name = 1;
                opt.output_priv = &path_list;
diff --combined builtin/rerere.c
index 39ad60169d6f4cd53e560e922410b48cc01f7886,3c8e45843e148758fece8b64015754b7d56ec6d1..9b1e3a7cf50674ffdd834d08edba184f5c7c285d
@@@ -40,7 -40,7 +40,7 @@@ static int git_rerere_gc_config(const c
  
  static void garbage_collect(struct string_list *rr)
  {
-       struct string_list to_remove = { NULL, 0, 0, 1 };
+       struct string_list to_remove = STRING_LIST_INIT_DUP;
        DIR *dir;
        struct dirent *e;
        int i, cutoff;
@@@ -102,7 -102,7 +102,7 @@@ static int diff_two(const char *file1, 
  
  int cmd_rerere(int argc, const char **argv, const char *prefix)
  {
-       struct string_list merge_rr = { NULL, 0, 0, 1 };
+       struct string_list merge_rr = STRING_LIST_INIT_DUP;
        int i, fd, flags = 0;
  
        if (2 < argc) {
                        if (!has_rerere_resolution(name))
                                unlink_rr_item(name);
                }
 -              unlink_or_warn(git_path("rr-cache/MERGE_RR"));
 +              unlink_or_warn(git_path("MERGE_RR"));
        } else if (!strcmp(argv[1], "gc"))
                garbage_collect(&merge_rr);
        else if (!strcmp(argv[1], "status"))
diff --combined merge-recursive.c
index 7635659969f498b7a00b5019da32593bf7b9ba89,1c065d306f4cea8076c29b56f277404a1c815eb0..6cff9cdc86b1db7c4bd0a75175a77b2474417dfb
@@@ -136,10 -136,16 +136,10 @@@ static void output_commit_title(struct 
                if (parse_commit(commit) != 0)
                        printf("(bad commit)\n");
                else {
 -                      const char *s;
 -                      int len;
 -                      for (s = commit->buffer; *s; s++)
 -                              if (*s == '\n' && s[1] == '\n') {
 -                                      s += 2;
 -                                      break;
 -                              }
 -                      for (len = 0; s[len] && '\n' != s[len]; len++)
 -                              ; /* do nothing */
 -                      printf("%.*s\n", len, s);
 +                      const char *title;
 +                      int len = find_commit_subject(commit->buffer, &title);
 +                      if (len)
 +                              printf("%.*s\n", len, title);
                }
        }
  }
@@@ -800,7 -806,8 +800,8 @@@ static int process_renames(struct merge
                           struct string_list *b_renames)
  {
        int clean_merge = 1, i, j;
-       struct string_list a_by_dst = {NULL, 0, 0, 0}, b_by_dst = {NULL, 0, 0, 0};
+       struct string_list a_by_dst = STRING_LIST_INIT_NODUP;
+       struct string_list b_by_dst = STRING_LIST_INIT_NODUP;
        const struct rename *sre;
  
        for (i = 0; i < a_renames->nr; i++) {
@@@ -1208,7 -1215,7 +1209,7 @@@ int merge_trees(struct merge_options *o
        }
  
        if (sha_eq(common->object.sha1, merge->object.sha1)) {
 -              output(o, 0, "Already uptodate!");
 +              output(o, 0, "Already up-to-date!");
                *result = head;
                return 1;
        }