]> asedeno.scripts.mit.edu Git - git.git/blobdiff - builtin/revert.c
Introduce advise() to print hints
[git.git] / builtin / revert.c
index b84b5b8645dce4fee190e7b11a5ac8ec24a994fc..74c1581fdc73129e61c2ade90701900586e3ee82 100644 (file)
@@ -241,6 +241,15 @@ static void set_author_ident_env(const char *message)
                        sha1_to_hex(commit->object.sha1));
 }
 
+static void advise(const char *advice, ...)
+{
+       va_list params;
+
+       va_start(params, advice);
+       vreportf("hint: ", advice, params);
+       va_end(params);
+}
+
 static char *help_msg(void)
 {
        struct strbuf helpbuf = STRBUF_INIT;
@@ -492,7 +501,8 @@ static int do_pick_commit(void)
                }
        }
 
-       strbuf_addstr(&mebuf, me);
+       strbuf_addf(&mebuf, "%s of commit %s", me,
+                   find_unique_abbrev(commit->object.sha1, DEFAULT_ABBREV));
 
        if (!strategy || !strcmp(strategy, "recursive") || action == REVERT) {
                res = do_recursive_merge(base, next, base_label, next_label,
@@ -518,24 +528,15 @@ static int do_pick_commit(void)
                        mebuf.buf, help_msg());
                rerere(allow_rerere_auto);
        } else {
-               fprintf(stderr, "Finished one %s.\n", mebuf.buf);
+               if (!no_commit)
+                       res = run_git_commit(defmsg);
        }
 
        strbuf_release(&mebuf);
        free_message(&msg);
-
-       if (res)
-               return 1;
-
-       if (!no_commit) {
-               res = run_git_commit(defmsg);
-               free(defmsg);
-               return res;
-       }
-
        free(defmsg);
 
-       return 0;
+       return res;
 }
 
 static void prepare_revs(struct rev_info *revs)