rev-parse(1): logically group options
[gitweb.git] / sequencer.c
index cf8fbeb8d5ac2b6ca3b498f2115c02eeea22910a..f7be7d8be66992567fe2140c6aecdd3cc6140d38 100644 (file)
@@ -474,7 +474,7 @@ static int do_pick_commit(struct commit *commit, struct replay_opts *opts)
        struct commit_message msg = { NULL, NULL, NULL, NULL, NULL };
        char *defmsg = NULL;
        struct strbuf msgbuf = STRBUF_INIT;
-       int res, unborn = 0;
+       int res, unborn = 0, allow;
 
        if (opts->no_commit) {
                /*
@@ -624,14 +624,18 @@ static int do_pick_commit(struct commit *commit, struct replay_opts *opts)
                      msg.subject);
                print_advice(res == 1, opts);
                rerere(opts->allow_rerere_auto);
-       } else {
-               int allow = allow_empty(opts, commit);
-               if (allow < 0)
-                       return allow;
-               if (!opts->no_commit)
-                       res = run_git_commit(defmsg, opts, allow);
+               goto leave;
+       }
+
+       allow = allow_empty(opts, commit);
+       if (allow < 0) {
+               res = allow;
+               goto leave;
        }
+       if (!opts->no_commit)
+               res = run_git_commit(defmsg, opts, allow);
 
+leave:
        free_message(&msg);
        free(defmsg);
 
@@ -1077,10 +1081,10 @@ int sequencer_pick_revisions(struct replay_opts *opts)
                        continue;
 
                if (!get_sha1(name, sha1)) {
-                       enum object_type type = sha1_object_info(sha1, NULL);
-
-                       if (type > 0 && type != OBJ_COMMIT)
+                       if (!lookup_commit_reference_gently(sha1, 1)) {
+                               enum object_type type = sha1_object_info(sha1, NULL);
                                die(_("%s: can't cherry-pick a %s"), name, typename(type));
+                       }
                } else
                        die(_("%s: bad revision"), name);
        }