* Re: bug?: stgit creates (unneccessary?) conflicts when pulling
From: Catalin Marinas @ 2006-03-03 22:07 UTC (permalink / raw)
To: Karl Hasselström; +Cc: git
In-Reply-To: <20060303142413.GB16456@diana.vm.bytemark.co.uk>
Karl Hasselström wrote:
> On 2006-02-28 22:45:56 +0000, Catalin Marinas wrote:
>>I attached another patch that should work properly. It also pushes
>>empty patches on the stack if they were merged upstream (a 'stg
>>clean' is required to remove them). This is useful for the push
>>--undo command if you are not happy with the result.
>
> It appears to work for me. I still had to fix things up manually when
> pulling the uncommit patch though, since you had made a minor change
> in "uncommit.py":
>
> Pushing patch "uncommit"...Error: File "stgit/commands/uncommit.py" added in branches but different
Yes, I made some minor modifications (one of them was the copyright).
> Is there a way to make stgit not fall on its face when faced with this
> situation? Surely it ought to be possible to create a merged file with
> conflict markers? (I realize this is harder when there is no common
> ancestor, but these files are 95% identical!)
I've been thinking about this but it's not straight-forward. I tried
using /dev/null as the common ancestor but both diff3 and wiggle put the
whole file text in the conflict regions. These tools are not smart
enough to compare the conflict regions and reduce them.
Another approach would be to have a script that creates the common
ancestor only with the common lines between the two files and pass this
file as an argument to diff3. This wouldn't probably be that difficult,
maybe some combination of diff and sed and apply the result to one of
the files to remove the diff'ed lines.
Catalin
^ permalink raw reply
* Re: bug?: stgit creates (unneccessary?) conflicts when pulling
From: Catalin Marinas @ 2006-03-03 21:57 UTC (permalink / raw)
To: git
In-Reply-To: <20060303141329.GA16456@diana.vm.bytemark.co.uk>
Karl Hasselström wrote:
> We could perhaps do a little better. Instead of just noting whether
> the patch vanishes when reverse-applied, save the top and bottom of
> the patch as reverse-applied, and then replace the patch with the
> reverse of that. If the patch vanishes, this does what your patch does
> right now. If the patch does not vanish, all that remains is the parts
> that upstream didn't accept. (And as before, if the patch didn't
> reverse-apply cleanly, assume upstream hasn't accepted it at all yet.)
I don't fully understand this. If a patch reverse-applies cleanly, it
means that it was fully merged upstream. If it wasn't fully merged,
direct applying would fail and we should fall back to a three-way merge.
I'm not sure whether the latter would cause conflicts or not. The
disadvantage would be more time spent with trying two types of merges.
Anyway, I'll push the current patch but remain open to improvements. If
you get something working with your idea, please post a patch.
Catalin
^ permalink raw reply
* [PATCH] contrib/git-svn: fix a copied-tree bug in an overzealous assertion
From: Eric Wong @ 2006-03-03 21:35 UTC (permalink / raw)
To: Junio C Hamano, git list
I thought passing --stop-on-copy to svn would save us from all
the trouble svn-arch-mirror had with directory (project) copies.
I was wrong, there was one thing I overlooked.
If a tree was moved from /foo/trunk to /bar/foo/trunk with no
other changes in r10, but the last change was done in r5, the
Last Changed Rev (from svn info) in /bar/foo/trunk will still be
r5, even though the copy in the repository didn't exist until
r10.
Now, if we ever detect that the Last Changed Rev isn't what
we're expecting, we'll run svn diff and only croak if there are
differences between them.
Signed-off-by: Eric Wong <normalperson@yhbt.net>
---
contrib/git-svn/git-svn.perl | 15 +++++++++++----
1 files changed, 11 insertions(+), 4 deletions(-)
35f4b65079f730e7413b8b585e44526e489e8b1c
diff --git a/contrib/git-svn/git-svn.perl b/contrib/git-svn/git-svn.perl
index 25d2935..c575883 100755
--- a/contrib/git-svn/git-svn.perl
+++ b/contrib/git-svn/git-svn.perl
@@ -337,10 +337,17 @@ sub assert_svn_wc_clean {
my ($svn_rev, $treeish) = @_;
croak "$svn_rev is not an integer!\n" unless ($svn_rev =~ /^\d+$/);
croak "$treeish is not a sha1!\n" unless ($treeish =~ /^$sha1$/o);
- my $svn_info = svn_info('.');
- if ($svn_rev != $svn_info->{'Last Changed Rev'}) {
- croak "Expected r$svn_rev, got r",
- $svn_info->{'Last Changed Rev'},"\n";
+ my $lcr = svn_info('.')->{'Last Changed Rev'};
+ if ($svn_rev != $lcr) {
+ print STDERR "Checking for copy-tree ... ";
+ # use
+ my @diff = grep(/^Index: /,(safe_qx(qw(svn diff),
+ "-r$lcr:$svn_rev")));
+ if (@diff) {
+ croak "Nope! Expected r$svn_rev, got r$lcr\n";
+ } else {
+ print STDERR "OK!\n";
+ }
}
my @status = grep(!/^Performing status on external/,(`svn status`));
@status = grep(!/^\s*$/,@status);
--
1.2.4.g198d
^ permalink raw reply related
* Re: [PATCH 1/3] cg-mv doesn't work with bash 3.1.7 due to excessive quotes
From: Josef Weidendorfer @ 2006-03-03 16:34 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Pavel Roskin, git, Petr Baudis
In-Reply-To: <7vbqwo3xo4.fsf@assigned-by-dhcp.cox.net>
On Friday 03 March 2006 06:27, you wrote:
> Pavel Roskin <proski@gnu.org> writes:
>
> > - ARGS2["${#ARGS2[@]}"]="$_git_relpath${arg%/}"
> > + ARGS2[${#ARGS2[@]}]="$_git_relpath${arg%/}"
>
> Is this an application bug? It looks like a workaround for a
> bug in the shell...
This line in cg-mv is needed to work around at least two
bugs in git-mv:
* "git-mv a/ b/" not working.
Fix was to strip all trailing slashes of args (fixed in 1.2.4)
* "cd subdir; git-mv ../file ."
Fix is to run git-mv from base directory (see separate patch for git-mv)
I think cg-mv should be able to be a direct wrapper for git-mv with
the next maintenance release.
Pasky: do you know of other problems with git-mv?
Josef
^ permalink raw reply
* [PATCH] git-mv: fix moves into a subdir from outside
From: Josef Weidendorfer @ 2006-03-03 16:23 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
git-mv needs to be run from the base directory so that
the check if a file is under revision also covers files
outside of a subdirectory. Previously, e.g. in the git repo,
cd Documentation; git-mv ../README .
produced the error
Error: '../README' not under version control
The test is extended for this case; it previously only tested
one direction.
Signed-off-by: Josef Weidendorfer <Josef.Weidendorfer@gmx.de>
---
git-mv.perl | 8 ++++++++
t/t7001-mv.sh | 18 ++++++++++++++++--
2 files changed, 24 insertions(+), 2 deletions(-)
08d21abe95064934ea559b88801415e09b19f628
diff --git a/git-mv.perl b/git-mv.perl
index f3e859a..0a63860 100755
--- a/git-mv.perl
+++ b/git-mv.perl
@@ -62,9 +62,17 @@ else {
$dstDir = "";
}
+my $subdir_prefix = `git rev-parse --show-prefix`;
+chomp($subdir_prefix);
+
+# run in git base directory, so that git-ls-files lists all revisioned files
+chdir "$GIT_DIR/..";
+
# normalize paths, needed to compare against versioned files and update-index
# also, this is nicer to end-users by doing ".//a/./b/.//./c" ==> "a/b/c"
for (@srcArgs, @dstArgs) {
+ # prepend git prefix as we run from base directory
+ $_ = $subdir_prefix.$_;
s|^\./||;
s|/\./|/| while (m|/\./|);
s|//+|/|g;
diff --git a/t/t7001-mv.sh b/t/t7001-mv.sh
index 43d74c5..811a479 100755
--- a/t/t7001-mv.sh
+++ b/t/t7001-mv.sh
@@ -11,17 +11,31 @@ test_expect_success \
git-commit -m add -a'
test_expect_success \
- 'moving the file' \
+ 'moving the file out of subdirectory' \
'cd path0 && git-mv COPYING ../path1/COPYING'
# in path0 currently
test_expect_success \
'commiting the change' \
- 'cd .. && git-commit -m move -a'
+ 'cd .. && git-commit -m move-out -a'
test_expect_success \
'checking the commit' \
'git-diff-tree -r -M --name-status HEAD^ HEAD | \
grep -E "^R100.+path0/COPYING.+path1/COPYING"'
+test_expect_success \
+ 'moving the file back into subdirectory' \
+ 'cd path0 && git-mv ../path1/COPYING COPYING'
+
+# in path0 currently
+test_expect_success \
+ 'commiting the change' \
+ 'cd .. && git-commit -m move-in -a'
+
+test_expect_success \
+ 'checking the commit' \
+ 'git-diff-tree -r -M --name-status HEAD^ HEAD | \
+ grep -E "^R100.+path1/COPYING.+path0/COPYING"'
+
test_done
--
1.2.0.g719b
^ permalink raw reply related
* Re: [PATCH] Add --temp and --stage=all options to checkout-index.
From: Shawn Pearce @ 2006-03-03 15:13 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <7vmzg83xro.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano <junkio@cox.net> wrote:
> Shawn Pearce <spearce@spearce.org> writes:
>
> > Unfortunately this change lead me down a path which changed the core
> > checkout code also used by apply and read-tree.
>
> ... which makes it much harder to swallow without careful
> inspection X-<.
>
> I think the patch only appears much bigger than it actually is,
> because of reindentation effect coming from "if (to-temp-file)".
> However, I am too tired to carefully examine them tonight, so I
> hope you do not mind my postponing this for now.
Not at all. I read over the diff before sending it and thought it
made the patch look much worse than it really is, simply because
of the reindentation. :-|
Sometimes good 'ole diff ain't that great for conveying a change.
--
Shawn.
^ permalink raw reply
* Re: bug?: stgit creates (unneccessary?) conflicts when pulling
From: Karl Hasselström @ 2006-03-03 14:24 UTC (permalink / raw)
To: git
In-Reply-To: <b0943d9e0602281445w7160d915y@mail.gmail.com>
On 2006-02-28 22:45:56 +0000, Catalin Marinas wrote:
> On 27/02/06, Catalin Marinas <catalin.marinas@gmail.com> wrote:
>
> > An idea (untested, I don't even know whether it's feasible) would
> > be to check which patches were merged by reverse-applying them
> > starting with the last. In this situation, all the merged patches
> > should just revert their changes. You only need to do a git-diff
> > between the bottom and the top of the patch and git-apply the
> > output (maybe without even modifying the tree). If this operation
> > succeeds, the patch was integrated and you don't even need to push
> > it.
>
> I attached another patch that should work properly. It also pushes
> empty patches on the stack if they were merged upstream (a 'stg
> clean' is required to remove them). This is useful for the push
> --undo command if you are not happy with the result.
>
> I'll try this patch for a bit more before pushing into the
> repository.
It appears to work for me. I still had to fix things up manually when
pulling the uncommit patch though, since you had made a minor change
in "uncommit.py":
Pushing patch "uncommit"...Error: File "stgit/commands/uncommit.py" added in branches but different
Is there a way to make stgit not fall on its face when faced with this
situation? Surely it ought to be possible to create a merged file with
conflict markers? (I realize this is harder when there is no common
ancestor, but these files are 95% identical!)
--
Karl Hasselström, kha@treskal.com
www.treskal.com/kalle
^ permalink raw reply
* Re: bug?: stgit creates (unneccessary?) conflicts when pulling
From: Karl Hasselström @ 2006-03-03 14:13 UTC (permalink / raw)
To: git
In-Reply-To: <b0943d9e0603010953iccf64a4v@mail.gmail.com>
On 2006-03-01 17:53:53 +0000, Catalin Marinas wrote:
> This won't solve the problem since testing whether patch "a" was
> merged upstream will fail because its reverse won't apply cleanly
> onto the upstream HEAD. Of course, you can try combination of
> upstream commits and local patches but it's not really feasible.
>
> As I said, this method doesn't solve all the upstream merge
> situations but it is OK for most of them.
We could perhaps do a little better. Instead of just noting whether
the patch vanishes when reverse-applied, save the top and bottom of
the patch as reverse-applied, and then replace the patch with the
reverse of that. If the patch vanishes, this does what your patch does
right now. If the patch does not vanish, all that remains is the parts
that upstream didn't accept. (And as before, if the patch didn't
reverse-apply cleanly, assume upstream hasn't accepted it at all yet.)
--
Karl Hasselström, kha@treskal.com
www.treskal.com/kalle
^ permalink raw reply
* Re: [PATCH 1/3] cg-mv doesn't work with bash 3.1.7 due to excessive quotes
From: Pavel Roskin @ 2006-03-03 14:11 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <7vbqwo3xo4.fsf@assigned-by-dhcp.cox.net>
On Thu, 2006-03-02 at 21:27 -0800, Junio C Hamano wrote:
> Pavel Roskin <proski@gnu.org> writes:
>
> > - ARGS2["${#ARGS2[@]}"]="$_git_relpath${arg%/}"
> > + ARGS2[${#ARGS2[@]}]="$_git_relpath${arg%/}"
>
> Is this an application bug? It looks like a workaround for a
> bug in the shell...
Indeed, bash 3.00.16 (FC4) is fine with the original cg-mv. On the
other hand, bash 3.1.7 (FC development) doesn't even like this:
$ arg["0"]=0
bash: "0": syntax error: operand expected (error token is ""0"")
I don't see any relevant information in the NEWS file, so even if it's
no a bug, it's an undocumented feature :-)
Anyway, the quotes are excessive, bash is (sort of) correct to complain
about it, and I don't see any other instances of quoting array arguments
in cogito.
The quotes in question have always existed in cg-mv, they were not added
to work around anything.
--
Regards,
Pavel Roskin
^ permalink raw reply
* workaround fat/ntfs deficiencies for t3600-rm.sh (git-rm)
From: Alex Riesen @ 2006-03-03 10:20 UTC (permalink / raw)
To: Git Mailing List; +Cc: Junio C Hamano, Carl Worth
[-- Attachment #1: Type: text/plain, Size: 243 bytes --]
Signed-off-by: Alex Riesen <ariesen@harmanbecker.com>
---
chmod u-w and even chmod a-w dont work on fat and ntfs.
The actually do something, but rm a file from that directory
will succeed anyway. That's windows permission model to you...
[-- Attachment #2: 0001-workaround-fat-ntfs-deficiencies-for-t3600-rm.sh-git-rm.txt --]
[-- Type: text/plain, Size: 1900 bytes --]
>From nobody Mon Sep 17 00:00:00 2001
From: Alex Riesen <raa.lkml@gmail.com>
Date: Fri Mar 3 11:15:05 2006 +0100
Subject: workaround fat/ntfs deficiencies for t3600-rm.sh (git-rm)
---
t/t3600-rm.sh | 23 +++++++++++++++++------
1 files changed, 17 insertions(+), 6 deletions(-)
583a9faeab3a200fc970577458b7827d86aa7df1
diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh
index cabfadd..d1947e1 100755
--- a/t/t3600-rm.sh
+++ b/t/t3600-rm.sh
@@ -8,11 +8,20 @@ test_description='Test of the various op
. ./test-lib.sh
# Setup some files to be removed, some with funny characters
-touch -- foo bar baz 'space embedded' 'tab embedded' 'newline
-embedded' -q
-git-add -- foo bar baz 'space embedded' 'tab embedded' 'newline
-embedded' -q
-git-commit -m "add files"
+touch -- foo bar baz 'space embedded' -q
+git-add -- foo bar baz 'space embedded' -q
+git-commit -m "add normal files"
+test_tabs=y
+if touch -- 'tab embedded' 'newline
+embedded'
+then
+git-add -- 'tab embedded' 'newline
+embedded'
+git-commit -m "add files with tabs and newlines"
+else
+ say 'Your filesystem does not allow tabs in filenames.'
+ test_tabs=n
+fi
test_expect_success \
'Pre-check that foo exists and is in index before git-rm foo' \
@@ -42,16 +51,18 @@ test_expect_success \
'Test that "git-rm -- -q" succeeds (remove a file that looks like an option)' \
'git-rm -- -q'
-test_expect_success \
+test "$test_tabs" = y && test_expect_success \
"Test that \"git-rm -f\" succeeds with embedded space, tab, or newline characters." \
"git-rm -f 'space embedded' 'tab embedded' 'newline
embedded'"
+if test "$test_tabs" = y; then
chmod u-w .
test_expect_failure \
'Test that "git-rm -f" fails if its rm fails' \
'git-rm -f baz'
chmod u+w .
+fi
test_expect_success \
'When the rm in "git-rm -f" fails, it should not remove the file from the index' \
--
1.2.4.ga091
^ permalink raw reply related
* [PATCH] send-email: accept --no-signed-off-by-cc as the documentation states
From: Eric Wong @ 2006-03-03 9:28 UTC (permalink / raw)
To: junkio, ryan; +Cc: git, Eric Wong
--no-signed-off-cc is still supported, for backwards compatibility
Signed-off-by: Eric Wong <normalperson@yhbt.net>
---
git-send-email.perl | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
374f3e5c7fd49c4949df9b29ed03287e6ceb2e2c
diff --git a/git-send-email.perl b/git-send-email.perl
index b0d095b..7c8d512 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -54,7 +54,7 @@ my $rc = GetOptions("from=s" => \$from,
"compose" => \$compose,
"quiet" => \$quiet,
"suppress-from" => \$suppress_from,
- "no-signed-off-cc" => \$no_signed_off_cc,
+ "no-signed-off-cc|no-signed-off-by-cc" => \$no_signed_off_cc,
);
# Now, let's fill any that aren't set in with defaults:
--
1.2.3.g4676
^ permalink raw reply related
* [PATCH 8/9] contrib/git-svn: add --id/-i=$GIT_SVN_ID command-line switch
From: Eric Wong @ 2006-03-03 9:20 UTC (permalink / raw)
To: junkio; +Cc: git
In-Reply-To: <11413776092493-git-send-email-normalperson@yhbt.net>
I ended up using GIT_SVN_ID far more than I ever thought I
would. Typing less is good.
Signed-off-by: Eric Wong <normalperson@yhbt.net>
---
contrib/git-svn/git-svn.perl | 19 +++++++++++--------
1 files changed, 11 insertions(+), 8 deletions(-)
1d3dc63f7ed276863c71f9a212471658f359ef75
diff --git a/contrib/git-svn/git-svn.perl b/contrib/git-svn/git-svn.perl
index 041791b..db199a3 100755
--- a/contrib/git-svn/git-svn.perl
+++ b/contrib/git-svn/git-svn.perl
@@ -10,13 +10,6 @@ use vars qw/ $AUTHOR $VERSION
$AUTHOR = 'Eric Wong <normalperson@yhbt.net>';
$VERSION = '0.10.0';
$GIT_DIR = $ENV{GIT_DIR} || "$ENV{PWD}/.git";
-$GIT_SVN = $ENV{GIT_SVN_ID} || 'git-svn';
-$GIT_SVN_INDEX = "$GIT_DIR/$GIT_SVN/index";
-$ENV{GIT_DIR} ||= $GIT_DIR;
-$SVN_URL = undef;
-$REV_DIR = "$GIT_DIR/$GIT_SVN/revs";
-$SVN_WC = "$GIT_DIR/$GIT_SVN/tree";
-
# make sure the svn binary gives consistent output between locales and TZs:
$ENV{TZ} = 'UTC';
$ENV{LC_ALL} = 'C';
@@ -78,7 +71,17 @@ foreach (keys %cmd) {
my %opts;
%opts = %{$cmd{$cmd}->[2]} if (defined $cmd);
-GetOptions(%opts, 'help|H|h' => \$_help, 'version|V' => \$_version ) or exit 1;
+GetOptions(%opts, 'help|H|h' => \$_help,
+ 'version|V' => \$_version,
+ 'id|i=s' => \$GIT_SVN) or exit 1;
+
+$GIT_SVN ||= $ENV{GIT_SVN_ID} || 'git-svn';
+$GIT_SVN_INDEX = "$GIT_DIR/$GIT_SVN/index";
+$ENV{GIT_DIR} ||= $GIT_DIR;
+$SVN_URL = undef;
+$REV_DIR = "$GIT_DIR/$GIT_SVN/revs";
+$SVN_WC = "$GIT_DIR/$GIT_SVN/tree";
+
usage(0) if $_help;
version() if $_version;
usage(1) unless defined $cmd;
--
1.2.3.g4676
^ permalink raw reply related
* [PATCH 2/9] contrib/git-svn: several small bug fixes and changes
From: Eric Wong @ 2006-03-03 9:20 UTC (permalink / raw)
To: junkio; +Cc: git
In-Reply-To: <11413776074148-git-send-email-normalperson@yhbt.net>
* Fixed manually-edited commit messages not going to
remotes/git-svn on sequential commits after the sequential
commit optimization.
* format help correctly after adding 'show-ignore'
* sha1_short regexp matches down to 4 hex characters
(from git-rev-parse --short documentation)
* Print the first line of the commit message when we commit to
SVN next to the sha1.
* Document 'T' (type change) in the comments
Signed-off-by: Eric Wong <normalperson@yhbt.net>
---
contrib/git-svn/git-svn.perl | 27 +++++++++++++++++----------
1 files changed, 17 insertions(+), 10 deletions(-)
43965ace71422148acb1bae488d78cbcfc5ca65e
diff --git a/contrib/git-svn/git-svn.perl b/contrib/git-svn/git-svn.perl
index 1f9a470..67368a5 100755
--- a/contrib/git-svn/git-svn.perl
+++ b/contrib/git-svn/git-svn.perl
@@ -32,7 +32,7 @@ use Getopt::Long qw/:config gnu_getopt n
use File::Spec qw//;
use POSIX qw/strftime/;
my $sha1 = qr/[a-f\d]{40}/;
-my $sha1_short = qr/[a-f\d]{6,40}/;
+my $sha1_short = qr/[a-f\d]{4,40}/;
my ($_revision,$_stdin,$_no_ignore_ext,$_no_stop_copy,$_help,$_rmdir,$_edit,
$_find_copies_harder, $_l, $_version, $_upgrade);
my (@_branch_from, %tree_map);
@@ -90,12 +90,12 @@ Usage: $0 <command> [options] [arguments
Available commands:
foreach (sort keys %cmd) {
- print $fd ' ',pack('A10',$_),$cmd{$_}->[1],"\n";
+ print $fd ' ',pack('A13',$_),$cmd{$_}->[1],"\n";
}
print $fd <<"";
\nGIT_SVN_ID may be set in the environment to an arbitrary identifier if
you're tracking multiple SVN branches/repositories in one git repository
-and want to keep them separate.
+and want to keep them separate. See git-svn(1) for more information.
exit $exit;
}
@@ -245,7 +245,7 @@ sub commit {
print "Reading from stdin...\n";
@commits = ();
while (<STDIN>) {
- if (/\b([a-f\d]{6,40})\b/) {
+ if (/\b($sha1_short)\b/) {
unshift @commits, $1;
}
}
@@ -267,7 +267,6 @@ sub commit {
chdir $SVN_WC or croak $!;
my $svn_current_rev = svn_info('.')->{'Last Changed Rev'};
foreach my $c (@revs) {
- print "Committing $c\n";
my $mods = svn_checkout_tree($svn_current_rev, $c);
if (scalar @$mods == 0) {
print "Skipping, no changes detected\n";
@@ -514,7 +513,7 @@ sub svn_checkout_tree {
my ($svn_rev, $treeish) = @_;
my $from = file_to_s("$REV_DIR/$svn_rev");
assert_svn_wc_clean($svn_rev,$from);
- print "diff-tree '$from' '$treeish'\n";
+ print "diff-tree $from $treeish\n";
my $pid = open my $diff_fh, '-|';
defined $pid or croak $!;
if ($pid == 0) {
@@ -525,7 +524,7 @@ sub svn_checkout_tree {
}
my $mods = parse_diff_tree($diff_fh);
unless (@$mods) {
- # git can do empty commits, SVN doesn't allow it...
+ # git can do empty commits, but SVN doesn't allow it...
return $mods;
}
my ($rm, $add) = precommit_check($mods);
@@ -612,7 +611,7 @@ sub svn_commit_tree {
my ($svn_rev, $commit) = @_;
my $commit_msg = "$GIT_DIR/$GIT_SVN/.svn-commit.tmp.$$";
my %log_msg = ( msg => '' );
- open my $msg, '>', $commit_msg or croak $!;
+ open my $msg, '>', $commit_msg or croak $!;
chomp(my $type = `git-cat-file -t $commit`);
if ($type eq 'commit') {
@@ -627,7 +626,6 @@ sub svn_commit_tree {
if (!$in_msg) {
$in_msg = 1 if (/^\s*$/);
} else {
- $log_msg{msg} .= $_;
print $msg $_ or croak $!;
}
}
@@ -639,6 +637,15 @@ sub svn_commit_tree {
my $editor = $ENV{VISUAL} || $ENV{EDITOR} || 'vi';
system($editor, $commit_msg);
}
+
+ # file_to_s removes all trailing newlines, so just use chomp() here:
+ open $msg, '<', $commit_msg or croak $!;
+ { local $/; chomp($log_msg{msg} = <$msg>); }
+ close $msg or croak $!;
+
+ my ($oneline) = ($log_msg{msg} =~ /([^\n\r]+)/);
+ print "Committing $commit: $oneline\n";
+
my @ci_output = safe_qx(qw(svn commit -F),$commit_msg);
my ($committed) = grep(/^Committed revision \d+\./,@ci_output);
unlink $commit_msg;
@@ -1037,7 +1044,7 @@ diff-index line ($m hash)
mode_a => first column of diff-index output, no leading ':',
mode_b => second column of diff-index output,
sha1_b => sha1sum of the final blob,
- chg => change type [MCRAD],
+ chg => change type [MCRADT],
file_a => original file name of a file (iff chg is 'C' or 'R')
file_b => new/current file name of a file (any chg)
}
--
1.2.3.g4676
^ permalink raw reply related
* [PATCH 9/9] contrib/git-svn: better documenting of CLI switches
From: Eric Wong @ 2006-03-03 9:20 UTC (permalink / raw)
To: junkio; +Cc: git
In-Reply-To: <11413776092524-git-send-email-normalperson@yhbt.net>
Also, fix a asciidoc formatting error
Signed-off-by: Eric Wong <normalperson@yhbt.net>
---
contrib/git-svn/git-svn.perl | 29 +++++++++++++++--------------
contrib/git-svn/git-svn.txt | 17 ++++++++++++++++-
2 files changed, 31 insertions(+), 15 deletions(-)
65d8e4920084c96f82b4604ded1bd4e4fa91d3d8
diff --git a/contrib/git-svn/git-svn.perl b/contrib/git-svn/git-svn.perl
index db199a3..808b933 100755
--- a/contrib/git-svn/git-svn.perl
+++ b/contrib/git-svn/git-svn.perl
@@ -60,16 +60,7 @@ for (my $i = 0; $i < @ARGV; $i++) {
}
};
-# we may be called as git-svn-(command), or git-svn(command).
-foreach (keys %cmd) {
- if (/git\-svn\-?($_)(?:\.\w+)?$/) {
- $cmd = $1;
- last;
- }
-}
-
-my %opts;
-%opts = %{$cmd{$cmd}->[2]} if (defined $cmd);
+my %opts = %{$cmd{$cmd}->[2]} if (defined $cmd);
GetOptions(%opts, 'help|H|h' => \$_help,
'version|V' => \$_version,
@@ -97,15 +88,25 @@ sub usage {
print $fd <<"";
git-svn - bidirectional operations between a single Subversion tree and git
Usage: $0 <command> [options] [arguments]\n
-Available commands:
+
+ print $fd "Available commands:\n" unless $cmd;
foreach (sort keys %cmd) {
+ next if $cmd && $cmd ne $_;
print $fd ' ',pack('A13',$_),$cmd{$_}->[1],"\n";
+ foreach (keys %{$cmd{$_}->[2]}) {
+ # prints out arguments as they should be passed:
+ my $x = s#=s$## ? '<arg>' : s#=i$## ? '<num>' : '';
+ print $fd ' ' x 17, join(', ', map { length $_ > 1 ?
+ "--$_" : "-$_" }
+ split /\|/,$_)," $x\n";
+ }
}
print $fd <<"";
-\nGIT_SVN_ID may be set in the environment to an arbitrary identifier if
-you're tracking multiple SVN branches/repositories in one git repository
-and want to keep them separate. See git-svn(1) for more information.
+\nGIT_SVN_ID may be set in the environment or via the --id/-i switch to an
+arbitrary identifier if you're tracking multiple SVN branches/repositories in
+one git repository and want to keep them separate. See git-svn(1) for more
+information.
exit $exit;
}
diff --git a/contrib/git-svn/git-svn.txt b/contrib/git-svn/git-svn.txt
index 7306048..8e9a971 100644
--- a/contrib/git-svn/git-svn.txt
+++ b/contrib/git-svn/git-svn.txt
@@ -116,6 +116,8 @@ OPTIONS
They are both passed directly to git-diff-tree see
git-diff-tree(1) for more information.
+ADVANCED OPTIONS
+----------------
-b<refname>::
--branch <refname>::
Used with 'fetch' or 'commit'.
@@ -131,8 +133,21 @@ OPTIONS
This option may be specified multiple times, once for each
branch.
+-i<GIT_SVN_ID>::
+--id <GIT_SVN_ID>::
+ This sets GIT_SVN_ID (instead of using the environment). See
+ the section on "Tracking Multiple Repositories or Branches" for
+ more information on using GIT_SVN_ID.
+
COMPATIBILITY OPTIONS
---------------------
+--upgrade::
+ Only used with the 'rebuild' command.
+
+ Run this if you used an old version of git-svn that used
+ 'git-svn-HEAD' instead of 'remotes/git-svn' as the branch
+ for tracking the remote.
+
--no-ignore-externals::
Only used with the 'fetch' and 'rebuild' command.
@@ -177,7 +192,7 @@ Tracking and contributing to an Subversi
git-svn commit remotes/git-svn..my-branch
# Something is committed to SVN, pull the latest into your branch::
git-svn fetch && git pull . remotes/git-svn
-# Append svn:ignore settings to the default git exclude file:
+# Append svn:ignore settings to the default git exclude file::
git-svn show-ignore >> .git/info/exclude
DESIGN PHILOSOPHY
--
1.2.3.g4676
^ permalink raw reply related
* [PATCH 4/9] contrib/git-svn: allow --authors-file to be specified
From: Eric Wong @ 2006-03-03 9:20 UTC (permalink / raw)
To: junkio; +Cc: git
In-Reply-To: <11413776082010-git-send-email-normalperson@yhbt.net>
Syntax is compatible with git-svnimport and git-cvsimport:
normalperson = Eric Wong <normalperson@yhbt.net>
If this option is specified and git-svn encounters an SVN
committer name that it cannot parse, it git-svn will abort.
Signed-off-by: Eric Wong <normalperson@yhbt.net>
---
contrib/git-svn/git-svn.perl | 40 ++++++++++++++++++++++++++++++++--------
1 files changed, 32 insertions(+), 8 deletions(-)
c501f8378dfb5529993755caaf99ca632418e382
diff --git a/contrib/git-svn/git-svn.perl b/contrib/git-svn/git-svn.perl
index edae9d4..c2b4ee9 100755
--- a/contrib/git-svn/git-svn.perl
+++ b/contrib/git-svn/git-svn.perl
@@ -34,8 +34,8 @@ use POSIX qw/strftime/;
my $sha1 = qr/[a-f\d]{40}/;
my $sha1_short = qr/[a-f\d]{4,40}/;
my ($_revision,$_stdin,$_no_ignore_ext,$_no_stop_copy,$_help,$_rmdir,$_edit,
- $_find_copies_harder, $_l, $_version, $_upgrade);
-my (@_branch_from, %tree_map);
+ $_find_copies_harder, $_l, $_version, $_upgrade, $_authors);
+my (@_branch_from, %tree_map, %users);
GetOptions( 'revision|r=s' => \$_revision,
'no-ignore-externals' => \$_no_ignore_ext,
@@ -46,6 +46,7 @@ GetOptions( 'revision|r=s' => \$_revisio
'help|H|h' => \$_help,
'branch|b=s' => \@_branch_from,
'find-copies-harder' => \$_find_copies_harder,
+ 'authors-file|authors|A=s' => \$_authors,
'l=i' => \$_l,
'version|V' => \$_version,
'no-stop-on-copy' => \$_no_stop_copy );
@@ -73,6 +74,19 @@ foreach (keys %cmd) {
last;
}
}
+
+# '<svn username> = real-name <email address>' mapping based on git-svnimport:
+if ($_authors) {
+ open my $authors, '<', $_authors or die "Can't open $_authors $!\n";
+ while (<$authors>) {
+ chomp;
+ next unless /^(\S+?)\s*=\s*(.+?)\s*<(.+)>\s*$/;
+ my ($user, $name, $email) = ($1, $2, $3);
+ $users{$user} = [$name, $email];
+ }
+ close $authors or croak $!;
+}
+
usage(0) if $_help;
version() if $_version;
usage(1) unless (defined $cmd);
@@ -740,6 +754,10 @@ sub svn_log_raw {
author => $author,
lines => $lines,
msg => '' );
+ if (defined $_authors && ! defined $users{$author}) {
+ die "Author: $author not defined in ",
+ "$_authors file\n";
+ }
push @svn_log, \%log_msg;
$state = 'msg_start';
next;
@@ -884,12 +902,8 @@ sub git_commit {
$msg_fh->flush == 0 or croak $!;
seek $msg_fh, 0, 0 or croak $!;
- $ENV{GIT_AUTHOR_NAME} = $ENV{GIT_COMMITTER_NAME} =
- $log_msg->{author};
- $ENV{GIT_AUTHOR_EMAIL} = $ENV{GIT_COMMITTER_EMAIL} =
- $log_msg->{author}."\@$uuid";
- $ENV{GIT_AUTHOR_DATE} = $ENV{GIT_COMMITTER_DATE} =
- $log_msg->{date};
+ set_commit_env($log_msg, $uuid);
+
my @exec = ('git-commit-tree',$tree);
push @exec, '-p', $_ foreach @exec_parents;
open STDIN, '<&', $msg_fh or croak $!;
@@ -915,6 +929,16 @@ sub git_commit {
return $commit;
}
+sub set_commit_env {
+ my ($log_msg, $uuid) = @_;
+ my $author = $log_msg->{author};
+ my ($name,$email) = defined $users{$author} ? @{$users{$author}}
+ : ($author,"$author\@$uuid");
+ $ENV{GIT_AUTHOR_NAME} = $ENV{GIT_COMMITTER_NAME} = $name;
+ $ENV{GIT_AUTHOR_EMAIL} = $ENV{GIT_COMMITTER_EMAIL} = $email;
+ $ENV{GIT_AUTHOR_DATE} = $ENV{GIT_COMMITTER_DATE} = $log_msg->{date};
+}
+
sub apply_mod_line_blob {
my $m = shift;
if ($m->{mode_b} =~ /^120/) {
--
1.2.3.g4676
^ permalink raw reply related
* [PATCH 7/9] contrib/git-svn: avoid re-reading the repository uuid, it never changes
From: Eric Wong @ 2006-03-03 9:20 UTC (permalink / raw)
To: junkio; +Cc: git
In-Reply-To: <11413776092820-git-send-email-normalperson@yhbt.net>
If it does change, we're screwed anyways as SVN will refuse to
commit or update. We also never access more than one SVN
repository per-invocation, so we can store it as a global, too.
Signed-off-by: Eric Wong <normalperson@yhbt.net>
---
contrib/git-svn/git-svn.perl | 27 ++++++++++++---------------
1 files changed, 12 insertions(+), 15 deletions(-)
3dc689059bd5cffa12bb2b8cdc0f1965d5f6cee2
diff --git a/contrib/git-svn/git-svn.perl b/contrib/git-svn/git-svn.perl
index 69b6be3..041791b 100755
--- a/contrib/git-svn/git-svn.perl
+++ b/contrib/git-svn/git-svn.perl
@@ -4,7 +4,7 @@
use warnings;
use strict;
use vars qw/ $AUTHOR $VERSION
- $SVN_URL $SVN_INFO $SVN_WC
+ $SVN_URL $SVN_INFO $SVN_WC $SVN_UUID
$GIT_SVN_INDEX $GIT_SVN
$GIT_DIR $REV_DIR/;
$AUTHOR = 'Eric Wong <normalperson@yhbt.net>';
@@ -114,7 +114,6 @@ sub version {
sub rebuild {
$SVN_URL = shift or undef;
- my $repo_uuid;
my $newest_rev = 0;
if ($_upgrade) {
sys('git-update-ref',"refs/remotes/$GIT_SVN","$GIT_SVN-HEAD");
@@ -150,7 +149,7 @@ sub rebuild {
# if we merged or otherwise started elsewhere, this is
# how we break out of it
- next if (defined $repo_uuid && ($uuid ne $repo_uuid));
+ next if (defined $SVN_UUID && ($uuid ne $SVN_UUID));
next if (defined $SVN_URL && ($url ne $SVN_URL));
print "r$rev = $c\n";
@@ -159,7 +158,7 @@ sub rebuild {
croak "SVN repository location required: $url\n";
}
$SVN_URL ||= $url;
- $repo_uuid ||= setup_git_svn();
+ $SVN_UUID ||= setup_git_svn();
$latest = $rev;
}
assert_revision_eq_or_unknown($rev, $c);
@@ -252,7 +251,7 @@ sub commit {
print "Reading from stdin...\n";
@commits = ();
while (<STDIN>) {
- if (/\b($sha1_short)\b/) {
+ if (/\b($sha1_short)\b/o) {
unshift @commits, $1;
}
}
@@ -320,14 +319,14 @@ sub setup_git_svn {
mkpath(["$GIT_DIR/$GIT_SVN/info"]);
mkpath([$REV_DIR]);
s_to_file($SVN_URL,"$GIT_DIR/$GIT_SVN/info/url");
- my $uuid = svn_info($SVN_URL)->{'Repository UUID'} or
+ $SVN_UUID = svn_info($SVN_URL)->{'Repository UUID'} or
croak "Repository UUID unreadable\n";
- s_to_file($uuid,"$GIT_DIR/$GIT_SVN/info/uuid");
+ s_to_file($SVN_UUID,"$GIT_DIR/$GIT_SVN/info/uuid");
open my $fd, '>>', "$GIT_DIR/$GIT_SVN/info/exclude" or croak $!;
print $fd '.svn',"\n";
close $fd or croak $!;
- return $uuid;
+ return $SVN_UUID;
}
sub assert_svn_wc_clean {
@@ -850,9 +849,7 @@ sub git_commit {
my ($log_msg, @parents) = @_;
assert_revision_unknown($log_msg->{revision});
my $out_fh = IO::File->new_tmpfile or croak $!;
- my $info = svn_info('.');
- my $uuid = $info->{'Repository UUID'};
- defined $uuid or croak "Unable to get Repository UUID\n";
+ $SVN_UUID ||= svn_info('.')->{'Repository UUID'};
map_tree_joins() if (@_branch_from && !%tree_map);
@@ -891,11 +888,11 @@ sub git_commit {
my $msg_fh = IO::File->new_tmpfile or croak $!;
print $msg_fh $log_msg->{msg}, "\ngit-svn-id: ",
"$SVN_URL\@$log_msg->{revision}",
- " $uuid\n" or croak $!;
+ " $SVN_UUID\n" or croak $!;
$msg_fh->flush == 0 or croak $!;
seek $msg_fh, 0, 0 or croak $!;
- set_commit_env($log_msg, $uuid);
+ set_commit_env($log_msg);
my @exec = ('git-commit-tree',$tree);
push @exec, '-p', $_ foreach @exec_parents;
@@ -923,10 +920,10 @@ sub git_commit {
}
sub set_commit_env {
- my ($log_msg, $uuid) = @_;
+ my ($log_msg) = @_;
my $author = $log_msg->{author};
my ($name,$email) = defined $users{$author} ? @{$users{$author}}
- : ($author,"$author\@$uuid");
+ : ($author,"$author\@$SVN_UUID");
$ENV{GIT_AUTHOR_NAME} = $ENV{GIT_COMMITTER_NAME} = $name;
$ENV{GIT_AUTHOR_EMAIL} = $ENV{GIT_COMMITTER_EMAIL} = $email;
$ENV{GIT_AUTHOR_DATE} = $ENV{GIT_COMMITTER_DATE} = $log_msg->{date};
--
1.2.3.g4676
^ permalink raw reply related
* [PATCH 5/9] contrib/git-svn: cleanup option parsing
From: Eric Wong @ 2006-03-03 9:20 UTC (permalink / raw)
To: junkio; +Cc: git
In-Reply-To: <11413776082506-git-send-email-normalperson@yhbt.net>
Signed-off-by: Eric Wong <normalperson@yhbt.net>
---
contrib/git-svn/git-svn.perl | 65 +++++++++++++++++++++++-------------------
1 files changed, 35 insertions(+), 30 deletions(-)
a080e189728de9a7aa834b61205df9d8de1025ba
diff --git a/contrib/git-svn/git-svn.perl b/contrib/git-svn/git-svn.perl
index c2b4ee9..5d547e8 100755
--- a/contrib/git-svn/git-svn.perl
+++ b/contrib/git-svn/git-svn.perl
@@ -24,6 +24,7 @@ $ENV{LC_ALL} = 'C';
# If SVN:: library support is added, please make the dependencies
# optional and preserve the capability to use the command-line client.
# use eval { require SVN::... } to make it lazy load
+# We don't use any modules not in the standard Perl distribution:
use Carp qw/croak/;
use IO::File qw//;
use File::Basename qw/dirname basename/;
@@ -37,26 +38,25 @@ my ($_revision,$_stdin,$_no_ignore_ext,$
$_find_copies_harder, $_l, $_version, $_upgrade, $_authors);
my (@_branch_from, %tree_map, %users);
-GetOptions( 'revision|r=s' => \$_revision,
- 'no-ignore-externals' => \$_no_ignore_ext,
- 'stdin|' => \$_stdin,
- 'edit|e' => \$_edit,
- 'rmdir' => \$_rmdir,
- 'upgrade' => \$_upgrade,
- 'help|H|h' => \$_help,
+my %fc_opts = ( 'no-ignore-externals' => \$_no_ignore_ext,
'branch|b=s' => \@_branch_from,
- 'find-copies-harder' => \$_find_copies_harder,
- 'authors-file|authors|A=s' => \$_authors,
- 'l=i' => \$_l,
- 'version|V' => \$_version,
- 'no-stop-on-copy' => \$_no_stop_copy );
+ 'authors-file|A=s' => \$_authors );
my %cmd = (
- fetch => [ \&fetch, "Download new revisions from SVN" ],
- init => [ \&init, "Initialize and fetch (import)"],
- commit => [ \&commit, "Commit git revisions to SVN" ],
- 'show-ignore' => [ \&show_ignore, "Show svn:ignore listings" ],
- rebuild => [ \&rebuild, "Rebuild git-svn metadata (after git clone)" ],
- help => [ \&usage, "Show help" ],
+ fetch => [ \&fetch, "Download new revisions from SVN",
+ { 'revision|r=s' => \$_revision, %fc_opts } ],
+ init => [ \&init, "Initialize and fetch (import)", { } ],
+ commit => [ \&commit, "Commit git revisions to SVN",
+ { 'stdin|' => \$_stdin,
+ 'edit|e' => \$_edit,
+ 'rmdir' => \$_rmdir,
+ 'find-copies-harder' => \$_find_copies_harder,
+ 'l=i' => \$_l,
+ %fc_opts,
+ } ],
+ 'show-ignore' => [ \&show_ignore, "Show svn:ignore listings", { } ],
+ rebuild => [ \&rebuild, "Rebuild git-svn metadata (after git clone)",
+ { 'no-ignore-externals' => \$_no_ignore_ext,
+ 'upgrade' => \$_upgrade } ],
);
my $cmd;
for (my $i = 0; $i < @ARGV; $i++) {
@@ -75,21 +75,14 @@ foreach (keys %cmd) {
}
}
-# '<svn username> = real-name <email address>' mapping based on git-svnimport:
-if ($_authors) {
- open my $authors, '<', $_authors or die "Can't open $_authors $!\n";
- while (<$authors>) {
- chomp;
- next unless /^(\S+?)\s*=\s*(.+?)\s*<(.+)>\s*$/;
- my ($user, $name, $email) = ($1, $2, $3);
- $users{$user} = [$name, $email];
- }
- close $authors or croak $!;
-}
+my %opts;
+%opts = %{$cmd{$cmd}->[2]} if (defined $cmd);
+GetOptions(%opts, 'help|H|h' => \$_help, 'version|V' => \$_version ) or exit 1;
usage(0) if $_help;
version() if $_version;
-usage(1) unless (defined $cmd);
+usage(1) unless defined $cmd;
+load_authors() if $_authors;
svn_check_ignore_externals();
$cmd{$cmd}->[0]->(@ARGV);
exit 0;
@@ -1047,6 +1040,18 @@ sub map_tree_joins {
}
}
+# '<svn username> = real-name <email address>' mapping based on git-svnimport:
+sub load_authors {
+ open my $authors, '<', $_authors or die "Can't open $_authors $!\n";
+ while (<$authors>) {
+ chomp;
+ next unless /^(\S+?)\s*=\s*(.+?)\s*<(.+)>\s*$/;
+ my ($user, $name, $email) = ($1, $2, $3);
+ $users{$user} = [$name, $email];
+ }
+ close $authors or croak $!;
+}
+
__END__
Data structures:
--
1.2.3.g4676
^ permalink raw reply related
* [PATCH 6/9] contrib/git-svn: create a more recent master if one does not exist
From: Eric Wong @ 2006-03-03 9:20 UTC (permalink / raw)
To: junkio; +Cc: git
In-Reply-To: <11413776081545-git-send-email-normalperson@yhbt.net>
In a new repository, the initial fetch creates a master branch
if one does not exist so HEAD has something to point to.
It now creates a master at the end of the initial fetch run,
pointing to the latest revision. Previously it pointed to the
first revision imported, which is generally less useful.
Signed-off-by: Eric Wong <normalperson@yhbt.net>
---
contrib/git-svn/git-svn.perl | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
7d3cf853ffbe0d1ce8a15fa5ac3dad793ddb5021
diff --git a/contrib/git-svn/git-svn.perl b/contrib/git-svn/git-svn.perl
index 5d547e8..69b6be3 100755
--- a/contrib/git-svn/git-svn.perl
+++ b/contrib/git-svn/git-svn.perl
@@ -224,9 +224,6 @@ sub fetch {
sys(@svn_co, $SVN_URL, $SVN_WC);
chdir $SVN_WC or croak $!;
$last_commit = git_commit($base, @parents);
- unless (-f "$GIT_DIR/refs/heads/master") {
- sys(qw(git-update-ref refs/heads/master),$last_commit);
- }
assert_svn_wc_clean($base->{revision}, $last_commit);
} else {
chdir $SVN_WC or croak $!;
@@ -242,6 +239,9 @@ sub fetch {
$last_commit = git_commit($log_msg, $last_commit, @parents);
}
assert_svn_wc_clean($last_rev, $last_commit);
+ unless (-e "$GIT_DIR/refs/heads/master") {
+ sys(qw(git-update-ref refs/heads/master),$last_commit);
+ }
return pop @$svn_log;
}
--
1.2.3.g4676
^ permalink raw reply related
* [PATCH 3/9] contrib/git-svn: strip 'git-svn-id:' when commiting to SVN
From: Eric Wong @ 2006-03-03 9:20 UTC (permalink / raw)
To: junkio; +Cc: git
In-Reply-To: <114137760733-git-send-email-normalperson@yhbt.net>
We regenerate and use git-svn-id: whenever we fetch or otherwise
commit to remotes/git-svn. We don't actually know what revision
number we'll commit to SVN at commit time, so this is useless.
It won't throw off things like 'rebuild', though, which knows to
only use the last instance of git-svn-id: in a log message
Signed-off-by: Eric Wong <normalperson@yhbt.net>
---
contrib/git-svn/git-svn.perl | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
15b28ddfc496fa88cffdfddcc9262cae635a34d0
diff --git a/contrib/git-svn/git-svn.perl b/contrib/git-svn/git-svn.perl
index 67368a5..edae9d4 100755
--- a/contrib/git-svn/git-svn.perl
+++ b/contrib/git-svn/git-svn.perl
@@ -625,6 +625,9 @@ sub svn_commit_tree {
while (<$msg_fh>) {
if (!$in_msg) {
$in_msg = 1 if (/^\s*$/);
+ } elsif (/^git-svn-id: /) {
+ # skip this, we regenerate the correct one
+ # on re-fetch anyways
} else {
print $msg $_ or croak $!;
}
--
1.2.3.g4676
^ permalink raw reply related
* contrib/git-svn: polishing up
From: Eric Wong @ 2006-03-03 9:20 UTC (permalink / raw)
To: junkio; +Cc: git
Mostly small things: documentation and code cleanups.
One bugfix of some significance:
Edited commit messages are parsed back to remotes/git-svn
correctly. The sequential commit optimization broke this :x
Significant new features:
--branch/-b is interesting and fun for those of you who miss 'real'
branch support in SVN.
--authors-file/-A support, because git-svnimport has it :)
None of the core commit/fetch tree-writing code was touched.
git-svn.perl | 210 ++++++++++++++++++++++++++++++++++++++++-------------------
git-svn.txt | 34 ++++++++-
2 files changed, 176 insertions(+), 68 deletions(-)
^ permalink raw reply
* [PATCH 1/9] contrib/git-svn: add -b/--branch switch for branch detection
From: Eric Wong @ 2006-03-03 9:20 UTC (permalink / raw)
To: junkio; +Cc: git
In-Reply-To: <11413776074123-git-send-email-normalperson@yhbt.net>
I've said I don't like branches in Subversion, and I still don't.
This is a bit more flexible, though, as the argument for -b is any
arbitrary git head/tag reference.
This makes some things easier:
* Importing git history into a brand new SVN branch.
* Tracking multiple SVN branches via GIT_SVN_ID, even from multiple
repositories.
* Adding tags from SVN (still need to use GIT_SVN_ID, though).
* Even merge tracking is supported, if and only the heads end up with
100% equivalent tree objects. This is more stricter but more robust
and foolproof than parsing commit messages, imho.
Signed-off-by: Eric Wong <normalperson@yhbt.net>
---
contrib/git-svn/git-svn.perl | 38 ++++++++++++++++++++++++++++++++++++++
contrib/git-svn/git-svn.txt | 17 ++++++++++++++++-
2 files changed, 54 insertions(+), 1 deletions(-)
536109ffa6682954d3b2bb6a184978fd185ecaa4
diff --git a/contrib/git-svn/git-svn.perl b/contrib/git-svn/git-svn.perl
index 0e092c5..1f9a470 100755
--- a/contrib/git-svn/git-svn.perl
+++ b/contrib/git-svn/git-svn.perl
@@ -35,6 +35,7 @@ my $sha1 = qr/[a-f\d]{40}/;
my $sha1_short = qr/[a-f\d]{6,40}/;
my ($_revision,$_stdin,$_no_ignore_ext,$_no_stop_copy,$_help,$_rmdir,$_edit,
$_find_copies_harder, $_l, $_version, $_upgrade);
+my (@_branch_from, %tree_map);
GetOptions( 'revision|r=s' => \$_revision,
'no-ignore-externals' => \$_no_ignore_ext,
@@ -43,6 +44,7 @@ GetOptions( 'revision|r=s' => \$_revisio
'rmdir' => \$_rmdir,
'upgrade' => \$_upgrade,
'help|H|h' => \$_help,
+ 'branch|b=s' => \@_branch_from,
'find-copies-harder' => \$_find_copies_harder,
'l=i' => \$_l,
'version|V' => \$_version,
@@ -831,6 +833,8 @@ sub git_commit {
my $uuid = $info->{'Repository UUID'};
defined $uuid or croak "Unable to get Repository UUID\n";
+ map_tree_joins() if (@_branch_from && !%tree_map);
+
# commit parents can be conditionally bound to a particular
# svn revision via: "svn_revno=commit_sha1", filter them out here:
my @exec_parents;
@@ -852,6 +856,17 @@ sub git_commit {
git_addremove();
chomp(my $tree = `git-write-tree`);
croak if $?;
+ if (exists $tree_map{$tree}) {
+ my %seen_parent = map { $_ => 1 } @exec_parents;
+ foreach (@{$tree_map{$tree}}) {
+ # MAXPARENT is defined to 16 in commit-tree.c:
+ if ($seen_parent{$_} || @exec_parents > 16) {
+ next;
+ }
+ push @exec_parents, $_;
+ $seen_parent{$_} = 1;
+ }
+ }
my $msg_fh = IO::File->new_tmpfile or croak $!;
print $msg_fh $log_msg->{msg}, "\ngit-svn-id: ",
"$SVN_URL\@$log_msg->{revision}",
@@ -975,6 +990,29 @@ sub check_upgrade_needed {
}
}
+# fills %tree_map with a reverse mapping of trees to commits. Useful
+# for finding parents to commit on.
+sub map_tree_joins {
+ foreach my $br (@_branch_from) {
+ my $pid = open my $pipe, '-|';
+ defined $pid or croak $!;
+ if ($pid == 0) {
+ exec(qw(git-rev-list --pretty=raw), $br) or croak $?;
+ }
+ while (<$pipe>) {
+ if (/^commit ($sha1)$/o) {
+ my $commit = $1;
+ my ($tree) = (<$pipe> =~ /^tree ($sha1)$/o);
+ unless (defined $tree) {
+ die "Failed to parse commit $commit\n";
+ }
+ push @{$tree_map{$tree}}, $commit;
+ }
+ }
+ close $pipe or croak $?;
+ }
+}
+
__END__
Data structures:
diff --git a/contrib/git-svn/git-svn.txt b/contrib/git-svn/git-svn.txt
index 4102deb..7306048 100644
--- a/contrib/git-svn/git-svn.txt
+++ b/contrib/git-svn/git-svn.txt
@@ -27,7 +27,7 @@ For importing svn, git-svnimport is pote
operating on repositories organized under the recommended
trunk/branch/tags structure, and should be faster, too.
-git-svn completely ignores the very limited view of branching that
+git-svn mostly ignores the very limited view of branching that
Subversion has. This allows git-svn to be much easier to use,
especially on repositories that are not organized in a manner that
git-svnimport is designed for.
@@ -116,6 +116,21 @@ OPTIONS
They are both passed directly to git-diff-tree see
git-diff-tree(1) for more information.
+-b<refname>::
+--branch <refname>::
+ Used with 'fetch' or 'commit'.
+
+ This can be used to join arbitrary git branches to remotes/git-svn
+ on new commits where the tree object is equivalent.
+
+ When used with different GIT_SVN_ID values, tags and branches in
+ SVN can be tracked this way, as can some merges where the heads
+ end up having completely equivalent content. This can even be
+ used to track branches across multiple SVN _repositories_.
+
+ This option may be specified multiple times, once for each
+ branch.
+
COMPATIBILITY OPTIONS
---------------------
--no-ignore-externals::
--
1.2.3.g4676
^ permalink raw reply related
* Re: cygwin: push/pull takes very long time
From: Alex Riesen @ 2006-03-03 9:10 UTC (permalink / raw)
To: Christopher Faylor; +Cc: Git Mailing List
In-Reply-To: <20060303002806.GB7497@trixie.casa.cgf.cx>
On 3/3/06, Christopher Faylor <me@cgf.cx> wrote:
> On Thu, Mar 02, 2006 at 10:54:08PM +0100, Alex Riesen wrote:
> >Alex Riesen, Thu, Mar 02, 2006 18:09:23 +0100:
> >>I'll cleanup the profiling code and send it as well soon (I had to
> >>instrument x*alloc).
> >
> >This is not exactly the same. It counts free as well, even if that is
> >not really interesting - there are places were there is more frees than
> >allocs. Probably something missed or a result coming from libc.
> >
> >Also it is _not_ the code I used for windows. I had to have a global
> >variable for argv[0], which needs modification of all main()s, which
> >gets too easily out of sync.
>
> I wasn't following this discussion closely so maybe this is useless
> information, but for Cygwin you can either use the undocumented global
> __argv or you can use /proc/cmdline. /proc/self/cmdline is going to be
> pretty slow, however.
Oh, thanks. The speed is of no problem here: it's in atexit callback.
> It looks like pure Windows console apps define _argv in stdlib.h also
> but I've never used this and don't know if it is what it looks like.
It works as usual argv. I used "char **__argv", got the message from linker:
Info: resolving ___argv by linking to __imp____argv (auto-import)
which I almost expected.
^ permalink raw reply
* Re: [PATCH] annotate should number lines starting with 1
From: Junio C Hamano @ 2006-03-03 7:09 UTC (permalink / raw)
To: Luck, Tony; +Cc: git, Martin Langhoff
In-Reply-To: <200603022327.k22NRVek023304@agluck-lia64.sc.intel.com>
"Luck, Tony" <tony.luck@intel.com> writes:
> C programmers are well used to counting from zero, but every
> other text file tool starts counting from 1.
Thanks.
I agree with this patch 100%, so I am going to take this patch.
But git-cvsserver might need some adjustments.
Martin?
^ permalink raw reply
* Re: [PATCH] annotate should number lines starting with 1
From: Junio C Hamano @ 2006-03-03 7:09 UTC (permalink / raw)
To: Luck, Tony; +Cc: git, Martin Langhoff
In-Reply-To: <200603022327.k22NRVek023304@agluck-lia64.sc.intel.com>
"Luck, Tony" <tony.luck@intel.com> writes:
> C programmers are well used to counting from zero, but every
> other text file tool starts counting from 1.
Thanks.
I agree with this patch 100%, so I am going to take this patch.
But git-cvsserver might need some adjustments.
Martin?
^ permalink raw reply
* Re: [PATCH 1/3] cg-mv doesn't work with bash 3.1.7 due to excessive quotes
From: Junio C Hamano @ 2006-03-03 5:27 UTC (permalink / raw)
To: Pavel Roskin; +Cc: git
In-Reply-To: <20060303011154.14619.71590.stgit@dv.roinet.com>
Pavel Roskin <proski@gnu.org> writes:
> - ARGS2["${#ARGS2[@]}"]="$_git_relpath${arg%/}"
> + ARGS2[${#ARGS2[@]}]="$_git_relpath${arg%/}"
Is this an application bug? It looks like a workaround for a
bug in the shell...
Not that I care too much either way -- I do not use shell arrays
myself ;-).
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox