Deprecate support for .git/info/grafts

The grafts feature was a convenient way to "stitch together" ancient history to the fresh start of linux.git. Its implementation is, however, not up to Git's standards, as there are too many ways where it can lead to surprising and unwelcome behavior. For example, when pushing from a repository with active grafts, it is possible to miss commits that have been "grafted out", resulting in a broken state on the other side. Also, the grafts feature is limited to "rewriting" commits' list of parents, it cannot replace anything else. The much younger feature implemented as `git replace` set out to remedy those limitations and dangerous bugs. Seeing as `git replace` is pretty mature by now (since 4228e8bc98 (replace: add --graft option, 2014-07-19) it can perform the graft file's duties), it is time to deprecate support for the graft file, and to retire it eventually. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Schindelin committed Apr 29, 2018 at 00:44 UTC f9f99b3f7d06716336b239bcf122eb5a7348bfd5
4 files changed +22
advice.c
+2
@@ -19,6 +19,7 @@ int advice_rm_hints = 1;
19 int advice_add_embedded_repo = 1;
20 int advice_ignored_hook = 1;
21 int advice_waiting_for_editor = 1;
22 +int advice_graft_file_deprecated = 1;
23
24 static struct {
25 const char *name;
@@ -42,6 +43,7 @@ static struct {
43 { "addembeddedrepo", &advice_add_embedded_repo },
44 { "ignoredhook", &advice_ignored_hook },
45 { "waitingforeditor", &advice_waiting_for_editor },
46 + { "graftfiledeprecated", &advice_graft_file_deprecated },
47
48 /* make this an alias for backward compatibility */
49 { "pushnonfastforward", &advice_push_update_rejected }
advice.h
+1
@@ -21,6 +21,7 @@ extern int advice_rm_hints;
21 extern int advice_add_embedded_repo;
22 extern int advice_ignored_hook;
23 extern int advice_waiting_for_editor;
24 +extern int advice_graft_file_deprecated;
25
26 int git_default_advice_config(const char *var, const char *value);
27 __attribute__((format (printf, 1, 2)))
commit.c
+10
@@ -12,6 +12,7 @@
12 #include "prio-queue.h"
13 #include "sha1-lookup.h"
14 #include "wt-status.h"
15 +#include "advice.h"
16
17 static struct commit_extra_header *read_commit_extra_header_lines(const char *buf, size_t len, const char **);
18
@@ -176,6 +177,15 @@ static int read_graft_file(const char *graft_file)
177 struct strbuf buf = STRBUF_INIT;
178 if (!fp)
179 return -1;
180 + if (advice_graft_file_deprecated)
181 + advise(_("Support for <GIT_DIR>/info/grafts is deprecated\n"
182 + "and will be removed in a future Git version.\n"
183 + "\n"
184 + "Please use \"git replace --convert-graft-file\"\n"
185 + "to convert the grafts into replace refs.\n"
186 + "\n"
187 + "Turn this message off by running\n"
188 + "\"git config advice.graftFileDeprecated false\""));
189 while (!strbuf_getwholeline(&buf, fp, '\n')) {
190 /* The format is just "Commit Parent1 Parent2 ...\n" */
191 struct commit_graft *graft = read_graft_line(&buf);
t/t6001-rev-list-graft.sh
+9
@@ -110,4 +110,13 @@ do
110 "
111
112 done
113 +
114 +test_expect_success 'show advice that grafts are deprecated' '
115 + git show HEAD 2>err &&
116 + test_i18ngrep "git replace" err &&
117 + test_config advice.graftFileDeprecated false &&
118 + git show HEAD 2>err &&
119 + test_i18ngrep ! "git replace" err
120 +'
121 +
122 test_done