Skip to content

Commit 82352cb

Browse files
jaysoffiangitster
authored andcommitted
cherry-pick: do not give irrelevant advice when cherry-pick punted
If a cherry-pick did not even start because the working tree had local changes that would overlap with the operation, we shouldn't be advising the users to resolve conflicts nor to conclude it with "git commit". Signed-off-by: Jay Soffian <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9fa8aec commit 82352cb

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

builtin/revert.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ static void advise(const char *advice, ...)
223223
va_end(params);
224224
}
225225

226-
static void print_advice(void)
226+
static void print_advice(int show_hint)
227227
{
228228
char *msg = getenv("GIT_CHERRY_PICK_HELP");
229229

@@ -238,9 +238,11 @@ static void print_advice(void)
238238
return;
239239
}
240240

241-
advise("after resolving the conflicts, mark the corrected paths");
242-
advise("with 'git add <paths>' or 'git rm <paths>'");
243-
advise("and commit the result with 'git commit'");
241+
if (show_hint) {
242+
advise("after resolving the conflicts, mark the corrected paths");
243+
advise("with 'git add <paths>' or 'git rm <paths>'");
244+
advise("and commit the result with 'git commit'");
245+
}
244246
}
245247

246248
static void write_message(struct strbuf *msgbuf, const char *filename)
@@ -516,7 +518,7 @@ static int do_pick_commit(void)
516518
: _("could not apply %s... %s"),
517519
find_unique_abbrev(commit->object.sha1, DEFAULT_ABBREV),
518520
msg.subject);
519-
print_advice();
521+
print_advice(res == 1);
520522
rerere(allow_rerere_auto);
521523
} else {
522524
if (!no_commit)

0 commit comments

Comments
 (0)