From: "Tom Clarkson via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Avery Pennarun <apenwarr@gmail.com>,
Ed Maste <emaste@freebsd.org>,
Johannes Schindelin <Johannes.Schindelin@gmx.de>,
Tom Clarkson <tom@tqclarkson.com>,
Tom Clarkson <tom@tqclarkson.com>
Subject: [PATCH v2 5/7] subtree: add git subtree use and ignore commands
Date: Tue, 06 Oct 2020 22:05:11 +0000 [thread overview]
Message-ID: <2d103292cecfef3b29d221b3d8f05adb0add4475.1602021913.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.493.v2.git.1602021913.gitgitgadget@gmail.com>
From: Tom Clarkson <tom@tqclarkson.com>
Tell split to use or ignore larger sections of the history. In most cases
split does this automatically based on metadata from subtree add.
Signed-off-by: Tom Clarkson <tom@tqclarkson.com>
---
contrib/subtree/git-subtree.sh | 78 ++++++++++++++++++++++++++++------
1 file changed, 66 insertions(+), 12 deletions(-)
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 1559100c0e..e56621a986 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -9,13 +9,15 @@ then
set -- -h
fi
OPTS_SPEC="\
-git subtree add --prefix=<prefix> <commit>
-git subtree add --prefix=<prefix> <repository> <ref>
-git subtree merge --prefix=<prefix> <commit>
-git subtree pull --prefix=<prefix> <repository> <ref>
-git subtree push --prefix=<prefix> <repository> <ref>
-git subtree split --prefix=<prefix> <commit>
-git subtree map --prefix=<prefix> <mainline> <subtree>
+git subtree add --prefix=<prefix> <commit>
+git subtree add --prefix=<prefix> <repository> <ref>
+git subtree merge --prefix=<prefix> <commit>
+git subtree pull --prefix=<prefix> <repository> <ref>
+git subtree push --prefix=<prefix> <repository> <ref>
+git subtree split --prefix=<prefix> <commit>
+git subtree map --prefix=<prefix> <mainline> <subtree>
+git subtree ignore --prefix=<prefix> <commit>
+git subtree use --prefix=<prefix> <commit>
--
h,help show the help
q quiet
@@ -162,7 +164,7 @@ command="$1"
shift
case "$command" in
-add|merge|pull|map)
+add|merge|pull|map|ignore|use)
default=
;;
split|push)
@@ -431,6 +433,18 @@ find_mainline_ref () {
done
}
+exclude_processed_refs () {
+ if test -r "$cachedir/processed"
+ then
+ cat "$cachedir/processed" |
+ while read rev
+ do
+ debug "read $rev"
+ echo "^$rev"
+ done
+ fi
+}
+
copy_commit () {
# We're going to set some environment vars here, so
# do it in a subshell to get rid of them safely later
@@ -796,20 +810,60 @@ cmd_add_commit () {
}
cmd_map () {
- oldrev="$1"
- newrev="$2"
- if test -z "$oldrev"
+ if test -z "$1"
then
die "You must provide a revision to map"
fi
+ oldrev=$(git rev-parse --revs-only "$1") || exit $?
+ newrev=
+
+ if test -n "$2"
+ then
+ newrev=$(git rev-parse --revs-only "$2") || exit $?
+ fi
+
cache_setup || exit $?
cache_set "$oldrev" "$newrev"
say "Mapped $oldrev => $newrev"
}
+cmd_ignore () {
+ revs=$(git rev-parse $default --revs-only "$@") || exit $?
+ ensure_single_rev $revs
+
+ say "Ignoring $revs"
+
+ cache_setup || exit $?
+
+ git rev-list $revs |
+ while read rev
+ do
+ cache_set "$rev" ""
+ done
+
+ echo "$revs" >>"$cachedir/processed"
+}
+
+cmd_use () {
+ revs=$(git rev-parse $default --revs-only "$@") || exit $?
+ ensure_single_rev $revs
+
+ say "Using existing subtree $revs"
+
+ cache_setup || exit $?
+
+ git rev-list $revs |
+ while read rev
+ do
+ cache_set "$rev" "$rev"
+ done
+
+ echo "$revs" >>"$cachedir/processed"
+}
+
cmd_split () {
debug "Splitting $dir..."
cache_setup || exit $?
@@ -827,7 +881,7 @@ cmd_split () {
done
fi
- unrevs="$(find_existing_splits "$dir" "$revs")"
+ unrevs="$(find_existing_splits "$dir" "$revs") $(exclude_processed_refs)"
mainline="$(find_mainline_ref "$dir" "$revs")"
if test -n "$mainline"
--
gitgitgadget
next prev parent reply other threads:[~2020-10-06 22:05 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-11 5:49 [PATCH 0/7] subtree: Fix handling of complex history Tom Clarkson via GitGitGadget
2020-05-11 5:49 ` [PATCH 1/7] subtree: handle multiple parents passed to cache_miss Tom Clarkson via GitGitGadget
2020-05-11 5:49 ` [PATCH 2/7] subtree: exclude commits predating add from recursive processing Tom Clarkson via GitGitGadget
2020-05-11 5:49 ` [PATCH 3/7] subtree: persist cache between split runs Tom Clarkson via GitGitGadget
2020-05-11 5:49 ` [PATCH 4/7] subtree: add git subtree map command Tom Clarkson via GitGitGadget
2020-05-11 5:49 ` [PATCH 5/7] subtree: add git subtree use and ignore commands Tom Clarkson via GitGitGadget
2020-05-11 5:50 ` [PATCH 6/7] subtree: more robustly distinguish subtree and mainline commits Tom Clarkson via GitGitGadget
2020-05-11 5:50 ` [PATCH 7/7] subtree: document new subtree commands Tom Clarkson via GitGitGadget
2020-10-04 17:52 ` [PATCH 0/7] subtree: Fix handling of complex history Ed Maste
2020-10-04 19:27 ` Johannes Schindelin
2020-10-05 16:47 ` Junio C Hamano
2020-10-05 21:37 ` Ed Maste
2020-10-07 16:31 ` Johannes Schindelin
2020-10-06 22:05 ` [PATCH v2 " Tom Clarkson via GitGitGadget
2020-10-06 22:05 ` [PATCH v2 1/7] subtree: handle multiple parents passed to cache_miss Tom Clarkson via GitGitGadget
2020-10-07 13:12 ` Ed Maste
2020-10-06 22:05 ` [PATCH v2 2/7] subtree: exclude commits predating add from recursive processing Tom Clarkson via GitGitGadget
2020-10-07 15:36 ` Johannes Schindelin
2020-10-06 22:05 ` [PATCH v2 3/7] subtree: persist cache between split runs Tom Clarkson via GitGitGadget
2020-10-07 16:06 ` Johannes Schindelin
2020-10-06 22:05 ` [PATCH v2 4/7] subtree: add git subtree map command Tom Clarkson via GitGitGadget
2020-10-06 22:05 ` Tom Clarkson via GitGitGadget [this message]
2020-10-07 16:29 ` [PATCH v2 5/7] subtree: add git subtree use and ignore commands Johannes Schindelin
2020-10-06 22:05 ` [PATCH v2 6/7] subtree: more robustly distinguish subtree and mainline commits Tom Clarkson via GitGitGadget
2020-10-07 19:42 ` Johannes Schindelin
2020-10-06 22:05 ` [PATCH v2 7/7] subtree: document new subtree commands Tom Clarkson via GitGitGadget
2020-10-07 19:43 ` Johannes Schindelin
2020-10-07 19:46 ` [PATCH v2 0/7] subtree: Fix handling of complex history Johannes Schindelin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2d103292cecfef3b29d221b3d8f05adb0add4475.1602021913.git.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=apenwarr@gmail.com \
--cc=emaste@freebsd.org \
--cc=git@vger.kernel.org \
--cc=tom@tqclarkson.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).