Commit graph

360 commits

Author SHA1 Message Date
David D. Kilzer 8d7c4fad3f git-svn: Remove unnecessary Git::SVN::Util package
Digest::MD5 is loaded regardless of the package in which it's
declared, so move its 'use' statement and the md5sum() function
into the main package.

Signed-off-by: David D. Kilzer <ddkilzer@kilzer.net>
Acked-by: Eric Wong <normalperson@yhbt.net>
2007-11-30 23:32:51 -08:00
Andy Whitcroft 70ae04e4e8 git-svn: add support for pulling author from From: and Signed-off-by:
Add support for pulling the real author of a commit from the From:
and first Signed-off-by: fields of the SVN commit message.

Signed-off-by: Andy Whitcroft <apw@shadowen.org>
Acked-by: Eric Wong <normalperson@yhbt.net>
2007-11-30 23:32:51 -08:00
Gustaf Hendeby f4dd334bff git-svn now reads settings even if called in subdirectory
Previously, git-svn first read the .git/config file for settings as if
current working directory was the repository top-directory, and after
that made sure to cd into top-directory.  The result was a silent
failur to read configuration settings.  This patch changes the order
these two things are done.

Signed-off-by: Gustaf Hendeby <hendeby@isy.liu.se>
Acked-by: Eric Wong <normalperson@yhbt.net>
2007-11-30 23:29:27 -08:00
Eric Wong a5460eb7bb git-svn: allow `info' command to work offline
Cache the repository root whenever we connect to the repository.
This will allow us to notice URL changes if the user changes the
URL in .git/config, too.

If the repository is no longer accessible, or if `git svn info'
is the first and only command run; then '(offline)' will be
displayed for "Repository Root:" in the output.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-11-21 20:11:11 -08:00
David D. Kilzer 8b014d7157 git-svn: info --url [path]
Return the svn URL for the given path, or return the svn
repository URL if no path is given.

Added 18 tests to t/t9119-git-svn-info.sh.

Signed-off-by: David D. Kilzer <ddkilzer@kilzer.net>
Acked-by: Eric Wong <normalperson@yhbt.net>
2007-11-21 20:11:11 -08:00
David D. Kilzer e6fefa926d git-svn info: implement info command
Implement "git-svn info" for files and directories based on the
"svn info" command.  Note that the -r/--revision argument is not
supported yet.

Added 18 tests in t/t9119-git-svn-info.sh.

[ew: small fix to work without arguments on all working directories]

Signed-off-by: David D. Kilzer <ddkilzer@kilzer.net>
Acked-by: Eric Wong <normalperson@yhbt.net>
2007-11-21 20:11:11 -08:00
David D. Kilzer b2b3ada7fc git-svn: extract reusable code into utility functions
Extacted canonicalize_path() in the main package.

Created new Git::SVN::Util package with an md5sum() function.  A
new package was created so that Digest::MD5 did not have to be
loaded in the main package.  Replaced code in the SVN::Git::Editor
and SVN::Git::Fetcher packages with calls to md5sum().

Extracted the format_svn_date(), parse_git_date() and
set_local_timezone() functions within the Git::SVN::Log package.

Signed-off-by: David D. Kilzer <ddkilzer@kilzer.net>
Acked-by: Eric Wong <normalperson@yhbt.net>
2007-11-21 20:11:11 -08:00
David Reiss 826a93398d git-svn: Fix a typo and add a comma in an error message in git-svn
Signed-off-by: David Reiss <dreiss@facebook.com>
Acked-by: Eric Wong <normalperson@yhbt.net>
2007-11-17 13:39:47 -08:00
David D Kilzer 111947ef8c git-svn log: handle unreachable revisions like "svn log"
When unreachable revisions are given to "svn log", it displays all commit
logs in the given range that exist in the current tree.  (If no commit
logs are found in the current tree, it simply prints a single commit log
separator.)  This patch makes "git-svn log" behave the same way.

Ten tests added to t/t9116-git-svn-log.sh.

Signed-off-by: David D Kilzer <ddkilzer@kilzer.net>
Acked-by: Eric Wong <normalperson@yhbt.net>
2007-11-17 13:28:21 -08:00
David D Kilzer 60f3ff1257 git-svn log: include commit log for the smallest revision in a range
The "svn log -rM:N" command shows commit logs inclusive in the range [M,N].
Previously "git-svn log" always excluded the commit log for the smallest
revision in a range, whether the range was ascending or descending.  With
this patch, the smallest revision in a range is always shown.

Updated tests for ascending and descending revision ranges.

Signed-off-by: David D Kilzer <ddkilzer@kilzer.net>
Acked-by: Eric Wong <normalperson@yhbt.net>
2007-11-17 13:28:21 -08:00
David D Kilzer fede44b2e1 git-svn log: fix ascending revision ranges
Fixed typo in Git::SVN::Log::git_svn_log_cmd().  Previously a command like
"git-svn log -r1:4" would only show a commit log separator.

Added tests for ascending and descending revision ranges.

Signed-off-by: David D Kilzer <ddkilzer@kilzer.net>
Acked-by: Eric Wong <normalperson@yhbt.net>
2007-11-17 13:28:21 -08:00
Konstantin V. Arkhipov 3caf320ba8 git-svn's dcommit must use subversion's config
When doing dcommit git-svn must use subversion's config or newly created
files will not include svn's properties
(defined in [auto-props] with 'enable-auto-props = yes').

Signed-off-by: Konstantin V. Arkhipov <voxus@onphp.org>
Acked-by: Eric Wong <normalperson@yhbt.net>
2007-11-17 13:28:21 -08:00
Eric Wong cfbe7ab333 git-svn: support for funky branch and project names over HTTP(S)
SVN requires that paths be URI-escaped for HTTP(S) repositories.
file:// and svn:// repositories do not need these rules.

Additionally, accessing individual paths inside repositories
(check_path() and get_log() do NOT require escapes to function
and in fact it breaks things).

Noticed-by: Michael J. Cohen <mjc@cruiseplanners.com>
Signed-off-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-12 00:22:49 -08:00
Junio C Hamano 35865ca245 Merge branch 'maint'
* maint:
  for-each-ref: fix off by one read.
  git-branch: remove mention of non-existent '-b' option
  git-svn: prevent dcommitting if the index is dirty.
  Fix memory leak in traverse_commit_list
2007-11-12 00:14:15 -08:00
Benoit Sigoure c8cfa3e4a5 git-svn: prevent dcommitting if the index is dirty.
dcommit uses rebase to sync the history with what has just been pushed to
SVN.  Trying to dcommit with a dirty index is troublesome for rebase, so now
the user will get an error message if he attempts to dcommit with a dirty
index.

Signed-off-by: Benoit Sigoure <tsuna@lrde.epita.fr>
Acked-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-11 23:40:32 -08:00
Junio C Hamano fe61935007 Merge branch 'maint'
* maint:
  Remove a couple of duplicated include
  grep with unmerged index
  git-daemon: fix remote port number in log entry
  git-svn: t9114: verify merge commit message in test
  git-svn: fix dcommit clobbering when committing a series of diffs
2007-11-05 22:03:47 -08:00
Eric Wong c74d9acf20 git-svn: fix dcommit clobbering when committing a series of diffs
Our revision number sent to SVN is set to the last revision we
committed if we've made any previous commits in a dcommit
invocation.

Although our SVN Editor code uses the delta of two (old) trees
to generate information to send upstream, it'll still send
complete resultant files upstream; even if the tree they're
based against is out-of-date.

The combination of sending a file that does not include the
latest changes, but set with a revision number of a commit we
just made will cause SVN to accept the resultant file even if it
was generated against an old tree.

More trouble was caused when fixing this because we were
rebasing uncessarily at times.  We used git-diff-tree to check
the imported SVN revision against our HEAD, not the last tree we
committed to SVN.  The unnecessary rebasing caused merge commits
upstream to SVN to fail.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-05 12:57:34 -08:00
Benoit Sigoure aa807bc266 git-svn: sort the options in the --help message.
"git svn <cmd> --help" gave options in the order they were found in a
Perl hash, which meant "randomly" to humans.

Signed-off-by: Benoit Sigoure <tsuna@lrde.epita.fr>
Acked-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-03 21:39:12 -07:00
Benoit Sigoure 207f1a75e7 git-svn: simplify the handling of fatal errors
* git-svn.perl (&fatal): Append the newline at the end of the error
	message.
	Adjust all callers.

Signed-off-by: Benoit Sigoure <tsuna@lrde.epita.fr>
Acked-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-10-17 02:47:37 -04:00
Benoit Sigoure 51e057cf80 git-svn: add git svn proplist
This allows one to easily retrieve a list of svn properties from within
git-svn without requiring svn or knowing the URL of a repository.

	* git-svn.perl (%cmd): Add the command `proplist'.
	(&cmd_proplist): New.
	* t/t9101-git-svn-props.sh: Test git svn proplist.

Signed-off-by: Benoit Sigoure <tsuna@lrde.epita.fr>
Acked-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-10-17 02:47:37 -04:00
Benoit Sigoure 1515345156 git-svn: add git svn propget
This allows one to easily retrieve a single SVN property from within
git-svn without requiring svn or remembering the URL of a repository

	* git-svn.perl (%cmd): Add the new command `propget'.
	($cmd_dir_prefix): New global.
	(&get_svnprops): New helper.
	(&cmd_propget): New.  Use &get_svnprops.
	* t/t9101-git-svn-props.sh: Add a test case for propget.

[ew: make sure the rev-parse --show-prefix call doesn't break
     the `git-svn clone' command]

Signed-off-by: Benoit Sigoure <tsuna@lrde.epita.fr>
Acked-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-10-17 02:47:37 -04:00
Benoit Sigoure d05ddec51e git-svn: implement git svn create-ignore
git svn create-ignore (to create one .gitignore per directory
from the svn:ignore properties.  This has the disadvantage of
committing the .gitignore during the next dcommit, but when you
import a repo with tons of ignores (>1000), using git svn show-ignore
to build .git/info/exclude is *not* a good idea, because things like
git-status will end up doing >1000 fnmatch *per file* in the repo,
which leads to git-status taking more than 4s on my Core2Duo 2Ghz 2G
RAM)

	* git-svn.perl (%cmd): Add the new command `create-ignore'.
	(&cmd_create_ignore): New.
	* t/t9101-git-svn-props.sh: Adjust the test-case for show-ignore and
	add a test case for create-ignore.

[ew: added commit message from
  <05CAB148-56ED-4FF1-8AAB-4BA2A0B70C2C@lrde.epita.fr> ]

Signed-off-by: Benoit Sigoure <tsuna@lrde.epita.fr>
Acked-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-10-17 02:47:36 -04:00
Benoit Sigoure 01bdab84e3 git-svn: add a generic tree traversal to fetch SVN properties
* git-svn.perl (&traverse_ignore): Remove.
	(&prop_walk): New.
	(&cmd_show_ignore): Use prop_walk.

[ew: This will ease the implementation of the `create-ignore',
     `propget', and `proplist' commands]

Signed-off-by: Benoit Sigoure <tsuna@lrde.epita.fr>
Acked-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-10-17 02:47:36 -04:00
Eygene Ryabinkin fd499bcc9d git-svn: use "no warnings 'once'" to disable false-positives
Some variables coming from the Subversion's Perl bindings are used
in our code only once, so the interpreter warns us about it.  These
warnings are false-positives, because the variables themselves are
initialized in the binding's guts, that are made by SWIG.

Credits to Sam Vilain for his note about "no warnings 'once'".

[ew: minor formatting change]

Signed-off-by: Eygene Ryabinkin <rea-git@codelabs.ru>
Acked-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-10-16 20:33:13 -04:00
Eygene Ryabinkin 602015e0e6 git-svn: respect Subversion's [auth] section configuration values
Parameters 'store-passwords' and 'store-auth-creds' from Subversion's
configuration (~/.subversion/config) were not respected.  This was
fixed: the default values for these parameters are set to 'yes' to
follow Subversion behaviour.

Signed-off-by: Eygene Ryabinkin <rea-git@codelabs.ru>
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Acked-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2007-10-15 21:28:48 -04:00
Steven Walter 9ff74e95da Don't checkout the full tree if avoidable
In most cases of branching, the tree is copied unmodified from the trunk
to the branch.  When that is done, we can simply start with the parent's
index and apply the changes on the branch as usual.

[ew: rewritten from Steven's original to use SVN::Client instead
     of the command-line svn client.

     Since SVN::Client connects separately, we'll share our
     authentication providers array between our usages of
     SVN::Client and SVN::Ra, too.  Bypassing the high-level
     SVN::Client library can avoid this, but the code will be
     much more complex.  Regardless, any implementation of this
     seems to require restarting a connection to the remote
     server.

     Also of note is that SVN 1.4 and later allows a more
     efficient diff_summary to be done instead of a full diff,
     but since this code is only to support SVN < 1.4.4, we'll
     ignore it for now.]

Signed-off-by: Steven Walter <stevenrwalter@gmail.com>
Signed-off-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-10-03 17:54:34 -07:00
Junio C Hamano 4f337e2466 Merge branch 'maint'
* maint:
  git-svn: don't attempt to spawn pager if we don't want one
  Supplant the "while case ... break ;; esac" idiom
  User Manual: add a chapter for submodules
  user-manual: don't assume refs are stored under .git/refs
  Detect exec bit in more cases.
  Conjugate "search" correctly in the git-prune-packed man page.
  Move the paragraph specifying where the .idx and .pack files should be
  Documentation/git-lost-found.txt: drop unnecessarily duplicated name.
2007-09-23 17:13:55 -07:00
Eric Wong b019304886 git-svn: don't attempt to spawn pager if we don't want one
Even though config_pager() unset the $pager variable, we were
blindly calling exec() on it through run_pager().

Noticed-by: Chris Moore <christopher.ian.moore@gmail.com>
Signed-off-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-09-23 17:07:10 -07:00
Junio C Hamano 23d23385b3 Merge branch 'lh/svn-first-parent'
* lh/svn-first-parent:
  git-svn: always use --first-parent
  git-svn: add support for --first-parent
2007-09-14 22:37:43 -07:00
Eric Wong 7b02b85a66 git-svn: understand grafts when doing dcommit
Use the rev-list --parents functionality to read the parents
of the commit.  cat-file only shows the raw object with the
original parents and doesn't take into account grafts; so
we'll rely on rev-list machinery for the smarts here.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-09-09 02:30:33 -07:00
Eric Wong a51cdb0c04 git-svn: fix "Malformed network data" with svn:// servers
We have a workaround for the reparent function not working
correctly on the SVN native protocol servers.  This workaround
opens a new connection (SVN::Ra object) to the new
URL/directory.

Since libsvn appears limited to only supporting one connection
at a time, this workaround invalidates the Git::SVN::Ra object
that is $self inside gs_fetch_loop_common().  So we need to
restart that connection once all the fetching is done for each
loop iteration to be able to run get_log() successfully.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-09-07 22:23:48 -07:00
Lars Hjemli 4dbfe2e9bd git-svn: always use --first-parent
This makes git-svn unconditionally invoke git-log with --first-parent when
it is trying to discover its upstream subversion branch and collecting the
commit ids which should be pushed to it with dcommit. The reason for always
using --first-parent is to make git-svn behave in a predictable way when the
ancestry chain contains merges with other git-svn branches.

Since git-svn now always uses 'git-log --first-parent' there is no longer
any need for the --first-parent option to git-svn, so this is removed.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Acked-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-09-06 22:53:16 -07:00
Lars Hjemli 05b4df3153 git-svn: add support for --first-parent
When git-svn uses git-log to find embedded 'git-svn-id'-lines in commit
messages, it can get confused when local history contains merges with
other git-svn branches. But if --first-parent is supplied to git-log,
working_head_info() will only see 'branch-local' commits and thus the
first commit containing a 'git-svn-id' line should refer to the correct
subversion branch.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Acked-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-09-05 15:24:16 -07:00
Eric Wong 751eb39590 git-svn: fix dcommit clobbering upstream when committing multiple changes
Although dcommit could detect if the first commit in the series
would conflict with the HEAD revision in SVN, it could not
detect conflicts in further commits it made.

Now we rebase each uncommitted change after each revision is
committed to SVN to ensure that we are up-to-date.  git-rebase
will bail out on conflict errors if our next change cannot be
applied and committed to SVN cleanly, preventing accidental
clobbering of changes on the SVN-side.

--no-rebase users will have trouble with this, and are thus
warned if they are committing more than one commit.  Fixing this
for (hopefully uncommon) --no-rebase users would be more complex
and will probably happen at a later date.

Thanks to David Watson for finding this and the original test.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-08-31 23:22:51 -07:00
Junio C Hamano eeebd8d8c5 git-svn: Protect against "diff.color = true".
If the configuration of the user has "diff.color = true", the
output from "log" we invoke internally added color codes, which
broke the parser.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
Tested-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Acked-by: Eric Wong <normalperson@yhbt.net>
2007-08-31 23:22:51 -07:00
martin f. krafft 8f728fb96f git-svn init/clone --stdlayout option to default-init trunk/tags/branches
The --stdlayout option to git-svn init/clone initialises the default
Subversion values of trunk,tags,branches: -T trunk -b branches -t tags.
If any of the -T/-t/-b options are given in addition, they are given
preference.

[ew: fixed whitespace and added "-s" shortcut]

Signed-off-by: martin f. krafft <madduck@madduck.net>
Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-08-23 00:18:02 -07:00
Eric Wong 15d54753bb git-svn: dcommit prints out the URL to be committed to
This will print out the URL that dcommit will operate on.
If used with --dry-run this will print out the URL without
making changes to the repository.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-08-22 23:41:36 -07:00
Eric Wong 6ed77266c6 git-svn: fix log with single revision against a non-HEAD branch
Running git-svn log <ref> -r<rev> against a <ref> other than the
current HEAD did not work if the <rev> was exclusive to the
other branch.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-08-15 12:09:48 -07:00
Robert Ewald bf655fd700 git-svn: Translate invalid characters in refname
In git some characters are invalid as documented
in git-check-ref-format. In subversion these characters might
be valid, so a translation is required.

This patch does this translation by url escaping characters, that
are not allowed.

Credit goes to Eric Wong, martin f. krafft and Jan Hudec

Signed-off-by: Robert Ewald <robewald@gmx.net>
Acked-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-07-30 17:49:50 -07:00
Richard MUSIL 575d025c0d git-svn: Minimalistic patch which allows svn usernames with space(s).
Changed filter for username in svn-authors file, so even 'user name' is accepted.

Acked-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-07-18 17:01:10 -07:00
Eric Wong 29633bb91c git-svn: fix commiting renames over DAV with funky file names
Renaming files with non-URI friendly characters caused
breakage when committing to DAV repositories (over http(s)).

Even if I try leaving out the $self->{url} from the return value
of url_path(), a partial (without host), unescaped path name
does not work.

Filenames for DAV repos need to be URI-encoded before being
passed to the library.  Since this bug did not affect file://
and svn:// repos, the git-svn test library needed to be expanded
to include support for starting Apache with mod_dav_svn enabled.

This new test is not enabled by default, but can be enabled by
setting SVN_HTTPD_PORT to any available TCP/IP port on
127.0.0.1.

Additionally, for running this test, the following variables
(with defaults shown) can be changed for the suitable system.
The default values are set for Debian systems:

  SVN_HTTPD_MODULE_PATH=/usr/lib/apache2/modules
  SVN_HTTPD_PATH=/usr/sbin/apache2

Signed-off-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-07-15 22:35:09 -07:00
Eric Wong 46cf98baa5 git-svn: remove leading slashes from fetch lines in the generate config
We were previously sensitive to leading slashes in the fetch
lines and incorrectly writing them to the config if the user
used them (needlessly) in the command-line.

This fixes the issue and allows us to play nicely with legacy
configs that have leading slashes in fetch lines.

Thanks to Bradford Smith for figuring this out for me:
>
> This works:
>
> git-svn clone https://my.server.net/repos/path/ -Ttrunk/testing
>   -ttags/testing -bbranches/testing testing
>
> This doesn't:
>
> git-svn clone https://my.server.net/repos/path -T/trunk/testing
>   -t/tags/testing -b/branches/testing testing

Signed-off-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-07-14 13:47:08 -07:00
Eric Wong 7730fbe624 git-svn: fix blocking with svn:// servers after do_switch
We now explicitly disconnect before starting new SVN::Ra
connections.  SVN::Ra objects will automatically be disconnected
from the server on DESTROY.

SVN servers seem to have problems accepting multiple connections
from one client, and the SVN library has trouble being connected
to multiple servers at once.  This appears to cause opening the
second connection to block, and cause git-svn to be unusable
after using the do_switch() function.

git-svn opens another connection because a workaround is
necesary for the buggy reparent function handling on certain
versions of svn:// and svn+ssh:// servers.  Instead of using the
reparent function (analogous to chdir), it will reopen a new
connection to a different URL on the SVN server.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-07-04 21:06:07 -07:00
Junio C Hamano 1fd81efad0 Merge branch 'ew/svn'
* ew/svn:
  git-svn: allow dcommit to retain local merge information
2007-07-02 01:46:22 -07:00
Junio C Hamano 0305b63654 Merge branch 'ei/worktree+filter'
* ei/worktree+filter:
  filter-branch: always export GIT_DIR if it is set
  setup_git_directory: fix segfault if repository is found in cwd
  test GIT_WORK_TREE
  extend rev-parse test for --is-inside-work-tree
  Use new semantics of is_bare/inside_git_dir/inside_work_tree
  introduce GIT_WORK_TREE to specify the work tree
  test git rev-parse
  rev-parse: introduce --is-bare-repository
  rev-parse: document --is-inside-git-dir
2007-07-01 13:10:42 -07:00
Junio C Hamano 8b4edcf04d Merge branch 'mk/svn'
* mk/svn:
  git-svn: honor ~/.subversion/ client cert file settings.
2007-06-30 23:48:54 -07:00
Sam Vilain 40cb8f8f08 git-svn: cache max revision in rev_db databases
Cache the maximum revision for each rev_db URL rather than looking it
up each time.  This saves a lot of time when rebuilding indexes on a
freshly cloned repository.

Signed-off-by: Sam Vilain <sam.vilain@catalyst.net.nz>
Acked-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-06-30 23:36:32 -07:00
Sam Vilain 3dfab993c8 git-svn: use git-log rather than rev-list | xargs cat-file
This saves a bit of time when rebuilding the git-svn index.

Signed-off-by: Sam Vilain <sam.vilain@catalyst.net.nz>
Acked-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-06-30 23:36:16 -07:00
Michael Krelin 6caf5b1891 git-svn: honor ~/.subversion/ client cert file settings.
Currently, whenever svn repository http server requests client
certificate, prompt provider is invoked, ignoring any
ssl-client-cert-file settings in ~/.subversion/servers.

Moreover, it happens more than once per session, which is quite
irritating.

Signed-off-by: Michael Krelin <hacker@klever.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-06-30 20:52:41 -07:00
Sam Vilain c5f71ad099 git-svn: avoid string eval for defining functions
You don't need to use string eval to define new functions; assigning a
code reference to the target symbol table is enough.

Acked-by: Eric Wong <normalperson@yhbt.net>

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-06-16 01:20:26 -07:00
Eric Wong 733a65aa5d git-svn: allow dcommit to retain local merge information
dcommit will still rewrite the HEAD commit and the history of the first
parents of each HEAD~1, HEAD~2, HEAD~3 as it always has.

However, any merge parents (HEAD^2, HEAD^^2, HEAD~2^2) will now be
preserved when the new HEAD and HEAD~[0-9]+ commits are rewritten to SVN
with dcommit.  Commits written to SVN will still not have any merge
information besides anything in the commit message.

Thanks to Joakim Tjernlund, Junio C Hamano and Steven Grimm
for explanations, feedback, examples and test case.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-06-13 11:24:23 -07:00
Eric Wong 38570a47fc git-svn: reduce stat() calls for a backwards compatibility check
Also, this fixes a bug where in an odd case a remote named
"config" could get renamed to ".metadata".

Signed-off-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-06-13 11:23:51 -07:00
Eric Wong b54a901e05 git-svn: cleanup: factor out longest_common_path() function
I hadn't looked at this code in a while and had to read this
again to figure out what it did.  To avoid having to do this
again in the future, I just gave gave the hunk a descriptive
name.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-06-13 10:56:44 -07:00
Matthias Lederhofer 7ae3df8c0a Use new semantics of is_bare/inside_git_dir/inside_work_tree
Up to now to check for a working tree this was used:
	!is_bare && !inside_git_dir
(the check for bare is redundant because is_inside_git_dir
returned already 1 for bare repositories).
Now the check is:
	inside_work_tree && !inside_git_dir

Signed-off-by: Matthias Lederhofer <matled@gmx.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-06-06 16:07:53 -07:00
Matthias Lederhofer 493c774e58 rev-parse: introduce --is-bare-repository
Signed-off-by: Matthias Lederhofer <matled@gmx.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-06-06 16:07:53 -07:00
Eric Wong 7faf068660 git-svn: avoid md5 calculation entirely if SVN doesn't provide one
There's no point in calculating an MD5 if we're not going to use
it.  We'll also avoid the possibility of there being a bug in the
Perl MD5 library not being able to handle zero-sized files.

This is a followup to 20b3d206ac,
which allows us to track repositories that do not provide MD5
checksums.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-05-28 23:49:47 -07:00
James Y Knight 20b3d206ac Fix git-svn to handle svn not reporting the md5sum of a file, and test.
Acked-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-05-26 01:17:58 -07:00
Eric Wong dc431666d3 git-svn: don't minimize-url when doing an init that tracks multiple paths
I didn't have a chance to test the off-by-default minimize-url
stuff enough before, but it's quite broken for people passing
the --trunk/-T, --tags/-t, --branches/-b switches to "init" or
"clone" commands.

Additionally, follow-parent functionality seems broken when we're
not connected to the root of the repository.

Default behavior for "traditional" git-svn users who only track
one directory (without needing follow-parent) should be
reasonable, as those users started using things before
minimize-url functionality existed.

Behavior for users more used to the git-svnimport-like command
line will also benefit from a more-flexible command-line than
svnimport given the assumption they're working with
non-restrictive read permissions on the repository.

I hope to properly fix these bugs when I get a chance to in the
next week or so, but I would like to get this stopgap measure of
reverting to the old behavior as soon as possible.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-05-19 12:28:50 -07:00
Eric Wong 6442754d6c git-svn: avoid crashing svnserve when creating new directories
When sorting directory names by depth (slash ("/") count) and
closing the deepest directories first (as the protocol
requires), we failed to put the root baton (with an empty string
as its key "") after top-level directories (which did not have
any slashes).

This resulted in svnserve being in a situation it couldn't
handle and caused a segmentation fault on the remote server.

This bug did not affect users of DAV and filesystem repositories.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
Confirmed-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-05-19 12:26:36 -07:00
Eric Wong 4a1bb4c3f8 git-svn: don't attempt to minimize URLs by default
For tracking branches and tags, git-svn prefers to connect
to the root of the repository or at least the level that
houses branches and tags as well as trunk.  However, users
that are accustomed to tracking a single directory have
no use for this feature.

As pointed out by Junio, users may not have permissions to
connect to connect to a higher-level path in the repository.

While the current minimize_url() function detects lack of
permissions to certain paths _after_ successful logins, it
cannot effectively determine if it is trying to access a
login-only portion of a repo when the user expects to
connect to a part where anonymous access is allowed.

For people used to the git-svnimport switches of
--trunk, --tags, --branches, they'll already pass the
repository root (or root+subdirectory), so minimize URL
isn't of too much use to them, either.

For people *not* used to git-svnimport, git-svn also
supports:

 git svn init --minimize-url \
  --trunk http://repository-root/foo/trunk \
  --branches http://repository-root/foo/branches \
  --tags http://repository-root/foo/tags

And this is where the new --minimize-url command-line switch
comes in to allow for this behavior to continue working.
2007-05-13 12:10:43 -07:00
Eric Wong 4c03c3eb4e git-svn: fix segfaults due to initial SVN pool being cleared
Some parts of SVN always seem to use it, even if the SVN::Ra
object we're using is no longer used and we've created a new one
in its place.  It's also true that only one SVN::Ra connection
can exist at once...  Using SVN::Pool->new_default when the
SVN::Ra object is created doesn't seem to help very much,
either...

Hopefully this fixes all segfault problems users have been
experiencing over the past few months.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-05-13 12:10:42 -07:00
Eric Wong 0dc03d6a30 git-svn: clean up caching of SVN::Ra functions
This patch was originally intended to make the Perl GC more
sensitive to the SVN::Pool objects and not accidentally clean
them up when they shouldn't be (causing segfaults).  That didn't
work, but this patch makes the code a bit cleaner regardless

Put our caches for get_dir and check_path calls directly into
the SVN::Ra object so they auto-expire when it is destroyed.

dirents returned by get_dir() no longer needs the pool object
stored persistently along with the cache data, as they'll be
converted to native Perl hash references.

Since calling rev_proplist repeatedly per-revision is no longer
needed in git-svn, we do not cache calls to it.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-05-13 12:10:42 -07:00
Eric Wong 645833b564 git-svn: don't drop the username from URLs when dcommit is run
We no longer store usernames in URLs stored in git-svn-id lines
for dcommit, so we shouldn't rely on those URLs when connecting
to the remote repository to commit.
2007-05-13 12:10:42 -07:00
Karl Hasselström 171af11082 Add --no-rebase option to git-svn dcommit
git-svn dcommit exports commits to Subversion, then imports them back
to git again, and last but not least rebases or resets HEAD to the
last of the new commits. I guess this rebasing is convenient when
using just git, but when the commits to be exported are managed by
StGIT, it's really annoying. So add an option to disable this
behavior. And document it, too!

Signed-off-by: Karl Hasselström <kha@treskal.com>
Acked-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-05-04 15:08:31 -07:00
Adam Roben b3cb7e4582 git-svn: Add 'find-rev' command
This patch adds a new 'find-rev' command to git-svn that lets you easily
translate between SVN revision numbers and git tree-ish.

Signed-off-by: Adam Roben <aroben@apple.com>
Acked-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-04-30 15:58:37 -07:00
Junio C Hamano bcd8ee5b43 Fix symlink handling in git-svn, related to PerlIO
After reading the leading contents from a symlink data obtained
from subversion, which we expect to begin with 'link ', the code
forked to hash the remainder (which should match readlink()
result) using git-hash-objects, by redirecting its STDIN from
the filehandle we read that 'link ' from.  This was Ok with Perl
on modern Linux, but on Mac OS, the read in the parent process
slurped more than we asked for in stdio buffer, and the child
did not correctly see the "remainder".

This attempts to fix the issue by using lower level sysseek and
sysread instead of seek and read to bypass the stdio buffer.

Signed-off-by: Junio C Hamano <junkio@cox.net>
Acked-by: Eric Wong <normalperson@yhbt.net>
Acked-by: Seth Falcon <sethfalcon@gmail.com>
2007-04-30 15:50:13 -07:00
Adam Roben 26e60160a0 git-svn: Added 'find-rev' command
This patch adds a new 'find-rev' command to git-svn that lets you easily
translate between SVN revision numbers and git tree-ish.

Signed-off-by: Adam Roben <aroben@apple.com>
Acked-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-04-27 23:18:15 -07:00
Adam Roben 56973d20c1 git-svn: Ignore usernames in URLs in find_by_url
Usernames don't matter for the purposes of find_by_url, so always remove them
before doing any comparisons.

Signed-off-by: Adam Roben <aroben@apple.com>
Acked-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-04-25 23:05:44 -07:00
Adam Roben b03c7a63a0 git-svn: Don't rely on $_ after making a function call
Many functions and operators in perl set $_, so its value cannot be relied upon
after calling arbitrary functions. The solution is simply to copy the value of
$_ into a local variable that will not get overwritten.

Signed-off-by: Adam Roben <aroben@apple.com>
Acked-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-04-25 20:58:02 -07:00
Adam Roben ce11873921 Remove usernames from all commit messages, not just when using svmprops
Signed-off-by: Sam Vilain <sam.vilain@catalyst.net.nz>
Signed-off-by: Adam Roben <aroben@apple.com>
Acked-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-04-24 21:40:17 -07:00
Eric Wong 0c1ec5a1f7 git-svn: don't allow globs to match regular files
git only tracks the histories of full directories, not
that of individual files.  Sometimes, SVN users will
place[1] a regular file in the directory designated
for subdirectories of branches or tags.

Thanks to jrockway on #git for pointing this out.

[1] mistakenly or otherwise, such as a README

Signed-off-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-04-18 12:39:04 -07:00
Eric Wong c284914a7c git-svn: quiet some warnings when run only with --version/--help
These are harmless but annoying.  They were introduced in
512b620bd9

Signed-off-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-04-17 03:33:22 -07:00
Eric Wong d627de6b13 git-svn: respect lower bound of -r/--revision when following parent
When an explicit --revision argument is specified, do not fetch
past the specified range into the beginning of history.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-04-17 03:33:22 -07:00
Eric Wong c16d08713e git-svn: fix log command to avoid infinite loop on long commit messages
This bug has been around since the the conversion to use the
Git.pm library back in October or November.  Eventually I'd like
"git rev-list/log" to have the option to not truncate overly
long messages.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-04-08 19:54:07 -07:00
Eric Wong 13c823fb52 git-svn: dcommit/rebase confused by patches with git-svn-id: lines
When patches are merged from another git-svn managed branch,
they will have the git-svn-id: metadata line in them (generated
by git-format-patch).

When doing rebase or dcommit via git-svn, this would cause
git-svn to find the wrong upstream branch.  We now verify
that the commit is consistent with the value in the .rev_db
file.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-04-08 19:53:54 -07:00
Eric Wong 512b620bd9 git-svn: bail out on incorrect command-line options
"git svn log" is the only command that needs the pass-through
option in Getopt::Long; otherwise we will bail out and let the
user know something is wrong.

Also, avoid printing out unaccepted mixed-case options (that
are reserved for the command-line) such as --useSvmProps
in the usage() function.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-04-08 19:53:42 -07:00
Eric Wong d6bad6610a git-svn: fail on rebase if we are unable to find a ref to rebase against
If we're on an invalid HEAD, we should detect this and avoid
attempting to continue.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-03-31 15:22:59 -07:00
Eric Wong a6a15a9958 git-svn: avoid respewing similar error messages for missing paths
We ignore errors if the path we're tracking did not exist for
a particular revision range, but we still print out warnings
telling the user about that.

As pointed out by Seth Falcon, this amounts to a lot of warnings
that could confuse and worry users.  I'm not entirely comfortable
completely silencing the warnings, but showing one warning per
path that we track should be reasonable.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-03-31 01:11:13 -07:00
Eric Wong 0b59451c1b git-svn: fix rel_path() when not connected to the repository root
This should fix fetching for people who did not use
"git svn --minimize" or cannot connect to the repository root
due to the lack of permissions.

I'm not sure what I was on when I made the change to the
rel_path() function in 4e9f6cc78e
that made it die() when we weren't connected to the repository
root :x

Thanks to Sven Verdoolaege for reporting this bug.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-03-25 18:01:28 -07:00
Eric Wong dee41f3e55 git-svn: add -l/--local command to "git svn rebase"
This avoids fetching new revisions remotely, and is usefuly
versus plain "git rebase" because the user does not have to
specify which remote head to rebase against.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-03-13 21:18:37 -07:00
Eric Wong 102a0a2db1 git-svn: fix show-ignore when not connected to the repository root
It was traversing the entire repository before.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-03-04 00:34:01 -08:00
Eric Wong 2e5e24803f git-svn: fix some potential bugs with --follow-parent
When using do_switch:

  We only need to ensure the index is clean and set to that of the
  parent tree) we rely on being able to reconstruct full files
  with deltas transferred over the network.

When using do_update:

  We may safely unlink the index if we are fetching an entire
  new tree with do_update.  Having an old index (from a
  previously deleted/abandoned directory) around can cause
  irrelevant files to be mistakenly kept.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 02:21:59 -08:00
Eric Wong e2c475d91c git-svn: fix reconnections to different paths of svn:// repositories
Clearing the pool of the previous SVN::Ra connection we have
seems to to fix mysterious connection dropping errors when
reconnecting to different paths of svn:// repositories hosted by
rubyforge.org.

Note: I'm not sure *why* this fixes things things,
but it does for me.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 01:59:34 -08:00
Eric Wong f30603fcf3 git-svn: fix clone when a target directory has been specified
Several bugs caused this to fail:

* GIT_DIR was set incorrectly after entering the target directory

* Avoid double chdir-ing when clone is called with an explicit path

* create target subdirectory *before* running git-init when using
  the multi-init path

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 01:26:26 -08:00
Sam Vilain 18ea92bd81 git-svn: don't consider SVN URL usernames significant when comparing
http://foo@blah.com/path is the same as http://blah.com/path, so
remove usernames from URLs before storing them in commits, and when
reading them from commits.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 01:01:02 -08:00
Eric Wong 5253dc33b7 git-svn: ensure we're at the top-level and can access $GIT_DIR
If we are run inside a subdirectory of a working tree, we'll
chdir to the top first before touching anything.  This also
prevents the accidental creation of .git directories inside
subdirectories since they need metadata.

Noticed by maio on #git

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:13 -08:00
Eric Wong 1a97a50604 git-svn: give show-ignore HEAD smarts, like dcommit and log
This allows the user to run git-svn show-ignore on there
current HEAD without needing to remember which branch/ref they
branched from with -i.  Also, find_by_url should correctly
handle cases where the URL passed to it is not valid.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:13 -08:00
Eric Wong 0dfaf0a4e1 git-svn: allow metadata options to be specified with 'init' and 'clone'
Since the options that affect the way metadata is handled in
git-svn, should be consistently set/unset throughout history
imported by git-svn; it makes sense to allow the user to set
certain options from the command-line that will write to the
config file when initially creating the repository.

Also, fix some formatting issues while we're updating
documentation.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:13 -08:00
Eric Wong befc9adc0c git-svn: fix useSvmProps, hopefully for the last time
svm:mirror is not useful at all for us.  Parts of the old unit
test were broken and based on my misunderstanding of the
svm:mirror property.

When we read svm:source; make sure we correctly handle the '!'
in it: it is used to separate the path of the repository root
from the virtual path within the repository.  We don't need
to make that distinction, honestly!

We also ensure that subdirectories are also mirrored with the
correct URL if we're using useSvmProps.

We have a new test that uses dumped repo that was really
created using SVN::Mirror to avoid ambiguities and
mis-understandings about the svm: properties.

Note: trailing whitespace in the svm.dump file is unfortunately
a reality and required by SVN; so please ignore it when applying
this patch.

Also, ensure that the -R/--remote/--svn-remote flag is always
in effect if explicitly passed via the command-line.  This
allows us to track logically different mirrors sharing the
same URL (probably common with SVN::Mirror/SVK users).

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:13 -08:00
Eric Wong 62e349d235 git-svn: add support for using svnsync properties
This is similar to useSvmProps, but far simpler in
implementation because svnsync retains a 1:1
between revision numbers and relative paths within
the repository

Config keys: svn.useSvnsyncProps
             svn-remote.<repo>.useSvnsyncProps

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:13 -08:00
Eric Wong aea736cc6d git-svn: allow overriding of the SVN repo root in metadata
This feature allows users to create repositories from alternate
URLs.  For example, an administrator could run git-svn on the
server locally (accessing via file://) but wish to distribute
the repository with a public http:// or svn:// URL in the
metadata so users of it will see the public URL.

Config key: svn-remote.<remote>.rewriteRoot

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:13 -08:00
Eric Wong 0425ea9088 git-svn: add 'clone' command, an alias for init + fetch
Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:13 -08:00
Eric Wong b7e5348c7f git-svn: hide the private git-svn 'config' file as '.metadata'
Having it named as 'config' prevents us from tracking a
ref named 'config', which is a huge mistake.

On the non-technical side, the word 'config' implies that
a user can freely modify it; but that's not the case
here.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:13 -08:00
Eric Wong d6d3346bab git-svn: fix some issues for people migrating from older versions
* Fixed logic for renaming old .rev_db -> .rev_db.$uuid

 * correctly handle manual migrations for those who decide to
   start use globbing to handle branches/tags over individual
   'fetch' keys

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:13 -08:00
Eric Wong 905f8b7dfc git-svn: add a 'rebase' command
This works similarly to 'svn update' or 'git pull' except that
it preserves linear history with 'git rebase' instead of 'git
merge' for ease of dcommit-ing with git-svn.

While we're at it, put the working_head_info() logic
into its own function and allow --fetch-all/--all for
dcommit and rebase (which will fetch all refs in the
current [svn-remote] instead of just the working one).

Note that the '-a' switch (short for --fetch-all/--all) has been
removed as it conflicts with the non-svn 'git fetch'

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:13 -08:00
Eric Wong 1e889ef36c git-svn: checkout files on new fetches
On newly-created repositories, 'refs/heads/master' does not
point to anything.  This can be confusing to new users; so we
update 'master' to point to the last imported ref after fetching
is done.

Once 'master' is valid; we assume HEAD points to it; and if
the repository is not bare, then checkout the files if the
working tree is clean and unused.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:13 -08:00
Eric Wong 488a63ec23 git-svn: add support for --stat in the log command
Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:13 -08:00
Eric Wong a836a0e172 git-svn: documentation updates for new functionality
Force the showing of the --minimize flag as an option in the
'migrate' help.

Also, fix the usage function to correctly filter out
the deprecated aliases.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:13 -08:00
Eric Wong 60d9c97adf git-svn: allow dcommit for those who only fetch from SVM with useSvmProps
This allows users to use SVM (SVN::Mirror) to mirror a remote
repository to use dcommit to commit to the repository that SVM
was mirroring.  When dcommit is used in this manner, the automatic
fetch + rebase/reset does not happen; in which case the user will
have to manually invoke svm/svk, run 'git svn fetch', and finally
'git rebase'.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:13 -08:00
Eric Wong 7447b4bc83 git-svn: error checking for invalid [svn-remote "..."] sections
We don't end up trying to pass an undef URL over to SVN::Ra->new
because it'll segfault.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:13 -08:00
Eric Wong e8d120bd5a git-svn: remember to check for clean indices on globbed refs, too
Also, warn about dirty indices and avoid an unncessary
write-tree call if the index is clean.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:12 -08:00
Eric Wong 6af1db447b git-svn: allow --log-window-size to be specified, default to 100
The newer default value should should lower memory usage for
large fetches and also help with fetching from less reliable
servers.  Previously the value was 1000 and memory usage
got a bit high on some repositories and fetching became
less reliable in some cases.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:12 -08:00
Eric Wong b4d57e5ea3 git-svn: simplify the (multi-)init methods of fetching
Also, some changes to avoid creating dead dirs under
.git/svn/.  We now create all directories as late as
possible.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:12 -08:00
Eric Wong 28710f74ea git-svn: brown paper bag fixes
* avoid skipping modification-only changes in fetch
  * correctly fetch when we only have branches and tags
    to glob from (no fetch keys defined)

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:12 -08:00
Eric Wong dadc6d2a09 git-svn: allow 'init' to act as multi-init
multi-init is now just an alias that requires -T/-t/-b;
all options that 'init' can now accept.

This will hopefully simplify usage and reduce typing.

Also, allow the --shared option in 'init' to take an optional
argument now that 'git-init --shared' supports an optional
argument.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:12 -08:00
Eric Wong e98671e5c2 git-svn: hopefully make 'fetch' more user-friendly
multi-fetch is deprecated, "fetch -a" is easier to type
By default, fetch will fetch everything from its default
[svn-remote]; if fetch [--all|-a] is specified, then it will
fetch from all svn remotes.  Refspecs on the command-line
(like git-fetch) are not supported.

Also, enable -r/--revision arguments for fetch so
users can shoot themselves in the foot^W^W^W^W^W
skip some history and do the equivalent of a shallow
clone/fetch they're not interested in.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:12 -08:00
Eric Wong 3bc718ba66 git-svn: usability fixes for the 'git svn log' command
Similar in spirit to the recent dcommit change, we now
look at 'HEAD' by default to look for a GIT_SVN_ID
so the user won't have to pass -i <GIT_SVN_ID> argument.

We are also more tolerant of of people passing bare remote names
as a result (just $GIT_SVN_ID without the -i)

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:12 -08:00
Eric Wong ce207c7ad1 git-svn: include merges when calling rev-list for decommit
Merge commits can be created when following certain parents,
(most notably 'R' cases) and we definitely don't want to exclude
them.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:12 -08:00
Eric Wong a8ae26235c git-svn: make dcommit usable for glob users
* dcommit no longer requires the correct -i/GIT_SVN_ID option
   passed to it.  Since you're committing from HEAD (or another
   commit that is a parent of HEAD), you'll be able to find
   a commit with metadata information containing the SVN URL
   that your HEAD was descended from anyways.

 * I don't think dcommit ever worked for people using the
   noMetadata option; so I don't think relying on metadata
   is an issue.

 * useSvmProps users shouldn't commit to SVN::Mirror created
   repositories anyways, right?

 * Users of globbing should automatically be able to commit
   to paths that are not explicitly set in .git/config

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:12 -08:00
Eric Wong db03cd24a1 git-svn: handle multi-init without --trunk, UseSvmProps fixes
multi-init did not write a svn-remote.<remote>.url config
entry without a --trunk argument.

Also, The svm:mirror property is used by SVN::Mirror to track
the path of the repository that we are mirroring.  We need to
append that to the source (which is (presumably) just the URL of
the repository root).

Lastly, we now look harder for svm:(source|mirror|uuid) properties
in sub and parent directories.  Since our relative path could
be tweaked.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:12 -08:00
Eric Wong c3560e535c git-svn: write the highest maxRex out for branches and tags
Even if nothing touched paths we care about in a fetch;
increment the maxRev like we do with rev_db since
we don't like having to run get_log on revisions we've
seen before.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:12 -08:00
Eric Wong 26a62d57a2 git-svn: use separate, per-repository .rev_db files
We need a separate .rev_db file for each repository we're
tracking.  This allows us to track the same logical path off
multiple mirrors.  We preserve a symlink to the old .rev_db
(no-UUID) if we're (auto-)migrating from an old version to
preserve backwards compatibility.

Also, get rid of the uuid() wrapper since we cache UUID in our
private config, and the SVN::Ra::get_uuid() function memoizes
the return value per-connection.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:12 -08:00
Eric Wong 97ae091169 git-svn: extra safety for noMetadata and useSvmProps users
Make sure we flush our userspace buffers and and fsync(2)
.rev_db information to disk if we use these options because
we really don't want to lose this information.

Also, disallow --use-svm-props and --no-metadata from the
command-line because history will be inconsistent if they're
only used occasionally.  If a user wants to use these options,
they must be set in the config so they're always on.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:12 -08:00
Eric Wong 93f2689ccd git-svn: use private $GIT_DIR/svn/config file more
Switch max_rev storage over to using it for globbing
branches and tags.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:12 -08:00
Eric Wong 91b03282b5 git-svn: add support for per-[svn-remote "..."] options
Available options are currently:

  svn-remote.<remote>.{noMetadata,useSvmProps,followParent}

These boolean switches will override options set globally in
[svn], and even override options set on the command-line (this
should probably change in the future, however).

Note that the noMetadata and useSvmProps options conflict.  It's
both technically and logically impossible to use them together.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:12 -08:00
Eric Wong 8a49ee9759 git-svn: add support for SVN::Mirror/svk using revprops for metadata
Pass --use-svm-props or set the svn.usesvmprops key with git-config
to enable using properties set by SVN::Mirror when it mirrored the
upstream URL.

This is heavily based on work from Sam Vilain:
> From: Sam Vilain <sam@vilain.net>
> Date: Sun, 11 Feb 2007 12:34:45 +1300
> Subject: [PATCH] git-svn: re-map repository URLs and UUIDs on SVK mirror paths
>
> If an SVN revision has a property, "svm:headrev", it is likely that
> the revision was created by SVN::Mirror (a part of SVK).  The property
> contains a repository UUID and a revision.  We want to make it look
> like we are mirroring the original URL, so introduce a helper function
> that returns the original identity URL and UUID, and use it when
> generating commit messages.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:12 -08:00
Eric Wong 490f49ea58 git-svn: remove optimized commit stuff for set-tree
I may resurrect it for dcommit at some point, but nobody really
uses set-tree anymore and I don't feel like introducing more
complexity into the code at this point.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:12 -08:00
Eric Wong 74a81227f9 git-svn: correctly handle globs with a right-hand-side path component
Several bugs were found and fixed while getting this to work:

 * Remember the 'R'(eplace) case of actions and treat it like we
   would an 'A'(dd) case.

 * Fix a small case of follow-parent missing a parent if a
   subdirectory was modified in the revision where the parent was
   copied.

 * dirents returned by get_dir sometimes expire if the data
   structure is too big and the pool is destroyed, so we
   cache get_dir (along with check_path and get_revprops)
   temporarily along with its pool.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:12 -08:00
Eric Wong 9e3cdbd4f2 git-svn: correctly handle the -q flag in SVN::Git::Fetcher
Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:12 -08:00
Eric Wong 4e9f6cc78e git-svn: fix buggy regular expression usage in several places
I incorrectly used $path/? and $path/* to strip off leading
directories, but places where $path = 'branches/0.17' would
incorrectly strip changes to 'branches/0.17.1' as well.

For globs, we require that our '*' is its own path component
(surrounded by '/' or nothing).  Enforce this when --prefix= is
passed to us, too.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:12 -08:00
Eric Wong 0bed5eaa0e git-svn: enable follow-parent functionality by default
--no-follow-parent disables and reverts it back to the old
default behavior of not following parents (if you don't care for
full history).

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:11 -08:00
Eric Wong e20bea6545 git-svn: remove some noisy debugging messages
We don't need them anymore, all the rough points of
the --follow-parent implementation have been worked out.

The only improvement in the future will probably be
--follow-parent-harder, which will track subdirectories and
follow individual file history (so annotate/blame can be
complete); but that is still a ways off.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:11 -08:00
Eric Wong d542aedb94 git-svn: remove check_path calls before calling do_update
These checks were needed before git-svn got smarter about
match_paths() and using path information returned by get_log().
We also have extra checking against fetching revisions
out-of-order these days; so we don't have to worry about that as
much.  We also check for tree deletions in match_paths() and
skip those as well.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:11 -08:00
Eric Wong b9dffd8cad git-svn: --follow-parent tracks multi-parent paths
We can have a branch that was deleted, then re-added under the
same name but copied from another path, in which case we'll have
multiple parents (we don't want to break the original ref, nor
lose copypath info).

Add a test for this, too, of course.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:11 -08:00
Eric Wong e518192f3b git-svn: implement auto-discovery of branches/tags
This is similar to the way git proper handles refs, except we
use the keys 'branches' and 'tags' to distinguish when we want
to use wildcards.

The left-hand side of the ':' contains the remote path, and must
have one asterisk ('*') in it for the branch name.  The asterisk
may be in any component of the path as long as is it on its own
directory level.

The right-hand side contains the refname and must have the
asterisk as the last path component.

        branches = branches/*:refs/remotes/*
        tags = tags/*:refs/remotes/tags/*

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:11 -08:00
Eric Wong d2ae14346c git-svn: run get_log() on a sub-directory if possible
This is an optimization that should conserve network
bandwidth on certain repositories and configurations.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:11 -08:00
Eric Wong fbcc1737d6 git-svn: reintroduce using a single get_log() to fetch
We'll need to rely on path matching to handle wildcard support for branches and
tags.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:11 -08:00
Eric Wong 4bb9ed0466 git-svn: prepare multi-init for wildcard support
Update the tests since we no longer write so many things to the
config.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:11 -08:00
Eric Wong 9fa00b655c git-svn: just name the default svn-remote "svn" instead of "git-svn"
It can be confusing and redundant, since historically the
default remote ref (not remote itself) has been "git-svn", too.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:11 -08:00
Eric Wong 502c1bf629 git-svn: avoid extra get_log calls when refspecs are added for fetching
Since fetch_loop_common starts from the lowest revision number
in a group of Git::SVN objects; we want to avoid refetching
get_log for current users for things we've already cut it.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:11 -08:00
Eric Wong ef70de9685 git-svn: get rid of revisions_eq check for --follow-parent
This was originally needed before we used the delta fetcher and
had a less-clean follow-parent implementation that could leave
holes in the history.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:11 -08:00
Eric Wong 471bc00052 git-svn: migrations default to [svn-remote "git-svn"]
It looks better (like [remote "origin"]) instead of whatever
refname came up first in our directory traversal.  Of course
--remote= overrides this.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:11 -08:00
Eric Wong 88cf4107eb git-svn: save paths to tags/branches with for future reuse
Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:11 -08:00
Eric Wong d8115c5104 git-svn: don't write to the config file from --follow-parent
Having 'fetch' entries in the config file created from
--follow-parent is wasteful because it can cause *future* of
invocations to follow revisions we were never interested in
in the first place.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:11 -08:00
Eric Wong ce4b4af7ff git-svn: use sys* IO functions for reading rev_db
Using buffered IO for reading 40-41 bytes at a time isn't very
efficient.  Buffering writes for a short duration is alright
since we close() right away and buffers will be flushed.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:11 -08:00
Eric Wong 9c93fee51e git-svn: avoid redundant get_log calls between invocations
Prefill .rev_db to the maximum revision we tried to fetch;
and take advantage of that so we can avoid using get_log()
on ranges we've already seen (and have deemed uninteresting).

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:11 -08:00
Eric Wong 373274f978 git-svn: do our best to ensure that our ref and rev_db are consistent
Defer any signals that cause termination while they are
updating; and put the update-ref call as close to the rename()
as possible.  Also, make things extra-safe (but slower) for
people using --no-metadata since they can't rely on .rev_db
being rebuilt if it's clobbered (well, I'm calling update-ref
with the -m flag for reflogs, we don't yet have a way to rebuild
.rev_db from reflogs.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:11 -08:00
Eric Wong ecc712ddc4 git-svn: re-enable repacking flags
Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:11 -08:00
Eric Wong 47a0b75e01 git-svn: avoid a huge memory spike with high-numbered revisions
Passing very large strings as arguments is bad for memory usage
as it never seems to get freed in Perl.  The .rev_db format is
already not optimized for projects with sparse history.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:11 -08:00
Eric Wong d4eff2bda5 git-svn: make (multi-)fetch safer but slower
get_log with explicit paths is the safest way to get revisions
that change a particular path we're interested in.
Unfortunately that means we still have to run get_log multiple
times for each path we're interested in, and even more if
a path gets deleted.

The first argument of get_log() is an array reference, but we
shouldn't use more than one element in that array ref because
the non-existence of _one_ of those paths for a particular range
would cause an error for all paths in that range, so yes, we
need multiple get_log calls to be on the safe side...

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:11 -08:00
Eric Wong c7eba7163b git-svn: gracefully handle --follow-parent failures
We don't always know that a path will exist at a particular
revision.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:11 -08:00
Eric Wong 9760adcccc git-svn: reinstate --no-metadata, add --svn-remote=, variable cleanups
--svn-remote allows the default remote name to be overridden (useful
for tracking multiple SVN repositories).

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:11 -08:00
Eric Wong 8a603774de git-svn: fix several fetch bugs related to repeated invocations
We no longer delete the top-level directory even if it got
deleted from the upstream repository.  In gs_do_update; we
double-check that the path we're tracking exists at both
endpoints before proceeding.  We have also added additional
protection against fetching revisions out-of-order.

To simplify our internal interfaces, I've disabled passing the
'recursive' flag to the gs_do_{switch,update} wrapper functions
since we always want it in git-svn.  We also pass the
entire Git::SVN object rather than just the path because it
helped me debug.

When printing progress, the refname is printed out to make
it less confusing when multi-fetch is running.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:10 -08:00
Eric Wong f0ecca1041 git-svn: remove the 'rebuild' command and make the functionality automatic
Since refs/remotes/* are not automatically cloned, we expect the
user to be capable of copying those references themselves
anyways.

Also removed the documentation for --ignore-nodate while we're
at it; it has also been made automatic.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:10 -08:00
Eric Wong 289370578c git-svn: fetch tracks initial change with --follow-parent
We were still skipping path information from get_log if we are
tracking /r9270/drunk/subversion/bindings/..., but got something
like this in the log:

   A /r9270/drunk (from /r9270/trunk:14)

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:10 -08:00
Eric Wong 5d3b7cd5fe git-svn: don't rely on do_switch + reparenting with svn(+ssh)://
I can't seem to figure out what I or the SVN libraries are doing
wrong, but it appears to be related to reparent and probably
some global structure that gets reset if multiple SVN
connections are being used.

So now, in order to use do_switch; we'll open a new connection
to the repository with the complete URL; but we can't seem to
ever use an existing Ra object after another one has been
created...

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:10 -08:00
Eric Wong f7c3fc4a26 git-svn: reinstate the default SVN error handler after using get_log
We don't need our own error handler for other operations.  Also
add a message about the successfully do_switch or do_update in
follow-parent for debugging do_switch failures with svn:// and
svn+ssh:// connections.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:10 -08:00
Eric Wong 90c1b15da3 git-svn: just use Digest::MD5 instead of requiring it
Historically, git-svn did not always use Digest::MD5 because
it did not use the SVN::Delta::Editor interfaces.  Nowadays
it does, and the requires make strace more noisy.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:10 -08:00
Eric Wong 24e22aa8a5 git-svn: cleanup: move editor-specific variables into the editor namespace
Also removed some unused/redundant functions.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:10 -08:00
Eric Wong ce2a0f2f9d git-svn: stop using path names as refnames with --follow-parent
Using path names as refnames breaks horribly if a user is
tracking one large, toplevel directory, and a lower-level
directory is followed from another project is a parent
of another ref, as it will cause refnames such as:
'refs/remotes/trunk/path/to/stuff', which will conflict
with a refname of 'refs/remotes/trunk'.

Now we just append @$revno to the end of it the current
refname.  And if we have followed back to a grandparent, then
we'll strip any existing '@$parent_revno' strings before
appending our own '@$revno' string to it.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
2007-02-23 00:57:10 -08:00