Skip to content

Commit 9791554

Browse files
peffgitster
authored andcommitted
cherry-pick: show commit name instead of sha1
When we have a conflict, we advise the user to do: git commit -c $sha1 This works fine, but is unnecessarily confusing and annoying for the user to type, when: git commit -c $the_thing_you_called_cherry_pick_with works just as well. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 08565bd commit 9791554

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

builtin-revert.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ static const char * const cherry_pick_usage[] = {
3838
static int edit, no_replay, no_commit, mainline, signoff;
3939
static enum { REVERT, CHERRY_PICK } action;
4040
static struct commit *commit;
41+
static const char *commit_name;
4142
static int allow_rerere_auto;
4243

4344
static const char *me;
@@ -49,7 +50,6 @@ static void parse_args(int argc, const char **argv)
4950
const char * const * usage_str =
5051
action == REVERT ? revert_usage : cherry_pick_usage;
5152
unsigned char sha1[20];
52-
const char *arg;
5353
int noop;
5454
struct option options[] = {
5555
OPT_BOOLEAN('n', "no-commit", &no_commit, "don't automatically commit"),
@@ -64,10 +64,10 @@ static void parse_args(int argc, const char **argv)
6464

6565
if (parse_options(argc, argv, NULL, options, usage_str, 0) != 1)
6666
usage_with_options(usage_str, options);
67-
arg = argv[0];
6867

69-
if (get_sha1(arg, sha1))
70-
die ("Cannot find '%s'", arg);
68+
commit_name = argv[0];
69+
if (get_sha1(commit_name, sha1))
70+
die ("Cannot find '%s'", commit_name);
7171
commit = lookup_commit_reference(sha1);
7272
if (!commit)
7373
exit(1);
@@ -198,7 +198,7 @@ static void set_author_ident_env(const char *message)
198198
sha1_to_hex(commit->object.sha1));
199199
}
200200

201-
static char *help_msg(const unsigned char *sha1)
201+
static char *help_msg(const char *name)
202202
{
203203
struct strbuf helpbuf = STRBUF_INIT;
204204
char *msg = getenv("GIT_CHERRY_PICK_HELP");
@@ -214,7 +214,7 @@ static char *help_msg(const unsigned char *sha1)
214214
strbuf_addf(&helpbuf,
215215
" When committing, use the option '-c %s'\n"
216216
"to retain authorship and message.",
217-
find_unique_abbrev(sha1, DEFAULT_ABBREV));
217+
name);
218218
}
219219
return strbuf_detach(&helpbuf, NULL);
220220
}
@@ -403,7 +403,7 @@ static int revert_or_cherry_pick(int argc, const char **argv)
403403
if (commit_lock_file(&msg_file) < 0)
404404
die ("Error wrapping up %s", defmsg);
405405
fprintf(stderr, "Automatic %s failed.%s\n",
406-
me, help_msg(commit->object.sha1));
406+
me, help_msg(commit_name));
407407
rerere(allow_rerere_auto);
408408
exit(1);
409409
}

0 commit comments

Comments
 (0)