cherry-pick: format help message as strbuf
[gitweb.git] / builtin-revert.c
index 8ac86f09434d1dad830c924de8cadcef6705e1e5..77e4f4eed37d5ab320b6df95b76f9af776ca2fbb 100644 (file)
@@ -68,15 +68,9 @@ static void parse_args(int argc, const char **argv)
 
        if (get_sha1(arg, sha1))
                die ("Cannot find '%s'", arg);
-       commit = (struct commit *)parse_object(sha1);
+       commit = lookup_commit_reference(sha1);
        if (!commit)
-               die ("Could not find %s", sha1_to_hex(sha1));
-       if (commit->object.type == OBJ_TAG) {
-               commit = (struct commit *)
-                       deref_tag((struct object *)commit, arg, strlen(arg));
-       }
-       if (commit->object.type != OBJ_COMMIT)
-               die ("'%s' does not point to a commit", arg);
+               exit(1);
 }
 
 static char *get_oneline(const char *message)
@@ -206,23 +200,23 @@ static void set_author_ident_env(const char *message)
 
 static char *help_msg(const unsigned char *sha1)
 {
-       static char helpbuf[1024];
+       struct strbuf helpbuf = STRBUF_INIT;
        char *msg = getenv("GIT_CHERRY_PICK_HELP");
 
        if (msg)
                return msg;
 
-       strcpy(helpbuf, "  After resolving the conflicts,\n"
-              "mark the corrected paths with 'git add <paths>' "
-              "or 'git rm <paths>' and commit the result.");
+       strbuf_addstr(&helpbuf, "  After resolving the conflicts,\n"
+               "mark the corrected paths with 'git add <paths>' or 'git rm <paths>'\n"
+               "and commit the result.");
 
        if (action == CHERRY_PICK) {
-               sprintf(helpbuf + strlen(helpbuf),
-                       "\nWhen commiting, use the option "
-                       "'-c %s' to retain authorship and message.",
+               strbuf_addf(&helpbuf,
+                       "  When committing, use the option '-c %s'\n"
+                       "to retain authorship and message.",
                        find_unique_abbrev(sha1, DEFAULT_ABBREV));
        }
-       return helpbuf;
+       return strbuf_detach(&helpbuf, NULL);
 }
 
 static struct tree *empty_tree(void)