* Re: [PATCH] remove ARM and Mozilla SHA1 implementations
From: Johannes Schindelin @ 2009-08-24 16:52 UTC (permalink / raw)
To: Nicolas Pitre; +Cc: Junio C Hamano, git
In-Reply-To: <alpine.DEB.1.00.0908241333130.11375@intel-tinevez-2-302>
Hi,
On Mon, 24 Aug 2009, Johannes Schindelin wrote:
> On Mon, 24 Aug 2009, Nicolas Pitre wrote:
>
> > On Tue, 18 Aug 2009, Johannes Schindelin wrote:
> >
> > > On Mon, 17 Aug 2009, Nicolas Pitre wrote:
> > >
> > > > They are both slower than the new BLK_SHA1 implementation, so it is
> > > > pointless to keep them around.
> > > >
> > > > Signed-off-by: Nicolas Pitre <nico@cam.org> ---
> > > >
> > > > Someone else would need to make the call for the PPC version.
> > >
> > > If I don't forget, I can test tomorrow on 2 different 32-bit PPCs and
> > > possibly one 64-bit PPC.
> >
> > Did you forget? ;-)
>
> Yes.
At long last (XTools took a real long time to install here; it is an old
PowerPC running MacOSX):
Best of 10 "git rev-list --all" runs on a full Git repository (including
my own tree):
before 30ae47b4
1.85 real, 1.52 user, 0.28 sys
after 30ae47b4
1.86 real, 1.52 user, 0.28 sys
To be frank, the 1.85 looks like an outlier, so I think there is exactly 0
difference between the two.
If you want me to perform other tests, please let me know; I'll be back at
this computer tomorrow.
Ciao,
Dscho
^ permalink raw reply
* Re: [PATCH] import-tars: Allow per-tar author and commit message.
From: Peter Krefting @ 2009-08-24 17:07 UTC (permalink / raw)
To: Nanako Shiraishi, Sam Vilain; +Cc: git
In-Reply-To: <4A91B8BB.1030906@vilain.net>
Nanako Shiraishi:
> Instead of requiring the user to have millions of separate files, how
> about reading a single metainfo file that may look like this?
The advantage of having one (or more) files per tarball is that I can use
the shell's tab completion to make sure I spell the name of the archive
correctly. And that it makes it a lot easier to parse.
Sam Vilain:
> Also I wonder if there isn't a nicer interface for users. Why not allow
> the file to specify From:, Committer: etc as header lines
Good idea. My initial patch was simple, just using the .msg file to add a
message. Then I needed to have a different author for one commit, so I added
the .author file. Then came the changes that are in the current import-tars
that separates author and committer, hence the .committer file. Somewhere
along there it became a bit too complex.
Parsing the .msg file for (optional) committer and author info is probably
better. I'll update the patch.
--
\\// Peter - http://www.softwolves.pp.se/
^ permalink raw reply
* Re: [PATCH] Add script for importing bits-and-pieces to Git.
From: Peter Krefting @ 2009-08-24 17:10 UTC (permalink / raw)
To: Thomas Adam; +Cc: git
In-Reply-To: <18071eea0908231328r58b0e22ap20e664d2904420a0@mail.gmail.com>
Thomas Adam:
> Minor nit. Better written as:
> my ($size, $mtime) = (stat(FILE))[7,9];
Ah. Another obscure Perl syntax to consider :-) I'll send an updated patch.
Thanks.
--
\\// Peter - http://www.softwolves.pp.se/
^ permalink raw reply
* [PATCH v2] Add script for importing bits-and-pieces to Git.
From: Peter Krefting @ 2009-08-24 17:09 UTC (permalink / raw)
To: git
Allows the user to import version history that is stored in bits and
pieces in the file system, for instance snapshots of old development
trees, or day-by-day backups. A configuration file is used to
describe the relationship between the different files and allow
describing branches and merges, as well as authorship and commit
messages.
Output is created in a format compatible with git-fast-import.
Full documentation is provided inline in perldoc format.
Signed-off-by: Peter Krefting <peter@softwolves.pp.se>
---
Changed the use of stat() as suggested by Thomas Adam.
contrib/fast-import/import-directories.perl | 332 +++++++++++++++++++++++++++
1 files changed, 332 insertions(+), 0 deletions(-)
create mode 100755 contrib/fast-import/import-directories.perl
diff --git a/contrib/fast-import/import-directories.perl b/contrib/fast-import/import-directories.perl
new file mode 100755
index 0000000..98079ad
--- /dev/null
+++ b/contrib/fast-import/import-directories.perl
@@ -0,0 +1,332 @@
+#!/usr/bin/perl -w
+#
+# Copyright 2008-2009 Peter Krefting <peter@softwolves.pp.se>
+#
+# ------------------------------------------------------------------------
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+# ------------------------------------------------------------------------
+
+=pod
+
+=head1 NAME
+
+import-directories - Import bits and pieces to Git.
+
+=head1 SYNOPSIS
+
+B<import-directories.perl> F<configfile>
+
+=head1 DESCRIPTION
+
+Script to import arbitrary projects version controlled by the "copy the
+source directory to a new location and edit it there"-version controlled
+projects into version control. Handles projects with arbitrary branching
+and version trees, taking a file describing the inputs and generating a
+file compatible with the L<git-fast-import(1)> format.
+
+=head1 CONFIGURATION FILE
+
+=head2 Format
+
+The configuration file is using a standard I<.ini> format.
+
+ ; Comments start with semi-colons
+ [section]
+ key=value
+
+=head2 Global configuration
+
+Global configuration is done in the B<[config]> section, which should be
+the first section in the file. Configuration can be changed by
+repeating configuration sections later on.
+
+ [config]
+ ; configure conversion of CRLFs. "convert" means that all CRLFs
+ ; should be converted into LFs (suitable for the core.autocrlf
+ ; setting set to true in Git). "none" means that all data is
+ ; treated as binary.
+ crlf=convert
+
+=head2 Revision configuration
+
+Each revision that is to be imported is described in three
+sections. Sections should be defined chronologically, so that a
+revision's parent has always been defined when a new revision
+is introduced. All sections for one revision should be defined
+before defining the next revision.
+
+Revisions are specified numerically, but they numbers need not be
+consecutive, only unique.
+
+=pod
+
+=head3 Revision description section
+
+A section whose section name is just an integer gives meta-data
+about the revision.
+
+ [3]
+ ; author sets the author of the revisions
+ author=Peter Krefting <peter@softwolves.pp.se>
+ ; branch sets the branch that the revision should be committed to
+ branch=master
+ ; parent describes the revision that is the parent of this commit
+ ; (optional)
+ parent=1
+ ; merges describes a revision that is merged into this commit
+ ; (optional; can be repeated)
+ merges=2
+ ; selects one file to take the timestamp from
+ ; (optional; if unspecified, the most recent file from the .files
+ ; section is used)
+ timestamp=3/source.c
+
+=head3 Revision contents section
+
+A section whose section name is an integer followed by B<.files>
+describes the files included in this revision.
+
+ [3.files]
+ ; the key is the path inside the repository, the value is the path
+ ; as seen from the importer script.
+ source.c=3/source.c
+ source.h=3/source.h
+
+=head3 Revision commit message section
+
+A section whose section name is an integer followed by B<.message>
+gives the commit message. This section is read verbatim.
+
+ [3.message]
+ Implement foobar.
+ ; trailing blank lines are ignored.
+
+=cut
+
+# Globals
+use strict;
+use integer;
+my $crlfmode = 0;
+my @revs;
+my (%revmap, %message, %files, %author, %branch, %parent, %merges, %time, %timesource);
+my $sectiontype = 0;
+my $rev = 0;
+my $mark = 1;
+
+# Check command line
+if ($#ARGV == -1 || $ARGV[0] =~ /^--?h/)
+{
+ exec('perldoc', $0);
+ exit 1;
+}
+
+# Open configuration
+my $config = $ARGV[0];
+open CFG, '<', $config or die "Cannot open configuration file \"$config\": ";
+
+# Open output
+my $output = $ARGV[1];
+open OUT, '>', $output or die "Cannot create output file \"$output\": ";
+binmode OUT;
+
+LINE: while (my $line = <CFG>)
+{
+ $line =~ s/\r?\n$//;
+ next LINE if $sectiontype != 4 && $line eq '';
+ next LINE if $line =~ /^;/;
+ my $oldsectiontype = $sectiontype;
+ my $oldrev = $rev;
+
+ # Sections
+ if ($line =~ m"^\[(config|(\d+)(|\.files|\.message))\]$")
+ {
+ if ($1 eq 'config')
+ {
+ $sectiontype = 1;
+ }
+ elsif ($3 eq '')
+ {
+ $sectiontype = 2;
+ $rev = $2;
+ # Create a new revision
+ die "Duplicate rev: $line\n " if defined $revmap{$rev};
+ print "Reading revision $rev\n";
+ push @revs, $rev;
+ $revmap{$rev} = $mark ++;
+ $time{$revmap{$rev}} = 0;
+ }
+ elsif ($3 eq '.files')
+ {
+ $sectiontype = 3;
+ $rev = $2;
+ die "Revision mismatch: $line\n " unless $rev == $oldrev;
+ }
+ elsif ($3 eq '.message')
+ {
+ $sectiontype = 4;
+ $rev = $2;
+ die "Revision mismatch: $line\n " unless $rev == $oldrev;
+ }
+ else
+ {
+ die "Internal parse error: $line\n ";
+ }
+ next LINE;
+ }
+
+ # Parse data
+ if ($sectiontype != 4)
+ {
+ # Key and value
+ if ($line =~ m"^(.*)=(.*)$")
+ {
+ my ($key, $value) = ($1, $2);
+ # Global configuration
+ if (1 == $sectiontype)
+ {
+ if ($key eq 'crlf')
+ {
+ $crlfmode = 1, next LINE if $value eq 'convert';
+ $crlfmode = 0, next LINE if $value eq 'none';
+ }
+ die "Unknown configuration option: $line\n ";
+ }
+ # Revision specification
+ if (2 == $sectiontype)
+ {
+ my $current = $revmap{$rev};
+ $author{$current} = $value, next LINE if $key eq 'author';
+ $branch{$current} = $value, next LINE if $key eq 'branch';
+ $parent{$current} = $value, next LINE if $key eq 'parent';
+ $timesource{$current} = $value, next LINE if $key eq 'timestamp';
+ push(@{$merges{$current}}, $value), next LINE if $key eq 'merges';
+ die "Unknown revision option: $line\n ";
+ }
+ # Filespecs
+ if (3 == $sectiontype)
+ {
+ # Add the file and create a marker
+ die "File not found: $line\n " unless -f $value;
+ my $current = $revmap{$rev};
+ ${$files{$current}}{$key} = $mark;
+ my $time = &fileblob($value, $crlfmode, $mark ++);
+
+ # Update revision timestamp if more recent than other
+ # files seen, or if this is the file we have selected
+ # to take the time stamp from using the "timestamp"
+ # directive.
+ if ((defined $timesource{$current} && $timesource{$current} eq $value)
+ || $time > $time{$current})
+ {
+ $time{$current} = $time;
+ }
+ }
+ }
+ else
+ {
+ die "Parse error: $line\n ";
+ }
+ }
+ else
+ {
+ # Commit message
+ my $current = $revmap{$rev};
+ if (defined $message{$current})
+ {
+ $message{$current} .= "\n";
+ }
+ $message{$current} .= $line;
+ }
+}
+close CFG;
+
+# Start spewing out data for git-fast-import
+foreach my $commit (@revs)
+{
+ # Progress
+ print OUT "progress Creating revision $commit\n";
+
+ # Create commit header
+ my $mark = $revmap{$commit};
+
+ # Branch and commit id
+ print OUT "commit refs/heads/", $branch{$mark}, "\nmark :", $mark, "\n";
+
+ # Author and timestamp
+ die "No timestamp defined for $commit (no files?)\n" unless defined $time{$mark};
+ print OUT "committer ", $author{$mark}, " ", $time{$mark}, " +0100\n";
+
+ # Commit message
+ die "No message defined for $commit\n" unless defined $message{$mark};
+ my $message = $message{$mark};
+ $message =~ s/\n$//; # Kill trailing empty line
+ print OUT "data ", length($message), "\n", $message, "\n";
+
+ # Parent and any merges
+ print OUT "from :", $revmap{$parent{$mark}}, "\n" if defined $parent{$mark};
+ if (defined $merges{$mark})
+ {
+ foreach my $merge (@{$merges{$mark}})
+ {
+ print OUT "merge :", $revmap{$merge}, "\n";
+ }
+ }
+
+ # Output file marks
+ print OUT "deleteall\n"; # start from scratch
+ foreach my $file (sort keys %{$files{$mark}})
+ {
+ print OUT "M 644 :", ${$files{$mark}}{$file}, " $file\n";
+ }
+ print OUT "\n";
+}
+
+# Create one file blob
+sub fileblob
+{
+ my ($filename, $crlfmode, $mark) = @_;
+
+ # Import the file
+ print OUT "progress Importing $filename\nblob\nmark :$mark\n";
+ open FILE, '<', $filename or die "Cannot read $filename\n ";
+ binmode FILE;
+ my ($size, $mtime) = (stat(FILE))[7,9];
+ my $file;
+ read FILE, $file, $size;
+ close FILE;
+ $file =~ s/\r\n/\n/g if $crlfmode;
+ print OUT "data ", length($file), "\n", $file, "\n";
+
+ return $time;
+}
+
+__END__
+
+=pod
+
+=head1 EXAMPLES
+
+B<import-directories.perl> F<project.import>
+
+=head1 AUTHOR
+
+Copyright 2008-2009 Peter Krefting E<lt>peter@softwolves.pp.se>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation.
+
+=cut
--
1.6.3.3
^ permalink raw reply related
* Re: [PATCH] remove ARM and Mozilla SHA1 implementations
From: Nicolas Pitre @ 2009-08-24 17:27 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: Junio C Hamano, git
In-Reply-To: <alpine.DEB.1.00.0908241849160.8306@pacific.mpi-cbg.de>
On Mon, 24 Aug 2009, Johannes Schindelin wrote:
> Hi,
>
> On Mon, 24 Aug 2009, Johannes Schindelin wrote:
>
> > On Mon, 24 Aug 2009, Nicolas Pitre wrote:
> >
> > > On Tue, 18 Aug 2009, Johannes Schindelin wrote:
> > >
> > > > On Mon, 17 Aug 2009, Nicolas Pitre wrote:
> > > >
> > > > > They are both slower than the new BLK_SHA1 implementation, so it is
> > > > > pointless to keep them around.
> > > > >
> > > > > Signed-off-by: Nicolas Pitre <nico@cam.org> ---
> > > > >
> > > > > Someone else would need to make the call for the PPC version.
> > > >
> > > > If I don't forget, I can test tomorrow on 2 different 32-bit PPCs and
> > > > possibly one 64-bit PPC.
> > >
> > > Did you forget? ;-)
> >
> > Yes.
>
> At long last (XTools took a real long time to install here; it is an old
> PowerPC running MacOSX):
>
> Best of 10 "git rev-list --all" runs on a full Git repository (including
> my own tree):
>
> before 30ae47b4
>
> 1.85 real, 1.52 user, 0.28 sys
>
> after 30ae47b4
>
> 1.86 real, 1.52 user, 0.28 sys
>
> To be frank, the 1.85 looks like an outlier, so I think there is exactly 0
> difference between the two.
Maybe there wasn't any _code_ difference after all. According to the
Makefile, only mingw defines NO_OPENSSL (although there might certainly
be others).
TRy a build with PPC_SHA1=1, and then compare with BLK_SHA1=1.
And best is to time a fsck --full.
Nicolas
^ permalink raw reply
* Re: [PATCH] send-email: confirm on empty mail subjects
From: Jan Engelhardt @ 2009-08-24 17:27 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <7vhbwlpigo.fsf@alter.siamese.dyndns.org>
On Thursday 2009-08-06 08:25, Junio C Hamano wrote:
>Jan Engelhardt <jengelh@medozas.de> writes:
>
>> When the user forgot to enter a subject in a compose session,
>> send-email will now inquire whether this is really intended, similar
>> to what the Alpine MUA does when a subject is absent.
>
>This seems to break t9001...
>
Did I miss something in building?
19:26 sovereign:../git/git-1.6.4.1 > quilt pu
Applying patch patches/send-email-empty-subject.diff
patching file git-send-email.perl
Now at patch patches/send-email-empty-subject.diff
19:26 sovereign:../git/git-1.6.4.1 > cd t
19:26 sovereign:../git-1.6.4.1/t > ./t9001-send-email.sh
* ok 1: prepare reference tree
* ok 2: Setup helper tool
* ok 3: Extract patches
* ok 4: No confirm with --suppress-cc
* ok 5: No confirm with --confirm=never
* ok 6: No confirm with sendemail.confirm=never
* ok 7: Send patches
* ok 8: Verify commandline
* ok 9: Show all headers
* ok 10: Prompting works
* ok 11: cccmd works
* ok 12: reject long lines
* ok 13: no patch was sent
* ok 14: Author From: in message body
* ok 15: Author From: not in message body
* ok 16: allow long lines with --no-validate
* ok 17: Invalid In-Reply-To
* ok 18: Valid In-Reply-To when prompting
* ok 19: setup fake editor
* ok 20: --compose works
* ok 21: first message is compose text
* ok 22: second message is patch
* ok 23: sendemail.cc set
* ok 24: sendemail.cc unset
* ok 25: sendemail.cccmd
* ok 26: --suppress-cc=all
* ok 27: --suppress-cc=body
* ok 28: --suppress-cc=body --suppress-cc=cccmd
* ok 29: --suppress-cc=sob
* ok 30: --suppress-cc=bodycc
* ok 31: --suppress-cc=cc
* ok 32: --confirm=always
* ok 33: --confirm=auto
* ok 34: --confirm=cc
* ok 35: --confirm=compose
* ok 36: confirm by default (due to cc)
* ok 37: confirm by default (due to --compose)
* ok 38: confirm detects EOF (inform assumes y)
* ok 39: confirm detects EOF (auto causes failure)
* ok 40: confirm doesnt loop forever
* ok 41: utf8 Cc is rfc2047 encoded
* ok 42: --compose adds MIME for utf8 body
* ok 43: --compose respects user mime type
* ok 44: --compose adds MIME for utf8 subject
* ok 45: detects ambiguous reference/file conflict
* ok 46: feed two files
* ok 47: in-reply-to but no threading
* ok 48: no in-reply-to and no threading
* ok 49: threading but no chain-reply-to
* passed all 49 test(s)
^ permalink raw reply
* [PATCH v2] import-tars: Allow per-tar author and commit message.
From: Peter Krefting @ 2009-08-24 17:55 UTC (permalink / raw)
To: git
Instead of having each imported tar ball's commit message be "Imported
from filename.tar", optionally take a commit message from a file
called "filename.tar.msg". The author and committer of the tar ball
can also be overridden by embedding an "Author:" or "Committer:" header
in the .msg file.
Signed-off-by: Peter Krefting <peter@softwolves.pp.se>
---
Instead of having a .author and .committer file to override the author
and committer, allow embedding this information in the .msg file, as
suggested by Sam Vilain <sam@vilain.net>.
contrib/fast-import/import-tars.perl | 38 +++++++++++++++++++++++++++++++--
1 files changed, 35 insertions(+), 3 deletions(-)
diff --git a/contrib/fast-import/import-tars.perl b/contrib/fast-import/import-tars.perl
index 78e40d2..0d59434 100755
--- a/contrib/fast-import/import-tars.perl
+++ b/contrib/fast-import/import-tars.perl
@@ -109,12 +109,44 @@ foreach my $tar_file (@ARGV)
$have_top_dir = 0 if $top_dir ne $1;
}
+ # Optionally read a commit message from <filename.tar>.msg
+ # Add a line on the form "Committer: name <e-mail>" to override
+ # the committer and "Author: name <e-mail>" to override the
+ # author for this tar ball.
+ my $commit_msg = "Imported from $tar_file.";
+ my $this_committer_name = $committer_name;
+ my $this_committer_email = $committer_email;
+ my $this_author_name = $author_name;
+ my $this_author_email = $author_email;
+ if (open MSG, '<', "${tar_file}.msg")
+ {
+ $commit_msg = '';
+ while (<MSG>)
+ {
+ if (/^Committer:\s+([^<>]*)\s+<(.*)>\s*$/i)
+ {
+ $this_committer_name = $1;
+ $this_committer_email = $2;
+ }
+ elsif (/^Author:\s+([^<>]*)\s+<(.*)>\s*$/i)
+ {
+ $this_author_name = $1;
+ $this_author_email = $2;
+ }
+ else
+ {
+ $commit_msg .= $_;
+ }
+ }
+ close MSG;
+ }
+
print FI <<EOF;
commit $branch_ref
-author $author_name <$author_email> $author_time +0000
-committer $committer_name <$committer_email> $commit_time +0000
+author $this_author_name <$this_author_email> $author_time +0000
+committer $this_committer_name <$this_committer_email> $commit_time +0000
data <<END_OF_COMMIT_MESSAGE
-Imported from $tar_file.
+$commit_msg
END_OF_COMMIT_MESSAGE
deleteall
--
1.6.3.3
^ permalink raw reply related
* Re: [PATCH] send-email: confirm on empty mail subjects
From: Junio C Hamano @ 2009-08-24 18:19 UTC (permalink / raw)
To: Jan Engelhardt; +Cc: git
In-Reply-To: <alpine.LSU.2.00.0908241927300.5382@fbirervta.pbzchgretzou.qr>
Jan Engelhardt <jengelh@medozas.de> writes:
> On Thursday 2009-08-06 08:25, Junio C Hamano wrote:
>
>>Jan Engelhardt <jengelh@medozas.de> writes:
>>
>>> When the user forgot to enter a subject in a compose session,
>>> send-email will now inquire whether this is really intended, similar
>>> to what the Alpine MUA does when a subject is absent.
>>
>>This seems to break t9001...
>>
>
> Did I miss something in building?
>
> 19:26 sovereign:../git/git-1.6.4.1 > quilt pu
> Applying patch patches/send-email-empty-subject.diff
> patching file git-send-email.perl
Is this using 'pu' with your patch? Near the tip of the 'pu' branch I
have a iffy workaround to "unbreak" the issue, but it is a rather
sledgehammer approach I do not feel comfortable enough to squash into your
patch yet.
^ permalink raw reply
* Re: Pulling one commit at a time.
From: Avery Pennarun @ 2009-08-24 18:19 UTC (permalink / raw)
To: Sanjiv Gupta; +Cc: Nanako Shiraishi, git
In-Reply-To: <4A92318F.6050105@microchip.com>
On Mon, Aug 24, 2009 at 6:22 AM, Sanjiv Gupta<sanjiv.gupta@microchip.com> wrote:
> Excellent description. Thanks for that. I want to merge commits one by one
> because I want to run a regression suite on each commit and therefore know
> if any one is causing failures.
Hi Sanjiv,
'git bisect' is an even better way to do this, in my experience. I
wrote a program (http://github.com/apenwarr/gitbuilder/) that
automatically runs regression tests against all the new versions on
all the new branches. It then publishes the results on a web page and
via RSS.
gitbuilder does take a shortcut: if commit x passes and commit x+10
passes, it doesn't bother to test commit x+1..9. However, if x+10
fails, it bisects automatically to find the first commit that caused a
failure. You could disable this shortcut easily enough, however.
Have fun,
Avery
^ permalink raw reply
* Re: What's cooking in git.git (Aug 2009, #04; Sun, 23)
From: Adam Simpkins @ 2009-08-24 18:26 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git@vger.kernel.org
In-Reply-To: <7v1vn2qb29.fsf@alter.siamese.dyndns.org>
On Sun, Aug 23, 2009 at 06:01:50PM -0700, Junio C Hamano wrote:
>
> * as/maint-graph-interesting-fix (2009-08-18) 1 commit.
> - graph API: fix bug in graph_is_interesting()
>
> I need to queue the associated test after getting it signed-off.
Whoops. Sorry about that.
Signed-off-by: Adam Simpkins <simpkins@facebook.com>
--
Adam Simpkins
simpkins@facebook.com
^ permalink raw reply
* Re: [PATCH] Add script for importing bits-and-pieces to Git.
From: Randal L. Schwartz @ 2009-08-24 18:37 UTC (permalink / raw)
To: Peter Krefting; +Cc: Thomas Adam, git
In-Reply-To: <alpine.DEB.2.00.0908241909420.16576@perkele.intern.softwolves.pp.se>
>>>>> "Peter" == Peter Krefting <peter@softwolves.pp.se> writes:
Peter> Ah. Another obscure Perl syntax to consider :-) I'll send an updated
Peter> patch. Thanks.
It's fair game to say it's not "obscure" if it's in Learning Perl,
and that was in Learning Perl.
Minor trivia note: that's one of the three Perl syntax features
that I can take credit for having created, back in the day.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
^ permalink raw reply
* Re: gitosis-lite
From: Jakub Narebski @ 2009-08-24 18:44 UTC (permalink / raw)
To: Sitaram Chamarty; +Cc: Git Mailing List, Tommi Virtanen
In-Reply-To: <2e24e5b90908240528v56fdf30cq4c046fca321a3b17@mail.gmail.com>
Sitaram Chamarty <sitaramc@gmail.com> writes:
> I created a new project called gitosis-lite, which combines
> the essential pieces of gitosis with the per-branch
> permissions stuff in the example in the howto directory of
> git.git.
As for the name: gitness, gitamine, gitrify,... ;-)
> The config file is different, (there's an annotated example
> you can look at).
>
> The "why" and the "what" are all at
> http://github.com/sitaramc/gitosis-lite
A few comments about the code, taking gl-auth-command as example.
> #!/usr/bin/perl -w
>
> use strict;
Wouldn't it be better to use "use warnings" instead of 'perl -w'?
> # === auth-command ===
> # the command that GL users actually run
>
> # part of the gitosis-lite (GL) suite
>
> # how run: via sshd, being listed in "command=" in ssh authkeys
> # when: every login by a GL user
> # input: $1 is GL username, plus $SSH_ORIGINAL_COMMAND
> # output:
> # security:
> # - currently, we just make some basic checks, copied from gitosis
>
> # robustness:
>
> # other notes:
It would be, I think, better if you have used POD for such
documentation. One would be able to generate manpage using pod2man,
and it is no less readable in source code. See e.g. perl/Git.pm or
contrib/hooks/update-paranoid.
> our $GL_ADMINDIR;
> our $GL_CONF;
> our $GL_KEYDIR;
> our $GL_CONF_COMPILED;
> our $REPO_BASE;
> our %repos;
Why is the reason behind using 'our' instead of 'my' here?
> # first, fix the biggest gripe I have with gitosis, a 1-line change
> my $user=$ENV{GL_USER}=shift; # there; now that's available everywhere!
Eh? This is standalone script, isn't it? Shouldn't it be
my $user = $ENV{GL_USER} = $ARGV[0]; # there; now that's available everywhere!
> my $perm = 'W'; $perm = 'R' if $verb =~ $R_COMMANDS;
Either split it into two lines, or use ?: confitional operator:
my $perm = ($verb =~ $R_COMMANDS ? 'R' : 'W');
> open(LOG, ">>", "$GL_ADMINDIR/log");
> print LOG "\n", scalar(localtime), " $ENV{SSH_ORIGINAL_COMMAND} $user\n";
> close(LOG);
It is better practice to use lexical variables instead of barewords
for filehandles:
if (open my $logfh, ">>", "$GL_ADMINDIR/log") {
print $logfh "\n", scalar(localtime), " $ENV{SSH_ORIGINAL_COMMAND} $user\n";
close $logfh;
}
Don't forget to check for error.
> $repo = "'$REPO_BASE/$repo.git'";
> exec("git", "shell", "-c", "$verb $repo");
That's not enough. You have to shell-quote $repo, like in gitweb or
using String::ShellQuote module, or somehow use list form to pass
arguments to git-shell. You protect here againts spaces in filename,
but not againts "'" (single quote) and for show shells "!"
(exclamation mark).
--
Jakub Narebski
Poland
ShadeHawk on #git
^ permalink raw reply
* Re: sr/gfi-options, was Re: What's cooking in git.git (Aug 2009, #04; Sun, 23)
From: Sverre Rabbelier @ 2009-08-24 18:45 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: Junio C Hamano, git
In-Reply-To: <alpine.DEB.1.00.0908241641390.11375@intel-tinevez-2-302>
Heya,
On Mon, Aug 24, 2009 at 07:45, Johannes
Schindelin<Johannes.Schindelin@gmx.de> wrote:
> On Sun, 23 Aug 2009, Junio C Hamano wrote:
>> * sr/gfi-options (2009-08-13) 3 commits
>> - fast-import: test the new option command
>> - fast-import: add option command
>> - fast-import: put option parsing code in seperate functions
>>
>> What is this used by?
>
> By a hg-fast-import Sverre was writing for me:
And possibly also by the p4 helper I think?
> Sverre hinted at the possibility of ripping this out of hg-git and putting
> it into a hg:// helper.
I don't know if I have time for that this week, but it's at the top of
my todo list :).
--
Cheers,
Sverre Rabbelier
^ permalink raw reply
* Re: [PATCH] import-tars: Allow per-tar author and commit message.
From: Junio C Hamano @ 2009-08-24 18:54 UTC (permalink / raw)
To: Peter Krefting; +Cc: Nanako Shiraishi, Sam Vilain, git
In-Reply-To: <alpine.DEB.2.00.0908241659380.16576@perkele.intern.softwolves.pp.se>
Peter Krefting <peter@softwolves.pp.se> writes:
> Nanako Shiraishi:
>
>> Instead of requiring the user to have millions of separate files,
>> how about reading a single metainfo file that may look like this?
>
> The advantage of having one (or more) files per tarball is that I can
> use the shell's tab completion to make sure I spell the name of the
> archive correctly. And that it makes it a lot easier to parse.
>
>
> Sam Vilain:
>
>> Also I wonder if there isn't a nicer interface for users. Why not allow
>> the file to specify From:, Committer: etc as header lines
>
> Good idea.
That sounds like a sensible thing to do.
I however am a bit uneasy to see that the patch didn't seem to (and the
rerolled one does not seem to, either) allow any way to forbid reading of
the .msg files, other than an obvious workaround of running "find | xargs
rm" beforehand. Unlike your "import-directories" that is a brand new
program without any existing users, you are touching code that other
people have already used, and you do not want to change the behaviour for
them only because they happen to have unrelated files in the same
directory.
^ permalink raw reply
* Re: Possible regression: overwriting untracked files in a fresh repo
From: Jeff King @ 2009-08-24 19:07 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: git
In-Reply-To: <alpine.DEB.1.00.0908241829510.11375@intel-tinevez-2-302>
On Mon, Aug 24, 2009 at 06:31:21PM +0200, Johannes Schindelin wrote:
> I _think_ that this used to complain about untracked files being
> overwritten:
>
> $ git init
> $ git remote add -f origin <url>
> $ git checkout -b blub origin/master
>
> It does not do that here (any longer, IIAC). Intended?
I agree that it probably _should_ complain, but I don't think it ever
did. I tried a handful of released versions as far back as v1.4.4, and
all of them overwrite local files without complaining. My test was:
-- >8 --
#!/bin/sh
rm -rf parent child
mkdir parent && (
cd parent &&
git init-db &&
echo content >file &&
git add file &&
git commit -m add
) &&
mkdir child && (
cd child &&
git init-db &&
git fetch ../parent master:origin &&
echo precious >file &&
! git checkout -b foo origin
)
-- >8 --
However, if I then do this:
(cd parent && echo content >another && git add . && git commit -m more)
(cd child && git fetch ../parent && git checkout -b new FETCH_HEAD)
then it does complain. I'm guessing there is a different code path for
the case that we have no index at all, and that it is not properly
checking for overwrites.
But now I have a small child waking up so I can't look into it further.
:)
-Peff
^ permalink raw reply
* Re: Pulling one commit at a time.
From: Sanjiv Gupta @ 2009-08-24 19:08 UTC (permalink / raw)
To: Avery Pennarun; +Cc: Nanako Shiraishi, git
In-Reply-To: <32541b130908241119t1b969d30q8c8b484481f30ace@mail.gmail.com>
Avery Pennarun wrote:
> On Mon, Aug 24, 2009 at 6:22 AM, Sanjiv Gupta<sanjiv.gupta@microchip.com> wrote:
>
>> Excellent description. Thanks for that. I want to merge commits one by one
>> because I want to run a regression suite on each commit and therefore know
>> if any one is causing failures.
>>
>
> Hi Sanjiv,
>
> 'git bisect' is an even better way to do this, in my experience. I
> wrote a program (http://github.com/apenwarr/gitbuilder/) that
> automatically runs regression tests against all the new versions on
> all the new branches. It then publishes the results on a web page and
> via RSS.
>
> gitbuilder does take a shortcut: if commit x passes and commit x+10
> passes, it doesn't bother to test commit x+1..9.
Even, I won't need to run in between commits in that case.
What I wanted to do is to
1. off load this job to a script which sends an email to the developer
who broke something,
2. schedule that script
3. and sit back relaxed myself.
Looks like you already have the tool. Thanks.
BTW, git is not git, it's great.
thanks to everybody who replied.
- Sanjiv
> However, if x+10
> fails, it bisects automatically to find the first commit that caused a
> failure. You could disable this shortcut easily enough, however.
>
> Have fun,
>
> Avery
>
^ permalink raw reply
* Re: sr/gfi-options, was Re: What's cooking in git.git (Aug 2009, #04; Sun, 23)
From: Daniel Barkalow @ 2009-08-24 19:09 UTC (permalink / raw)
To: Sverre Rabbelier; +Cc: Johannes Schindelin, Junio C Hamano, git
In-Reply-To: <fabb9a1e0908241145p2a1fe59fgef42a4c46209f154@mail.gmail.com>
[-- Attachment #1: Type: TEXT/PLAIN, Size: 689 bytes --]
On Mon, 24 Aug 2009, Sverre Rabbelier wrote:
> Heya,
>
> On Mon, Aug 24, 2009 at 07:45, Johannes
> Schindelin<Johannes.Schindelin@gmx.de> wrote:
> > On Sun, 23 Aug 2009, Junio C Hamano wrote:
> >> * sr/gfi-options (2009-08-13) 3 commits
> >> - fast-import: test the new option command
> >> - fast-import: add option command
> >> - fast-import: put option parsing code in seperate functions
> >>
> >> What is this used by?
> >
> > By a hg-fast-import Sverre was writing for me:
>
> And possibly also by the p4 helper I think?
Nope, I didn't actually need it. I think the cvs helper wants it, though,
since that is using the marks file.
-Daniel
*This .sig left intentionally blank*
^ permalink raw reply
* Re: [PATCH v2] Add script for importing bits-and-pieces to Git.
From: Junio C Hamano @ 2009-08-24 19:10 UTC (permalink / raw)
To: Peter Krefting; +Cc: git
In-Reply-To: <20090824171110.DA9202FC20@perkele>
Peter Krefting <peter@softwolves.pp.se> writes:
> +=head1 NAME
> +
> +import-directories - Import bits and pieces to Git.
> +
> +=head1 SYNOPSIS
> +
> +B<import-directories.perl> F<configfile>
> +
> +=head1 DESCRIPTION
> +
> +Script to import arbitrary projects version controlled by the "copy the
> +source directory to a new location and edit it there"-version controlled
> +projects into version control. Handles projects with arbitrary branching
> +and version trees, taking a file describing the inputs and generating a
> +file compatible with the L<git-fast-import(1)> format.
Nice write-up.
> +=head1 CONFIGURATION FILE
> +
> +=head2 Format
> +
> +The configuration file is using a standard I<.ini> format.
You might want to mention that this format is different from what git uses
for its .git/config and .gitmodules files, and none of the rules apply to
them (namely, two/three-level names, case sensitivity, allowed letters in
variable names, stripping of whitespaces around values, and value quoting)
described in 'git help config' apply to this file.
It was the first "huh" I had when reading your description below, when you
used "[3]" as a section name and "source.c" as a variable.
> +=head2 Revision configuration
> +
> +Each revision that is to be imported is described in three
> +sections. Sections should be defined chronologically, so that a
> +revision's parent has always been defined when a new revision
> +is introduced. All sections for one revision should be defined
> +before defining the next revision.
> +
> +Revisions are specified numerically, but they numbers need not be
> +consecutive, only unique.
You might want to clarify that they do not need to be monotonically
increasing either---you can have #3 as the root and then #1 with its
parent set to #3, right?
As you seem to be supporting merges, you might want to say topologically
instead of chronologically---this is minor, as you give more precise
definition "all parents must come before a child" in that sentence later.
> + timestamp=3/source.c
> + ...
> +=head3 Revision contents section
> +
> +A section whose section name is an integer followed by B<.files>
> +describes the files included in this revision.
To somebody who knows git it may be obvious but perhaps "describes all the
files" (or "lists all the files") would be clearer? Otherwise, a naive
reader might be frustrated by getting unexpected results after listing
only modified or added files in this section.
> + [3.files]
> + ; the key is the path inside the repository, the value is the path
> + ; as seen from the importer script.
> + source.c=3/source.c
> + source.h=3/source.h
How are problematic characters in pathnames (say, SP, '=' or worse LF)
handled? Do they need to be quoted, and if so how?
As an example in the documentation, 3/source.c is a bit unfortunate. It
may be risking to get misunderstood that somehow the directory name must
match the revision label (numeric section name), which I think is not what
you meant to say here. Perhaps use something like:
source.c = project-v0.0.3/soruce.c
to clarify?
> +=head3 Revision commit message section
> +
> +A section whose section name is an integer followed by B<.message>
> +gives the commit message. This section is read verbatim.
Meaning "everything up to the beginning of the next section"? Can a
commit message have a line that begins with a '[', perhaps as long as it
does not contain a matching ']', so that such a line does not
misinterpreted as starting a new, possibly invalid, section?
^ permalink raw reply
* Re: sr/gfi-options, was Re: What's cooking in git.git (Aug 2009, #04; Sun, 23)
From: Sverre Rabbelier @ 2009-08-24 19:44 UTC (permalink / raw)
To: Daniel Barkalow; +Cc: Johannes Schindelin, Junio C Hamano, git
In-Reply-To: <alpine.LNX.2.00.0908241456400.28290@iabervon.org>
Heya,
On Mon, Aug 24, 2009 at 12:09, Daniel Barkalow<barkalow@iabervon.org> wrote:
> Nope, I didn't actually need it. I think the cvs helper wants it, though,
> since that is using the marks file.
Ah, that's right, the p4 helper uses a python script (like mine), and
the cvs helper uses a marks file (like mine). I got the two confused
:).
--
Cheers,
Sverre Rabbelier
^ permalink raw reply
* Re: [PATCH] remove ARM and Mozilla SHA1 implementations
From: Peter Harris @ 2009-08-24 20:10 UTC (permalink / raw)
To: Nicolas Pitre; +Cc: Johannes Schindelin, Junio C Hamano, git
In-Reply-To: <alpine.LFD.2.00.0908241318000.6044@xanadu.home>
On Mon, Aug 24, 2009 at 1:27 PM, Nicolas Pitre<nico@cam.org> wrote:
>
> TRy a build with PPC_SHA1=1, and then compare with BLK_SHA1=1.
> And best is to time a fsck --full.
I happen to have an old POWER3 AIX box available.
I got tired of waiting for a fsck --full to complete on the git repo,
so I used git://anongit.freedesktop.org/git/xcb/libxcb instead. Best
of five runs:
OpenSSL:
$ time ../git-1.6.4.1/git fsck --full
real 0m4.120s
user 0m3.776s
sys 0m0.031s
BLK_SHA1:
$ time ../git-blk/git fsck --full
real 0m4.231s
user 0m3.867s
sys 0m0.026s
PPC_SHA1:
CC ppc/sha1ppc.o
Assembler:
/tmp//ccdODWpe.s: line 8: 1252-142 Syntax error.
/tmp//ccdODWpe.s: line 9: 1252-142 Syntax error.
[same error repeated 42 times]
gmake: *** [ppc/sha1ppc.o] Error 1
Hmm. So that may not help so much after all. Let me know if there are
any other tests you would like me to run.
This machine has:
$ gcc --version
gcc (GCC) 3.3.2
$ as -v
as V5.3
$ lsattr -E -l proc0
frequency 200000000 Processor Speed False
smt_enabled false Processor SMT enabled False
smt_threads 0 Processor SMT threads False
state enable Processor state False
type PowerPC_POWER3 Processor type False
Peter Harris
^ permalink raw reply
* [PATCH v4 0/4] fast-import: add a new option command
From: Sverre Rabbelier @ 2009-08-24 20:52 UTC (permalink / raw)
To: Junio C Hamano, Shawn O. Pearce, Johannes Schindelin, Git List
The only difference with v3 is that the --import-marks refactoring is
done in a seperate patch.
Meant as replacement for sr/gfi-options in pu.
Sverre Rabbelier (4):
fast-import: put option parsing code in seperate functions
fast-import: put marks reading in it's own function
fast-import: add option command
fast-import: test the new option command
Documentation/git-fast-import.txt | 23 ++++
fast-import.c | 235 +++++++++++++++++++++++++------------
t/t9300-fast-import.sh | 58 +++++++++
3 files changed, 239 insertions(+), 77 deletions(-)
^ permalink raw reply
* [PATCH v4 1/4] fast-import: put option parsing code in seperate functions
From: Sverre Rabbelier @ 2009-08-24 20:52 UTC (permalink / raw)
To: Junio C Hamano, Shawn O. Pearce, Johannes Schindelin, Git List
Cc: Sverre Rabbelier
In-Reply-To: <1251147156-19279-1-git-send-email-srabbelier@gmail.com>
Putting the options in their own functions increases readability of
the option parsing block and makes it easier to reuse the option
parsing code later on.
Signed-off-by: Sverre Rabbelier <srabbelier@gmail.com>
---
Unchanged from v3.
fast-import.c | 115 +++++++++++++++++++++++++++++++++++++--------------------
1 files changed, 75 insertions(+), 40 deletions(-)
diff --git a/fast-import.c b/fast-import.c
index 7ef9865..b904f20 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -291,6 +291,7 @@ static unsigned long branch_count;
static unsigned long branch_load_count;
static int failure;
static FILE *pack_edges;
+static unsigned int show_stats = 1;
/* Memory pools */
static size_t mem_pool_alloc = 2*1024*1024 - sizeof(struct mem_pool);
@@ -2337,7 +2338,7 @@ static void parse_progress(void)
skip_optional_lf();
}
-static void import_marks(const char *input_file)
+static void option_import_marks(const char *input_file)
{
char line[512];
FILE *f = fopen(input_file, "r");
@@ -2372,6 +2373,76 @@ static void import_marks(const char *input_file)
fclose(f);
}
+static void option_date_format(const char *fmt)
+{
+ if (!strcmp(fmt, "raw"))
+ whenspec = WHENSPEC_RAW;
+ else if (!strcmp(fmt, "rfc2822"))
+ whenspec = WHENSPEC_RFC2822;
+ else if (!strcmp(fmt, "now"))
+ whenspec = WHENSPEC_NOW;
+ else
+ die("unknown --date-format argument %s", fmt);
+}
+
+static void option_max_pack_size(const char *packsize)
+{
+ max_packsize = strtoumax(packsize, NULL, 0) * 1024 * 1024;
+}
+
+static void option_depth(const char *depth)
+{
+ max_depth = strtoul(depth, NULL, 0);
+ if (max_depth > MAX_DEPTH)
+ die("--depth cannot exceed %u", MAX_DEPTH);
+}
+
+static void option_active_branches(const char *branches)
+{
+ max_active_branches = strtoul(branches, NULL, 0);
+}
+
+static void option_export_marks(const char *marks)
+{
+ mark_file = xstrdup(marks);
+}
+
+static void option_export_pack_edges(const char *edges)
+{
+ if (pack_edges)
+ fclose(pack_edges);
+ pack_edges = fopen(edges, "a");
+ if (!pack_edges)
+ die_errno("Cannot open '%s'", edges);
+}
+
+static void parse_one_option(const char *option)
+{
+ if (!prefixcmp(option, "date-format=")) {
+ option_date_format(option + 12);
+ } else if (!prefixcmp(option, "max-pack-size=")) {
+ option_max_pack_size(option + 14);
+ } else if (!prefixcmp(option, "depth=")) {
+ option_depth(option + 6);
+ } else if (!prefixcmp(option, "active-branches=")) {
+ option_active_branches(option + 16);
+ } else if (!prefixcmp(option, "import-marks=")) {
+ option_import_marks(option + 13);
+ } else if (!prefixcmp(option, "export-marks=")) {
+ option_export_marks(option + 13);
+ } else if (!prefixcmp(option, "export-pack-edges=")) {
+ option_export_pack_edges(option + 18);
+ } else if (!prefixcmp(option, "force")) {
+ force_update = 1;
+ } else if (!prefixcmp(option, "quiet")) {
+ show_stats = 0;
+ } else if (!prefixcmp(option, "stats")) {
+ show_stats = 1;
+ } else {
+ die("Unsupported option: %s", option);
+ }
+}
+
static int git_pack_config(const char *k, const char *v, void *cb)
{
if (!strcmp(k, "pack.depth")) {
@@ -2398,7 +2469,7 @@ static const char fast_import_usage[] =
int main(int argc, const char **argv)
{
- unsigned int i, show_stats = 1;
+ unsigned int i;
git_extract_argv0_path(argv[0]);
@@ -2419,44 +2490,8 @@ int main(int argc, const char **argv)
if (*a != '-' || !strcmp(a, "--"))
break;
- else if (!prefixcmp(a, "--date-format=")) {
- const char *fmt = a + 14;
- if (!strcmp(fmt, "raw"))
- whenspec = WHENSPEC_RAW;
- else if (!strcmp(fmt, "rfc2822"))
- whenspec = WHENSPEC_RFC2822;
- else if (!strcmp(fmt, "now"))
- whenspec = WHENSPEC_NOW;
- else
- die("unknown --date-format argument %s", fmt);
- }
- else if (!prefixcmp(a, "--max-pack-size="))
- max_packsize = strtoumax(a + 16, NULL, 0) * 1024 * 1024;
- else if (!prefixcmp(a, "--depth=")) {
- max_depth = strtoul(a + 8, NULL, 0);
- if (max_depth > MAX_DEPTH)
- die("--depth cannot exceed %u", MAX_DEPTH);
- }
- else if (!prefixcmp(a, "--active-branches="))
- max_active_branches = strtoul(a + 18, NULL, 0);
- else if (!prefixcmp(a, "--import-marks="))
- import_marks(a + 15);
- else if (!prefixcmp(a, "--export-marks="))
- mark_file = a + 15;
- else if (!prefixcmp(a, "--export-pack-edges=")) {
- if (pack_edges)
- fclose(pack_edges);
- pack_edges = fopen(a + 20, "a");
- if (!pack_edges)
- die_errno("Cannot open '%s'", a + 20);
- } else if (!strcmp(a, "--force"))
- force_update = 1;
- else if (!strcmp(a, "--quiet"))
- show_stats = 0;
- else if (!strcmp(a, "--stats"))
- show_stats = 1;
- else
- die("unknown option %s", a);
+
+ parse_one_option(a + 2);
}
if (i != argc)
usage(fast_import_usage);
--
1.6.4.16.g72c66.dirty
^ permalink raw reply related
* [PATCH v4 2/4] fast-import: put marks reading in it's own function
From: Sverre Rabbelier @ 2009-08-24 20:52 UTC (permalink / raw)
To: Junio C Hamano, Shawn O. Pearce, Johannes Schindelin, Git List
Cc: Sverre Rabbelier
In-Reply-To: <1251147156-19279-2-git-send-email-srabbelier@gmail.com>
All options do nothing but set settings, with the exception of the
--input-marks option. Delay the reading of the marks file till after
all options have been parsed.
Signed-off-by: Sverre Rabbelier <srabbelier@gmail.com>
---
New in the series, as requested by Shawn for easier review.
fast-import.c | 73 ++++++++++++++++++++++++++++++++-------------------------
1 files changed, 41 insertions(+), 32 deletions(-)
diff --git a/fast-import.c b/fast-import.c
index b904f20..812fcf0 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -315,6 +315,7 @@ static struct object_entry_pool *blocks;
static struct object_entry *object_table[1 << 16];
static struct mark_set *marks;
static const char *mark_file;
+static const char *input_file;
/* Our last blob */
static struct last_object last_blob = { STRBUF_INIT, 0, 0, 0 };
@@ -1643,6 +1644,42 @@ static void dump_marks(void)
}
}
+static void read_marks(void)
+{
+ char line[512];
+ FILE *f = fopen(input_file, "r");
+ if (!f)
+ die_errno("cannot read '%s'", input_file);
+ while (fgets(line, sizeof(line), f)) {
+ uintmax_t mark;
+ char *end;
+ unsigned char sha1[20];
+ struct object_entry *e;
+
+ end = strchr(line, '\n');
+ if (line[0] != ':' || !end)
+ die("corrupt mark line: %s", line);
+ *end = 0;
+ mark = strtoumax(line + 1, &end, 10);
+ if (!mark || end == line + 1
+ || *end != ' ' || get_sha1(end + 1, sha1))
+ die("corrupt mark line: %s", line);
+ e = find_object(sha1);
+ if (!e) {
+ enum object_type type = sha1_object_info(sha1, NULL);
+ if (type < 0)
+ die("object not found: %s", sha1_to_hex(sha1));
+ e = insert_object(sha1);
+ e->type = type;
+ e->pack_id = MAX_PACK_ID;
+ e->offset = 1; /* just not zero! */
+ }
+ insert_mark(mark, e);
+ }
+ fclose(f);
+}
+
+
static int read_next_command(void)
{
static int stdin_eof = 0;
@@ -2338,39 +2375,9 @@ static void parse_progress(void)
skip_optional_lf();
}
-static void option_import_marks(const char *input_file)
+static void option_import_marks(const char *marks)
{
- char line[512];
- FILE *f = fopen(input_file, "r");
- if (!f)
- die_errno("cannot read '%s'", input_file);
- while (fgets(line, sizeof(line), f)) {
- uintmax_t mark;
- char *end;
- unsigned char sha1[20];
- struct object_entry *e;
-
- end = strchr(line, '\n');
- if (line[0] != ':' || !end)
- die("corrupt mark line: %s", line);
- *end = 0;
- mark = strtoumax(line + 1, &end, 10);
- if (!mark || end == line + 1
- || *end != ' ' || get_sha1(end + 1, sha1))
- die("corrupt mark line: %s", line);
- e = find_object(sha1);
- if (!e) {
- enum object_type type = sha1_object_info(sha1, NULL);
- if (type < 0)
- die("object not found: %s", sha1_to_hex(sha1));
- e = insert_object(sha1);
- e->type = type;
- e->pack_id = MAX_PACK_ID;
- e->offset = 1; /* just not zero! */
- }
- insert_mark(mark, e);
- }
- fclose(f);
+ input_file = xstrdup(marks);
}
static void option_date_format(const char *fmt)
@@ -2495,6 +2502,8 @@ int main(int argc, const char **argv)
}
if (i != argc)
usage(fast_import_usage);
+ if (input_file)
+ read_marks();
rc_free = pool_alloc(cmd_save * sizeof(*rc_free));
for (i = 0; i < (cmd_save - 1); i++)
--
1.6.4.16.g72c66.dirty
^ permalink raw reply related
* [PATCH v4 3/4] fast-import: add option command
From: Sverre Rabbelier @ 2009-08-24 20:52 UTC (permalink / raw)
To: Junio C Hamano, Shawn O. Pearce, Johannes Schindelin, Git List
Cc: Sverre Rabbelier
In-Reply-To: <1251147156-19279-3-git-send-email-srabbelier@gmail.com>
This allows the frontend to specify any of the supported options as
long as no non-option command has been given. This way the
user does not have to include any frontend-specific options, but
instead she can rely on the frontend to tell fast-import what it
needs.
Also factor out parsing of argv and have it execute when we reach the
first non-option command, or after all commands have been read and
no non-option command has been encountered.
Lastly do not read the marks file till after all options have been
parsed, instead of when receiving the option.
Signed-off-by: Sverre Rabbelier <srabbelier@gmail.com>
---
Same as v3 but with the --import-marks change already done in 2/4
Documentation/git-fast-import.txt | 23 ++++++++++++++
fast-import.c | 61 +++++++++++++++++++++++++++++-------
2 files changed, 72 insertions(+), 12 deletions(-)
diff --git a/Documentation/git-fast-import.txt b/Documentation/git-fast-import.txt
index c2f483a..ed8bd0d 100644
--- a/Documentation/git-fast-import.txt
+++ b/Documentation/git-fast-import.txt
@@ -303,6 +303,11 @@ and control the current import process. More detailed discussion
standard output. This command is optional and is not needed
to perform an import.
+`option`::
+ Specify any of the options listed under OPTIONS to change
+ fast-import's behavior to suit the frontend's needs. This command
+ is optional and is not needed to perform an import.
+
`commit`
~~~~~~~~
Create or update a branch with a new commit, recording one logical
@@ -813,6 +818,24 @@ Placing a `progress` command immediately after a `checkpoint` will
inform the reader when the `checkpoint` has been completed and it
can safely access the refs that fast-import updated.
+`option`
+~~~~~~~~
+Processes the specified option so that git fast-import behaves in a
+way that suits the frontend's needs.
+Note that options specified by the frontend are overridden by any
+options the user may specify to git fast-import itself.
+
+....
+ 'option' SP <option> LF
+....
+
+The `<option>` part of the command may contain any of the options
+listed in the OPTIONS section, without the leading '--' and is
+treated in the same way.
+
+Option commands must be the first commands on the input, to give an
+option command after any non-option command is an error.
+
Crash Reports
-------------
If fast-import is supplied invalid input it will terminate with a
diff --git a/fast-import.c b/fast-import.c
index 812fcf0..dff2937 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -292,6 +292,8 @@ static unsigned long branch_load_count;
static int failure;
static FILE *pack_edges;
static unsigned int show_stats = 1;
+static int global_argc;
+static const char **global_argv;
/* Memory pools */
static size_t mem_pool_alloc = 2*1024*1024 - sizeof(struct mem_pool);
@@ -349,6 +351,9 @@ static struct recent_command *rc_free;
static unsigned int cmd_save = 100;
static uintmax_t next_mark;
static struct strbuf new_data = STRBUF_INIT;
+static int seen_non_option_command;
+
+static void parse_argv(void);
static void write_branch_report(FILE *rpt, struct branch *b)
{
@@ -1700,6 +1705,11 @@ static int read_next_command(void)
if (stdin_eof)
return EOF;
+ if (!seen_non_option_command
+ && prefixcmp(command_buf.buf, "option ")) {
+ parse_argv();
+ }
+
rc = rc_free;
if (rc)
rc_free = rc->next;
@@ -2450,6 +2460,16 @@ static void parse_one_option(const char *option)
}
}
+static void parse_option(void)
+{
+ char* option = command_buf.buf + 7;
+
+ if (seen_non_option_command)
+ die("Got option command '%s' after non-option command", option);
+
+ parse_one_option(option);
+}
+
static int git_pack_config(const char *k, const char *v, void *cb)
{
if (!strcmp(k, "pack.depth")) {
@@ -2474,6 +2494,26 @@ static int git_pack_config(const char *k, const char *v, void *cb)
static const char fast_import_usage[] =
"git fast-import [--date-format=f] [--max-pack-size=n] [--depth=n] [--active-branches=n] [--export-marks=marks.file]";
+static void parse_argv(void)
+{
+ unsigned int i;
+
+ for (i = 1; i < global_argc; i++) {
+ const char *a = global_argv[i];
+
+ if (*a != '-' || !strcmp(a, "--"))
+ break;
+
+ parse_one_option(a + 2);
+ }
+ if (i != global_argc)
+ usage(fast_import_usage);
+
+ seen_non_option_command = 1;
+ if (input_file)
+ read_marks();
+}
+
int main(int argc, const char **argv)
{
unsigned int i;
@@ -2492,18 +2532,8 @@ int main(int argc, const char **argv)
avail_tree_table = xcalloc(avail_tree_table_sz, sizeof(struct avail_tree_content*));
marks = pool_calloc(1, sizeof(struct mark_set));
- for (i = 1; i < argc; i++) {
- const char *a = argv[i];
-
- if (*a != '-' || !strcmp(a, "--"))
- break;
-
- parse_one_option(a + 2);
- }
- if (i != argc)
- usage(fast_import_usage);
- if (input_file)
- read_marks();
+ global_argc = argc;
+ global_argv = argv;
rc_free = pool_alloc(cmd_save * sizeof(*rc_free));
for (i = 0; i < (cmd_save - 1); i++)
@@ -2526,9 +2556,16 @@ int main(int argc, const char **argv)
parse_checkpoint();
else if (!prefixcmp(command_buf.buf, "progress "))
parse_progress();
+ else if (!prefixcmp(command_buf.buf, "option "))
+ parse_option();
else
die("Unsupported command: %s", command_buf.buf);
}
+
+ // argv hasn't been parsed yet, do so
+ if (!seen_non_option_command)
+ parse_argv();
+
end_packfile();
dump_branches();
--
1.6.4.16.g72c66.dirty
^ permalink raw reply related
* [PATCH v4 4/4] fast-import: test the new option command
From: Sverre Rabbelier @ 2009-08-24 20:52 UTC (permalink / raw)
To: Junio C Hamano, Shawn O. Pearce, Johannes Schindelin, Git List
Cc: Sverre Rabbelier
In-Reply-To: <1251147156-19279-4-git-send-email-srabbelier@gmail.com>
Test three options (quiet and import/export-marks) and verify that the
commandline options override these.
Signed-off-by: Sverre Rabbelier <srabbelier@gmail.com>
---
Unchanged from v3.
t/t9300-fast-import.sh | 58 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 58 insertions(+), 0 deletions(-)
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 821be7c..62369e5 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -1088,4 +1088,62 @@ INPUT_END
test_expect_success 'P: fail on blob mark in gitlink' '
test_must_fail git fast-import <input'
+###
+### series Q (options)
+###
+
+cat >input << EOF
+option quiet
+blob
+data 3
+hi
+
+EOF
+
+touch empty
+
+test_expect_success 'Q: quiet option results in no stats being output' '
+ cat input | git fast-import 2> output &&
+ test_cmp empty output
+'
+
+cat >input << EOF
+option export-marks=git.marks
+blob
+mark :1
+data 3
+hi
+
+EOF
+
+test_expect_success \
+ 'Q: export-marks option results in a marks file being created' \
+ 'cat input | git fast-import &&
+ grep :1 git.marks'
+
+test_expect_success \
+ 'Q: export-marks options can be overriden by commandline options' \
+ 'cat input | git fast-import --export-marks=other.marks &&
+ grep :1 other.marks'
+
+cat >input << EOF
+option import-marks=marks.out
+option export-marks=marks.new
+EOF
+
+test_expect_success \
+ 'Q: import to output marks works without any content' \
+ 'cat input | git fast-import &&
+ test_cmp marks.out marks.new'
+
+cat >input <<EOF
+option import-marks=nonexistant.marks
+option export-marks=marks.new
+EOF
+
+test_expect_success \
+ 'Q: import marks uses the commandline marks file when the stream specifies one' \
+ 'cat input | git fast-import --import-marks=marks.out &&
+ test_cmp marks.out marks.new'
+
test_done
--
1.6.4.16.g72c66.dirty
^ permalink raw reply related
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