git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Wong <normalperson@yhbt.net>
To: "David D. Kilzer" <ddkilzer@kilzer.net>
Cc: git@vger.kernel.org
Subject: Re: [RFC PATCH] git-svn info: implement info command
Date: Sat, 17 Nov 2007 14:54:02 -0800	[thread overview]
Message-ID: <20071117225402.GC28755@muzzle> (raw)
In-Reply-To: <1194884349-11504-1-git-send-email-ddkilzer@kilzer.net>

"David D. Kilzer" <ddkilzer@kilzer.net> wrote:
> Implement "git-svn info" for files and directories based on the "svn info"
> command.  Note that the -r/--revision argument is not supported yet.
> 
> Added 18 tests in t/t9117-git-svn-info.sh.
> 
> Signed-off-by: David D. Kilzer <ddkilzer@kilzer.net>
> ---
> 
> Looking for feedback on this patch.  Specifically, I'm looking for insight
> for the two FIXME comments in the cmd_info() function added to git-svn.
> (I can't help but think I'm missing a plumbing command or a basic concept.
> Pointers to code, web pages or man pages are welcome.)
> 
> Note that I've tried to cover all the bases that "svn info" does (by using
> tests), except supporting the -r/--revision argument.

Hi David,

Wow.  I can honestly say I've never even noticed the "Schedule:" field
in `svn info'.  I would've been perfectly happy to accept an
implementation of `git svn info' without that :)

> I've also tried to be aggressive in extracting common code into functions.

I like it, but this should be a separate patch.

> +sub canonicalize_path {
> +	my ($path) = @_;
> +	my $dotSlashAdded = 0;

camelCase variables requires more time for the brain to parse (they're
easier to write, but take more time to read), please use snake_case like
the rest of git-svn (and git).

> +sub cmd_info {
> +	my $path = canonicalize_path(shift or ".");
> +	unless (scalar(@_) == 0) {
> +		die "Too many arguments specified\n";
> +	}
> +
> +	# FIXME: We use a combination of git-diff, git-ls-files and git-cat-file
> +	# to divine the state and type of object that was passed in as $path.
> +	# There has to be a better way.  Note that only $diffStatus is used
> +	# beyond setting $isDirectory below.

I agree it's pretty ugly.  You can probably expand git-runstatus to do
this.  git-commit.sh used to use something like this until git-runstatus
was added.  On the other hand, I'd be content if we dropped support
for this info entirely since `git-status' is perfectly good.

IMNSHO, "URL:" and "Repository Root:" and occasionally "Revision:" (on the
top-level directory) would be the only useful things this command would
have to offer.

Being able to run something like `git svn info --url <path>'
to get something like http://svn.foo.org/project/trunk/<path> would be
nice, too.

> +
> +	my $diffStatus = (split(' ', command_oneline(qw(diff --cached --name-status --), $path) || ""))[0] || "";

Please wrap lines at 80 characters.  I have a hard time following long
lines.

> +		my $checksum;
> +		# FIXME: We fail to generate the correct checksum for deleted
> +		# symlinks here.  How do we know if a deleted file was a symlin

git ls-tree HEAD <filename> will show the mode of a deleted file

> @@ -0,0 +1,236 @@
> +#!/bin/sh
> +#
> +# Copyright (c) 2007 David D. Kilzer
> +
> +test_description='git-svn info'
> +
> +. ./lib-git-svn.sh
> +
> +test_expect_success 'setup repository and import' "
> +	rm -rf info gitwc svnwc &&

All git tests should start you off on a clean trash/ directory...

> +	mkdir info &&
> +	cd info &&
> +		echo one > file &&
> +		ln -s file symlink-file &&
> +		mkdir directory &&
> +		touch directory/.placeholder &&
> +		ln -s directory symlink-directory &&
> +		svn import -m 'initial' . $svnrepo &&
> +	cd .. &&
> +	mkdir gitwc &&
> +	cd gitwc &&
> +		git-svn init $svnrepo &&
> +		git-svn fetch &&
> +	cd .. &&
> +	svn co $svnrepo svnwc &&
> +	touch -c -r svnwc/file gitwc/file &&
> +	touch -c -r svnwc/directory gitwc/directory &&
> +	touch -c -r svnwc/symlink-file gitwc/symlink-file &&
> +	touch -c -r svnwc/symlink-directory gitwc/symlink-directory

Are -r and -c portable?  I remember writing test-chmtime to workaround
some arguments for touch not being portable.

> +test_expect_success 'info no arguments' "
> +	(cd svnwc; svn info) > expected.info-no-arguments &&
> +	(cd gitwc; git-svn info) > actual.info-no-arguments &&
> +	diff -u expected.info-no-arguments actual.info-no-arguments
> +	"

Can we expect the output of "svn info" to not change between
versions?  I know "svn status" has changed between versions of
svn.  I'd prefer if we keep the expected.* files hard-coded
in a test directory and compare those instead.  Maybe use sed
to substitute placeholders for timestamps..

Also, git-diff can be used against arbitrary files nowadays, no
need to rely on a working diff command in the system :)

> +test_expect_success 'info added-file' "
> +	echo two > gitwc/added-file &&
> +	cd gitwc &&
> +		git add added-file &&
> +	cd .. &&
> +	cp -p gitwc/added-file svnwc/added-file &&

I can't remember if cp -p is portable, either...

-- 
Eric Wong

  reply	other threads:[~2007-11-17 22:54 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-12 16:19 [RFC PATCH] git-svn info: implement info command David D. Kilzer
2007-11-17 22:54 ` Eric Wong [this message]
2007-11-21  6:43   ` [PATCH 0/3] Implement git-svn: info David D. Kilzer
2007-11-21  6:43     ` [PATCH 1/3] git-svn: extract reusable code into utility functions David D. Kilzer
2007-11-21  6:43       ` [PATCH 2/3] git-svn info: implement info command David D. Kilzer
2007-11-21  6:43         ` [PATCH 3/3] git-svn: info --url [path] David D. Kilzer
2007-11-21  6:49           ` [PATCH 3/3 v2] " David D. Kilzer
2007-11-21  6:59     ` [PATCH 0/3] Implement git-svn: info David D. Kilzer
2007-11-21  9:18       ` Eric Wong
2007-11-21  9:20         ` Eric Wong

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=20071117225402.GC28755@muzzle \
    --to=normalperson@yhbt.net \
    --cc=ddkilzer@kilzer.net \
    --cc=git@vger.kernel.org \
    /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).