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>
Lars Hjemli committed
Sep 5, 2007 at 11:35 UTC
05b4df31537a653eaa30d2c6f53e05d7a12d1bc8
2 files changed
+23
-4
Documentation/git-svn.txt
+10
@@ -317,6 +317,16 @@ This is only used with the 'dcommit' command.
317
Print out the series of git arguments that would show
318
which diffs would be committed to SVN.
319
320
+--first-parent::
321
+
322
+This is only used with the 'dcommit', 'rebase', 'log', 'find-rev' and
323
+'show-ignore' commands.
324
+
325
+These commands tries to detect the upstream subversion branch by means of
326
+the embedded 'git-svn-id' line in commit messages. When --first-parent is
327
+specified, git-svn only follows the first parent of each commit, effectively
328
+ignoring commits brought into the current branch through merge-operations.
329
+
330
--
331
332
ADVANCED OPTIONS
git-svn.perl
+13
-4
@@ -59,7 +59,7 @@ my ($_stdin, $_help, $_edit,
59
$_template, $_shared,
60
$_version, $_fetch_all, $_no_rebase,
61
$_merge, $_strategy, $_dry_run, $_local,
62
- $_prefix, $_no_checkout, $_verbose);
62
+ $_prefix, $_no_checkout, $_verbose, $_first_parent);
63
$Git::SVN::_follow_parent = 1;
64
my %remote_opts = ( 'username=s' => \$Git::SVN::Prompt::_username,
65
'config-dir=s' => \$Git::SVN::Ra::config_dir,
@@ -119,12 +119,15 @@ my %cmd = (
119
'dry-run|n' => \$_dry_run,
120
'fetch-all|all' => \$_fetch_all,
121
'no-rebase' => \$_no_rebase,
122
+ 'first-parent' => \$_first_parent,
123
%cmt_opts, %fc_opts } ],
124
'set-tree' => [ \&cmd_set_tree,
125
"Set an SVN repository to a git tree-ish",
126
{ 'stdin|' => \$_stdin, %cmt_opts, %fc_opts, } ],
127
'show-ignore' => [ \&cmd_show_ignore, "Show svn:ignore listings",
127
- { 'revision|r=i' => \$_revision } ],
128
+ { 'revision|r=i' => \$_revision,
129
+ 'first-parent' => \$_first_parent
130
+ } ],
131
'multi-fetch' => [ \&cmd_multi_fetch,
132
"Deprecated alias for $0 fetch --all",
133
{ 'revision|r=s' => \$_revision, %fc_opts } ],
@@ -145,15 +148,19 @@ my %cmd = (
148
'authors-file|A=s' => \$_authors,
149
'color' => \$Git::SVN::Log::color,
150
'pager=s' => \$Git::SVN::Log::pager,
151
+ 'first-parent' => \$_first_parent
152
} ],
153
'find-rev' => [ \&cmd_find_rev, "Translate between SVN revision numbers and tree-ish",
150
- { } ],
154
+ {
155
+ 'first-parent' => \$_first_parent
156
+ } ],
157
'rebase' => [ \&cmd_rebase, "Fetch and rebase your working directory",
158
{ 'merge|m|M' => \$_merge,
159
'verbose|v' => \$_verbose,
160
'strategy|s=s' => \$_strategy,
161
'local|l' => \$_local,
162
'fetch-all|all' => \$_fetch_all,
163
+ 'first-parent' => \$_first_parent,
164
%fc_opts } ],
165
'commit-diff' => [ \&cmd_commit_diff,
166
'Commit a diff between two trees',
@@ -811,7 +818,9 @@ sub cmt_metadata {
818
819
sub working_head_info {
820
my ($head, $refs) = @_;
814
- my ($fh, $ctx) = command_output_pipe('log', '--no-color', $head);
821
+ my @args = ('log', '--no-color');
822
+ push @args, '--first-parent' if $_first_parent;
823
+ my ($fh, $ctx) = command_output_pipe(@args, $head);
824
my $hash;
825
my %max;
826
while (<$fh>) {