git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Strain, Roger L" <roger.strain@swri.org>
To: <git@vger.kernel.org>
Cc: Jonathan Nieder <jrnieder@gmail.com>,
	Junio C Hamano <gitster@pobox.com>,
	Stephen R Guglielmo <srguglielmo@gmail.com>,
	"David A . Greene" <greened@obbligato.org>,
	Matthieu Moy <Matthieu.Moy@imag.fr>,
	Stephen R Guglielmo <srg@guglielmo.us>,
	Dave Ware <davidw@realtimegenomics.com>,
	David Aguilar <davvid@gmail.com>
Subject: [PATCH 3/4] subtree: use commits before rejoins for splits
Date: Fri, 28 Sep 2018 13:35:39 -0500	[thread overview]
Message-ID: <20180928183540.48968-4-roger.strain@swri.org> (raw)
In-Reply-To: <20180928183540.48968-1-roger.strain@swri.org>

Adds recursive evaluation of parent commits which were not part of the
initial commit list when performing a split.

Split expects all relevant commits to be reachable from the target commit
but not reachable from any previous rejoins. However, a branch could be
based on a commit prior to a rejoin, then later merged back into the
current code. In this case, a parent to the commit will not be present in
the initial list of commits, trigging an "incorrect order" warning.

Previous behavior was to consider that commit to have no parent, creating
an original commit containing all subtree content. This commit is not
present in an existing subtree commit graph, changing commit hashes and
making pushing to a subtree repo impossible.

New behavior will recursively check these unexpected parent commits to
track them back to either an earlier rejoin, or a true original commit.
The generated synthetic commits will properly match previously-generated
commits, allowing successful pushing to a prior subtree repo.

Signed-off-by: Strain, Roger L <roger.strain@swri.org>
---
 contrib/subtree/git-subtree.sh | 26 ++++++++++++++++++++------
 1 file changed, 20 insertions(+), 6 deletions(-)

diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index d8861f306..23dd04cbe 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -231,12 +231,14 @@ cache_miss () {
 }
 
 check_parents () {
-	missed=$(cache_miss "$@")
+	missed=$(cache_miss "$1")
+	local indent=$(($2 + 1))
 	for miss in $missed
 	do
 		if ! test -r "$cachedir/notree/$miss"
 		then
 			debug "  incorrect order: $miss"
+			process_split_commit "$miss" "" "$indent"
 		fi
 	done
 }
@@ -606,8 +608,20 @@ ensure_valid_ref_format () {
 process_split_commit () {
 	local rev="$1"
 	local parents="$2"
-	revcount=$(($revcount + 1))
-	progress "$revcount/$revmax ($createcount)"
+	local indent=$3
+
+	if test $indent -eq 0
+	then
+		revcount=$(($revcount + 1))
+	else
+		# processing commit without normal parent information;
+		# fetch from repo
+		parents=$(git show -s --pretty=%P "$rev")
+		extracount=$(($extracount + 1))
+	fi
+
+	progress "$revcount/$revmax ($createcount) [$extracount]"
+
 	debug "Processing commit: $rev"
 	exists=$(cache_get "$rev")
 	if test -n "$exists"
@@ -617,14 +631,13 @@ process_split_commit () {
 	fi
 	createcount=$(($createcount + 1))
 	debug "  parents: $parents"
+	check_parents "$parents" "$indent"
 	newparents=$(cache_get $parents)
 	debug "  newparents: $newparents"
 
 	tree=$(subtree_for_commit "$rev" "$dir")
 	debug "  tree is: $tree"
 
-	check_parents $parents
-
 	# ugly.  is there no better way to tell if this is a subtree
 	# vs. a mainline commit?  Does it matter?
 	if test -z "$tree"
@@ -744,10 +757,11 @@ cmd_split () {
 	revmax=$(eval "$grl" | wc -l)
 	revcount=0
 	createcount=0
+	extracount=0
 	eval "$grl" |
 	while read rev parents
 	do
-		process_split_commit "$rev" "$parents"
+		process_split_commit "$rev" "$parents" 0
 	done || exit $?
 
 	latest_new=$(cache_get latest_new)
-- 
2.19.0.windows.1


  parent reply	other threads:[~2018-09-28 18:35 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-28 18:56 [PATCH 0/4] Multiple subtree split fixes regarding complex repos Strain, Roger L
2018-09-28 18:35 ` [PATCH 1/4] subtree: refactor split of a commit into standalone method Strain, Roger L
2018-09-28 18:35 ` [PATCH 2/4] subtree: make --ignore-joins pay attention to adds Strain, Roger L
2018-09-28 18:35 ` Strain, Roger L [this message]
2018-09-28 18:35 ` [PATCH 4/4] subtree: improve decision on merges kept in split Strain, Roger L
2018-10-11 19:46 ` [PATCH v2 0/4] Multiple subtree split fixes regarding complex repos Roger Strain
2018-10-12  7:35   ` Junio C Hamano
2018-10-11 19:46 ` [PATCH v2 1/4] subtree: refactor split of a commit into standalone method Roger Strain
2018-10-11 19:46 ` [PATCH v2 2/4] subtree: make --ignore-joins pay attention to adds Roger Strain
2018-10-11 19:46 ` [PATCH v2 3/4] subtree: use commits before rejoins for splits Roger Strain
2018-10-11 19:46 ` [PATCH v2 4/4] subtree: improve decision on merges kept in split Roger Strain

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180928183540.48968-4-roger.strain@swri.org \
    --to=roger.strain@swri.org \
    --cc=Matthieu.Moy@imag.fr \
    --cc=davidw@realtimegenomics.com \
    --cc=davvid@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=greened@obbligato.org \
    --cc=jrnieder@gmail.com \
    --cc=srg@guglielmo.us \
    --cc=srguglielmo@gmail.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.
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 NNTP newsgroup(s).