Thread (27 messages) 27 messages, 3 authors, 2020-10-07

Re: [PATCH v2 5/7] subtree: add git subtree use and ignore commands

From: Johannes Schindelin <hidden>
Date: 2020-10-07 16:29:54

Hi Tom,

On Tue, 6 Oct 2020, Tom Clarkson via GitGitGadget wrote:
quoted hunk ↗ jump to hunk
@@ -796,20 +810,60 @@ cmd_add_commit () {
 }

 cmd_map () {
-	oldrev="$1"
-	newrev="$2"

-	if test -z "$oldrev"
+	if test -z "$1"
I'd like to keep the nice name. Maybe if it is `local`, there is no longer
a need to replace `$oldrev` by `$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
+
Would it not make more sense to validate the parameters before calling
`cmd_map`?

In any case, this strikes me like a subject for another commit.

Thanks,
Dscho

P.S.: I'll have to stop reviewing here for the moment, not sure whether
I'll come back to it later today or maybe tomorrow.

quoted hunk ↗ jump to hunk
 	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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help