1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-06-02 05:56:11 +02:00
Commit Graph

576 Commits

Author SHA1 Message Date
Eric Wong 47092c1067 git-svn: lazy load some modules
We can delay loading some modules until we need them for uncommon
code paths.  For example, persistent memoization is not often
needed, so we can avoid loading the modules for it until we
encounter svn::mergeinfo during fetch.

This gives a tiny reduction in syscalls (from 15641 to 15305) when
running "git svn info" and counting via "strace -fc".  Further,
more invasive work will be needed to noticeably improve performance.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2015-02-26 20:19:21 +00:00
Ramkumar Ramachandra a94655dcfe git-svn: make it play nicely with submodules
It's a simple matter of opening the directory specified in the gitfile.

[ew: tweaked check to avoid open() on directories]

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Eric Wong <normalperson@yhbt.net>
2015-01-15 08:35:55 +00:00
Alfred Perlstein 83c9433e67 git-svn: support for git-svn propset
This change allows git-svn to support setting subversion properties.

It is useful for manually setting properties when committing to a
subversion repo that *requires* properties to be set without requiring
moving your changeset to separate subversion checkout in order to
set props.

This change is initially from David Fraser, appearing at:

  http://mid.gmane.org/1927112650.1281253084529659.JavaMail.root@klofta.sjsoft.com>

They are now forward-ported to most recent git along with fixes to
deal with files in subdirectories.

Style and functional changes from Eric Wong have been taken
in their entirety from:

  http://mid.gmane.org/20141201094911.GA13931@dcvr.yhbt.net

There is a nit to point out: the code does not support
adding props unless there are also content changes to the files as
well.  This is demonstrated in the testcase.

[ew - simplify Git.pm usage for check-attr
    - improve shell portability for tests
    - minor phrasing changes in commit message]

Signed-off-by: David Fraser <davidf@sjsoft.com>
Signed-off-by: Alfred Perlstein <alfred@freebsd.org>
Signed-off-by: Eric Wong <normalperson@yhbt.net>
2014-12-09 22:03:15 +00:00
Eric Wong 30d45f798d git-svn: delay term initialization
On my Debian 7 system, this fixes annoying warnings when the output
of "git svn" commands are redirected:

    Unable to get Terminal Size. The TIOCGWINSZ ioctl didn't work.
    The COLUMNS and LINES environment variables didn't work. The
    resize program didn't work.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2014-09-14 08:08:54 +00:00
Eric Wong a831a3fd86 git svn: find-rev allows short switches for near matches
Allow -B and -A to act as short aliases for --before and --after
options respectively.  This reduces typing and hopefully allows
reuse of muscle memory for grep(1) users.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2014-09-14 08:08:24 +00:00
Eric Wong 4950eed520 git svn: info: correctly handle absolute path args
Calling "git svn info $(pwd)" would hit:
  "Reading from filehandle failed at ..."
errors due to improper prefixing and canonicalization.

Strip the toplevel path from absolute filesystem paths to ensure
downstream canonicalization routines are only exposed to paths
tracked in git (or SVN).

v2:
  Thanks to Andrej Manduch for originally noticing the issue
  and fixing my original version of this to handle
  more corner cases such as "/path/to/top/../top" and
  "/path/to/top/../top/file" as shown in the new test cases.

v3:
  Fix pathname portability problems pointed out by Johannes Sixt
  with a hint from brian m. carlson.

Cc: Johannes Sixt <j6t@kdbg.org>
Cc: "brian m. carlson" <sandals@crustytoothpaste.net>
Signed-off-by: Andrej Manduch <amanduch@gmail.com>
Signed-off-by: Eric Wong <normalperson@yhbt.net>
2014-09-14 08:08:24 +00:00
Monard Vong 785a1c8258 git-svn: branch: avoid systematic prompt for cert/pass
Commands such as "git svn init/fetch/dcommit" do not prompt for client
certificate/password if they are stored in SVN config file.  Make
"git svn branch" consistent with the other commands, as SVN::Client is
capable of building its own authentication baton from information in the
SVN config directory.

Signed-off-by: Monard Vong <travelingsoul86@gmail.com>
Signed-off-by: Eric Wong <normalperson@yhbt.net>
2014-09-14 08:08:24 +00:00
Johan Herland fe191fcaa5 Git 2.0: git svn: Set default --prefix='origin/' if --prefix is not given
git-svn by default puts its Subversion-tracking refs directly in
refs/remotes/*. This runs counter to Git's convention of using
refs/remotes/$remote/* for storing remote-tracking branches.

Furthermore, combining git-svn with regular git remotes run the risk of
clobbering refs under refs/remotes (e.g. if you have a git remote
called "tags" with a "v1" branch, it will overlap with the git-svn's
tracking branch for the "v1" tag from Subversion.

Even though the git-svn refs stored in refs/remotes/* are not "proper"
remote-tracking branches (since they are not covered by a proper git
remote's refspec), they clearly represent a similar concept, and would
benefit from following the same convention.

For example, if git-svn tracks Subversion branch "foo" at
refs/remotes/foo, and you create a local branch refs/heads/foo to add
some commits to be pushed back to Subversion (using "git svn dcommit),
then it is clearly unhelpful of Git to throw

  warning: refname 'foo' is ambiguous.

every time you checkout, rebase, or otherwise interact with the branch.

The existing workaround for this is to supply the --prefix=quux/ to
git svn init/clone, so that git-svn's tracking branches end up in
refs/remotes/quux/* instead of refs/remotes/*. However, encouraging
users to specify --prefix to work around a design flaw in git-svn is
suboptimal, and not a long term solution to the problem. Instead,
git-svn should default to use a non-empty prefix that saves
unsuspecting users from the inconveniences described above.

This patch will only affect newly created git-svn setups, as the
--prefix option only applies to git svn init (and git svn clone).
Existing git-svn setups will continue with their existing (lack of)
prefix. Also, if anyone somehow prefers git-svn's old layout, they
can recreate that by explicitly passing an empty prefix (--prefix "")
on the git svn init/clone command line.

The patch changes the default value for --prefix from "" to "origin/",
updates the git-svn manual page, and fixes the fallout in the git-svn
testcases.

(Note that this patch might be easier to review using the --word-diff
and --word-diff-regex=. diff options.)

[ew: squashed description of <= 1.9 behavior into manpage]

Suggested-by: Thomas Ferris Nicolaisen <tfnico@gmail.com>
Signed-off-by: Johan Herland <johan@herland.net>
Signed-off-by: Eric Wong <normalperson@yhbt.net>
2014-04-19 11:30:13 +00:00
Johan Herland f849bb6b3b git-svn: Warn about changing default for --prefix in Git v2.0
In Git v2.0, we will change the default --prefix for init/clone from
none/empty to "origin/" (which causes SVN-tracking branches to be
placed at refs/remotes/origin/* instead of refs/remotes/*).

This patch warns users about the upcoming change, both in the git-svn
manual page, and on stderr when running init/clone in the "multi-mode"
without providing a --prefix.

Cc: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Johan Herland <johan@herland.net>
Signed-off-by: Eric Wong <normalperson@yhbt.net>
2013-10-12 22:30:53 +00:00
Nicolas Vigier 60786bd41a git-svn: fix signed commit parsing
When parsing a commit object, git-svn wrongly think that a line
containing spaces means the end of headers and the start of the commit
message. In case of signed commit, the gpgsig entry contains a line with
one space, so "git svn dcommit" will include part of the signature in
the commit message.

An example of such problem :
http://svnweb.mageia.org/treasurer?view=revision&revision=86

This commit changes the regex to only match an empty line as separator
between the headers and the commit message.

Signed-off-by: Nicolas Vigier <boklm@mars-attacks.org>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Eric Wong <normalperson@yhbt.net>
2013-10-10 06:48:10 +00:00
Junio C Hamano eac9a1a195 Merge branch 'vl/typofix'
* vl/typofix:
  random typofixes (committed missing a 't', successful missing an 's')
2013-06-26 15:07:52 -07:00
Veres Lajos f7e604ed39 random typofixes (committed missing a 't', successful missing an 's')
Signed-off-by: Veres Lajos <vlajos@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-06-19 11:31:33 -07:00
Slava Kardakov 9926f66fbd Fix `git svn` `rebase` & `dcommit` if top-level HEAD directory exist
When a file (or a directory) called HEAD exists in the working tree,
internal calls git svn makes trigger "did you mean a revision or a
path?" ambiguity check.

    $ git svn rebase
    fatal: ambiguous argument 'HEAD': both revision and filename
    Use '--' to separate paths from revisions, like this:
    'git <command> [<revision>...] -- [<file>...]'
    rev-list --first-parent --pretty=medium HEAD: command returned error: 128

Explicitly disambiguate by adding "--" after the revision.

Signed-off-by: Slava Kardakov <ojab@ojab.ru>
Reviewed-by: Jeff King <peff@peff.net>
Acked-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-06-12 13:38:48 -07:00
Tobias Schulte f4f4c7fc00 git-svn: introduce --parents parameter for commands branch and tag
This parameter is equivalent to the parameter --parents on svn cp commands
and is useful for non-standard repository layouts.

Signed-off-by: Tobias Schulte <tobias.schulte@gliderpilot.de>
Signed-off-by: Eric Wong <normalperson@yhbt.net>
2013-05-20 22:05:54 +00:00
Paul Walmsley a7b102302a git-svn: added an --include-path flag
The SVN::Fetcher module is now able to filter for inclusion as well
as exclusion (as used by --ignore-path). Also added tests, documentation
changes and git completion script.

If you have an SVN repository with many top level directories and you
only want a git-svn clone of some of them then using --ignore-path is
difficult as it requires a very long regexp. In this case it's much
easier to filter for inclusion.

[ew: remove trailing whitespace]

Signed-off-by: Paul Walmsley <pjwhams@gmail.com>
Signed-off-by: Eric Wong <normalperson@yhbt.net>
2013-05-09 01:13:36 +00:00
Michael Contreras e234ac9d47 git-svn: avoid self-referencing mergeinfo
When svn.pushmergeinfo is set, the target branch is included in the
mergeinfo if it was previously merged into one of the source branches.
SVN does not do this.

Remove merge target branch path from resulting mergeinfo when
svn.pushmergeinfo is set to better match the behavior of SVN. Update the
svn-mergeinfo-push test.

[ew: 80 columns]

Signed-off-by: Michael Contreras <michael@inetric.com>
Reported-by: Avishay Lavie <avishay.lavie@gmail.com>
Acked-by: Eric Wong <normalperson@yhbt.net>
2013-05-09 01:07:39 +00:00
David Aguilar 0b670abd97 git-svn: use a lowercase "usage:" string
Make the usage string consistent with Git.

Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-02-24 21:30:03 -08:00
David Aguilar 1ca6e587c9 git-svn: use a lowercase "usage:" string
Make the usage string consistent with Git.

Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-02-24 13:31:05 -08:00
Barry Wardell bc93ceb7c5 git-svn: Simplify calculation of GIT_DIR
Since git-rev-parse already checks for the $GIT_DIR environment
variable and that it returns an actual git repository, there is no
need to repeat the checks again here.

This also fixes a problem where git-svn did not work in cases where
.git was a file with a gitdir: link.

[ew: squashed test case,
 delay setting GIT_DIR until after `git rev-parse --cdup` to fix t9101,
 (thanks to Junio)]

Signed-off-by: Barry Wardell <barry.wardell@gmail.com>
Signed-off-by: Eric Wong <normalperson@yhbt.net>
2013-01-24 10:21:23 +00:00
John Keeping 2934a484fd git-svn: teach find-rev to find near matches
When a single SVN repository is split into multiple Git repositories
many SVN revisions will exist in only one of the Git repositories
created.  For some projects the only way to build a working artifact is
to check out corresponding versions of various repositories, with no
indication of what those are in the Git world - in the SVN world the
revision numbers are sufficient.

By adding "--before" to "git-svn find-rev" we can say "tell me what this
repository looked like when that other repository looked like this":

    git svn find-rev --before \
        r$(git --git-dir=/over/there.git svn find-rev HEAD)

Signed-off-by: John Keeping <john@keeping.me.uk>
Signed-off-by: Eric Wong <normalperson@yhbt.net>
2013-01-17 23:28:12 +00:00
Eric Wong f3045919d1 git-svn: use path accessor for Git::SVN objects
The accessors should improve maintainability and enforce
consistent access to Git::SVN objects.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
2012-10-05 22:48:12 +00:00
Junio C Hamano 9d305e5e70 Merge branch 'ms/git-svn-1.7'
A series by Michael Schwern via Eric to update git-svn to revamp the
way URLs are internally passed around, to make it work with SVN 1.7.

* ms/git-svn-1.7:
  git-svn: remove ad-hoc canonicalizations
  git-svn: canonicalize newly-minted URLs
  git-svn: introduce add_path_to_url function
  git-svn: canonicalize earlier
  git-svn: replace URL escapes with canonicalization
  git-svn: attempt to mimic SVN 1.7 URL canonicalization
  t9107: fix typo
  t9118: workaround inconsistency between SVN versions
  Git::SVN{,::Ra}: canonicalize earlier
  git-svn: path canonicalization uses SVN API
  Git::SVN::Utils: remove irrelevant comment
  git-svn: add join_paths() to safely concatenate paths
  git-svn: factor out _collapse_dotdot function
  git-svn: use SVN 1.7 to canonicalize when possible
  git-svn: move canonicalization to Git::SVN::Utils
  use Git::SVN{,::RA}->url accessor globally
  use Git::SVN->path accessor globally
  Git::SVN::Ra: use accessor for URLs
  Git::SVN: use accessor for URLs internally
  Git::SVN: use accessors internally for path
2012-08-22 11:51:20 -07:00
Robert Luberda e48fb750f5 git svn: handle errors and concurrent commits in dcommit
dcommit didn't handle errors returned by SVN and coped very
poorly with concurrent commits that appear in SVN repository
while dcommit was running. In both cases it left git repository
in inconsistent state: index (which was reset with `git reset
--mixed' after a successful commit to SVN) no longer matched the
checkouted tree, when the following commit failed or needed to be
rebased. See http://bugs.debian.org/676904 for examples.

This patch fixes the issues by:
- introducing error handler for dcommit. The handler will try
  to rebase or reset working tree before returning error to the
  end user. dcommit_rebase function was extracted out of cmd_dcommit
  to ensure consistency between cmd_dcommit and the error handler.
- calling `git reset --mixed' only once after all patches are
  successfully committed to SVN. This ensures index is not touched
  for most of the time of dcommit run.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2012-08-10 19:53:18 +00:00
Michael G. Schwern 5eaa1fd086 git-svn: remove ad-hoc canonicalizations
[ew: commit title]

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2012-08-02 21:46:06 +00:00
Michael G. Schwern d2fd119c4f git-svn: introduce add_path_to_url function
Remove the ad-hoc versions.

This is mostly to normalize the process and ensure the URLs produced
don't have double slashes or anything.

Also provides a place to fix the corner case where a file path
contains a percent sign.

[ew: commit title]

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2012-08-02 21:46:03 +00:00
Michael G. Schwern 8266fc8be1 git-svn: canonicalize earlier
Just a few things I noticed.  Its good to canonicalize as early as
possible.

[ew: commit title]

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2012-08-02 21:46:02 +00:00
Michael G. Schwern 9c27a57b2d git-svn: replace URL escapes with canonicalization
The old hand-rolled URL escape functions were inferior to
canonicalization functions.

Continuing to move towards getting everything canonicalizing the same way.

* Git::SVN->init_remote_config and Git::SVN::Ra->minimize_url both
  have to canonicalize the same way else init_remote_config
  will incorrectly think they're different URLs causing
  t9107-git-svn-migrate.sh to fail.

[ew: commit title]

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2012-08-02 21:46:01 +00:00
Michael G. Schwern ca475a61f8 git-svn: add join_paths() to safely concatenate paths
Otherwise you might wind up with things like...

    my $path1 = undef;
    my $path2 = 'foo';
    my $path = $path1 . '/' . $path2;

creating '/foo'.  Or this...

    my $path1 = 'foo/';
    my $path2 = 'bar';
    my $path = $path1 . '/' . $path2;

creating 'foo//bar'.

Could have used File::Spec, but I'm shying away from it due to SVN
1.7's pickiness about paths.  Felt it would be better to have our own
we can control completely.

[ew: commit title]

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2012-08-02 21:44:04 +00:00
Michael G. Schwern 91e6e0c56c git-svn: move canonicalization to Git::SVN::Utils
So they can be used by others.

I'd like to test them, but they're going to become SVN API wrappers shortly
and those aren't predictable.

No functional change.

[ew: commit title]

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2012-08-02 21:43:02 +00:00
Michael G. Schwern b1ea6c3829 use Git::SVN{,::RA}->url accessor globally
Note: The structure returned from Git::SVN->read_all_remotes() does not
appear to contain objects, so I'm leaving them alone.

That's everything converted over to the url and path accessors.

No functional change.

[ew: commit title]

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2012-08-02 21:42:59 +00:00
Michael G. Schwern 6a8d999ed4 use Git::SVN->path accessor globally
No functional change.

[ew: commit title]

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2012-08-02 21:42:58 +00:00
Michael G. Schwern 3d9be15fc2 Extract Git::SVN::GlobSpec from git-svn.
Straight cut & paste.  That's the last class.

* Make Git::SVN load it on its own, its the only thing that needs it.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2012-07-27 22:36:19 +00:00
Michael G. Schwern 10c2aa5928 Move Git::IndexInfo into its own file.
Straight cut & paste.  Didn't require any fixing.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2012-07-27 22:36:17 +00:00
Michael G. Schwern e96cdba110 Load all the modules in one place and before running code.
Just makes the code easier to follow.  No functional change.

Also eliminate an unused lexical $SVN.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2012-07-27 22:36:16 +00:00
Michael G. Schwern b772cb9994 Extract Git::SVN::Migration from git-svn.
Straight cut & paste.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2012-07-27 22:36:14 +00:00
Michael G. Schwern b0e75250c8 Prepare Git::SVN::Migration for extraction from git-svn.
* Load Git command functions on its own.
* Load Git::SVN modules on its own.

Drive by refactorings...
* Use our() instead of use vars.
* Eliminate the auto loading of Git functions.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2012-07-27 22:36:12 +00:00
Michael G. Schwern b74fda1c9b Extract Git::SVN::Log from git-svn.
Straight cut & paste.

Also noticed Git::SVN::Ra wasn't in the compile test.  It is now.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2012-07-27 22:36:06 +00:00
Michael G. Schwern 2c96a6c3f1 Prepare Git::SVN::Log for extraction from git-svn.
* Load Git command functions itself.

* Can't access the git-svn switch lexical any more, but its only used by
  Git::SVN::Log so turn it into a Git::SVN::Log global.

* Load Git::SVN as needed.  No need to load it always, its only used twice.

* Moved a state variable to the routine it's used for. (Drive by refactoring)

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2012-07-27 22:35:26 +00:00
Michael G. Schwern 5c71028fce Move initialization of Git::SVN variables into Git::SVN.
Also it can compile on its own now, yay!

Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Eric Wong <normalperson@yhbt.net>
2012-07-27 22:14:54 +00:00
Michael G. Schwern 29499c0b27 Extract Git::SVN from git-svn into its own .pm file.
Except for adding the 1; at the end, this is a straight copy & paste.

Tests still pass, but its doubtful Git::SVN will compile on its own
without git-svn being loaded.  Next commit will fix that.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Eric Wong <normalperson@yhbt.net>
2012-07-27 22:14:53 +00:00
Michael G. Schwern 0f80aa03cf Prepare Git::SVN for extraction into its own file.
This means it should be able to load without git-svn being loaded.

* Load Git.pm on its own and all the needed command functions.

* It needs to grab at a git-svn lexical $_prefix representing the --prefix
  option.  Provide opt_prefix() for that.  This is a refactoring artifact.
  The prefix should really be passed into Git::SVN->new.

* Unqualify unnecessarily fully qualified globals like
  $Git::SVN::default_repo_id.

* Lexically isolate the class just to make sure nothing is leaking out.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Eric Wong <normalperson@yhbt.net>
2012-07-27 22:14:52 +00:00
Michael G. Schwern c2768fa152 Extract some utilities from git-svn to allow extracting Git::SVN.
Put them in a new module called Git::SVN::Utils.  Yeah, not terribly
original and it will be a dumping ground.  But its better than having
them in the main git-svn program.  At least they can be documented
and tested.

* fatal() is used by many classes.
* Change the $can_compress lexical into a function.

This should be enough to extract Git::SVN.

Signed-off-by: Michael G. Schwern <schwern@pobox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Eric Wong <normalperson@yhbt.net>
2012-07-27 22:14:50 +00:00
Marcin Owsiany e3bd4ddaa9 git-svn: don't create master if another head exists
git-svn insists on creating the "master" head (unless it exists) on every
"fetch". It is useful that it gets created initially, when no head exists
- users expect this git convention of having a "master" branch on initial
clone.

However creating it when there already is another head does not provide any
value - the ref is never updated, so it just gets stale after a while.  Also,
some users find it annoying that it gets recreated, especially when they would
like the git branch names to follow SVN repository branch names. More
background in http://thread.gmane.org/gmane.comp.version-control.git/115030

Make git-svn skip the "master" creation if HEAD already points at a valid head.
This means "master" does get created on initial "clone" but does not get
recreated once a user deletes it.

Also, make post_fetch_checkout work with any head that is pointed to by HEAD,
not just "master".

Also, use fatal error handling consistent with the rest of the program for
post_fetch_checkout.

Signed-off-by: Marcin Owsiany <marcin@owsiany.pl>
Signed-off-by: Eric Wong <normalperson@yhbt.net>
2012-07-19 08:15:50 +00:00
Jonathan Nieder 68f532f4ba git-svn: use YAML format for mergeinfo cache when possible
Since v1.7.0-rc2~11 (git-svn: persistent memoization, 2010-01-30),
git-svn has maintained some private per-repository caches in
.git/svn/.caches to avoid refetching and recalculating some
mergeinfo-related information with every "git svn fetch".

These caches use the 'nstore' format from the perl core module
Storable, which can be read and written quickly and was designed for
transfer over the wire (the 'n' stands for 'network').  This format is
endianness-independent and independent of floating-point
representation.

Unfortunately the format is *not* independent of the perl version ---
new perl versions will write files that very old perl cannot read.
Worse, the format is not independent of the size of a perl integer.
So if you toggle perl's use64bitint compile-time option, then using
'git svn fetch' on your old repositories produces errors like this:

	Byte order is not compatible at ../../lib/Storable.pm (autosplit
	into ../../lib/auto/Storable/_retrieve.al) line 380, at
	/usr/share/perl/5.12/Memoize/Storable.pm line 21

That is, upgrading perl to a version that uses use64bitint for the
first time makes git-svn suddenly refuse to fetch in existing
repositories.  Removing .git/svn/.caches lets git-svn recover.

It's time to switch to a platform independent serializer backend with
better compatibility guarantees.  This patch uses YAML::Any.

Other choices were considered:

 - thawing data from Data::Dumper involves "eval".  Doing that without
   creating a security risk is fussy.

 - the JSON API works on scalars in memory and doesn't provide a
   standard way to serialize straight to disk.

YAML::Any is reasonably fast and has a pleasant API.  In most
backends, LoadFile() reads the entire file into a scalar anyway and
converts it as a second step, but having an interface that allows the
deserialization to happen on the fly without a temporary is still a
comfort.

YAML::Any is not a core perl module, so we take care to use it when
and only when it is available.  Installations without that module
should fall back to using Storable with all its quirks, keeping their
cache files in

	.git/svn/.caches/*.db

Installations with YAML peacefully coexist by keeping a separate set
of cache files in

	.git/svn/.caches/*.yaml.

In most cases, switching between is a one-time thing, so it doesn't
seem worth the complication to migrate existing caches.

The upshot: after this patch, as long as YAML::Any is installed you
can move your git repository between machines with different perl
installations and "git svn fetch" will work fine.  If you do not have
YAML::Any, the behavior is unchanged (and in particular does not get
any worse).

Reported-by: Sandro Weiser <sandro.weiser@informatik.tu-chemnitz.de>
Reported-by: Bdale Garbee <bdale@gag.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Eric Wong <normalperson@yhbt.net>
2012-06-10 08:47:53 +00:00
Jonathan Nieder 9f7ad1479d git-svn: make Git::SVN::RA a separate file
This slices off another 600 or so lines from the frighteningly long
git-svn.perl script.

The Git::SVN::Ra interface is similar enough to SVN::Ra that it is
probably safe to ignore most of its implementation on first reading.
(Documenting or moving functions that do not fit that pattern is left
as an exercise to the interested reader.)

[ew: rebased and fixed conflict against
 commit c26ddce86d
 (git-svn: platform auth providers are working only on 1.6.15 or newer)]

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Eric Wong <normalperson@yhbt.net>
2012-06-10 08:47:50 +00:00
Jonathan Nieder 8f9facfe94 git-svn: make Git::SVN::Editor a separate file
This makes the git-svn script shorter and less scary for beginners to
read through for the first time.  Take the opportunity to explain the
purpose and basic interface of the Git::SVN::Editor class while at it.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Eric Wong <normalperson@yhbt.net>
2012-06-10 08:45:56 +00:00
Junio C Hamano 7c0382bbee Merge branch 'jc/svn-auth-providers-unusable-at-1.6.12'
Regression fix for people with libsvn between 1.6.12 and 1.6.15, on
which we tried to use the non-working platform auth providers.

* jc/svn-auth-providers-unusable-at-1.6.12:
  git-svn: platform auth providers are working only on 1.6.15 or newer
2012-06-07 09:07:08 -07:00
Junio C Hamano c26ddce86d git-svn: platform auth providers are working only on 1.6.15 or newer
Matthijs Kooijman reports that the cut-off point 082afee (git-svn:
use platform specific auth providers, 2012-04-26) set at 1.6.12 to
use this feature safely was incorrect, and it is 1.6.15 instead:

    http://svn.apache.org/repos/asf/subversion/trunk/CHANGES
    Version 1.6.15
       * improve some swig parameter mapping (r984565, r1035745)

Signed-off-by: Junio C Hamano <gitster@pobox.com>
Acked-by: Eric Wong <normalperson@yhbt.net>
2012-06-04 12:54:48 -07:00
Jonathan Nieder a6180325e8 git-svn: make Git::SVN::Fetcher a separate file
This patch removes a chunk of code (the Git::SVN::Fetcher consumer of
libsvn's tree delta protocol) from git-svn.perl and documents its
interface so the hurried reader does not have to read that code right
away.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Eric Wong <normalperson@yhbt.net>
2012-05-29 00:17:59 +00:00
Jonathan Nieder 72827aa468 git-svn: rename SVN::Git::* packages to Git::SVN::*
Using names in the Git:: namespace means these cannot conflict with a
hypothetical binding teaching Subversion to interact with git
repositories.

Currently the packages are private to git-svn.perl so the choice of
name isn't likely to make much difference.  This change is mainly
meant as preparation for splitting out the packages in question as
modules on the public search path.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Eric Wong <normalperson@yhbt.net>
2012-05-29 00:17:59 +00:00