Skip to content

Commit

Permalink
Merge branch 'ph/cherry-pick-advice-refinement'
Browse files Browse the repository at this point in the history
* ph/cherry-pick-advice-refinement:
  cherry-pick: No advice to commit if --no-commit
  • Loading branch information
Junio C Hamano committed Feb 28, 2012
2 parents 524ee67 + ed727b1 commit 4d50dbc
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
17 changes: 11 additions & 6 deletions sequencer.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ static void write_cherry_pick_head(struct commit *commit, const char *pseudoref)
strbuf_release(&buf);
}

static void print_advice(int show_hint)
static void print_advice(int show_hint, struct replay_opts *opts)
{
char *msg = getenv("GIT_CHERRY_PICK_HELP");

Expand All @@ -138,10 +138,15 @@ static void print_advice(int show_hint)
return;
}

if (show_hint)
advise(_("after resolving the conflicts, mark the corrected paths\n"
"with 'git add <paths>' or 'git rm <paths>'\n"
"and commit the result with 'git commit'"));
if (show_hint) {
if (opts->no_commit)
advise(_("after resolving the conflicts, mark the corrected paths\n"
"with 'git add <paths>' or 'git rm <paths>'"));
else
advise(_("after resolving the conflicts, mark the corrected paths\n"
"with 'git add <paths>' or 'git rm <paths>'\n"
"and commit the result with 'git commit'"));
}
}

static void write_message(struct strbuf *msgbuf, const char *filename)
Expand Down Expand Up @@ -423,7 +428,7 @@ static int do_pick_commit(struct commit *commit, struct replay_opts *opts)
: _("could not apply %s... %s"),
find_unique_abbrev(commit->object.sha1, DEFAULT_ABBREV),
msg.subject);
print_advice(res == 1);
print_advice(res == 1, opts);
rerere(opts->allow_rerere_auto);
} else {
if (!opts->no_commit)
Expand Down
14 changes: 14 additions & 0 deletions t/t3507-cherry-pick-conflict.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,20 @@ test_expect_success 'advice from failed cherry-pick' "
test_i18ncmp expected actual
"

test_expect_success 'advice from failed cherry-pick --no-commit' "
pristine_detach initial &&
picked=\$(git rev-parse --short picked) &&
cat <<-EOF >expected &&
error: could not apply \$picked... picked
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'
EOF
test_must_fail git cherry-pick --no-commit picked 2>actual &&
test_i18ncmp expected actual
"

test_expect_success 'failed cherry-pick sets CHERRY_PICK_HEAD' '
pristine_detach initial &&
test_must_fail git cherry-pick picked &&
Expand Down

0 comments on commit 4d50dbc

Please sign in to comment.