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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Feb 11, 2010 at 16:08 UTC
97915544f84132b210a336d5877fafd7cb104abe
1 file changed
+7
-7
builtin-revert.c
+7
-7
@@ -38,6 +38,7 @@ static const char * const cherry_pick_usage[] = {
38
static int edit, no_replay, no_commit, mainline, signoff;
39
static enum { REVERT, CHERRY_PICK } action;
40
static struct commit *commit;
41
+static const char *commit_name;
42
static int allow_rerere_auto;
43
44
static const char *me;
@@ -49,7 +50,6 @@ static void parse_args(int argc, const char **argv)
50
const char * const * usage_str =
51
action == REVERT ? revert_usage : cherry_pick_usage;
52
unsigned char sha1[20];
52
- const char *arg;
53
int noop;
54
struct option options[] = {
55
OPT_BOOLEAN('n', "no-commit", &no_commit, "don't automatically commit"),
@@ -64,10 +64,10 @@ static void parse_args(int argc, const char **argv)
64
65
if (parse_options(argc, argv, NULL, options, usage_str, 0) != 1)
66
usage_with_options(usage_str, options);
67
- arg = argv[0];
67
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);
71
commit = lookup_commit_reference(sha1);
72
if (!commit)
73
exit(1);
@@ -198,7 +198,7 @@ static void set_author_ident_env(const char *message)
198
sha1_to_hex(commit->object.sha1));
199
}
200
201
-static char *help_msg(const unsigned char *sha1)
201
+static char *help_msg(const char *name)
202
{
203
struct strbuf helpbuf = STRBUF_INIT;
204
char *msg = getenv("GIT_CHERRY_PICK_HELP");
@@ -214,7 +214,7 @@ static char *help_msg(const unsigned char *sha1)
214
strbuf_addf(&helpbuf,
215
" When committing, use the option '-c %s'\n"
216
"to retain authorship and message.",
217
- find_unique_abbrev(sha1, DEFAULT_ABBREV));
217
+ name);
218
}
219
return strbuf_detach(&helpbuf, NULL);
220
}
@@ -403,7 +403,7 @@ static int revert_or_cherry_pick(int argc, const char **argv)
403
if (commit_lock_file(&msg_file) < 0)
404
die ("Error wrapping up %s", defmsg);
405
fprintf(stderr, "Automatic %s failed.%s\n",
406
- me, help_msg(commit->object.sha1));
406
+ me, help_msg(commit_name));
407
rerere(allow_rerere_auto);
408
exit(1);
409
}