]> git.ipfire.org Git - thirdparty/git.git/commitdiff
git-subtree: Bail out if we find output from Rust rewrite
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 6 Jul 2026 11:58:15 +0000 (12:58 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 6 Jul 2026 14:36:38 +0000 (07:36 -0700)
This is going to be forward compatible, but not backward compatible:
projects are expected to adopt the new tool, but not go back to this
old one.

CC: Colin Stagner <ask+git@howdoi.land>
CC: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/subtree/git-subtree.sh

index 791fd8260c470395ead376d1c2556f610b64c3a8..e9c7ca7cf513b1f1a088ee2719d58342c57cd9e1 100755 (executable)
@@ -278,6 +278,20 @@ main () {
        "cmd_$arg_command" "$@"
 }
 
+# Usage: reject_if_v2_config REV
+#
+# Bails if we find .git-subtree/config.  This file is used by the RIIR
+# git-subtree, which can read data from this script, but which generates
+# data that this script cannot cope with.  So if we find that the user's
+# project has already been processed with the new tool, we stop, to
+# avoid generating broken output.
+reject_if_v2_config () {
+       local config=.git-subtree/config
+       if git rev-parse --verify -q "$rev:$config"; then
+               die "fatal: tree contains $config: has been processed with new standalone (Rust) git-subtree; use that tool instead of this one.  See https://codeberg.org/diziet/git-subtree https://crates.io/crates/git-subtree"
+       fi
+}
+
 # Usage: cache_setup
 cache_setup () {
        assert test $# = 0
@@ -846,6 +860,7 @@ process_split_commit () {
 #    Or: cmd_add REPOSITORY REF
 cmd_add () {
 
+       reject_if_v2_config HEAD
        ensure_clean
 
        if test $# -eq 1
@@ -934,6 +949,8 @@ cmd_split () {
                die "fatal: you must provide exactly one revision, and optionally a repository.  Got: '$*'"
        fi
 
+       reject_if_v2_config "$rev"
+
        # Now validate prefix against the commit, not the working tree
        if ! git cat-file -e "$rev:$dir" 2>/dev/null
        then
@@ -1034,6 +1051,7 @@ cmd_merge () {
        then
                repository="$2"
        fi
+       reject_if_v2_config HEAD
        ensure_clean
 
        if test -n "$arg_addmerge_squash"