From: Deskin Miller <deskinm@umich.edu>
To: git@vger.kernel.org
Cc: normalperson@yhbt.net, gitster@pobox.com,
Deskin Miller <deskinm@umich.edu>
Subject: [PATCH] git-svn: Make following parents atomic
Date: Sun, 7 Dec 2008 11:06:10 -0500 [thread overview]
Message-ID: <1228665970-21204-1-git-send-email-deskinm@umich.edu> (raw)
find_parent_branch generates branch@rev type branches when one has to
look back through SVN history to properly get the history for a branch
copied from somewhere not already being tracked by git-svn. If in the
process of fetching this history, git-svn is interrupted, then when one
fetches again, it will use whatever was last fetched as the parent
commit and fail to fetch any more history which it didn't get to before
being terminated. This is especially troubling in that different
git-svn copies of the same SVN repository can end up with different
commit sha1s, incorrectly showing the history as divergent and
precluding easy collaboration using git push and fetch.
To fix this, when we initialise the Git::SVN object $gs to search for
and perhaps fetch history, we check if there are any commits in SVN in
the range between the current revision $gs is at, and the top revision
for which we were asked to fill history. If there are commits we're
missing in that range, we continue the fetch from the current revision
to the top, properly getting all history before using it as the parent
for the branch we're trying to create.
Signed-off-by: Deskin Miller <deskinm@umich.edu>
---
Patch is based on maint.
This was a nasty bug that took some work to figure out; I knew two
git-svn copies had diverged, but though I could look at the commits
where they diverged there was no good way to figure out what git-svn had
been doing at that point. I ended up writing a script to automate the
process and save information for me to analyse later; I'll be posting an
announcement with further explanation, but the repository is available
at
git://git.deskinm.fdns.net/git-svn-bugfix.git
Deskin Miller
git-svn.perl | 14 +++++++++++---
t/t9104-git-svn-follow-parent.sh | 33 +++++++++++++++++++++++++++++++++
2 files changed, 44 insertions(+), 3 deletions(-)
diff --git a/git-svn.perl b/git-svn.perl
index 56238da..c53d864 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -2318,9 +2318,17 @@ sub find_parent_branch {
$gs = Git::SVN->init($u, $p, $repo_id, $ref_id, 1);
}
my ($r0, $parent) = $gs->find_rev_before($r, 1);
- if (!defined $r0 || !defined $parent) {
- my ($base, $head) = parse_revision_argument(0, $r);
- if ($base <= $r) {
+ {
+ my ($base, $head);
+ if (!defined $r0 || !defined $parent) {
+ ($base, $head) = parse_revision_argument(0, $r);
+ } else {
+ if ($r0 < $r) {
+ $gs->ra->get_log([$gs->{path}], $r0 + 1, $r, 1,
+ 0, 1, sub { $base = $_[1] - 1 });
+ }
+ }
+ if (defined $base && $base <= $r) {
$gs->fetch($base, $r);
}
($r0, $parent) = $gs->last_rev_commit;
diff --git a/t/t9104-git-svn-follow-parent.sh b/t/t9104-git-svn-follow-parent.sh
index 4d964e2..8e7b95b 100755
--- a/t/t9104-git-svn-follow-parent.sh
+++ b/t/t9104-git-svn-follow-parent.sh
@@ -149,6 +149,39 @@ test_expect_success "track initial change if it was only made to parent" '
"`git rev-parse r9270-d~1`"
'
+test_expect_success "follow-parent is atomic" '
+ cd wc &&
+ svn up &&
+ svn mkdir stunk &&
+ cd stunk &&
+ echo "trunk stunk" > readme &&
+ svn add readme &&
+ cd .. &&
+ svn ci -m "trunk stunk" &&
+ echo "stunk like junk" >> stunk/readme &&
+ svn ci -m "really stunk" &&
+ cd .. &&
+ svn copy -m "stunk flunked" "$svnrepo"/stunk "$svnrepo"/flunk &&
+ git svn init --minimize-url -i stunk "$svnrepo"/stunk &&
+ git svn fetch -i stunk &&
+ git update-ref refs/remotes/flunk@17 refs/remotes/stunk~1 &&
+ git update-ref -d refs/remotes/stunk &&
+ git config --unset svn-remote.svn.fetch stunk &&
+ mkdir -p "$GIT_DIR"/svn/flunk@17 &&
+ rev_map=$(cd "$GIT_DIR"/svn/stunk && ls .rev_map*) &&
+ dd if="$GIT_DIR"/svn/stunk/$rev_map \
+ of="$GIT_DIR"/svn/flunk@17/$rev_map bs=24 count=1 &&
+ rm -rf "$GIT_DIR"/svn/stunk &&
+ git svn init --minimize-url -i flunk "$svnrepo"/flunk &&
+ git svn fetch -i flunk &&
+ git svn init --minimize-url -i stunk "$svnrepo"/stunk &&
+ git svn fetch -i stunk &&
+ test "`git rev-parse --verify refs/remotes/flunk@17`" \
+ = "`git rev-parse --verify refs/remotes/stunk`" &&
+ test "`git rev-parse --verify refs/remotes/flunk~1`" \
+ = "`git rev-parse --verify refs/remotes/stunk`"
+ '
+
test_expect_success "track multi-parent paths" '
svn cp -m "resurrect /glob" "$svnrepo"/r9270 "$svnrepo"/glob &&
git-svn multi-fetch &&
--
1.6.1.rc1.45.g123ed
next reply other threads:[~2008-12-07 16:07 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-07 16:06 Deskin Miller [this message]
2008-12-07 16:10 ` [ANNOUNCE] git-svn-bugfix script (Re: [PATCH] git-svn: Make following parents atomic) Deskin Miller
2008-12-07 22:24 ` [PATCH] git-svn: Make following parents atomic Deskin Miller
2008-12-08 6:20 ` [PATCH v2] " Deskin Miller
2008-12-08 8:33 ` Junio C Hamano
2008-12-08 13:31 ` [PATCH v3] " Deskin Miller
2008-12-08 23:35 ` Eric Wong
2008-12-16 13:22 ` Thomas Jarosch
2008-12-22 8:41 ` Thomas Jarosch
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=1228665970-21204-1-git-send-email-deskinm@umich.edu \
--to=deskinm@umich.edu \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=normalperson@yhbt.net \
/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).