git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v4 07/11] Deprecate support for .git/info/grafts

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Apr 21, 2018, 09:49 UTC
Message-ID
<1d96f3e3aad44df4d0dd93863d5d1a5157e38999.1524303776.git.johannes.schindelin@gmx.de>
In-Reply-To
<cover.1524303776.git.johannes.schindelin@gmx.de>

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>
---
 advice.c                  |  2 ++
 advice.h                  |  1 +
 commit.c                  | 10 ++++++++++
 t/t6001-rev-list-graft.sh |  9 +++++++++
 4 files changed, 22 insertions(+)
diff --git a/advice.c b/advice.c
index 406efc183ba..4411704fd45 100644
--- a/advice.c
+++ b/advice.c
@@ -19,6 +19,7 @@ int advice_rm_hints = 1;
 int advice_add_embedded_repo = 1;
 int advice_ignored_hook = 1;
 int advice_waiting_for_editor = 1;
+int advice_graft_file_deprecated = 1;
 
 static struct {
 	const char *name;
@@ -42,6 +43,7 @@ static struct {
 	{ "addembeddedrepo", &advice_add_embedded_repo },
 	{ "ignoredhook", &advice_ignored_hook },
 	{ "waitingforeditor", &advice_waiting_for_editor },
+	{ "graftfiledeprecated", &advice_graft_file_deprecated },
 
 	/* make this an alias for backward compatibility */
 	{ "pushnonfastforward", &advice_push_update_rejected }
diff --git a/advice.h b/advice.h
index 70568fa7922..9f5064e82a8 100644
--- a/advice.h
+++ b/advice.h
@@ -21,6 +21,7 @@ extern int advice_rm_hints;
 extern int advice_add_embedded_repo;
 extern int advice_ignored_hook;
 extern int advice_waiting_for_editor;
+extern int advice_graft_file_deprecated;
 
 int git_default_advice_config(const char *var, const char *value);
 __attribute__((format (printf, 1, 2)))
diff --git a/commit.c b/commit.c
index 2952ec987c5..451d3ce8dfe 100644
--- a/commit.c
+++ b/commit.c
@@ -12,6 +12,7 @@
 #include "prio-queue.h"
 #include "sha1-lookup.h"
 #include "wt-status.h"
+#include "advice.h"
 
 static struct commit_extra_header *read_commit_extra_header_lines(const char *buf, size_t len, const char **);
 
@@ -176,6 +177,15 @@ static int read_graft_file(const char *graft_file)
 	struct strbuf buf = STRBUF_INIT;
 	if (!fp)
 		return -1;
+	if (advice_graft_file_deprecated)
+		advise(_("Support for <GIT_DIR>/info/grafts is deprecated\n"
+			 "and will be removed in a future Git version.\n"
+			 "\n"
+			 "Please use \"git replace --convert-graft-file\"\n"
+			 "to convert the grafts into replace refs.\n"
+			 "\n"
+			 "Turn this message off by running\n"
+			 "\"git config advice.graftFileDeprecated false\""));
 	while (!strbuf_getwholeline(&buf, fp, '\n')) {
 		/* The format is just "Commit Parent1 Parent2 ...\n" */
 		struct commit_graft *graft = read_graft_line(&buf);
diff --git a/t/t6001-rev-list-graft.sh b/t/t6001-rev-list-graft.sh
index 05ddc69cf2a..7504ba47511 100755
--- a/t/t6001-rev-list-graft.sh
+++ b/t/t6001-rev-list-graft.sh
@@ -110,4 +110,13 @@ do
 	"
 
 done
+
+test_expect_success 'show advice that grafts are deprecated' '
+	git show HEAD 2>err &&
+	test_i18ngrep "git replace" err &&
+	test_config advice.graftFileDeprecated false &&
+	git show HEAD 2>err &&
+	test_i18ngrep ! "git replace" err
+'
+
 test_done
-- 
2.17.0.windows.1.15.gaa56ade3205
Previous: Johannes SchindelinNext: Johannes Schindelin
Message 61 of 115 in “Deprecate support for .git/info/grafts”
  1. Deprecate support for .git/info/graftsJohannes Schindelin, Apr 13, 2018
  2. Stefan BellerApr 13, 2018
  3. Johannes SchindelinApr 13, 2018
  4. Stefan BellerApr 13, 2018
  5. Johannes SchindelinApr 19, 2018
  6. Eric SunshineApr 13, 2018
  7. Johannes SchindelinApr 19, 2018
  8. 0/7 Deprecate .git/info/graftsJohannes Schindelin, Apr 19, 2018
  9. 1/7 replace: "libify" create_graft()Johannes Schindelin, Apr 19, 2018
  10. Junio C HamanoApr 20, 2018
  11. Jakub NarebskiApr 20, 2018
  12. Johannes SchindelinApr 20, 2018
  13. 2/7 replace: introduce --convert-graft-fileJohannes Schindelin, Apr 19, 2018
  14. Christian CouderApr 19, 2018
  15. Johannes SchindelinApr 20, 2018
  16. Junio C HamanoApr 20, 2018
  17. Johannes SchindelinApr 20, 2018
  18. 3/7 Add a test for `git replace --convert-graft-file`Johannes Schindelin, Apr 19, 2018
  19. Junio C HamanoApr 20, 2018
  20. Johannes SchindelinApr 20, 2018
  21. 4/7 Deprecate support for .git/info/graftsJohannes Schindelin, Apr 19, 2018
  22. 5/7 filter-branch: stop suggesting to use graftsJohannes Schindelin, Apr 19, 2018
  23. 6/7 technical/shallow: describe the relationship with replace refsJohannes Schindelin, Apr 19, 2018
  24. 7/7 technical/shallow: describe why shallow cannot use replace refsJohannes Schindelin, Apr 19, 2018
  25. 00/11 Deprecate .git/info/graftsJohannes Schindelin, Apr 20, 2018
  26. 01/11 argv_array: offer to split a string by whitespaceJohannes Schindelin, Apr 20, 2018
  27. Stefan BellerApr 20, 2018
  28. Johannes SchindelinApr 21, 2018
  29. 02/11 commit: Let the callback of for_each_mergetag return on errorJohannes Schindelin, Apr 20, 2018
  30. 03/11 replace: avoid using die() to indicate a bugJohannes Schindelin, Apr 20, 2018
  31. 04/11 replace: "libify" create_graft() and calleesJohannes Schindelin, Apr 20, 2018
  32. 05/11 replace: introduce --convert-graft-fileJohannes Schindelin, Apr 20, 2018
  33. 06/11 Add a test for `git replace --convert-graft-file`Johannes Schindelin, Apr 20, 2018
  34. SZEDER GáborApr 21, 2018
  35. Johannes SchindelinApr 21, 2018
  36. 07/11 Deprecate support for .git/info/graftsJohannes Schindelin, Apr 20, 2018
  37. 08/11 filter-branch: stop suggesting to use graftsJohannes Schindelin, Apr 20, 2018
  38. 09/11 technical/shallow: describe the relationship with replace refsJohannes Schindelin, Apr 20, 2018
  39. Philip OakleyApr 22, 2018
  40. Johannes SchindelinApr 24, 2018
  41. Philip OakleyApr 24, 2018
  42. Junio C HamanoApr 25, 2018
  43. Johannes SchindelinApr 25, 2018
  44. 10/11 technical/shallow: describe why shallow cannot use replace refsJohannes Schindelin, Apr 20, 2018
  45. 11/11 Remove obsolete script to convert grafts to replace refsJohannes Schindelin, Apr 20, 2018
  46. 00/11 Deprecate .git/info/graftsJohannes Schindelin, Apr 21, 2018
  47. 01/11 argv_array: offer to split a string by whitespaceJohannes Schindelin, Apr 21, 2018
  48. Junio C HamanoApr 24, 2018
  49. Junio C HamanoApr 24, 2018
  50. 02/11 commit: Let the callback of for_each_mergetag return on errorJohannes Schindelin, Apr 21, 2018
  51. 03/11 replace: avoid using die() to indicate a bugJohannes Schindelin, Apr 21, 2018
  52. 04/11 replace: "libify" create_graft() and calleesJohannes Schindelin, Apr 21, 2018
  53. Stefan BellerApr 23, 2018
  54. Johannes SchindelinApr 24, 2018
  55. Stefan BellerApr 24, 2018
  56. Johannes SchindelinApr 25, 2018
  57. 05/11 replace: introduce --convert-graft-fileJohannes Schindelin, Apr 21, 2018
  58. Eric SunshineApr 22, 2018
  59. Johannes SchindelinApr 24, 2018
  60. 06/11 Add a test for `git replace --convert-graft-file`Johannes Schindelin, Apr 21, 2018
  61. 07/11 Deprecate support for .git/info/graftsJohannes Schindelin, Apr 21, 2018
  62. 08/11 filter-branch: stop suggesting to use graftsJohannes Schindelin, Apr 21, 2018
  63. 09/11 technical/shallow: describe the relationship with replace refsJohannes Schindelin, Apr 21, 2018
  64. 10/11 technical/shallow: describe why shallow cannot use replace refsJohannes Schindelin, Apr 21, 2018
  65. 11/11 Remove obsolete script to convert grafts to replace refsJohannes Schindelin, Apr 21, 2018
  66. Stefan BellerApr 23, 2018
  67. 00/11 Deprecate .git/info/graftsJohannes Schindelin, Apr 25, 2018
  68. 01/11 argv_array: offer to split a string by whitespaceJohannes Schindelin, Apr 25, 2018
  69. 03/11 replace: avoid using die() to indicate a bugJohannes Schindelin, Apr 25, 2018
  70. 05/11 replace: introduce --convert-graft-fileJohannes Schindelin, Apr 25, 2018
  71. 02/11 commit: Let the callback of for_each_mergetag return on errorJohannes Schindelin, Apr 25, 2018
  72. 04/11 replace: "libify" create_graft() and calleesJohannes Schindelin, Apr 25, 2018
  73. 07/11 Deprecate support for .git/info/graftsJohannes Schindelin, Apr 25, 2018
  74. 06/11 Add a test for `git replace --convert-graft-file`Johannes Schindelin, Apr 25, 2018
  75. 08/11 filter-branch: stop suggesting to use graftsJohannes Schindelin, Apr 25, 2018
  76. 09/11 technical/shallow: stop referring to graftsJohannes Schindelin, Apr 25, 2018
  77. Jakub NarębskiApr 25, 2018
  78. Johannes SchindelinApr 26, 2018
  79. 11/11 Remove obsolete script to convert grafts to replace refsJohannes Schindelin, Apr 25, 2018
  80. 10/11 technical/shallow: describe why shallow cannot use replace refsJohannes Schindelin, Apr 25, 2018
  81. Junio C HamanoApr 26, 2018
  82. Johannes SchindelinApr 27, 2018
  83. 00/11 Deprecate .git/info/graftsJohannes Schindelin, Apr 27, 2018
  84. 01/11 argv_array: offer to split a string by whitespaceJohannes Schindelin, Apr 27, 2018
  85. 02/11 commit: Let the callback of for_each_mergetag return on errorJohannes Schindelin, Apr 27, 2018
  86. 03/11 replace: avoid using die() to indicate a bugJohannes Schindelin, Apr 27, 2018
  87. 04/11 replace: "libify" create_graft() and calleesJohannes Schindelin, Apr 27, 2018
  88. 05/11 replace: introduce --convert-graft-fileJohannes Schindelin, Apr 27, 2018
  89. 06/11 Add a test for `git replace --convert-graft-file`Johannes Schindelin, Apr 27, 2018
  90. SZEDER GáborApr 28, 2018
  91. Johannes SchindelinApr 28, 2018
  92. 07/11 Deprecate support for .git/info/graftsJohannes Schindelin, Apr 27, 2018
  93. 08/11 filter-branch: stop suggesting to use graftsJohannes Schindelin, Apr 27, 2018
  94. 09/11 technical/shallow: stop referring to graftsJohannes Schindelin, Apr 27, 2018
  95. 10/11 technical/shallow: describe why shallow cannot use replace refsJohannes Schindelin, Apr 27, 2018
  96. 11/11 Remove obsolete script to convert grafts to replace refsJohannes Schindelin, Apr 27, 2018
  97. Philip OakleyApr 28, 2018
  98. Johannes SchindelinApr 28, 2018
  99. Stefan BellerApr 28, 2018
  100. 00/12 Deprecate .git/info/graftsJohannes Schindelin, Apr 28, 2018
  101. 01/12 argv_array: offer to split a string by whitespaceJohannes Schindelin, Apr 28, 2018
  102. 02/12 commit: Let the callback of for_each_mergetag return on errorJohannes Schindelin, Apr 28, 2018
  103. 03/12 replace: avoid using die() to indicate a bugJohannes Schindelin, Apr 28, 2018
  104. 04/12 replace: "libify" create_graft() and calleesJohannes Schindelin, Apr 28, 2018
  105. 05/12 replace: prepare create_graft() for converting graft files wholesaleJohannes Schindelin, Apr 28, 2018
  106. 06/12 replace: introduce --convert-graft-fileJohannes Schindelin, Apr 28, 2018
  107. 07/12 Add a test for `git replace --convert-graft-file`Johannes Schindelin, Apr 28, 2018
  108. 08/12 Deprecate support for .git/info/graftsJohannes Schindelin, Apr 28, 2018
  109. advice: don't pointlessly suggest --convert-graft-fileÆvar Arnfjörð Bjarmason, Nov 27, 2018
  110. Junio C HamanoNov 28, 2018
  111. Johannes SchindelinNov 28, 2018
  112. 09/12 filter-branch: stop suggesting to use graftsJohannes Schindelin, Apr 28, 2018
  113. 10/12 technical/shallow: stop referring to graftsJohannes Schindelin, Apr 28, 2018
  114. 11/12 technical/shallow: describe why shallow cannot use replace refsJohannes Schindelin, Apr 28, 2018
  115. 12/12 Remove obsolete script to convert grafts to replace refsJohannes Schindelin, Apr 28, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.