Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilippe Blain <levraiphilippeblain@gmail.com>2022-10-21 18:13:37 +0300
committerJunio C Hamano <gitster@pobox.com>2022-10-21 23:51:06 +0300
commitf10d31cf2d41fb892fbda1fb2b77dd518418c1a1 (patch)
tree9d5063c075d3017741c9615ff57ad7ce0a9a5803 /contrib/subtree
parent7990142eb1b6fdd60e87f63f003bc593fc105260 (diff)
subtree: process 'git-subtree-split' trailer in separate function
Both functions 'find_latest_squash' (called by 'git subtree merge --squash' and 'git subtree split --rejoin') and 'find_existing_splits' (called by git 'subtree split') loop through commits that have a 'git-subtree-dir' trailer, and then process the 'git-subtree-mainline' and 'git-subtree-split' trailers for those commits. The processing done for the 'git-subtree-split' trailer is simple: we check if the object exists with 'rev-parse' and set the variable 'sub' to the object name, or we die if the object does not exist. In a future commit we will add more steps to the processing of this trailer in order to make the code more robust. To reduce code duplication, move the processing of the 'git-subtree-split' trailer to a dedicated function, 'process_subtree_split_trailer'. Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'contrib/subtree')
-rwxr-xr-xcontrib/subtree/git-subtree.sh15
1 files changed, 11 insertions, 4 deletions
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 2b3c429991..b90ca0036f 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -371,6 +371,15 @@ try_remove_previous () {
fi
}
+# Usage: process_subtree_split_trailer SPLIT_HASH MAIN_HASH
+process_subtree_split_trailer () {
+ assert test $# = 2
+ b="$1"
+ sq="$2"
+ sub="$(git rev-parse --verify --quiet "$b^{commit}")" ||
+ die "fatal: could not rev-parse split hash $b from commit $sq"
+}
+
# Usage: find_latest_squash DIR
find_latest_squash () {
assert test $# = 1
@@ -395,8 +404,7 @@ find_latest_squash () {
main="$b"
;;
git-subtree-split:)
- sub="$(git rev-parse --verify --quiet "$b^{commit}")" ||
- die "fatal: could not rev-parse split hash $b from commit $sq"
+ process_subtree_split_trailer "$b" "$sq"
;;
END)
if test -n "$sub"
@@ -447,8 +455,7 @@ find_existing_splits () {
main="$b"
;;
git-subtree-split:)
- sub="$(git rev-parse --verify --quiet "$b^{commit}")" ||
- die "fatal: could not rev-parse split hash $b from commit $sq"
+ process_subtree_split_trailer "$b" "$sq"
;;
END)
debug "Main is: '$main'"