Skip to content

Commit

Permalink
Updating the custom git-subtree script to current version (#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
BobaFetters authored Dec 1, 2023
1 parent b48030c commit e35ab39
Showing 1 changed file with 27 additions and 16 deletions.
43 changes: 27 additions & 16 deletions git-subtree.sh
Original file line number Diff line number Diff line change
Expand Up @@ -778,16 +778,20 @@ ensure_valid_ref_format () {
die "fatal: '$1' does not look like a ref"
}

# Usage: check if a commit from another subtree should be ignored from processing for splits
should_ignore_subtree_commit () {
if [ "$(git log -1 --grep="git-subtree-dir:" $1)" ]
then
if [[ -z "$(git log -1 --grep="git-subtree-mainline:" $1)" && -z "$(git log -1 --grep="git-subtree-dir: $dir$" $1)" ]]
then
return 0
fi
fi
return 1
# Usage: check if a commit from another subtree should be
# ignored from processing for splits
should_ignore_subtree_split_commit () {
assert test $# = 1
local rev="$1"
if test -n "$(git log -1 --grep="git-subtree-dir:" $rev)"
then
if test -z "$(git log -1 --grep="git-subtree-mainline:" $rev)" &&
test -z "$(git log -1 --grep="git-subtree-dir: $arg_prefix$" $rev)"
then
return 0
fi
fi
return 1
}

# Usage: process_split_commit REV PARENTS
Expand All @@ -796,11 +800,6 @@ process_split_commit () {
local rev="$1"
local parents="$2"

if should_ignore_subtree_commit $rev
then
return
fi

if test $indent -eq 0
then
revcount=$(($revcount + 1))
Expand Down Expand Up @@ -980,7 +979,19 @@ cmd_split () {
eval "$grl" |
while read rev parents
do
process_split_commit "$rev" "$parents"
if should_ignore_subtree_split_commit "$rev"
then
continue
fi
parsedparents=''
for parent in $parents
do
if ! should_ignore_subtree_split_commit "$parent"
then
parsedparents="$parsedparents$parent "
fi
done
process_split_commit "$rev" "$parsedparents"
done || exit $?

latest_new=$(cache_get latest_new) || exit $?
Expand Down

0 comments on commit e35ab39

Please sign in to comment.