Git development
 help / color / mirror / Atom feed
* repo-config needs a prefix.
From: Robert Shearman @ 2006-08-10  9:36 UTC (permalink / raw)
  To: Git Mailing List

[-- Attachment #1: Type: text/plain, Size: 321 bytes --]


This fixes the message received when invoking certain commands from 
outside of a git tree, so e.g. instead of receiving this:
/home/rob/bin/git-fetch: line 89: /FETCH_HEAD: Permission denied
We get this again:
fatal: Not a git repository: '.git'
---
  git.c |    2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)

[-- Attachment #2: c0aa527060f6ba202986564731e7277f11f31639.diff --]
[-- Type: text/x-patch, Size: 382 bytes --]

diff --git a/git.c b/git.c
index 18ba14a..f9c76a1 100644
--- a/git.c
+++ b/git.c
@@ -264,7 +264,7 @@ static void handle_internal_command(int 
 		{ "prune", cmd_prune, NEEDS_PREFIX },
 		{ "mv", cmd_mv, NEEDS_PREFIX },
 		{ "prune-packed", cmd_prune_packed, NEEDS_PREFIX },
-		{ "repo-config", cmd_repo_config },
+		{ "repo-config", cmd_repo_config, NEEDS_PREFIX },
 	};
 	int i;
 


^ permalink raw reply related

* [PATCH] repo-config needs a prefix.
From: Robert Shearman @ 2006-08-10  9:41 UTC (permalink / raw)
  To: Git Mailing List

[-- Attachment #1: Type: text/plain, Size: 410 bytes --]


This fixes the message received when invoking certain commands from 
outside of a git tree, so e.g. instead of receiving this:
/home/rob/bin/git-fetch: line 89: /FETCH_HEAD: Permission denied
We get this again:
fatal: Not a git repository: '.git'
Signed-off-by: Robert Shearman <rob@codeweavers.com>
---
  git.c |    2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)

This time with Signed-off-by line.

[-- Attachment #2: c0aa527060f6ba202986564731e7277f11f31639.diff --]
[-- Type: text/x-patch, Size: 382 bytes --]

diff --git a/git.c b/git.c
index 18ba14a..f9c76a1 100644
--- a/git.c
+++ b/git.c
@@ -264,7 +264,7 @@ static void handle_internal_command(int 
 		{ "prune", cmd_prune, NEEDS_PREFIX },
 		{ "mv", cmd_mv, NEEDS_PREFIX },
 		{ "prune-packed", cmd_prune_packed, NEEDS_PREFIX },
-		{ "repo-config", cmd_repo_config },
+		{ "repo-config", cmd_repo_config, NEEDS_PREFIX },
 	};
 	int i;
 


^ permalink raw reply related

* Re: repo-config needs a prefix.
From: Johannes Schindelin @ 2006-08-10  9:42 UTC (permalink / raw)
  To: Robert Shearman; +Cc: Git Mailing List
In-Reply-To: <44DAFE34.50701@codeweavers.com>

Hi,

On Thu, 10 Aug 2006, Robert Shearman wrote:

> -               { "repo-config", cmd_repo_config },
> +               { "repo-config", cmd_repo_config, NEEDS_PREFIX },

Doesn't this prevent

$ git-ls-remote kernel

from being run anywhere, when the relevant information is in 
$HOME/.gitconfig?

I'd rather fix git-fetch to cd to the root of the repo, since it really 
does not make sense to expect git-fetch to fetch just one subdirectory.

Ciao,
Dscho

^ permalink raw reply

* Re: setting up a git repo on apache
From: Alan Larkin @ 2006-08-10  9:43 UTC (permalink / raw)
  To: git
In-Reply-To: <Pine.LNX.4.63.0608091831320.1800@wbgn013.biozentrum.uni-wuerzburg.de>

Johannes Schindelin wrote:
> Hi,
> 
> On Wed, 9 Aug 2006, Alan Larkin wrote:
> 
>> $ git push http://localhost:/webdav/git/myproj master
>> Error: no DAV locking support on remote repo
> 
> What do the access_log and the error_log say about this?
> 
> It could also be that you have a "Require valid-user" somewhere in there 
> by mistake.
> 
> Further, you might want to check if it works _with_ authentication (I 
> never tried without, and I am not sure if it should be allowed to begin 
> with).
> 
> There is a recent thread by Junio, Rutger and me, which might help you:
> 
> http://thread.gmane.org/gmane.comp.version-control.git/24816/focus=24861
> 
> Hth,
> Dscho
> 
> 
> 
For the record, I followed the steps in the above linked thread as
closely as possible but the problem persists. It did however contain the
suggestion to use litmus to test the webdav and thats proving curious
insofar as several tests are failing, but in a not entirely reproducible
way. I mean, on one test I might see

14. cond_put.............. FAIL (PUT conditional on lock and etag
failed: 412 Precondition Failed)
15. fail_cond_put......... pass
16. cond_put_with_not..... pass
17. cond_put_corrupt_token WARNING: PUT failed with 400 not 423
    ...................... pass (with 1 warning)
18. complex_cond_put...... FAIL (PUT with complex conditional failed:
412 Precondition Failed)

and if run again I might see

14. cond_put.............. pass
15. fail_cond_put......... pass
16. cond_put_with_not..... pass
17. cond_put_corrupt_token WARNING: PUT failed with 400 not 423
    ...................... pass (with 1 warning)
18. complex_cond_put...... FAIL (PUT with complex conditional failed:
412 Precondition Failed)

and on another a different combination.

But this has no real place here, so I shall off and try find the
solution elsewhere and post back if its relevant.

Thanks for the help.

^ permalink raw reply

* Re: repo-config needs a prefix.
From: Junio C Hamano @ 2006-08-10  9:51 UTC (permalink / raw)
  To: Robert Shearman; +Cc: git
In-Reply-To: <44DAFE34.50701@codeweavers.com>

While I do agree that it would be better to give nicer message
when running "git-fetch" in bogus places, I do not know if your
patch is the right fix.  Especially, I am not sure if this
change meshes well with this fix a few months ago.

commit 4d599e6bb46d6ef3276425af34922fdbf3aac473
Author: Linus Torvalds <torvalds@osdl.org>
Date:   Thu May 25 08:22:42 2006 -0700

    bogus "fatal: Not a git repository"
    
    I was just testing that "git ls-remote" change by Junio, and when you're
    not in a git repository, it gives this totally bogus warning. The _target_
    obviously has to be a git repository, but there's no reason why you'd have
    to be in a local git repo when doing an ls-remote.

^ permalink raw reply

* [PATCH] gitweb: Whitespace cleanup - tabs are for indent, spaces are for align
From: Jakub Narebski @ 2006-08-10 10:38 UTC (permalink / raw)
  To: git

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
Errorneous code (using tabs for align) was generated with tab width 2;
error was noticed when browsing code with tab width 5.

 gitweb/gitweb.perl |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 855e05c..191ed79 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -1003,7 +1003,7 @@ sub git_get_paging_nav {
 	if ($page > 0) {
 		$paging_nav .= " &sdot; " .
 			$cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=$action;h=$hash;pg=" . ($page-1)),
-							 -accesskey => "p", -title => "Alt-p"}, "prev");
+			         -accesskey => "p", -title => "Alt-p"}, "prev");
 	} else {
 		$paging_nav .= " &sdot; prev";
 	}
@@ -1011,7 +1011,7 @@ sub git_get_paging_nav {
 	if ($nrevs >= (100 * ($page+1)-1)) {
 		$paging_nav .= " &sdot; " .
 			$cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=$action;h=$hash;pg=" . ($page+1)),
-							 -accesskey => "n", -title => "Alt-n"}, "next");
+			         -accesskey => "n", -title => "Alt-n"}, "next");
 	} else {
 		$paging_nav .= " &sdot; next";
 	}
@@ -1844,9 +1844,9 @@ sub git_log {
 		next if !%co;
 		my %ad = date_str($co{'author_epoch'});
 		git_header_div('commit',
-									 "<span class=\"age\">$co{'age_string'}</span>" .
-									 esc_html($co{'title'}) . $ref,
-									 $commit);
+		               "<span class=\"age\">$co{'age_string'}</span>" .
+		               esc_html($co{'title'}) . $ref,
+		               $commit);
 		print "<div class=\"title_text\">\n" .
 		      "<div class=\"log_link\">\n" .
 		      $cgi->a({-href => "$my_uri?" . esc_param("p=$project;a=commit;h=$commit")}, "commit") .
@@ -1911,8 +1911,8 @@ sub git_commit {
 	}
 	git_header_html(undef, $expires);
 	git_page_nav('commit', defined $co{'parent'} ? '' : 'commitdiff',
-							 $hash, $co{'tree'}, $hash,
-							 $formats_nav);
+	             $hash, $co{'tree'}, $hash,
+	             $formats_nav);
 
 	if (defined $co{'parent'}) {
 		git_header_div('commitdiff', esc_html($co{'title'}) . $ref, $hash);
-- 
1.4.1.1

^ permalink raw reply related

* Re: diff machinery cleanup
From: Jeff King @ 2006-08-10 10:38 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git
In-Reply-To: <7vejvpvsni.fsf@assigned-by-dhcp.cox.net>

On Thu, Aug 10, 2006 at 02:36:49AM -0700, Junio C Hamano wrote:

> In general, run_diff_X are _not_ designed to run twice.

OK, makes sense. As you probably guessed, the reason is for the
run-status in C.

> If you are working in "next" branch where Johannes's merge-recur
> work introduced discard_cache(), you could fake this somehow
> stashing away a copy of the original index, and once you are
> done with run_diff_index(), clean the slate by calling
> discard_cache() once you are done, and swap the original index
> in before running run_diff_files().

OK, doing a discard_cache() between the call to run_diff_index and
run_diff_files seems to clear up the problem. But if I understand
correctly, are you saying that run_diff_index has munged the index on
disk, and I really need to be poking at a temporary copy? If so, why
isn't that a problem when running (e.g.) "git-diff-index; git-ls-files"?

> To solve this cleanly without doing the index munging hack, you
> would (actually, I would) need to have a new path walker that
> walks index, tree and working tree in parallel, which I was
> working on in the git-status/git-commit rewrite I started and
> discarded a few days ago.

That does sound the cleanest, and it would enable a more useful status
message, as you mentioned before. What caused you to stop working on it?
Infeasible, or simply more infeasible than you would like right now?

-Peff

^ permalink raw reply

* Re: [PATCH and RFC] gitweb: Remove --full-history from git_history
From: Jakub Narebski @ 2006-08-10 10:46 UTC (permalink / raw)
  To: git
In-Reply-To: <7vk65h1t8q.fsf@assigned-by-dhcp.cox.net>

Junio C Hamano wrote:

> Fredrik Kuivinen <freku045@student.liu.se> writes:
> 
>> I don't think it was dropped in favor --full-history.
> 
> Correct.
> 
> The --full-history option is about merge simplification and has
> nothing to do with renames.

By the way, --full-history option is not documented: neither in
Documentation/git-rev-list.txt, nor in git-rev-list --usage

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

^ permalink raw reply

* Re: [PATCH 7] autoconf: Add support for setting CURLDIR, OPENSSLDIR, EXPATDIR
From: Jakub Narebski @ 2006-08-10 10:50 UTC (permalink / raw)
  To: git
In-Reply-To: <200608090215.10917.jnareb@gmail.com>

Jakub Narebski wrote:

> Add support for --with-openssl=PATH and --without-openssl,
> --with-curl=PATH and --without-curl, --with-expat=PATH and
> --without-expat ./configure options, each setting or unsetting
> appropriate NO_PACKAGE and if called with argument also PACKAGEDIR
> (of which only CURLDIR is documented in Makefile)
> 
> All above options are supported as override to autodetection; more to
> come in the same style (override to autodetection), so moved the bulk
> of comments for site configuration down.

Is this patch dropped?

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

^ permalink raw reply

* Re: cvs2svn and git progress
From: Jon Smirl @ 2006-08-10 13:32 UTC (permalink / raw)
  To: Martin Langhoff; +Cc: git, Shawn Pearce
In-Reply-To: <46a038f90608100028h3c74d6bx7618f56e3d600657@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 375 bytes --]

On 8/10/06, Martin Langhoff <martin.langhoff@gmail.com> wrote:
> On 8/10/06, Jon Smirl <jonsmirl@gmail.com> wrote:
> > I've finally got cvs2svn running through pass 7 now. It took me a
>
> Jon,
>
> great stuff. Is this published somewhere I can pull it from?

This is a diff relative to your git repo of cvs2svn

>
> cheers,
>
>
> martin
>


-- 
Jon Smirl
jonsmirl@gmail.com

[-- Attachment #2: delta.patch --]
[-- Type: text/x-patch, Size: 17974 bytes --]

diff --git a/cvs2svn_lib/collect_data.py b/cvs2svn_lib/collect_data.py
index c05e387..364582d 100644
--- a/cvs2svn_lib/collect_data.py
+++ b/cvs2svn_lib/collect_data.py
@@ -24,6 +24,10 @@ import os
 import re
 import time
 import stat
+import sha
+import zlib
+import struct
+from subprocess import Popen,PIPE
 
 from cvs2svn_lib.boolean import *
 from cvs2svn_lib.set_support import *
@@ -52,7 +56,6 @@ from cvs2svn_lib.metadata_database impor
 
 import cvs2svn_rcsparse
 
-
 branch_tag_re = re.compile(r'''
     ^
     ((?:\d+\.\d+\.)+)   # A nonzero even number of digit groups w/trailing dot
@@ -70,6 +73,10 @@ # assuming that the non-standard vendor 
 # default branch anyway, so we don't want this to match them anyway.
 vendor_revision = re.compile(r'^1\.1\.1\.\d+$')
 
+# Used to parse revision deltas which either add or delete text
+# format is add/delete start range
+deltaPattern = re.compile(r'^([ad])(\d+)\D+(\d+)$')
+
 
 def is_trunk_revision(rev):
   """Return True iff REV is a trunk revision."""
@@ -413,6 +420,14 @@ class _FileDataCollector(cvs2svn_rcspars
 
     pass
 
+  def set_head_revision(self, revision):
+    """This is a callback method declared in Sink."""
+    
+    self.git_head = revision
+    self.git_branches = {} 
+    self.git_next = {}
+    self.git_text = {}
+
   def define_revision(self, revision, timestamp, author, state,
                       branches, next):
     """This is a callback method declared in Sink."""
@@ -460,6 +475,11 @@ class _FileDataCollector(cvs2svn_rcspars
         self._primary_dependencies.append( (next, revision,) )
       else:
         self._primary_dependencies.append( (revision, next,) )
+        
+    # record the CVS diff structure, git code will build the revisions
+    self.git_branches[revision] = branches
+    self.git_next[revision] = next
+
 
   def _resolve_dependencies(self):
     """Store the primary and branch dependencies into the rev_data objects."""
@@ -476,7 +496,14 @@ class _FileDataCollector(cvs2svn_rcspars
     for branch_data in self.sdc.branches_data.values():
       # The branch_data's parent has the branch as a child regardless
       # of whether the branch had any subsequent commits:
-      parent_data = self._rev_data[branch_data.parent]
+      try:
+        parent_data = self._rev_data[branch_data.parent]
+      except KeyError:
+        sys.stderr.write("%s: in '%s':\n"
+                       "   Missing revision %s\n"
+                       % (warning_prefix,
+                          self.cvs_file.filename, branch_data.parent))
+        continue
       parent_data.branches_data.append(branch_data)
 
       if not Ctx().trunk_only and parent_data.child is not None:
@@ -497,7 +524,14 @@ class _FileDataCollector(cvs2svn_rcspars
     for tag_data_list in self.sdc.tags_data.values():
       for tag_data in tag_data_list:
         # The tag_data's rev has the tag as a child:
-        parent_data = self._rev_data[tag_data.rev]
+        try:
+          parent_data = self._rev_data[tag_data.rev]
+        except KeyError:
+            sys.stderr.write("%s: in '%s':\n"
+                       "   Missing revision %s\n"
+                       % (warning_prefix,
+                          self.cvs_file.filename, tag_data.rev))
+        continue
         parent_data.tags_data.append(tag_data)
 
         if not Ctx().trunk_only and parent_data.child is not None:
@@ -708,12 +742,14 @@ class _FileDataCollector(cvs2svn_rcspars
         self._get_rev_id(rev_data.child),
         self._determine_operation(rev_data),
         revision,
-        bool(text),
+        bool(text), "",
         lod,
         rev_data.is_first_on_branch(),
         tag_ids, branch_ids, closed_symbol_ids)
     rev_data.c_rev = c_rev
-    self.collect_data.add_cvs_revision(c_rev)
+
+    # record the CVS tree so that git can build the revisions
+    self.git_text[revision] = text
 
   def parse_completed(self):
     """Walk through all branches and tags and register them with their
@@ -725,6 +761,66 @@ class _FileDataCollector(cvs2svn_rcspars
 
     self.sdc.register_branch_blockers()
 
+    def git_write_file(revision, text):
+      header = 'blob ' + str(len(text)) + '\0'
+      sha1 = sha.new(header)
+      sha1.update(text)
+      digest = sha1.digest()
+      rev_data = self._rev_data[revision]
+      rev_data.c_rev.sha = sha1.hexdigest()
+      self.collect_data.add_cvs_revision(rev_data.c_rev)
+      print rev_data.c_rev.id, rev_data.c_rev.sha
+      
+      if digest not in self.collect_data.object_names:
+        self.collect_data.object_names[digest] = ""
+        self.collect_data.fimport.stdin.write(struct.pack("l",len(text)))
+        self.collect_data.fimport.stdin.write(text)
+        
+    def git_process_diffs(lines, deltas):
+      stack = []
+      delta = 0
+      while delta < len(deltas):
+        ops = deltaPattern.search(deltas[delta]).groups()
+
+        delta += 1
+        x = int(ops[1]) - 1
+        y = int(ops[2])
+        stack.append([ops[0], x, y, delta])
+        
+        if ops[0] == 'a':
+            delta += y
+
+      while stack != []:
+        ops = stack.pop()
+        if ops[0] == 'd':
+          lines[ops[1] : ops[1] + ops[2]] = {}
+        elif ops[0] == 'a':
+          lines[ops[1] + 1: ops[1] + 1] = deltas[ops[3] : ops[3] + ops[2]]
+
+    def git_process_revs(lines, revision):
+      
+      while revision:
+        deltas = self.git_text[revision].split('\n')
+        deltas.pop()
+        if len(deltas) > 0:
+          git_process_diffs(lines, deltas)
+
+        git_write_file(revision, ''.join(lines))
+
+        if len(self.git_branches[revision]):
+          for branch in self.git_branches[revision]:
+            git_process_revs(lines[:], branch)
+
+        revision = self.git_next[revision]
+        
+    revision = self.git_head
+
+    git_write_file(revision, self.git_text[revision])
+    
+    lines = self.git_text[revision].splitlines(True)
+    revision = self.git_next[revision]
+    if revision:
+      git_process_revs(lines, revision)
 
 ctrl_characters_regexp = re.compile('[\\\x00-\\\x1f\\\x7f]')
 
@@ -746,8 +842,14 @@ class _ProjectDataCollector:
     self.found_valid_file = False
     self.fatal_errors = []
     self.num_files = 0
+    collect_data.fimport = Popen(['git-fast-import', 'testme', '760000'], stdin = PIPE)
+    collect_data.object_names = {}
+
     os.path.walk(self.project.project_cvs_repos_path,
                  _ProjectDataCollector._visit_directory, self)
+    collect_data.fimport.stdin.close()
+    collect_data.object_names = {}
+
     if not self.fatal_errors and not self.found_valid_file:
       self.fatal_errors.append(
           '\n'
@@ -783,6 +885,7 @@ class _ProjectDataCollector:
     self.num_files += 1
 
   def _visit_directory(self, dirname, files):
+    
     for fname in files:
       verify_filename_legal(fname)
       if not fname.endswith(',v'):
@@ -793,7 +896,6 @@ class _ProjectDataCollector:
 
       self._process_file(pathname)
 
-
 class CollectData:
   """Repository for data collected by parsing the CVS repository files.
 
@@ -814,6 +916,7 @@ class CollectData:
     self.num_files = 0
     self.symbol_stats = SymbolStatisticsCollector()
     self.stats_keeper = stats_keeper
+    self.object_names = []
 
     # Key generator to generate unique keys for each CVSRevision object:
     self.key_generator = KeyGenerator()
@@ -836,5 +939,3 @@ class CollectData:
 
   def write_symbol_stats(self):
     self.symbol_stats.write()
-
-
diff --git a/cvs2svn_lib/cvs_item.py b/cvs2svn_lib/cvs_item.py
index beabd7c..995fb76 100644
--- a/cvs2svn_lib/cvs_item.py
+++ b/cvs2svn_lib/cvs_item.py
@@ -46,7 +46,7 @@ class CVSRevision(CVSItem):
                id, cvs_file,
                timestamp, metadata_id,
                prev_id, next_id,
-               op, rev, deltatext_exists,
+               op, rev, deltatext_exists, sha,
                lod, first_on_branch,
                tag_ids, branch_ids, closed_symbol_ids):
     """Initialize a new CVSRevision object.
@@ -61,6 +61,7 @@ class CVSRevision(CVSItem):
        OP              -->  (char) OP_ADD, OP_CHANGE, or OP_DELETE
        REV             -->  (string) this CVS rev, e.g., '1.3'
        DELTATEXT_EXISTS-->  (bool) true iff non-empty deltatext
+       SHA             -->  sha1 of git revision
        LOD             -->  (LineOfDevelopment) LOD where this rev occurred
        FIRST_ON_BRANCH -->  (bool) true iff the first rev on its branch
        TAG_IDS         -->  (list of int) ids of all tags on this revision
@@ -79,6 +80,7 @@ class CVSRevision(CVSItem):
     self.prev_id = prev_id
     self.next_id = next_id
     self.deltatext_exists = deltatext_exists
+    self.sha = sha
     self.lod = lod
     self.first_on_branch = first_on_branch
     self.tag_ids = tag_ids
@@ -113,6 +115,7 @@ class CVSRevision(CVSItem):
         self.op,
         self.rev,
         self.deltatext_exists,
+        self.sha,
         lod_id,
         self.first_on_branch,
         ' '.join(['%x' % id for id in self.tag_ids]),
@@ -122,7 +125,7 @@ class CVSRevision(CVSItem):
   def __setstate__(self, data):
     (self.id, cvs_file_id, self.timestamp, self.metadata_id,
      self.prev_id, self.next_id, self.op, self.rev,
-     self.deltatext_exists, lod_id, self.first_on_branch,
+     self.deltatext_exists, self.sha, lod_id, self.first_on_branch,
      tag_ids, branch_ids, closed_symbol_ids) = data
     self.cvs_file = Ctx()._cvs_file_db.get_file(cvs_file_id)
     if lod_id is None:
diff --git a/cvs2svn_lib/dumpfile_delegate.py b/cvs2svn_lib/dumpfile_delegate.py
index fb0606f..03a06d4 100644
--- a/cvs2svn_lib/dumpfile_delegate.py
+++ b/cvs2svn_lib/dumpfile_delegate.py
@@ -232,67 +232,20 @@ class DumpfileDelegate(SVNRepositoryMirr
     # If the file has keywords, we must prevent CVS/RCS from expanding
     # the keywords because they must be unexpanded in the repository,
     # or Subversion will get confused.
-    pipe_cmd, pipe = Ctx().project.cvs_repository.get_co_pipe(
-        c_rev, suppress_keyword_substitution=s_item.has_keywords)
+    #pipe_cmd, pipe = Ctx().project.cvs_repository.get_co_pipe(
+    #    c_rev, suppress_keyword_substitution=s_item.has_keywords)
 
     self.dumpfile.write('Node-path: %s\n'
                         'Node-kind: file\n'
                         'Node-action: %s\n'
                         '%s'  # no property header if no props
-                        'Text-content-length: '
                         % (self._utf8_path(c_rev.svn_path),
                            action, props_header))
 
-    pos = self.dumpfile.tell()
-
-    self.dumpfile.write('0000000000000000\n'
-                        'Text-content-md5: 00000000000000000000000000000000\n'
-                        'Content-length: 0000000000000000\n'
-                        '\n')
-
     if prop_contents:
       self.dumpfile.write(prop_contents)
 
-    # Insert a filter to convert all EOLs to LFs if neccessary
-    if s_item.needs_eol_filter:
-      data_reader = LF_EOL_Filter(pipe.stdout)
-    else:
-      data_reader = pipe.stdout
-
-    # Insert the rev contents, calculating length and checksum as we go.
-    checksum = md5.new()
-    length = 0
-    while True:
-      buf = data_reader.read(config.PIPE_READ_SIZE)
-      if buf == '':
-        break
-      checksum.update(buf)
-      length += len(buf)
-      self.dumpfile.write(buf)
-
-    pipe.stdout.close()
-    error_output = pipe.stderr.read()
-    exit_status = pipe.wait()
-    if exit_status:
-      raise FatalError("The command '%s' failed with exit status: %s\n"
-                       "and the following output:\n"
-                       "%s" % (pipe_cmd, exit_status, error_output))
-
-    # Go back to patch up the length and checksum headers:
-    self.dumpfile.seek(pos, 0)
-    # We left 16 zeros for the text length; replace them with the real
-    # length, padded on the left with spaces:
-    self.dumpfile.write('%16d' % length)
-    # 16... + 1 newline + len('Text-content-md5: ') == 35
-    self.dumpfile.seek(pos + 35, 0)
-    self.dumpfile.write(checksum.hexdigest())
-    # 35... + 32 bytes of checksum + 1 newline + len('Content-length: ') == 84
-    self.dumpfile.seek(pos + 84, 0)
-    # The content length is the length of property data, text data,
-    # and any metadata around/inside around them.
-    self.dumpfile.write('%16d' % (length + len(prop_contents)))
-    # Jump back to the end of the stream
-    self.dumpfile.seek(0, 2)
+    self.dumpfile.write('Git-sha1: %s\n' % (c_rev.sha))
 
     # This record is done (write two newlines -- one to terminate
     # contents that weren't themselves newline-termination, one to
diff --git a/cvs2svn_rcsparse/debug.py b/cvs2svn_rcsparse/debug.py
index cfeaf2b..c2d143d 100644
--- a/cvs2svn_rcsparse/debug.py
+++ b/cvs2svn_rcsparse/debug.py
@@ -1,22 +1,113 @@
-# -*-python-*-
 #
-# Copyright (C) 1999-2006 The ViewCVS Group. All Rights Reserved.
+# Copyright (C) 2000-2002 The ViewCVS Group. All Rights Reserved.
 #
 # By using this file, you agree to the terms and conditions set forth in
-# the LICENSE.html file which can be found at the top level of the ViewVC
-# distribution or at http://viewvc.org/license-1.html.
+# the LICENSE.html file which can be found at the top level of the ViewCVS
+# distribution or at http://viewcvs.sourceforge.net/license-1.html.
 #
-# For more information, visit http://viewvc.org/
+# Contact information:
+#   Greg Stein, PO Box 760, Palo Alto, CA, 94302
+#   gstein@lyra.org, http://viewcvs.sourceforge.net/
+#
+# -----------------------------------------------------------------------
+#
+# This software is being maintained as part of the ViewCVS project.
+# Information is available at:
+#    http://viewcvs.sourceforge.net/
 #
 # -----------------------------------------------------------------------
 
 """debug.py: various debugging tools for the rcsparse package."""
 
 import time
+import re
+import sha
+import zlib
+import os
+import struct
+from subprocess import Popen,PIPE
 
 from __init__ import parse
 import common
 
+deltaPattern = re.compile(r'^([ad])(\d+)\D+(\d+)$')
+
+class RevisionsSink(common.Sink):
+  
+  def __init__(self, fimport):
+    self.fimport = fimport
+                         
+  def set_head_revision(self, revision):
+    self.git_head = revision
+    self.git_branches = {} 
+    self.git_next = {}
+    self.git_text = {}
+
+  def define_revision(self, revision, timestamp, author, state,
+                      branches, next):
+    self.git_branches[revision] = branches
+    self.git_next[revision] = next
+
+  def set_revision_info(self, revision, log, text):
+    self.git_text[revision] = text
+
+  def parse_completed(self):
+
+    def write_file(text):
+      header = 'blob ' + str(len(text)) + '\0'
+      sha1 = sha.new(header)
+      sha1.update(text)
+      name = sha1.hexdigest()
+      
+      print 'length is ', len(text)
+      self.fimport.stdin.write(struct.pack("l",len(text)))
+      self.fimport.stdin.write(text)
+        
+    def process_diffs(lines, deltas):
+      stack = []
+      delta = 0
+      while delta < len(deltas):
+        ops = deltaPattern.search(deltas[delta]).groups()
+
+        delta += 1
+        x = int(ops[1]) - 1
+        y = int(ops[2])
+        stack.append([ops[0], x, y, delta])
+        
+        if ops[0] == 'a':
+            delta += y
+
+      while stack != []:
+        ops = stack.pop()
+        if ops[0] == 'd':
+          lines[ops[1] : ops[1] + ops[2]] = {}
+        elif ops[0] == 'a':
+          lines[ops[1] + 1: ops[1] + 1] = deltas[ops[3] : ops[3] + ops[2]]
+
+    def process_revs(lines, revision):
+      
+      while revision:
+        deltas = self.git_text[revision].split('\n')
+        deltas.pop()
+        if len(deltas) > 0:
+          process_diffs(lines, deltas)
+
+        write_file(''.join(lines))
+
+        if len(self.git_branches[revision]):
+          for branch in self.git_branches[revision]:
+            process_revs(lines[:], branch)
+
+        revision = self.git_next[revision]
+        
+    revision = self.git_head
+
+    write_file(self.git_text[revision])
+    
+    lines = self.git_text[revision].splitlines(True)
+    revision = self.git_next[revision]
+    if revision:
+      process_revs(lines, revision)
 
 class DebugSink(common.Sink):
   def set_head_revision(self, revision):
@@ -46,7 +137,7 @@ class DebugSink(common.Sink):
   def set_revision_info(self, revision, log, text):
     print 'revision:', revision
     print '    log:', log
-    print '    text:', text[:100], '...'
+    print '    text:', text
 
 
 class DumpSink(common.Sink):
@@ -90,9 +181,17 @@ class DumpSink(common.Sink):
     print 'parse_completed'
 
 
+def debug_file(fname):
+  parse(open(fname, 'rb'), DebugSink())
+
 def dump_file(fname):
   parse(open(fname, 'rb'), DumpSink())
 
+def revisions_file(fname):
+  fimport = Popen(['git-fast-import', 'testme'], stdin = PIPE)
+  parse(open(fname, 'rb'), RevisionsSink(fimport))
+  fimport.stdin.close()
+
 def time_file(fname):
   f = open(fname, 'rb')
   s = common.Sink()
@@ -116,7 +215,11 @@ if __name__ == '__main__':
     _usage()
   if sys.argv[1] == 'dump':
     dump_file(sys.argv[2])
+  elif sys.argv[1] == 'debug':
+    debug_file(sys.argv[2])
   elif sys.argv[1] == 'time':
     time_file(sys.argv[2])
+  elif sys.argv[1] == 'revisions':
+    revisions_file(sys.argv[2])
   else:
     _usage()
diff --git a/cvs2svn_rcsparse/default.py b/cvs2svn_rcsparse/default.py
index 14c9958..4e108f4 100644
--- a/cvs2svn_rcsparse/default.py
+++ b/cvs2svn_rcsparse/default.py
@@ -24,7 +24,7 @@ class _TokenStream:
   # the algorithm is about the same speed for any CHUNK_SIZE chosen.
   # grab a good-sized chunk, but not too large to overwhelm memory.
   # note: we use a multiple of a standard block size
-  CHUNK_SIZE  = 192 * 512  # about 100k
+  CHUNK_SIZE  = 4096 * 512  # about 2MB
 
 #  CHUNK_SIZE  = 5	# for debugging, make the function grind...
 

^ permalink raw reply related

* Re: What's in git.git, and announcing GIT 1.4.2-rc4
From: Alex Riesen @ 2006-08-10 13:34 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Johannes Schindelin
In-Reply-To: <7vy7txxts5.fsf@assigned-by-dhcp.cox.net>

On 8/10/06, Junio C Hamano <junkio@cox.net> wrote:
>   - A new merge strategy, merge-recur, which is a rewrite of
>     merge-recursive in C, by Johannes and Alex.

It still has problems devouring that monster merge I have (~20k entries,
with around 40 changed in the other branch, around 100 revs ago. Big
binary files involved. Renames and copies).
Perfomance is nowhere near usable: ~20min on Windows/3GHz/2Gb,
~4Min on Linux/1.4GHz/384Mb ;) I agree that Linux is much more bearable
but 4Min is still too much (especially comparing to that "stupid" resolve).

I noticed that it spends a lot of time finding renames (diffcore_std,
in particular).
Why doesn't it take that much time for "diff-tree -M -r base head1" +
"diff-tree -M -r base head2", I wonder...? (~30 sek, for that windows box).

Sorry, I can't provide the tree. I suppose Mozilla tree can be compared
to that thing, when it becomes available. Linux kernel is no good for
reproducing this problem: it's too clean and compact.

^ permalink raw reply

* Re: What's in git.git, and announcing GIT 1.4.2-rc4
From: Johannes Schindelin @ 2006-08-10 14:00 UTC (permalink / raw)
  To: Alex Riesen; +Cc: Junio C Hamano, git
In-Reply-To: <81b0412b0608100634j4f82d486nd8ba6dd3ac85b0e7@mail.gmail.com>

Hi,

On Thu, 10 Aug 2006, Alex Riesen wrote:

> On 8/10/06, Junio C Hamano <junkio@cox.net> wrote:
> >   - A new merge strategy, merge-recur, which is a rewrite of
> >     merge-recursive in C, by Johannes and Alex.
> 
> It still has problems devouring that monster merge I have (~20k entries,
> with around 40 changed in the other branch, around 100 revs ago. Big
> binary files involved. Renames and copies).
> Perfomance is nowhere near usable: ~20min on Windows/3GHz/2Gb,
> ~4Min on Linux/1.4GHz/384Mb ;) I agree that Linux is much more bearable
> but 4Min is still too much (especially comparing to that "stupid" resolve).
> 
> I noticed that it spends a lot of time finding renames (diffcore_std,
> in particular).

My next plans -- after making sure that merge-recursive is accurate 
(enough) -- was to use oprofile to find the expensive spots.

> Why doesn't it take that much time for "diff-tree -M -r base head1" +
> "diff-tree -M -r base head2", I wonder...? (~30 sek, for that windows box).

Could it be that it has many common ancestors? You have to do the rename 
handling twice for each merge...

> Sorry, I can't provide the tree. I suppose Mozilla tree can be compared
> to that thing, when it becomes available. Linux kernel is no good for
> reproducing this problem: it's too clean and compact.

The beauty of Open Source: since everyone can see your mess, you tend to 
be tidier...

Ciao,
Dscho

^ permalink raw reply

* Re: What's in git.git, and announcing GIT 1.4.2-rc4
From: Alex Riesen @ 2006-08-10 14:30 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: Junio C Hamano, git
In-Reply-To: <Pine.LNX.4.63.0608101558290.10541@wbgn013.biozentrum.uni-wuerzburg.de>

On 8/10/06, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> > I noticed that it spends a lot of time finding renames (diffcore_std,
> > in particular).
>
> My next plans -- after making sure that merge-recursive is accurate
> (enough) -- was to use oprofile to find the expensive spots.

BTW, it maybe subjective, but diff-tree seem to have slowed down too.

> > Why doesn't it take that much time for "diff-tree -M -r base head1" +
> > "diff-tree -M -r base head2", I wonder...? (~30 sek, for that windows box).
>
> Could it be that it has many common ancestors? You have to do the rename
> handling twice for each merge...

No. I'd notice that.

> > Sorry, I can't provide the tree. I suppose Mozilla tree can be compared
> > to that thing, when it becomes available. Linux kernel is no good for
> > reproducing this problem: it's too clean and compact.
>
> The beauty of Open Source: since everyone can see your mess, you tend to
> be tidier...

Yep. One of the reasons to have source closed: so your customers do
not see how dirty the mess they paid for is.

^ permalink raw reply

* [PATCH] discard_cache(): discard index, even if no file was mmap()ed
From: Johannes Schindelin @ 2006-08-10 14:47 UTC (permalink / raw)
  To: git, junkio


Since add_cacheinfo() can be called without a mapped index file,
discard_cache() _has_ to discard the entries, even when
cache_mmap == NULL.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>

---

	This fixes 41094b8e, the only showstopper I wrote
	about in my last -recur status report. The index file is
	now the same for -recur and -recursive when trying to recreate 
	41094b8e.

	Happy.

 read-cache.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/read-cache.c b/read-cache.c
index de8f690..3559bdc 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -841,14 +841,14 @@ int discard_cache()
 {
 	int ret;
 
+	active_nr = active_cache_changed = 0;
+	index_file_timestamp = 0;
+	cache_tree_free(&active_cache_tree);
 	if (cache_mmap == NULL)
 		return 0;
 	ret = munmap(cache_mmap, cache_mmap_size);
 	cache_mmap = NULL;
 	cache_mmap_size = 0;
-	active_nr = active_cache_changed = 0;
-	index_file_timestamp = 0;
-	cache_tree_free(&active_cache_tree);
 
 	/* no need to throw away allocated active_cache */
 	return ret;
-- 
1.4.2.rc4.g0d295-dirty

^ permalink raw reply related

* [PATCH 3/9] git-verify-pack: more careful path handling
From: Rene Scharfe @ 2006-08-10 15:02 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git
In-Reply-To: <11552221582769-git-send-email-rene.scharfe@lsrfire.ath.cx>

Use strlcpy() to copy the filename into a buffer and complain if it
doesn't fit.  Also move the path buffer into verify_one_pack(); it is
used only there.  Now we can const'ify the first argument of this
function.

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
---
 verify-pack.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/verify-pack.c b/verify-pack.c
index 7201596..2c814a6 100644
--- a/verify-pack.c
+++ b/verify-pack.c
@@ -1,10 +1,15 @@
 #include "cache.h"
 #include "pack.h"
 
-static int verify_one_pack(char *arg, int verbose)
+static int verify_one_pack(const char *path, int verbose)
 {
-	int len = strlen(arg);
+	char arg[PATH_MAX];
+	int len;
 	struct packed_git *g;
+
+	len = strlcpy(arg, path, PATH_MAX);
+	if (len >= PATH_MAX)
+		return error("name too long: %s", path);
 	
 	while (1) {
 		/* Should name foo.idx, but foo.pack may be named;
@@ -37,8 +42,6 @@ int main(int ac, char **av)
 	int nothing_done = 1;
 
 	while (1 < ac) {
-		char path[PATH_MAX];
-
 		if (!no_more_options && av[1][0] == '-') {
 			if (!strcmp("-v", av[1]))
 				verbose = 1;
@@ -48,8 +51,7 @@ int main(int ac, char **av)
 				usage(verify_pack_usage);
 		}
 		else {
-			strcpy(path, av[1]);
-			if (verify_one_pack(path, verbose))
+			if (verify_one_pack(av[1], verbose))
 				errs++;
 			nothing_done = 0;
 		}
-- 
1.4.2.rc2.g822a

^ permalink raw reply related

* [PATCH 4/9] git-verify-pack: insist on .idx extension
From: Rene Scharfe @ 2006-08-10 15:02 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git
In-Reply-To: <11552221582769-git-send-email-rene.scharfe@lsrfire.ath.cx>

git-verify-pack can be called with a filename without .idx extension.
add_packed_git() on the other hand depends on its presence.  So
instead of trying to call it with whatever the user gave us check for
that extension and add it if it's missing.

That means that you can't name your index file "blah" and your pack
file ".pack" anymore ("git-verify-pack blah" currently works in that
case).  I think this regression is a good change. ;-)

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
---
 verify-pack.c |   11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff a/verify-pack.c b/verify-pack.c
--- a/verify-pack.c
+++ b/verify-pack.c
@@ -18,13 +18,12 @@
 		if (has_extension(arg, len, ".pack")) {
 			strcpy(arg + len - 5, ".idx");
 			len--;
+		} else if (!has_extension(arg, len, ".idx")) {
+			if (len + 4 >= PATH_MAX)
+				return error("name too long: %s.idx", arg);
+			strcpy(arg + len, ".idx");
+			len += 4;
 		}
-		/* Should name foo.idx now */
-		if ((g = add_packed_git(arg, len, 1)))
-			break;
-		/* No?  did you name just foo? */
-		strcpy(arg + len, ".idx");
-		len += 4;
 		if ((g = add_packed_git(arg, len, 1)))
 			break;
 		return error("packfile %s not found.", arg);

^ permalink raw reply

* [PATCH 2/9] git-verify-pack: show usage when no pack was specified
From: Rene Scharfe @ 2006-08-10 15:02 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git
In-Reply-To: <11552221582769-git-send-email-rene.scharfe@lsrfire.ath.cx>

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
---
 verify-pack.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/verify-pack.c b/verify-pack.c
index ef00204..7201596 100644
--- a/verify-pack.c
+++ b/verify-pack.c
@@ -34,6 +34,7 @@ int main(int ac, char **av)
 	int errs = 0;
 	int verbose = 0;
 	int no_more_options = 0;
+	int nothing_done = 1;
 
 	while (1 < ac) {
 		char path[PATH_MAX];
@@ -50,8 +51,13 @@ int main(int ac, char **av)
 			strcpy(path, av[1]);
 			if (verify_one_pack(path, verbose))
 				errs++;
+			nothing_done = 0;
 		}
 		ac--; av++;
 	}
+
+	if (nothing_done)
+		usage(verify_pack_usage);
+
 	return !!errs;
 }
-- 
1.4.2.rc2.g822a

^ permalink raw reply related

* [PATCH 1/9] Add has_extension()
From: Rene Scharfe @ 2006-08-10 15:02 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git
In-Reply-To: <11552221582769-git-send-email-rene.scharfe@lsrfire.ath.cx>

The little helper has_extension() documents through its name what we are
trying to do and makes sure we don't forget the underrun check.

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
---
 git-compat-util.h |    6 ++++++
 help.c            |    2 +-
 http-fetch.c      |    2 +-
 index-pack.c      |    2 +-
 local-fetch.c     |    2 +-
 refs.c            |    2 +-
 sha1_file.c       |    2 +-
 verify-pack.c     |    2 +-
 8 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/git-compat-util.h b/git-compat-util.h
index 3bcf5b1..dd92093 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -139,6 +139,12 @@ static inline ssize_t xwrite(int fd, con
 	}
 }
 
+static inline int has_extension(const char *filename, int len, const char *ext)
+{
+	int extlen = strlen(ext);
+	return len > extlen && !memcmp(filename + len - extlen, ext, extlen);
+}
+
 /* Sane ctype - no locale, and works with signed chars */
 #undef isspace
 #undef isdigit
diff --git a/help.c b/help.c
index fb731cc..7a7f775 100644
--- a/help.c
+++ b/help.c
@@ -140,7 +140,7 @@ static void list_commands(const char *ex
 			continue;
 
 		entlen = strlen(de->d_name);
-		if (4 < entlen && !strcmp(de->d_name + entlen - 4, ".exe"))
+		if (has_extension(de->d_name, entlen, ".exe"))
 			entlen -= 4;
 
 		if (longest < entlen)
diff --git a/http-fetch.c b/http-fetch.c
index 36af3e5..6ea39f0 100644
--- a/http-fetch.c
+++ b/http-fetch.c
@@ -870,7 +870,7 @@ static void process_ls_pack(struct remot
 
 	if (strlen(ls->dentry_name) == 63 &&
 	    !strncmp(ls->dentry_name, "objects/pack/pack-", 18) &&
-	    !strncmp(ls->dentry_name+58, ".pack", 5)) {
+	    has_extension(ls->dentry_name, 63, ".pack")) {
 		get_sha1_hex(ls->dentry_name + 18, sha1);
 		setup_index(ls->repo, sha1);
 	}
diff --git a/index-pack.c b/index-pack.c
index b39953d..a91e39e 100644
--- a/index-pack.c
+++ b/index-pack.c
@@ -447,7 +447,7 @@ int main(int argc, char **argv)
 		usage(index_pack_usage);
 	if (!index_name) {
 		int len = strlen(pack_name);
-		if (len < 5 || strcmp(pack_name + len - 5, ".pack"))
+		if (!has_extension(pack_name, len, ".pack"))
 			die("packfile name '%s' does not end with '.pack'",
 			    pack_name);
 		index_name_buf = xmalloc(len);
diff --git a/local-fetch.c b/local-fetch.c
index 4bf86fb..59af57c 100644
--- a/local-fetch.c
+++ b/local-fetch.c
@@ -44,7 +44,7 @@ static int setup_indices(void)
 	while ((de = readdir(dir)) != NULL) {
 		int namelen = strlen(de->d_name);
 		if (namelen != 50 || 
-		    strcmp(de->d_name + namelen - 5, ".pack"))
+		    !has_extension(de->d_name, namelen, ".pack"))
 			continue;
 		get_sha1_hex(de->d_name + 5, sha1);
 		setup_index(sha1);
diff --git a/refs.c b/refs.c
index 02850b6..b01835f 100644
--- a/refs.c
+++ b/refs.c
@@ -147,7 +147,7 @@ static int do_for_each_ref(const char *b
 			namelen = strlen(de->d_name);
 			if (namelen > 255)
 				continue;
-			if (namelen>5 && !strcmp(de->d_name+namelen-5,".lock"))
+			if (has_extension(de->d_name, namelen, ".lock"))
 				continue;
 			memcpy(path + baselen, de->d_name, namelen+1);
 			if (stat(git_path("%s", path), &st) < 0)
diff --git a/sha1_file.c b/sha1_file.c
index 3d7a7d4..f0a4a7e 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -608,7 +608,7 @@ static void prepare_packed_git_one(char 
 		int namelen = strlen(de->d_name);
 		struct packed_git *p;
 
-		if (strcmp(de->d_name + namelen - 4, ".idx"))
+		if (!has_extension(de->d_name, namelen, ".idx"))
 			continue;
 
 		/* we have .idx.  Is it a file we can map? */
diff --git a/verify-pack.c b/verify-pack.c
index c99db9d..ef00204 100644
--- a/verify-pack.c
+++ b/verify-pack.c
@@ -10,7 +10,7 @@ static int verify_one_pack(char *arg, in
 		/* Should name foo.idx, but foo.pack may be named;
 		 * convert it to foo.idx
 		 */
-		if (!strcmp(arg + len - 5, ".pack")) {
+		if (has_extension(arg, len, ".pack")) {
 			strcpy(arg + len - 5, ".idx");
 			len--;
 		}
-- 
1.4.2.rc2.g822a

^ permalink raw reply related

* [PATCH 0/9] git-verify-pack: clean up and make builtin
From: Rene Scharfe @ 2006-08-10 15:02 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

This patch series makes git-verify-pack handle user supplied parameters
much more carefully and converts it to a builtin command.  As a bonus it
plugs a memory leak and makes some comments clearer.  It applies to the
current next branch (a934882).

^ permalink raw reply

* [PATCH 7/9] git-verify-pack: buffer overrun paranoia
From: Rene Scharfe @ 2006-08-10 15:02 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git
In-Reply-To: <11552221582769-git-send-email-rene.scharfe@lsrfire.ath.cx>

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
---
 verify-pack.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/verify-pack.c b/verify-pack.c
index 94fe0f3..1076001 100644
--- a/verify-pack.c
+++ b/verify-pack.c
@@ -26,6 +26,15 @@ static int verify_one_pack(const char *p
 		len += 4;
 	}
 
+	/*
+	 * add_packed_git() uses our buffer (containing "foo.idx") to
+	 * build the pack filename ("foo.pack").  Make sure it fits.
+	 */
+	if (len + 1 >= PATH_MAX) {
+		arg[len - 4] = '\0';
+		return error("name too long: %s.pack", arg);
+	}
+
 	pack = add_packed_git(arg, len, 1);
 	if (!pack)
 		return error("packfile %s not found.", arg);
-- 
1.4.2.rc2.g822a

^ permalink raw reply related

* [PATCH 6/9] git-verify-pack: free pack after use and a cleanup
From: Rene Scharfe @ 2006-08-10 15:02 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git
In-Reply-To: <11552221582769-git-send-email-rene.scharfe@lsrfire.ath.cx>

Plug memory leak in verify_one_pack() by freeing the struct packed_git
we got from add_packed_git().  Also rename g to pack and pull an
assignment out of an if statement while we're at it.

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
---
 verify-pack.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/verify-pack.c b/verify-pack.c
index 1dcef52..c7bed1e 100644
--- a/verify-pack.c
+++ b/verify-pack.c
@@ -5,7 +5,8 @@ static int verify_one_pack(const char *p
 {
 	char arg[PATH_MAX];
 	int len;
-	struct packed_git *g;
+	struct packed_git *pack;
+	int err;
 
 	len = strlcpy(arg, path, PATH_MAX);
 	if (len >= PATH_MAX)
@@ -25,10 +26,14 @@ static int verify_one_pack(const char *p
 		len += 4;
 	}
 
-	if (!(g = add_packed_git(arg, len, 1)))
+	pack = add_packed_git(arg, len, 1);
+	if (!pack)
 		return error("packfile %s not found.", arg);
 
-	return verify_pack(g, verbose);
+	err = verify_pack(pack, verbose);
+	free(pack);
+
+	return err;
 }
 
 static const char verify_pack_usage[] = "git-verify-pack [-v] <pack>...";
-- 
1.4.2.rc2.g822a

^ permalink raw reply related

* [PATCH 9/9] git-verify-pack: make builtin
From: Rene Scharfe @ 2006-08-10 15:02 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git
In-Reply-To: <11552221582769-git-send-email-rene.scharfe@lsrfire.ath.cx>

Convert git-verify-pack to a builtin command.  Also rename ac to argc
and av to argv for consistancy.

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
---
 Makefile              |    1 +
 builtin-verify-pack.c |   77 +++++++++++++++++++++++++++++++++++++++++++++++++
 builtin.h             |    1 +
 git.c                 |    1 +
 verify-pack.c         |   76 ------------------------------------------------
 5 files changed, 80 insertions(+), 76 deletions(-)

diff --git a/Makefile b/Makefile
index faa118a..07c421b 100644
--- a/Makefile
+++ b/Makefile
@@ -295,6 +295,7 @@ BUILTIN_OBJS = \
 	builtin-update-index.o \
 	builtin-update-ref.o \
 	builtin-upload-tar.o \
+	builtin-verify-pack.o \
 	builtin-write-tree.o
 
 GITLIBS = $(LIB_FILE) $(XDIFF_LIB)
diff --git a/builtin-verify-pack.c b/builtin-verify-pack.c
new file mode 100644
index 0000000..15f2502
--- /dev/null
+++ b/builtin-verify-pack.c
@@ -0,0 +1,79 @@
+#include "builtin.h"
+#include "cache.h"
+#include "pack.h"
+
+static int verify_one_pack(const char *path, int verbose)
+{
+	char arg[PATH_MAX];
+	int len;
+	struct packed_git *pack;
+	int err;
+
+	len = strlcpy(arg, path, PATH_MAX);
+	if (len >= PATH_MAX)
+		return error("name too long: %s", path);
+
+	/*
+	 * In addition to "foo.idx" we accept "foo.pack" and "foo";
+	 * normalize these forms to "foo.idx" for add_packed_git().
+	 */
+	if (has_extension(arg, len, ".pack")) {
+		strcpy(arg + len - 5, ".idx");
+		len--;
+	} else if (!has_extension(arg, len, ".idx")) {
+		if (len + 4 >= PATH_MAX)
+			return error("name too long: %s.idx", arg);
+		strcpy(arg + len, ".idx");
+		len += 4;
+	}
+
+	/*
+	 * add_packed_git() uses our buffer (containing "foo.idx") to
+	 * build the pack filename ("foo.pack").  Make sure it fits.
+	 */
+	if (len + 1 >= PATH_MAX) {
+		arg[len - 4] = '\0';
+		return error("name too long: %s.pack", arg);
+	}
+
+	pack = add_packed_git(arg, len, 1);
+	if (!pack)
+		return error("packfile %s not found.", arg);
+
+	err = verify_pack(pack, verbose);
+	free(pack);
+
+	return err;
+}
+
+static const char verify_pack_usage[] = "git-verify-pack [-v] <pack>...";
+
+int cmd_verify_pack(int argc, const char **argv, const char *prefix)
+{
+	int err = 0;
+	int verbose = 0;
+	int no_more_options = 0;
+	int nothing_done = 1;
+
+	while (1 < argc) {
+		if (!no_more_options && argv[1][0] == '-') {
+			if (!strcmp("-v", argv[1]))
+				verbose = 1;
+			else if (!strcmp("--", argv[1]))
+				no_more_options = 1;
+			else
+				usage(verify_pack_usage);
+		}
+		else {
+			if (verify_one_pack(argv[1], verbose))
+				err = 1;
+			nothing_done = 0;
+		}
+		argc--; argv++;
+	}
+
+	if (nothing_done)
+		usage(verify_pack_usage);
+
+	return err;
+}
diff --git a/builtin.h b/builtin.h
index c0bdb05..ade58c4 100644
--- a/builtin.h
+++ b/builtin.h
@@ -59,5 +59,6 @@ extern int cmd_upload_tar(int argc, cons
 extern int cmd_version(int argc, const char **argv, const char *prefix);
 extern int cmd_whatchanged(int argc, const char **argv, const char *prefix);
 extern int cmd_write_tree(int argc, const char **argv, const char *prefix);
+extern int cmd_verify_pack(int argc, const char **argv, const char *prefix);
 
 #endif
diff --git a/git.c b/git.c
index db0f867..5da7787 100644
--- a/git.c
+++ b/git.c
@@ -270,6 +270,7 @@ static void handle_internal_command(int 
 		{ "version", cmd_version },
 		{ "whatchanged", cmd_whatchanged, RUN_SETUP | USE_PAGER },
 		{ "write-tree", cmd_write_tree, RUN_SETUP },
+		{ "verify-pack", cmd_verify_pack },
 	};
 	int i;
 
diff --git a/verify-pack.c b/verify-pack.c
deleted file mode 100644
index f12cefe..0000000
--- a/verify-pack.c
+++ /dev/null
@@ -1,78 +0,0 @@
-#include "cache.h"
-#include "pack.h"
-
-static int verify_one_pack(const char *path, int verbose)
-{
-	char arg[PATH_MAX];
-	int len;
-	struct packed_git *pack;
-	int err;
-
-	len = strlcpy(arg, path, PATH_MAX);
-	if (len >= PATH_MAX)
-		return error("name too long: %s", path);
-	
-	/*
-	 * In addition to "foo.idx" we accept "foo.pack" and "foo";
-	 * normalize these forms to "foo.idx" for add_packed_git().
-	 */
-	if (has_extension(arg, len, ".pack")) {
-		strcpy(arg + len - 5, ".idx");
-		len--;
-	} else if (!has_extension(arg, len, ".idx")) {
-		if (len + 4 >= PATH_MAX)
-			return error("name too long: %s.idx", arg);
-		strcpy(arg + len, ".idx");
-		len += 4;
-	}
-
-	/*
-	 * add_packed_git() uses our buffer (containing "foo.idx") to
-	 * build the pack filename ("foo.pack").  Make sure it fits.
-	 */
-	if (len + 1 >= PATH_MAX) {
-		arg[len - 4] = '\0';
-		return error("name too long: %s.pack", arg);
-	}
-
-	pack = add_packed_git(arg, len, 1);
-	if (!pack)
-		return error("packfile %s not found.", arg);
-
-	err = verify_pack(pack, verbose);
-	free(pack);
-
-	return err;
-}
-
-static const char verify_pack_usage[] = "git-verify-pack [-v] <pack>...";
-
-int main(int ac, char **av)
-{
-	int err = 0;
-	int verbose = 0;
-	int no_more_options = 0;
-	int nothing_done = 1;
-
-	while (1 < ac) {
-		if (!no_more_options && av[1][0] == '-') {
-			if (!strcmp("-v", av[1]))
-				verbose = 1;
-			else if (!strcmp("--", av[1]))
-				no_more_options = 1;
-			else
-				usage(verify_pack_usage);
-		}
-		else {
-			if (verify_one_pack(av[1], verbose))
-				err = 1;
-			nothing_done = 0;
-		}
-		ac--; av++;
-	}
-
-	if (nothing_done)
-		usage(verify_pack_usage);
-
-	return err;
-}
-- 
1.4.2.rc2.g822a

^ permalink raw reply related

* [PATCH 5/9] git-verify-pack: get rid of while loop
From: Rene Scharfe @ 2006-08-10 15:02 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git
In-Reply-To: <11552221582769-git-send-email-rene.scharfe@lsrfire.ath.cx>

Get rid of that while loop which was apparently used as a way to avoid
goto's (why?).  It's easy now because there is only one break left at
the end of it.  Also make the comment clearer.

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
---
 verify-pack.c |   32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff a/verify-pack.c b/verify-pack.c
--- a/verify-pack.c
+++ b/verify-pack.c
@@ -11,23 +11,23 @@
 	if (len >= PATH_MAX)
 		return error("name too long: %s", path);
 	
-	while (1) {
-		/* Should name foo.idx, but foo.pack may be named;
-		 * convert it to foo.idx
-		 */
-		if (has_extension(arg, len, ".pack")) {
-			strcpy(arg + len - 5, ".idx");
-			len--;
-		} else if (!has_extension(arg, len, ".idx")) {
-			if (len + 4 >= PATH_MAX)
-				return error("name too long: %s.idx", arg);
-			strcpy(arg + len, ".idx");
-			len += 4;
-		}
-		if ((g = add_packed_git(arg, len, 1)))
-			break;
-		return error("packfile %s not found.", arg);
+	/*
+	 * In addition to "foo.idx" we accept "foo.pack" and "foo";
+	 * normalize these forms to "foo.idx" for add_packed_git().
+	 */
+	if (has_extension(arg, len, ".pack")) {
+		strcpy(arg + len - 5, ".idx");
+		len--;
+	} else if (!has_extension(arg, len, ".idx")) {
+		if (len + 4 >= PATH_MAX)
+			return error("name too long: %s.idx", arg);
+		strcpy(arg + len, ".idx");
+		len += 4;
 	}
+
+	if (!(g = add_packed_git(arg, len, 1)))
+		return error("packfile %s not found.", arg);
+
 	return verify_pack(g, verbose);
 }
 

^ permalink raw reply

* [PATCH 8/9] git-verify-pack: no need to count errors
From: Rene Scharfe @ 2006-08-10 15:02 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git
In-Reply-To: <11552221582769-git-send-email-rene.scharfe@lsrfire.ath.cx>

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
---
 verify-pack.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/verify-pack.c b/verify-pack.c
index 1076001..f12cefe 100644
--- a/verify-pack.c
+++ b/verify-pack.c
@@ -49,7 +49,7 @@ static const char verify_pack_usage[] = 
 
 int main(int ac, char **av)
 {
-	int errs = 0;
+	int err = 0;
 	int verbose = 0;
 	int no_more_options = 0;
 	int nothing_done = 1;
@@ -65,7 +65,7 @@ int main(int ac, char **av)
 		}
 		else {
 			if (verify_one_pack(av[1], verbose))
-				errs++;
+				err = 1;
 			nothing_done = 0;
 		}
 		ac--; av++;
@@ -74,5 +74,5 @@ int main(int ac, char **av)
 	if (nothing_done)
 		usage(verify_pack_usage);
 
-	return !!errs;
+	return err;
 }
-- 
1.4.2.rc2.g822a

^ permalink raw reply related

* Re: [PATCH 3/14] Generic ioremap_page_range: alpha conversion
From: Haavard Skinnemoen @ 2006-08-10 16:09 UTC (permalink / raw)
  To: linux-kernel; +Cc: git
In-Reply-To: <115522582724-git-send-email-hskinnemoen@atmel.com>

On Thu, 10 Aug 2006 18:03:35 +0200
Haavard Skinnemoen <hskinnemoen@atmel.com> wrote:

> From: Richard Henderson <rth@twiddle.net>

Uh...does anyone have an idea why git-send-email added this line for
me? All I did was add a Cc line to the mbox like this:

Cc: Richard Henderson <rth@twiddle.net>

> Convert Alpha to use generic ioremap_page_range() by turning
> __alpha_remap_area_pages() into an inline wrapper around
> ioremap_page_range().
> 
> Signed-off-by: Haavard Skinnemoen <hskinnemoen@atmel.com>

Håvard

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox