[Resent the cover letter, as I did not see it on public-inbox...] It is fragile, as there is no way for the revision machinery to say "but now I want to traverse the graph ignoring the graft file" e.g. when pushing commits to a remote repository (which, as a consequence, can miss commits). And we already have a better solution with `git replace --graft <comit> [<parent>...]`. Changes since v6: - Made --convert-graft-file issue a mere warning (instead of an error) when a graft leaves the parents unchanged, and is hence unnecessary. - Modified the regression test for --convert-graft-file to succeed even when the GPG prerequisite is unmet (thanks, Gábor!). - Reassured by Stefan's feedback, I refrained from reinstating the contrib/ script. Johannes Schindelin (12): argv_array: offer to split a string by whitespace commit: Let the callback of for_each_mergetag return on error replace: avoid using die() to indicate a bug replace: "libify" create_graft() and callees replace: prepare create_graft() for converting graft files wholesale replace: introduce --convert-graft-file Add a test for `git replace --convert-graft-file` Deprecate support for .git/info/grafts filter-branch: stop suggesting to use grafts technical/shallow: stop referring to grafts technical/shallow: describe why shallow cannot use replace refs Remove obsolete script to convert grafts to replace refs Documentation/git-filter-branch.txt | 2 +- Documentation/git-replace.txt | 11 +- Documentation/technical/shallow.txt | 20 +- advice.c | 2 + advice.h | 1 + argv-array.c | 20 ++ argv-array.h | 2 + builtin/replace.c | 234 ++++++++++++++++------ commit.c | 18 +- commit.h | 4 +- contrib/convert-grafts-to-replace-refs.sh | 28 --- log-tree.c | 13 +- t/t6001-rev-list-graft.sh | 9 + t/t6050-replace.sh | 28 +++ 14 files changed, 274 insertions(+), 118 deletions(-) delete mode 100755 contrib/convert-grafts-to-replace-refs.sh base-commit: 1f1cddd558b54bb0ce19c8ace353fd07b758510d Published-As: https://github.com/dscho/git/releases/tag/deprecate-grafts-v7 Fetch-It-Via: git fetch https://github.com/dscho/git deprecate-grafts-v7 Interdiff vs v6: diff --git a/builtin/replace.c b/builtin/replace.c index 35394ec1874..a87fca045be 100644 --- a/builtin/replace.c +++ b/builtin/replace.c @@ -429,7 +429,7 @@ static int check_mergetags(struct commit *commit, int argc, const char **argv) return for_each_mergetag(check_one_mergetag, commit, &mergetag_data); } -static int create_graft(int argc, const char **argv, int force) +static int create_graft(int argc, const char **argv, int force, int gentle) { struct object_id old_oid, new_oid; const char *old_ref = argv[0]; @@ -471,8 +471,13 @@ static int create_graft(int argc, const char **argv, int force) strbuf_release(&buf); - if (!oidcmp(&old_oid, &new_oid)) + if (!oidcmp(&old_oid, &new_oid)) { + if (gentle) { + warning("graft for '%s' unnecessary", oid_to_hex(&old_oid)); + return 0; + } return error("new commit is the same as the old one: '%s'", oid_to_hex(&old_oid)); + } return replace_object_oid(old_ref, &old_oid, "replacement", &new_oid, force); } @@ -492,7 +497,7 @@ static int convert_graft_file(int force) continue; argv_array_split(&args, buf.buf); - if (args.argc && create_graft(args.argc, args.argv, force)) + if (args.argc && create_graft(args.argc, args.argv, force, 1)) strbuf_addf(&err, "\n\t%s", buf.buf); argv_array_clear(&args); } @@ -583,7 +588,7 @@ int cmd_replace(int argc, const char **argv, const char *prefix) if (argc < 1) usage_msg_opt("-g needs at least one argument", git_replace_usage, options); - return create_graft(argc, argv, force); + return create_graft(argc, argv, force, 0); case MODE_CONVERT_GRAFT_FILE: if (argc != 0) diff --git a/t/t6050-replace.sh b/t/t6050-replace.sh index bed86a0af3d..d174bfed309 100755 --- a/t/t6050-replace.sh +++ b/t/t6050-replace.sh @@ -445,6 +445,14 @@ test_expect_success GPG '--graft on a commit with a mergetag' ' ' test_expect_success '--convert-graft-file' ' + git checkout -b with-graft-file && + test_commit root2 && + git reset --hard root2^ && + test_commit root1 && + test_commit after-root1 && + test_tick && + git merge -m merge-root2 root2 && + : add and convert graft file && printf "%s\n%s %s\n\n# comment\n%s\n" \ $(git rev-parse HEAD^^ HEAD^ HEAD^^ HEAD^2) \ -- 2.17.0.windows.1.36.gdf4ca5fb72a