git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Nieder <jrnieder@gmail.com>
To: Ramkumar Ramachandra <artagnon@gmail.com>
Cc: Git Mailing List <git@vger.kernel.org>,
	David Michael Barr <david.barr@cordelta.com>,
	Sverre Rabbelier <srabbelier@gmail.com>,
	Michael J Gruber <git@drmicha.warpmail.net>,
	Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH 5/6] Add infrastructure to write revisions in fast-export format
Date: Fri, 4 Jun 2010 14:02:22 -0500	[thread overview]
Message-ID: <20100604190222.GB21295@progeny.tock> (raw)
In-Reply-To: <1275658871-1473-6-git-send-email-artagnon@gmail.com>

Hi Ram,

Thanks for the style cleanup.

Ramkumar Ramachandra wrote:

> --- /dev/null
> +++ b/vcs-svn/repo_tree.c
[...]
> +static struct repo_dir *repo_clone_dir(struct repo_dir *orig_dir, uint32_t padding)
> +{
> +	uint32_t orig_o, new_o, dirent_o;
> +	orig_o = dir_offset(orig_dir);
> +	if (orig_o < num_dirs_saved) {
> +		new_o = dir_with_dirents_alloc(orig_dir->size + padding);
> +		orig_dir = dir_pointer(orig_o);
> +		dirent_o = dir_pointer(new_o)->first_offset;
> +	} else {
> +		if (padding == 0)
> +			return orig_dir;
> +		new_o = orig_o;
> +		dirent_o = dirent_alloc(orig_dir->size + padding);
> +	}
> +	memcpy(dirent_pointer(dirent_o), repo_first_dirent(orig_dir),
> +		   orig_dir->size * sizeof(struct repo_dirent));
> +	dir_pointer(new_o)->size = orig_dir->size + padding;
> +	dir_pointer(new_o)->first_offset = dirent_o;
> +	return dir_pointer(new_o);
> +}

This function expands a list of directory entries, copying it if
already committed as part of a previous revision.

The big downside is that as David mentioned it does not scale well with
the size of the directory and number of expansions.  But a patch is in
the pipeline to fix that.  I do not think it should hold the series up.

> +
> +static struct repo_dirent *repo_read_dirent(uint32_t revision, uint32_t *path)
> +{
> +	uint32_t name = 0;
> +	struct repo_dir *dir = NULL;
> +	struct repo_dirent *dirent = NULL;
> +	dir = repo_commit_root_dir(commit_pointer(revision));
> +	while (~(name = *path++)) {
> +		dirent = repo_dirent_by_name(dir, name);
> +		if (dirent == NULL) {
> +			return NULL;
> +		} else if (repo_dirent_is_dir(dirent)) {
> +			dir = repo_dir_from_dirent(dirent);
> +		} else {
> +			break;
> +		}

Style: would probably be clearer to write:

	while (~(name = *path++)) {
		dirent = repo_dirent_by_name(dir, name);
		if (!dirent || !repo_dirent_is_dir(dirent))
			break;
		dir = repo_dir_from_dirent(dirent);
	}

i.e., fewer unnecessary braces, and dealing with the exceptional cases
separately from the normal case.

As before, I wonder about the error cases.  Might it make sense to
report the error if someone tries to copy a nonexistent directory
from a previous revision?

> +static void
> +repo_write_dirent(uint32_t *path, uint32_t mode, uint32_t content_offset,
> +                  uint32_t del)

Function is too long for my taste (I realize this is a matter of
taste).  The innermost blocks would make sense as functions in their
own right.

[...]
> +static void repo_diff_r(uint32_t depth, uint32_t *path, struct repo_dir *dir1,
> +			struct repo_dir *dir2)
[...]
> +	while (de1 < max_de1 && de2 < max_de2) {
> +		if (de1->name_offset < de2->name_offset) {
> +			path[depth] = (de1++)->name_offset;
> +			fast_export_delete(depth + 1, path);
> +		} else if (de1->name_offset > de2->name_offset) {
> +			path[depth] = de2->name_offset;
> +			repo_git_add(depth + 1, path, de2++);
> +		} else {
> +			path[depth] = de1->name_offset;
> +			if (de1->mode != de2->mode ||
> +				de1->content_offset != de2->content_offset) {
> +				if (repo_dirent_is_dir(de1) && repo_dirent_is_dir(de2)) {

My 80-column terminal is suffering.  Why not use the common

	while (...) {
		if (exceptional case) {
			....
			continue;
		} else if (exceptional case) {
			...
			continue;
		}
		path[depth] = de1->name_offset;
		if (easy case) {
			...
			continue;
		}
		usual case
	}

pattern?

> +#define REPO_MAX_PATH_LEN 4096
> +#define REPO_MAX_PATH_DEPTH 1000

These limits are not checked; is the caller supposed to check them
itself?  Does svn obey them?

Jonathan

  reply	other threads:[~2010-06-04 19:03 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-04 13:41 [PATCH 0/6] Merge David's SVN exporter Ramkumar Ramachandra
2010-06-04 13:41 ` [PATCH 1/6] Add memory pool library Ramkumar Ramachandra
2010-06-04 18:29   ` Jonathan Nieder
2010-06-07 13:28     ` Ramkumar Ramachandra
2010-06-07 14:00       ` Erik Faye-Lund
2010-06-07 14:35         ` Ramkumar Ramachandra
2010-06-04 13:41 ` [PATCH 2/6] Add cpp macro implementation of treaps Ramkumar Ramachandra
2010-06-04 13:41 ` [PATCH 3/6] Add library for string-specific memory pool Ramkumar Ramachandra
2010-06-04 13:41 ` [PATCH 4/6] Add stream helper library Ramkumar Ramachandra
2010-06-04 18:35   ` Jonathan Nieder
2010-06-04 13:41 ` [PATCH 5/6] Add infrastructure to write revisions in fast-export format Ramkumar Ramachandra
2010-06-04 19:02   ` Jonathan Nieder [this message]
2010-06-07 12:35     ` Ramkumar Ramachandra
2010-06-07 13:36       ` David Michael Barr
2010-06-04 13:41 ` [PATCH 6/6] Add SVN dump parser Ramkumar Ramachandra
  -- strict thread matches above, loose matches on Subject: below --
2010-06-10 13:09 [PATCH 0/6] Another attempt to get the SVN exporter merged Ramkumar Ramachandra
2010-06-10 13:09 ` [PATCH 5/6] Add infrastructure to write revisions in fast-export format Ramkumar Ramachandra
2010-06-04 13:26 [PATCH 0/6] Merge David's SVN exporter into git.git Ramkumar Ramachandra
2010-06-04 13:26 ` [PATCH 5/6] Add infrastructure to write revisions in fast-export format Ramkumar Ramachandra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100604190222.GB21295@progeny.tock \
    --to=jrnieder@gmail.com \
    --cc=artagnon@gmail.com \
    --cc=david.barr@cordelta.com \
    --cc=git@drmicha.warpmail.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=srabbelier@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).