Skip to content

Commit dd21d43

Browse files
roger-straingitster
authored andcommitted
subtree: make --ignore-joins pay attention to adds
Changes the behavior of --ignore-joins to always consider a subtree add commit, and ignore only splits and squashes. The --ignore-joins option is documented to ignore prior --rejoin commits. However, it additionally ignored subtree add commits generated when a subtree was initially added to a repo. Due to the logic which determines whether a commit is a mainline commit or a subtree commit (namely, the presence or absence of content in the subtree prefix) this causes commits before the initial add to appear to be part of the subtree. An --ignore-joins split would therefore consider those commits part of the subtree history and include them at the beginning of the synthetic history, causing the resulting hashes to be incorrect for all later commits. Signed-off-by: Strain, Roger L <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 565e4b7 commit dd21d43

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

contrib/subtree/git-subtree.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,12 @@ find_existing_splits () {
340340
revs="$2"
341341
main=
342342
sub=
343-
git log --grep="^git-subtree-dir: $dir/*\$" \
343+
local grep_format="^git-subtree-dir: $dir/*\$"
344+
if test -n "$ignore_joins"
345+
then
346+
grep_format="^Add '$dir/' from commit '"
347+
fi
348+
git log --grep="$grep_format" \
344349
--no-show-signature --pretty=format:'START %H%n%s%n%n%b%nEND%n' $revs |
345350
while read a b junk
346351
do
@@ -730,12 +735,7 @@ cmd_split () {
730735
done
731736
fi
732737

733-
if test -n "$ignore_joins"
734-
then
735-
unrevs=
736-
else
737-
unrevs="$(find_existing_splits "$dir" "$revs")"
738-
fi
738+
unrevs="$(find_existing_splits "$dir" "$revs")"
739739

740740
# We can't restrict rev-list to only $dir here, because some of our
741741
# parents have the $dir contents the root, and those won't match.

0 commit comments

Comments
 (0)