Skip to content

Commit f9f99b3

Browse files
dschogitster
authored andcommitted
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 4228e8b (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 <[email protected]> Reviewed-by: Stefan Beller <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0115e03 commit f9f99b3

File tree

4 files changed

+22
-0
lines changed

4 files changed

+22
-0
lines changed

advice.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ int advice_rm_hints = 1;
1919
int advice_add_embedded_repo = 1;
2020
int advice_ignored_hook = 1;
2121
int advice_waiting_for_editor = 1;
22+
int advice_graft_file_deprecated = 1;
2223

2324
static struct {
2425
const char *name;
@@ -42,6 +43,7 @@ static struct {
4243
{ "addembeddedrepo", &advice_add_embedded_repo },
4344
{ "ignoredhook", &advice_ignored_hook },
4445
{ "waitingforeditor", &advice_waiting_for_editor },
46+
{ "graftfiledeprecated", &advice_graft_file_deprecated },
4547

4648
/* make this an alias for backward compatibility */
4749
{ "pushnonfastforward", &advice_push_update_rejected }

advice.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ extern int advice_rm_hints;
2121
extern int advice_add_embedded_repo;
2222
extern int advice_ignored_hook;
2323
extern int advice_waiting_for_editor;
24+
extern int advice_graft_file_deprecated;
2425

2526
int git_default_advice_config(const char *var, const char *value);
2627
__attribute__((format (printf, 1, 2)))

commit.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "prio-queue.h"
1313
#include "sha1-lookup.h"
1414
#include "wt-status.h"
15+
#include "advice.h"
1516

1617
static struct commit_extra_header *read_commit_extra_header_lines(const char *buf, size_t len, const char **);
1718

@@ -176,6 +177,15 @@ static int read_graft_file(const char *graft_file)
176177
struct strbuf buf = STRBUF_INIT;
177178
if (!fp)
178179
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\""));
179189
while (!strbuf_getwholeline(&buf, fp, '\n')) {
180190
/* The format is just "Commit Parent1 Parent2 ...\n" */
181191
struct commit_graft *graft = read_graft_line(&buf);

t/t6001-rev-list-graft.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,13 @@ do
110110
"
111111

112112
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+
113122
test_done

0 commit comments

Comments
 (0)