advice: don't pointlessly suggest --convert-graft-file

The advice to run 'git replace --convert-graft-file' added in f9f99b3f7d ("Deprecate support for .git/info/grafts", 2018-04-29) didn't add an exception for the 'git replace --convert-graft-file' codepath itself. As a result we'd suggest running --convert-graft-file while the user was running --convert-graft-file, which makes no sense. Before: $ git replace --convert-graft-file hint: Support for <GIT_DIR>/info/grafts is deprecated hint: and will be removed in a future Git version. hint: hint: Please use "git replace --convert-graft-file" hint: to convert the grafts into replace refs. hint: hint: Turn this message off by running hint: "git config advice.graftFileDeprecated false" Add a check for that case and skip printing the advice while the user is busy following our advice. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Nov 27, 2018 at 21:12 UTC 8821e90a09a6b86b92213882f3b9945bc21b94d1
2 files changed +5 -1
builtin/replace.c
+1
@@ -495,6 +495,7 @@ static int convert_graft_file(int force)
495 if (!fp)
496 return -1;
497
498 + advice_graft_file_deprecated = 0;
499 while (strbuf_getline(&buf, fp) != EOF) {
500 if (*buf.buf == '#')
501 continue;
t/t6050-replace.sh
+4 -1
@@ -461,7 +461,10 @@ test_expect_success '--convert-graft-file' '
461 printf "%s\n%s %s\n\n# comment\n%s\n" \
462 $(git rev-parse HEAD^^ HEAD^ HEAD^^ HEAD^2) \
463 >.git/info/grafts &&
464 - git replace --convert-graft-file &&
464 + git status 2>stderr &&
465 + test_i18ngrep "hint:.*grafts is deprecated" stderr &&
466 + git replace --convert-graft-file 2>stderr &&
467 + test_i18ngrep ! "hint:.*grafts is deprecated" stderr &&
468 test_path_is_missing .git/info/grafts &&
469
470 : verify that the history is now "grafted" &&