Merge branch 'rs/commit-list-append'
[gitweb.git] / sequencer.c
index 5fcbcb8875454574f4d3a52b5d1ac84b99452ba7..81d8ace35fa51f029cf78a4710a5668277a95af6 100644 (file)
@@ -123,7 +123,7 @@ static void write_cherry_pick_head(struct commit *commit, const char *pseudoref)
        strbuf_release(&buf);
 }
 
-static void print_advice(int show_hint)
+static void print_advice(int show_hint, struct replay_opts *opts)
 {
        char *msg = getenv("GIT_CHERRY_PICK_HELP");
 
@@ -138,10 +138,15 @@ static void print_advice(int show_hint)
                return;
        }
 
-       if (show_hint)
-               advise(_("after resolving the conflicts, mark the corrected paths\n"
-                        "with 'git add <paths>' or 'git rm <paths>'\n"
-                        "and commit the result with 'git commit'"));
+       if (show_hint) {
+               if (opts->no_commit)
+                       advise(_("after resolving the conflicts, mark the corrected paths\n"
+                                "with 'git add <paths>' or 'git rm <paths>'"));
+               else
+                       advise(_("after resolving the conflicts, mark the corrected paths\n"
+                                "with 'git add <paths>' or 'git rm <paths>'\n"
+                                "and commit the result with 'git commit'"));
+       }
 }
 
 static void write_message(struct strbuf *msgbuf, const char *filename)
@@ -159,7 +164,7 @@ static void write_message(struct strbuf *msgbuf, const char *filename)
 
 static struct tree *empty_tree(void)
 {
-       return lookup_tree((const unsigned char *)EMPTY_TREE_SHA1_BIN);
+       return lookup_tree(EMPTY_TREE_SHA1_BIN);
 }
 
 static int error_dirty_index(struct replay_opts *opts)
@@ -229,7 +234,7 @@ static int do_recursive_merge(struct commit *base, struct commit *next,
 
        if (!clean) {
                int i;
-               strbuf_addstr(msgbuf, "\nConflicts:\n\n");
+               strbuf_addstr(msgbuf, "\nConflicts:\n");
                for (i = 0; i < active_nr;) {
                        struct cache_entry *ce = active_cache[i++];
                        if (ce_stage(ce)) {
@@ -423,7 +428,7 @@ static int do_pick_commit(struct commit *commit, struct replay_opts *opts)
                      : _("could not apply %s... %s"),
                      find_unique_abbrev(commit->object.sha1, DEFAULT_ABBREV),
                      msg.subject);
-               print_advice(res == 1);
+               print_advice(res == 1, opts);
                rerere(opts->allow_rerere_auto);
        } else {
                if (!opts->no_commit)
@@ -463,33 +468,6 @@ static void read_and_refresh_cache(struct replay_opts *opts)
        rollback_lock_file(&index_lock);
 }
 
-/*
- * Append a commit to the end of the commit_list.
- *
- * next starts by pointing to the variable that holds the head of an
- * empty commit_list, and is updated to point to the "next" field of
- * the last item on the list as new commits are appended.
- *
- * Usage example:
- *
- *     struct commit_list *list;
- *     struct commit_list **next = &list;
- *
- *     next = commit_list_append(c1, next);
- *     next = commit_list_append(c2, next);
- *     assert(commit_list_count(list) == 2);
- *     return list;
- */
-static struct commit_list **commit_list_append(struct commit *commit,
-                                              struct commit_list **next)
-{
-       struct commit_list *new = xmalloc(sizeof(struct commit_list));
-       new->item = commit;
-       *next = new;
-       new->next = NULL;
-       return &new->next;
-}
-
 static int format_todo(struct strbuf *buf, struct commit_list *todo_list,
                struct replay_opts *opts)
 {