Code

Merge branch 'maint'
[git.git] / builtin-checkout.c
index b572b3bf69c791912717eae313942316cd77ac37..ad04a184a28b7cdbb5278cda9c467a2e37b0add8 100644 (file)
@@ -206,6 +206,8 @@ static int checkout_merged(int pos, struct checkout *state)
        ce = make_cache_entry(create_ce_mode(active_cache[pos+1]->ce_mode),
                              sha1,
                              path, 2, 0);
+       if (!ce)
+               die("make_cache_entry failed for path '%s'", path);
        status = checkout_entry(ce, state, NULL);
        return status;
 }
@@ -308,8 +310,7 @@ static void show_local_changes(struct object *head)
 
 static void describe_detached_head(char *msg, struct commit *commit)
 {
-       struct strbuf sb;
-       strbuf_init(&sb, 0);
+       struct strbuf sb = STRBUF_INIT;
        parse_commit(commit);
        pretty_print_commit(CMIT_FMT_ONELINE, commit, &sb, 0, NULL, NULL, 0, 0);
        fprintf(stderr, "%s %s... %s\n", msg,
@@ -358,8 +359,7 @@ struct branch_info {
 
 static void setup_branch_path(struct branch_info *branch)
 {
-       struct strbuf buf;
-       strbuf_init(&buf, 0);
+       struct strbuf buf = STRBUF_INIT;
        strbuf_addstr(&buf, "refs/heads/");
        strbuf_addstr(&buf, branch->name);
        branch->path = strbuf_detach(&buf, NULL);
@@ -482,7 +482,7 @@ static void update_refs_for_switch(struct checkout_opts *opts,
                                   struct branch_info *old,
                                   struct branch_info *new)
 {
-       struct strbuf msg;
+       struct strbuf msg = STRBUF_INIT;
        const char *old_desc;
        if (opts->new_branch) {
                create_branch(old->name, opts->new_branch, new->name, 0,
@@ -491,7 +491,6 @@ static void update_refs_for_switch(struct checkout_opts *opts,
                setup_branch_path(new);
        }
 
-       strbuf_init(&msg, 0);
        old_desc = old->name;
        if (!old_desc)
                old_desc = sha1_to_hex(old->commit->object.sha1);
@@ -736,8 +735,7 @@ no_reference:
        }
 
        if (opts.new_branch) {
-               struct strbuf buf;
-               strbuf_init(&buf, 0);
+               struct strbuf buf = STRBUF_INIT;
                strbuf_addstr(&buf, "refs/heads/");
                strbuf_addstr(&buf, opts.new_branch);
                if (!get_sha1(buf.buf, rev))