Add 'git svn help [cmd]' which works outside a repo.
PATCH 1/2 Add 'git svn help [cmd]' which works outside a repo.
Previously there was no explicit 'help' command, but 'git svn help' still printed the usage message (as an invalid command), provided you got past the initialization steps that required a valid repo.
---
This was just a minor nit I noticed while working on the 'git-svn reset' patch.
git-svn.perl | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
git-svn.perl +3 -0
@@ -219,6 +219,9 @@ for (my $i = 0; $i < @ARGV; $i++) { $cmd = $ARGV[$i]; splice @ARGV, $i, 1; last; + } elsif ($ARGV[$i] eq 'help') { + $cmd = $ARGV[$i+1]; + usage(0); } };
Signature · 1 line
1.6.3.GIT
PATCH 2/2 Add 'git svn reset' to unwind 'git svn fetch'
Add a command to unwind the effects of fetch by moving the rev_map and refs/remotes/git-svn back to an old SVN revision. This allows revisions to be re-fetched. Ideally SVN revs would be immutable, but permissions changes in the SVN repository or indiscriminate use of '--ignore-paths' can create situations where fetch cannot make progress.
---
I ran into a situation at work where a directory in our SVN repo was hidden from me using SVN permissions. Many, many revisions later the security settings were changed which exposed those files to me. The permissions change is NOT a revision-controlled event, so from the perspective of git-svn there were ollld revisions which actually changed content. As soon as someone checked in a change to one of the newly visible files, 'git-svn fetch' would fail with the dreaded "file not found in commit" errors.
I solved my problem by modifying my ignore-paths config to restore the status quo. I did look into what would be necessary to fix it, though, and 'git-svn reset' is the result. The code changes are actually pretty minor. They're dwarfed by the docs and the tests.
Documentation/git-svn.txt | 59 +++++++++++++++++++++++++++++++++++++++- git-svn.perl | 44 ++++++++++++++++++++++++++--- t/t9139-git-svn-reset.sh | 66 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 163 insertions(+), 6 deletions(-) create mode 100755 t/t9139-git-svn-reset.sh
Documentation/git-svn.txt +58 -1
@@ -215,7 +215,7 @@ config key: svn.commiturl (overwrites all svn-remote.<name>.commiturl options) The following features from `svn log' are supported: + -- ---revision=<n>[:<n>];; +-r/--revision=<n>[:<n>];; is supported, non-numeric args are not: HEAD, NEXT, BASE, PREV, etc ... -v/--verbose;;
@@ -313,6 +313,63 @@ Any other arguments are passed directly to 'git-log' Shows the Subversion externals. Use -r/--revision to specify a specific revision. +'reset':: + Undoes the effects of 'fetch' back to the specified revision. + This allows you to re-'fetch' an SVN revision. Normally the + contents of an SVN revision should never change and 'reset' + should not be necessary. However, if SVN permissions change, + or if you alter your --ignore-paths option, a 'fetch' may fail + with "not found in commit" (file not previously visible) or + "checksum mismatch" (missed a modification). If the problem + file cannot be ignored forever (with --ignore-paths) the only + way to repair the repo is to use 'reset'. + +Only the rev_map and refs/remotes/git-svn are changed. Follow 'reset' +with a 'fetch' and then 'git-reset' or 'git-rebase' to move local +branches onto the new tree. + +-r/--revision=<n>;; + Specify the most recent revision to keep. All later revisions + are discarded. +-p/--parent;; + Discard the specified revision as well, keeping the nearest + parent instead. +Example:;; +Assume you have local changes in "master", but you need to refetch "r2". + +------------ + r1---r2---r3 remotes/git-svn + \ + A---B master +------------ + +Fix the ignore-paths or SVN permissions problem that caused "r2" to +be incomplete in the first place. Then: + +[verse] +git svn reset -r2 -p +git svn fetch + +------------ + r1---r2'--r3' remotes/git-svn + \ + r2---r3---A---B master +------------ + +Then fixup "master" with 'git-rebase'. +Do NOT use 'git-merge' or your history will not be compatible with a +future 'dcommit'! + +[verse] +git rebase --onto remotes/git-svn A^ master + +------------ + r1---r2'--r3' remotes/git-svn + \ + A'--B' master +------------ + + -- OPTIONS
git-svn.perl +39 -5
100 lines not on this page · raw message
t/t9139-git-svn-reset.sh new file +66 -0
66 lines not on this page · raw message
Signature · 1 line
1.6.3.GIT
Re: [PATCH 2/2] Add 'git svn reset' to unwind 'git svn fetch'
Quoted 2 lines · Ben Jackson
Add a command to unwind the effects of fetch by moving the
rev_mapand refs/remotes/git-svn back to an old SVN revision.
I just realized this morning that I didn't do any special handling for bad revision input. I will submit a revised patch. In the mean time I would still like feedback on the concept and the docs.
Known issues:
1. Garbage revision input is accepted and prints several internal errors before bombing out. The repo is not harmed, though.
2. Huge revision numbers cause git-svn to spin for quite a while because I used the pre-existing find_rev_before which is a linear search.
3. Without --parent it should probably fail for a nonexistent rev rather than automatically find_rev_before..
Signature · 3 lines
Ben Jackson AD7GD <[email protected]> http://www.ben.com/
Re: [PATCH 2/2] Add 'git svn reset' to unwind 'git svn fetch'
Quoted 7 lines · Ben Jackson
Quoted 2 lines · Ben Jackson
Add a command to unwind the effects of fetch by moving the
rev_mapand refs/remotes/git-svn back to an old SVN revision.I just realized this morning that I didn't do any special handling for bad revision input. I will submit a revised patch. In the mean time I would still like feedback on the concept and the docs.
Hi Ben,
Sorry for the late response, I've been distracted with other projects. I like the overall idea of it, it would actually be useful for developing/debugging git-svn as well :)
Quoted 7 lines
Known issues:
1. Garbage revision input is accepted and prints several internal errors before bombing out. The repo is not harmed, though.
2. Huge revision numbers cause git-svn to spin for quite a while because I used the pre-existing
find_rev_beforewhich is a linear search.
find_rev_before can certainly be improved. I haven't noticed performance issues with it myself, but you should be able to improve it.
Quoted 2 lines
3. Without --parent it should probably fail for a nonexistent rev rather than automatically
find_rev_before..
Probably best to ignore the --parent flag and just pass 1 as the second argument to find_rev_before. That's how SVN operations work when a non-exact revision is specified..
Signature · 1 line
Eric Wong
Quoted 9 lines · Ben Jackson
Previously there was no explicit 'help' command, but 'git svn help' still printed the usage message (as an invalid command), provided you got past the initialization steps that required a valid repo.
Signed-off-by Ben Jackson <[email protected]>---
This was just a minor nit I noticed while working on the 'git-svn reset' patch.
Thanks Ben,
Acked and pushed out to git://git.bogomips.org/git-svn
Signature · 1 line
Eric Wong