Git development
 help / color / mirror / Atom feed
* Re: [PATCH] git-push: Accept -n as a synonym for --dry-run.
From: Junio C Hamano @ 2009-09-13  5:23 UTC (permalink / raw)
  To: Nelson Elhage; +Cc: Junio C Hamano, git
In-Reply-To: <20090913035421.GP4275@mit.edu>

Nelson Elhage <nelhage@MIT.EDU> writes:

> ... I think my
> general argument still stands for commands where that is not the case.

Cool down.

It is a mere subset of what I already said, so you are not arguing against
me at all.

    So the justification should be more like "push does not have any other
    option that deserves a short-and-sweet -n better, it will not have any
    such option in the future, and --dry-run is very often used that it
    deserves to use -n as its short-hand."

and I already said I tend to agree with the first two points.  Indeed the
first point is an absolute truth (the statement is about the current
state).

To answer the second point you need to look into the future, but I do not
foresee us adding a very useful option to the command whose usefulness far
outweigh that of dry-run and whose name begins with 'n' to want to use it
as the short-hand.  In such a case, it is likely that we would try very
hard to find a name that does not begin with 'n' to avoid the issue.

^ permalink raw reply

* Re: [PATCH] git-push: Accept -n as a synonym for --dry-run.
From: Junio C Hamano @ 2009-09-13  5:18 UTC (permalink / raw)
  To: Nelson Elhage; +Cc: git
In-Reply-To: <20090913034031.GO4275@mit.edu>

Nelson Elhage <nelhage@MIT.EDU> writes:

>> commit, push (as you identified), reflog, and send-email have --dry-run
>> but -n is not a synonym for it.  Some of them even use -n as a shorthand
>> for a more often used option than --dry-run.
>
> Can you point to an example of a git command supporting --dry-run, and
> using -n for something else?

Doesn't commit -n stand for no-verify?  I think that is how it is
documented.

> In fact, reflog already supports '-n' to mean dry-run,

Huh?  "git reflog -n 4" is for show-four-entries-from-the-top.

^ permalink raw reply

* Re: [PATCH] git-push: Accept -n as a synonym for --dry-run.
From: Nelson Elhage @ 2009-09-13  3:54 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git
In-Reply-To: <20090913034031.GO4275@mit.edu>

On Sat, Sep 12, 2009 at 11:40:31PM -0400, Nelson Elhage wrote:
> On Sat, Sep 12, 2009 at 07:44:29PM -0700, Junio C Hamano wrote:
> Can you point to an example of a git command supporting --dry-run, and
> using -n for something else? I personally would find that confusing,
> since -n is a common alias for dry-run both inside and outside of git
> (c.f. make, rsync, libtool). I guess patch(1) has that property, but
> none of your examples from git use -n to mean something else.

Oops, I missed 'commit' in your list, which I see (as of recently) has
that property. In that case, though, --dry-run was added after an
established -n option had been there for a long time; I think my
general argument still stands for commands where that is not the case.

- Nelson

^ permalink raw reply

* [PATCH] reflog documentation: -n is an alias for --dry-run
From: Nelson Elhage @ 2009-09-13  3:41 UTC (permalink / raw)
  To: git; +Cc: Nelson Elhage

Signed-off-by: Nelson Elhage <nelhage@mit.edu>
---
 Documentation/git-reflog.txt |    2 +-
 builtin-reflog.c             |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/Documentation/git-reflog.txt b/Documentation/git-reflog.txt
index 7f7a544..b434ff7 100644
--- a/Documentation/git-reflog.txt
+++ b/Documentation/git-reflog.txt
@@ -16,7 +16,7 @@ The command takes various subcommands, and different options
 depending on the subcommand:
 
 [verse]
-'git reflog expire' [--dry-run] [--stale-fix] [--verbose]
+'git reflog expire' [-n | --dry-run] [--stale-fix] [--verbose]
 	[--expire=<time>] [--expire-unreachable=<time>] [--all] <refs>...
 +
 'git reflog delete' ref@\{specifier\}...
diff --git a/builtin-reflog.c b/builtin-reflog.c
index 95198c5..f37c57b 100644
--- a/builtin-reflog.c
+++ b/builtin-reflog.c
@@ -13,9 +13,9 @@
  */
 
 static const char reflog_expire_usage[] =
-"git reflog (show|expire) [--verbose] [--dry-run] [--stale-fix] [--expire=<time>] [--expire-unreachable=<time>] [--all] <refs>...";
+"git reflog (show|expire) [--verbose] [-n | --dry-run] [--stale-fix] [--expire=<time>] [--expire-unreachable=<time>] [--all] <refs>...";
 static const char reflog_delete_usage[] =
-"git reflog delete [--verbose] [--dry-run] [--rewrite] [--updateref] <refs>...";
+"git reflog delete [--verbose] [-n | --dry-run] [--rewrite] [--updateref] <refs>...";
 
 static unsigned long default_reflog_expire;
 static unsigned long default_reflog_expire_unreachable;
-- 
1.6.3.1.499.ge7b8da

^ permalink raw reply related

* Re: [PATCH] git-push: Accept -n as a synonym for --dry-run.
From: Nelson Elhage @ 2009-09-13  3:40 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git
In-Reply-To: <7vfxar5zsi.fsf@alter.siamese.dyndns.org>

On Sat, Sep 12, 2009 at 07:44:29PM -0700, Junio C Hamano wrote:
> Sign-off?

Signed-off-by: Nelson Elhage <nelhage@mit.edu>

(I can resend the entire patch, but I'll resend with a new commit
message if appropriate after any discussion plays itself out).

> 
> Indeed -n is used in many places for --dry-run, but it is not _the_
> standard way.
> 
> commit, push (as you identified), reflog, and send-email have --dry-run
> but -n is not a synonym for it.  Some of them even use -n as a shorthand
> for a more often used option than --dry-run.

Can you point to an example of a git command supporting --dry-run, and
using -n for something else? I personally would find that confusing,
since -n is a common alias for dry-run both inside and outside of git
(c.f. make, rsync, libtool). I guess patch(1) has that property, but
none of your examples from git use -n to mean something else.

In fact, reflog already supports '-n' to mean dry-run, it's just not
documented. I'll send along a documentation patch to fix that.

I got the claim that -n was "standard" from parse-options.h, which
defines OPT__DRY_RUN, which defines both -n and --dry-run switches at
the same time. Given the number of commands that treat them as
synonymous, I think it would be a win for UI consistency to make them
synonymous everywhere.

> 
> So the justification should be more like "push does not any other option
> that deserves a short-and-sweet -n better, it will not have any such
> option in the future, and --dry-run is very often used that it deserves to
> use -n as its short-hand."
> 
> I tend to agree with the first two points, but I am not sure about the
> third point.  Do people dry-push that often?

I personally use --dry-run almost every time I push, which is what
inspired this patch. Especially now that the push.default can change
the behavior of push from repo to repo, I want to be sure I know what
I'm about to push. The recent 'git push --confirm' thread suggests I
am not the only person with this concern.

^ permalink raw reply

* Re: [RFC/PATCH v4 2/2] gitweb: append short hash ids to snapshot files
From: Junio C Hamano @ 2009-09-13  3:35 UTC (permalink / raw)
  To: Mark Rada; +Cc: git, Junio C Hamano, Jakub Narebski
In-Reply-To: <4AAC2917.6000306@mailservices.uwaterloo.ca>

Mark Rada <marada@uwaterloo.ca> writes:

> Teach gitweb how to produce nicer snapshot names by only using the
> short hash id. If clients make requests using a tree-ish that is not a
> partial or full SHA-1 hash, then the short hash will also be appended
> to whatever they asked for.
> ...
> +sub git_get_short_hash {
> +	my $project = shift;
> +	my $hash = shift;
> +	my $o_git_dir = $git_dir;
> +	my $retval = undef;
> +	$git_dir = "$projectroot/$project";
> +	if (open my $fd, '-|', git_cmd(), 'rev-parse', '--short', $hash) {
> +		$hash = <$fd>;
> +		close $fd;
> +		if (defined $hash && $hash =~ /^([0-9a-fA-F]{7,})$/) {

If you want to make sure it is 7 or longer, ask rev-parse to give you 7 or
longer explicitly, so that you won't be hit by default changing under you
in the future.

> @@ -5207,6 +5227,12 @@ sub git_snapshot {
> ...
> +
> +	if ($full_hash !~ /$hash/) {
> +		$hash .= '-' . git_get_short_hash($project, $hash);
> +	} else {
> +		$hash = git_get_short_hash($project, $hash);
> +	}

I do not get this test.  What is this unanchored pattern match about?

I do not think you wanted to allow matching a partial 1234567 $hash to
substitute a full 01234567..... $full_hash, so I am guessing that you
meant to say "$full_hash !~ /^$hash/" at least, or perhaps you meant even
"$full_hash ne $hash".

But that still does not make much sense to me.  Perhaps you meant to catch
a case where $hash is a tagname (or refname), i.e. $hash = 'v1.6.3' or
$hash = 'next'?

If that is indeed the case, then perhaps you should check for that more
explicitly, perhaps using "git show-ref $hash" or something.  I do not
know if the complexity (not just the "detect handcrafted $hash string that
is not an SHA-1", but this whole "give shorten one" topic) is worth it,
though.  And if you drop the hunk that changes user supplied $hash to
$full_hash in the output file name in your [PATCH 1/2], I do not think you
need this anyway.  If somebody asked for 'next', he will get 'next'.

If somebody asked for 01234... (full 40 hexdigits) because that was the
link on the gitweb output page, it might make sense to give him a
shortened name, but then the above conditional needs to be only:

	if ($full_hash eq $hash) {
        	$hash = git_get_short_hash($project, $hash);
	}

no?        

> +test_commit \
> +	'SnapshotFileTests' \
> +	'i can has snapshot?'
> +test_expect_success \
> +	'snapshots: give full hash' \
> +	'ID=`git rev-parse --verify HEAD` &&
> +	gitweb_run "p=.git;a=snapshot;h=$ID;sf=tgz" &&
> +	ID=`git rev-parse --short HEAD` &&
> +	grep ".git-$ID.tar.gz" gitweb.output'

I'd rather see these indented like:

        test_expect_success 'snapshots: give full hash' '
		ID=$(git rev-parse --verify HEAD) &&
		gitweb_run ...
        '

Also, if I am not mistaken, "test_commit" is not about doing any test, but
is a short-hand for doing an operation, right?  It would be better to have
it inside test_expect_success just in case your "git commit" or some other
commands are broken.  I.e. like

	test_expect_success 'create a test commit' '
		test_commit SnapshotFileTests "Can I have shapshot?"
        '

^ permalink raw reply

* Re: [RFC/PATCH v4 1/2] gitweb: check given hash before trying to create snapshot
From: Junio C Hamano @ 2009-09-13  3:30 UTC (permalink / raw)
  To: Mark Rada; +Cc: git, Jakub Narebski
In-Reply-To: <4AAC3833.8060905@mailservices.uwaterloo.ca>

Mark Rada <marada@uwaterloo.ca> writes:

> Makes things nicer in cases when you hand craft the snapshot URL but
> make a typo in defining the hash variable (e.g. netx instead of next);
> you will now get an error message instead of a broken tarball.
>
> To maintain backwards compatibility, git_get_head_hash is now a wrapper
> for git_get_full_hash, as suggested by Jakub Narebski.
>
> Tests for t9501 are included to demonstrate added functionality.
>
> Signed-off-by: Mark Rada <marada@uwaterloo.ca>
> ---
>
> 	This is just a re-send based on getting torn a new one by Junio.
> 	Changes since v3:
> 		- variables have been renamed for readability

Much nicer to read.  Thanks.

> @@ -5196,8 +5202,9 @@ sub git_snapshot {
>  		die_error(403, "Unsupported snapshot format");
>  	}
>  
> -	if (!defined $hash) {
> -		$hash = git_get_head_hash($project);
> +	my $full_hash = git_get_full_hash($project, $hash);
> +	if (!$full_hash) {
> +		die_error(404, 'Hash id was not valid');
>  	}

This is in the context of "snapshot", so obviously you care more about
just "such an object exists", don't you?  You also want it to be a
tree-ish.  Try giving it $hash = 'junio-gpg-pub' and see how it breaks.

> @@ -5210,7 +5217,7 @@ sub git_snapshot {
>  	$cmd = quote_command(
>  		git_cmd(), 'archive',
>  		"--format=$known_snapshot_formats{$format}{'format'}",
> -		"--prefix=$name/", $hash);
> +		"--prefix=$name/", $full_hash);

Why?  There was no justification as to why this change is necessary in the
commit log message.

^ permalink raw reply

* Re: [PATCH] preserve mtime of local clone
From: Junio C Hamano @ 2009-09-13  3:06 UTC (permalink / raw)
  To: Clemens Buchacher; +Cc: git, msysgit, Shawn O. Pearce
In-Reply-To: <20090912090348.GB9654@localhost>


Clemens Buchacher <drizzd@aon.at> writes:

> A local clone without hardlinks copies all objects, including dangling
> ones, to the new repository. Since the mtimes are renewed, those
> dangling objects cannot be pruned by "git gc --prune", even if they
> would have been old enough for pruning in the original repository.
>
> Instead, preserve mtime during copy. "git gc --prune" will then work
> in the clone just like it did in the original.
>
> Signed-off-by: Clemens Buchacher <drizzd@aon.at>
> ---
>
> On Sat, Sep 12, 2009 at 10:26:24AM +0200, Clemens Buchacher wrote:
>
>> If it's a problem we can use utime() instead. I was just trying to use the
>> file descriptors, since they were available. But the patch would be a little
>> smaller if I didn't touch copy_fd().
>
> Here we go.

Thanks.

This new feature is not wanted by most of the callers of copy_file(), and
it is not like they may want to conditionally pass 1 in preserve_times
someday.  I'd limit the damage like this replacement patch, instead.

Is it unreasonable to have a test for this one, by the way?

 builtin-clone.c |    2 +-
 cache.h         |    1 +
 copy.c          |   21 +++++++++++++++++++++
 3 files changed, 23 insertions(+), 1 deletions(-)

diff --git a/builtin-clone.c b/builtin-clone.c
index ad04808..bab2d84 100644
--- a/builtin-clone.c
+++ b/builtin-clone.c
@@ -269,7 +269,7 @@ static void copy_or_link_directory(struct strbuf *src, struct strbuf *dest)
 				die_errno("failed to create link '%s'", dest->buf);
 			option_no_hardlinks = 1;
 		}
-		if (copy_file(dest->buf, src->buf, 0666))
+		if (copy_file_with_time(dest->buf, src->buf, 0666))
 			die_errno("failed to copy file to '%s'", dest->buf);
 	}
 	closedir(dir);
diff --git a/cache.h b/cache.h
index 867918d..1668f28 100644
--- a/cache.h
+++ b/cache.h
@@ -923,6 +923,7 @@ extern const char *git_mailmap_file;
 extern void maybe_flush_or_die(FILE *, const char *);
 extern int copy_fd(int ifd, int ofd);
 extern int copy_file(const char *dst, const char *src, int mode);
+extern int copy_file_with_time(const char *dst, const char *src, int mode);
 extern void write_or_die(int fd, const void *buf, size_t count);
 extern int write_or_whine(int fd, const void *buf, size_t count, const char *msg);
 extern int write_or_whine_pipe(int fd, const void *buf, size_t count, const char *msg);
diff --git a/copy.c b/copy.c
index e54d15a..a7f58fd 100644
--- a/copy.c
+++ b/copy.c
@@ -35,6 +35,19 @@ int copy_fd(int ifd, int ofd)
 	return 0;
 }
 
+static int copy_times(const char *dst, const char *src)
+{
+	struct stat st;
+	struct utimbuf times;
+	if (stat(src, &st) < 0)
+		return -1;
+	times.actime = st.st_atime;
+	times.modtime = st.st_mtime;
+	if (utime(dst, &times) < 0)
+		return -1;
+	return 0;
+}
+
 int copy_file(const char *dst, const char *src, int mode)
 {
 	int fdi, fdo, status;
@@ -55,3 +68,11 @@ int copy_file(const char *dst, const char *src, int mode)
 
 	return status;
 }
+
+int copy_file_with_time(const char *dst, const char *src, int mode)
+{
+	int status = copy_file(dst, src, mode);
+	if (!status)
+		return copy_times(dst, src);
+	return status;
+}

^ permalink raw reply related

* Re: obnoxious CLI complaints
From: Junio C Hamano @ 2009-09-13  2:47 UTC (permalink / raw)
  To: John Tapsell; +Cc: Dmitry Potapov, Brendan Miller, Jakub Narebski, git
In-Reply-To: <43d8ce650909121608t2b9c4b9bw44104acceea26e12@mail.gmail.com>

John Tapsell <johnflux@gmail.com> writes:

> Ah, the manpage examples specifically give the --format=tar though.

So what?

> Why not have  --format=tgz  then or something?  Or better yet, give
> the filename on the command line and detect the format from the file
> extension.

That is an interesting enhancement and sounds like a useful feature.

^ permalink raw reply

* Re: [PATCH] git-push: Accept -n as a synonym for --dry-run.
From: Junio C Hamano @ 2009-09-13  2:44 UTC (permalink / raw)
  To: Nelson Elhage; +Cc: git
In-Reply-To: <1252800302-26560-1-git-send-email-nelhage@mit.edu>

Nelson Elhage <nelhage@MIT.EDU> writes:

> '-n' is the standard way to specify a dry run for other git commands,
> so make 'git-push' accept it as well.
> ---

Sign-off?

Indeed -n is used in many places for --dry-run, but it is not _the_
standard way.

commit, push (as you identified), reflog, and send-email have --dry-run
but -n is not a synonym for it.  Some of them even use -n as a shorthand
for a more often used option than --dry-run.

So the justification should be more like "push does not any other option
that deserves a short-and-sweet -n better, it will not have any such
option in the future, and --dry-run is very often used that it deserves to
use -n as its short-hand."

I tend to agree with the first two points, but I am not sure about the
third point.  Do people dry-push that often?

^ permalink raw reply

* [PATCH] quiltimport documentation: --dry-run and -n are synonyms
From: Junio C Hamano @ 2009-09-13  2:41 UTC (permalink / raw)
  To: git

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 Documentation/git-quiltimport.txt |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/Documentation/git-quiltimport.txt b/Documentation/git-quiltimport.txt
index d4037de..579e8d2 100644
--- a/Documentation/git-quiltimport.txt
+++ b/Documentation/git-quiltimport.txt
@@ -9,7 +9,7 @@ git-quiltimport - Applies a quilt patchset onto the current branch
 SYNOPSIS
 --------
 [verse]
-'git quiltimport' [--dry-run] [--author <author>] [--patches <dir>]
+'git quiltimport' [--dry-run | -n] [--author <author>] [--patches <dir>]
 
 
 DESCRIPTION
-- 
1.6.5.rc0.82.g1c5d9

^ permalink raw reply related

* Re: Effectively tracing project contributions with git
From: Theodore Tso @ 2009-09-13  2:28 UTC (permalink / raw)
  To: Joseph Wakeling; +Cc: Sverre Rabbelier, Jeff King, git
In-Reply-To: <4AAC3889.6030908@webdrake.net>

On Sun, Sep 13, 2009 at 02:10:49AM +0200, Joseph Wakeling wrote:
> 
> I don't see any solution that doesn't see me browsing diffs -- there's
> no metric that will solve the problem -- but if your stats work could
> help me get an output of the form 'here are all the diffs on file X by
> contributor Y in order of size, largest first' then I think it would
> help a LOT.

This will display all of the diffs on file (pathname) XXX by contributor YYY:

	git log -p --author=YYY XXX 

You might also find the diffstats useful:

	git log --stat --author=YYY XXX

Or if you want *only* the diffstats for the file in question, you might try:

	git log --stat --pretty=format: --author=YYY XXX | grep XXX

So the bottom line is git will allow you to extract quite a lot of
information.  You might need to do some perl- or shell- or python-
scripting to analyze or format the information, but the harder
question is determining exactly what question you want to ask.

Eliminating whitespace changes isn't hard (add the -b flag).  If you
want to eliminate variable renaming, that's harder since that requires
actually parsing the patch.  There are programs that will do that
(normally used by University professors to catch students cheating at
Programming 101 courses :-), but you'd need to do some shell (or perl
or python) scripting to splice them into the git invocations to
extract out the information.

Is there a particular reason why this is important to you?  Is it for
curiosity reasons; are you trying to build a case that you've
contacted all of the significant contributors for the purposes of
changing the license used on a file?  If it's the latter, what I'd
probably do is just simply collect everyone who has ever changed a
file (git log --format="%aN <%aE>" pathname/to/a/file | sort -u) and
try to get as many people as possible to agree to the license change.
For the ones who have _not_ agreed, or which you can not contact, you
can go back and just analyze their changes (git log --author=YYY) to
decide whether or not they are significant, and whether you need to
try extract hard to contact them, or in the worst case, find someone
to rewrite the parts of the file which they had modified in the past.

Or maybe you have some other reason for gathering said information.
Depending on what the high-level thing it is that you are trying to
do, there may be an easier or more elegant way to get the information
you are requesting.

						- Ted

^ permalink raw reply

* Re: [PATCH] transport-helper.c: don't leak fdopen'd stream buffers
From: Junio C Hamano @ 2009-09-13  2:27 UTC (permalink / raw)
  To: Jim Meyering; +Cc: git list, Daniel Barkalow, Johannes Sixt
In-Reply-To: <87hbv833kd.fsf@meyering.net>

Jim Meyering <jim@meyering.net> writes:

> diff --git a/transport-helper.c b/transport-helper.c
> index f57e84c..0bbd014 100644
> --- a/transport-helper.c
> +++ b/transport-helper.c
> @@ -49,6 +49,7 @@ static struct child_process *get_helper(struct transport *transport)
>  		if (!strcmp(buf.buf, "fetch"))
>  			data->fetch = 1;
>  	}
> +	fclose (file);
>  	return data->helper;
>  }
>
> @@ -88,6 +89,7 @@ static int fetch_with_fetch(struct transport *transport,
>  		if (strbuf_getline(&buf, file, '\n') == EOF)
>  			exit(128); /* child died, message supplied already */
>  	}
> +	fclose (file);
>  	return 0;
>  }

The callchain of fetch_with_fetch() looks like:

    fetch_with_fetch()
        helper = get_helper();
        --> get_helper()
            - start helper with start_command();
            - read from helper->out until it sees an empty line;
            - break out of the loop;
        <-- return helper
        - file = xfdopen(helper->out) to get another FILE on the fd
        - read the rest of the output from helper->out via file

It seems to me that the fclose() in get_helper() will close the underlying
fd and would break the caller, no?

I think "struct helper_data" should get a new FILE* field and once
somebody creates a FILE* out of its helper->out, that FILE* can be passed
around without a new xfdopen().

Or something like that.

Who is responsible for closing the underlying helper->out fd in the
start_command() API, by the way?

^ permalink raw reply

* Re: git push --confirm ?
From: Junio C Hamano @ 2009-09-13  0:41 UTC (permalink / raw)
  To: Jeff King; +Cc: Owen Taylor, git, Colin Walters
In-Reply-To: <20090912184342.GB20561@coredump.intra.peff.net>

Jeff King <peff@peff.net> writes:

> But what _would_ be useful is doing it atomically. You can certainly do
> all three of those steps from within one "git push" invocation, and I
> think that is enough without any protocol changes. The protocol already
> sends for each ref a line like:
>
>   <old-sha1> <new-sha1> <ref>
>
> and receive-pack will not proceed with the update unless the <old-sha1>
> matches what is about to be changed.

Be careful that using that information and doing things in one session
won't give you atomicity in the sense that it may still fail after you
said "yes that is what I want to push, really" to the confirmation
question.

It does save you an extra connection, compared to separate invocations
without and then with --dry-run, so it still is a plus.

I do not think this is an unreasonable option to have.  Just please don't
justify this change based on atomicity argument, but justify it as a mere
convenience feature.

^ permalink raw reply

* [PATCH] diffcore-order: Default the order file to .git/info/order.
From: Geoffrey Thomas @ 2009-09-12 23:49 UTC (permalink / raw)
  To: git; +Cc: Geoffrey Thomas

Since order files tend to be useful for all operations in the
project/repository, add a default location for the order file, so that
you don't have to specify -O<orderfile> on every diff or similar
operation.

Signed-off-by: Geoffrey Thomas <geofft@mit.edu>
---
 diff.c           |    3 +--
 diffcore-order.c |    6 ++++++
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/diff.c b/diff.c
index e1be189..148342c 100644
--- a/diff.c
+++ b/diff.c
@@ -3461,8 +3461,7 @@ void diffcore_std(struct diff_options *options)
 		diffcore_merge_broken();
 	if (options->pickaxe)
 		diffcore_pickaxe(options->pickaxe, options->pickaxe_opts);
-	if (options->orderfile)
-		diffcore_order(options->orderfile);
+	diffcore_order(options->orderfile);
 	diff_resolve_rename_copy();
 	diffcore_apply_filter(options->filter);
 
diff --git a/diffcore-order.c b/diffcore-order.c
index 23e9385..d116dc9 100644
--- a/diffcore-order.c
+++ b/diffcore-order.c
@@ -109,6 +109,12 @@ void diffcore_order(const char *orderfile)
 	if (!q->nr)
 		return;
 
+	if (!orderfile) {
+		orderfile = git_path("info/order");
+		if (access(orderfile, R_OK) != 0)
+			return;
+	}
+
 	o = xmalloc(sizeof(*o) * q->nr);
 	prepare_order(orderfile);
 	for (i = 0; i < q->nr; i++) {
-- 
1.5.6.5

^ permalink raw reply related

* Re: Effectively tracing project contributions with git
From: Joseph Wakeling @ 2009-09-13  0:10 UTC (permalink / raw)
  To: Sverre Rabbelier; +Cc: Jeff King, git
In-Reply-To: <fabb9a1e0909121203r527bc81ctd68382fc1107bf06@mail.gmail.com>

Sverre Rabbelier wrote:
> Git stats can aggregate diffs, so it can show you "this author made
> changes to this many lines to this file in total", but it doesn't work
> across renames. It also has an option to aggregate that to a total per
> project number, but I'm not sure how useful that is to your case, as
> you seem to be interested in a per-file/line basis? I agree with Jeff
> that you'll need to define more precisely what it is you want to know
> :).

That would certainly be a very useful function -- it wouldn't solve my
problem for me but would make it easier to identify core authors.  After
all, 'number of commits' doesn't necessarily correspond to meaningful
contribution -- many of them could be editorial -- but number of lines
(or the ratio of lines to commits) could be a much better indicator.

I don't see any solution that doesn't see me browsing diffs -- there's
no metric that will solve the problem -- but if your stats work could
help me get an output of the form 'here are all the diffs on file X by
contributor Y in order of size, largest first' then I think it would
help a LOT.

Is there a website where I can read more about your stats/metrics work?
 Beyond the applications to the present problem I have some other
reasons to be very interested in what can be done with git history stats.

Thanks & best wishes,

    -- Joe

^ permalink raw reply

* [RFC/PATCH v4 1/2] gitweb: check given hash before trying to create snapshot
From: Mark Rada @ 2009-09-13  0:09 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Jakub Narebski

Makes things nicer in cases when you hand craft the snapshot URL but
make a typo in defining the hash variable (e.g. netx instead of next);
you will now get an error message instead of a broken tarball.

To maintain backwards compatibility, git_get_head_hash is now a wrapper
for git_get_full_hash, as suggested by Jakub Narebski.

Tests for t9501 are included to demonstrate added functionality.

Signed-off-by: Mark Rada <marada@uwaterloo.ca>
---

	This is just a re-send based on getting torn a new one by Junio.
	Changes since v3:
		- variables have been renamed for readability


 gitweb/gitweb.perl                       |   19 +++++++++++++------
 t/t9501-gitweb-standalone-http-status.sh |   29 +++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+), 6 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 24b2193..e1beca5 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -1983,14 +1983,20 @@ sub quote_command {
 
 # get HEAD ref of given project as hash
 sub git_get_head_hash {
+	return git_get_full_hash(shift, 'HEAD');
+}
+
+# given a project and tree-ish, returns full hash
+sub git_get_full_hash {
 	my $project = shift;
+	my $hash = shift;
 	my $o_git_dir = $git_dir;
 	my $retval = undef;
 	$git_dir = "$projectroot/$project";
-	if (open my $fd, "-|", git_cmd(), "rev-parse", "--verify", "HEAD") {
-		my $head = <$fd>;
+	if (open my $fd, '-|', git_cmd(), 'rev-parse', '--verify', $hash) {
+		$hash = <$fd>;
 		close $fd;
-		if (defined $head && $head =~ /^([0-9a-fA-F]{40})$/) {
+		if (defined $hash && $hash =~ /^([0-9a-fA-F]{40})$/) {
 			$retval = $1;
 		}
 	}
@@ -5196,8 +5202,9 @@ sub git_snapshot {
 		die_error(403, "Unsupported snapshot format");
 	}
 
-	if (!defined $hash) {
-		$hash = git_get_head_hash($project);
+	my $full_hash = git_get_full_hash($project, $hash);
+	if (!$full_hash) {
+		die_error(404, 'Hash id was not valid');
 	}
 
 	my $name = $project;
@@ -5210,7 +5217,7 @@ sub git_snapshot {
 	$cmd = quote_command(
 		git_cmd(), 'archive',
 		"--format=$known_snapshot_formats{$format}{'format'}",
-		"--prefix=$name/", $hash);
+		"--prefix=$name/", $full_hash);
 	if (exists $known_snapshot_formats{$format}{'compressor'}) {
 		$cmd .= ' | ' . quote_command(@{$known_snapshot_formats{$format}{'compressor'}});
 	}
diff --git a/t/t9501-gitweb-standalone-http-status.sh b/t/t9501-gitweb-standalone-http-status.sh
index d0ff21d..632007e 100644
--- a/t/t9501-gitweb-standalone-http-status.sh
+++ b/t/t9501-gitweb-standalone-http-status.sh
@@ -75,4 +75,33 @@ test_expect_success \
 test_debug 'cat gitweb.output'
 
 
+# ----------------------------------------------------------------------
+# snapshot hash ids
+
+test_expect_success \
+	'snapshots: good treeish id' \
+	'gitweb_run "p=.git;a=snapshot;h=master;sf=tgz" &&
+	grep "Status: 200 OK" gitweb.output'
+test_debug 'cat gitweb.output'
+
+test_expect_success \
+	'snapshots: bad treeish id' \
+	'gitweb_run "p=.git;a=snapshot;h=frizzumFrazzum;sf=tgz" &&
+	grep "404 - Hash id was not valid" gitweb.output'
+test_debug 'cat gitweb.output'
+
+test_expect_success \
+	'snapshots: good object id' \
+	'ID=`git rev-parse --verify HEAD` &&
+	gitweb_run "p=.git;a=snapshot;h=$ID;sf=tgz" &&
+	grep "Status: 200 OK" gitweb.output'
+test_debug 'cat gitweb.output'
+
+test_expect_success \
+	'snapshots: bad object id' \
+	'gitweb_run "p=.git;a=snapshot;h=abcdef01234;sf=tgz" &&
+	grep "404 - Hash id was not valid" gitweb.output'
+test_debug 'cat gitweb.output'
+
+
 test_done
-- 
1.6.4.2

^ permalink raw reply related

* [PATCH] git-push: Accept -n as a synonym for --dry-run.
From: Nelson Elhage @ 2009-09-13  0:05 UTC (permalink / raw)
  To: git; +Cc: Nelson Elhage

'-n' is the standard way to specify a dry run for other git commands,
so make 'git-push' accept it as well.
---
 Documentation/git-push.txt |    3 ++-
 builtin-push.c             |    4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/Documentation/git-push.txt b/Documentation/git-push.txt
index 58d2bd5..ba6a8a2 100644
--- a/Documentation/git-push.txt
+++ b/Documentation/git-push.txt
@@ -9,7 +9,7 @@ git-push - Update remote refs along with associated objects
 SYNOPSIS
 --------
 [verse]
-'git push' [--all | --mirror | --tags] [--dry-run] [--receive-pack=<git-receive-pack>]
+'git push' [--all | --mirror | --tags] [-n | --dry-run] [--receive-pack=<git-receive-pack>]
 	   [--repo=<repository>] [-f | --force] [-v | --verbose]
 	   [<repository> <refspec>...]
 
@@ -82,6 +82,7 @@ nor in any Push line of the corresponding remotes file---see below).
 	if the configuration option `remote.<remote>.mirror` is
 	set.
 
+-n::
 --dry-run::
 	Do everything except actually send the updates.
 
diff --git a/builtin-push.c b/builtin-push.c
index 787011f..5e5f3ad 100644
--- a/builtin-push.c
+++ b/builtin-push.c
@@ -10,7 +10,7 @@
 #include "parse-options.h"
 
 static const char * const push_usage[] = {
-	"git push [--all | --mirror] [--dry-run] [--porcelain] [--tags] [--receive-pack=<git-receive-pack>] [--repo=<repository>] [-f | --force] [-v] [<repository> <refspec>...]",
+	"git push [--all | --mirror] [-n | --dry-run] [--porcelain] [--tags] [--receive-pack=<git-receive-pack>] [--repo=<repository>] [-f | --force] [-v] [<repository> <refspec>...]",
 	NULL,
 };
 
@@ -182,7 +182,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)
 		OPT_BIT( 0 , "mirror", &flags, "mirror all refs",
 			    (TRANSPORT_PUSH_MIRROR|TRANSPORT_PUSH_FORCE)),
 		OPT_BOOLEAN( 0 , "tags", &tags, "push tags"),
-		OPT_BIT( 0 , "dry-run", &flags, "dry run", TRANSPORT_PUSH_DRY_RUN),
+		OPT_BIT('n' , "dry-run", &flags, "dry run", TRANSPORT_PUSH_DRY_RUN),
 		OPT_BIT( 0,  "porcelain", &flags, "machine-readable output", TRANSPORT_PUSH_PORCELAIN),
 		OPT_BIT('f', "force", &flags, "force updates", TRANSPORT_PUSH_FORCE),
 		OPT_BOOLEAN( 0 , "thin", &thin, "use thin pack"),
-- 
1.6.3.1.499.ge7b8da

^ permalink raw reply related

* Re: Effectively tracing project contributions with git
From: Joseph Wakeling @ 2009-09-13  0:03 UTC (permalink / raw)
  To: Jeff King; +Cc: Sverre Rabbelier, git
In-Reply-To: <20090912185940.GA21277@coredump.intra.peff.net>

Jeff King wrote:
> We can probably help you with the git side of things, but defining "who
> contributed what" is kind of a hairy problem. You will need to define
> exactly how you want to count contributions.

Yes, that's pretty much what I'm looking for.  My thoughts on
contribution run along much the same lines as yours -- there's a need to
distinguish between meaningful additions and mere tweaks.

My general rule is that stuff like whitespace changes, changing the name
of variables, typo corrections etc. is not a meaningful contribution
although if someone had really done a lot of it I might see things
differently.  Substantial additions -- extending the code, comments or
documentation -- are what I'm after.  Ultimately this has to be decided
by me actually looking at things rather than metrics.

What I'm doing right now is to run a git shortlog on a file to get a
rough idea of the contributors and who are likely to be the main
authors, then using gitk to browse the commits for that file.  It's
time-consuming but works -- once I've identified at least one major
commit from someone I can ignore everything else by them and concentrate
on the remaining contributors.

What would help is some way to speed up the process of getting someone's
commits: 'give me all the diffs for file X by author Y'.  I'm not too
good at shell scripting so grep-y things don't spring easily to mind.

An alternative useful tool would be 'give me all the commits to this
file that change more than N lines'.

With those two -- particularly the first -- I think I'd be able to get a
fair way.  It won't work for the files where there has been a lot of
moving of content or renames, but that's mostly in the docs -- the code,
which is the really important thing, doesn't seem so bad (so far).

Thanks very much for the advice and careful thoughts,

Best wishes,

    -- Joe

^ permalink raw reply

* Re: [PATCH] use write_str_in_full helper to avoid literal string lengths
From: Junio C Hamano @ 2009-09-12 23:56 UTC (permalink / raw)
  To: Jim Meyering; +Cc: git list
In-Reply-To: <87skes35mf.fsf@meyering.net>

Jim Meyering <jim@meyering.net> writes:

>  ...Thus not requiring the added allocation, and still avoiding
> the maintenance risk of literal string lengths.
> These days, compilers are good enough that strlen("literal")
> imposes no run-time cost.
>
> Transformed via this:
>
>     perl -pi -e \
>         's/write_in_full\((.*?), (".*?"), \d+\)/write_str_in_full($1, $2)/'\
>       $(git grep -l 'write_in_full.*"')
>
>
> From fe368f8b3720f04c9dfce952711d2fb412b52e3c Mon Sep 17 00:00:00 2001
> From: Jim Meyering <meyering@redhat.com>
> Date: Sat, 12 Sep 2009 09:56:13 +0200
> Subject: [PATCH] use write_str_in_full helper to avoid literal string lengths
>
> * cache.h (write_str_in_full): Define function.
> * builtin-fetch.c (quickfetch): Use it.
> * builtin-reflog.c (expire_reflog): Likewise.
> * commit.c (write_shallow_commits): Likewise.
> * config.c (git_config_set_multivar): Likewise.
> * rerere.c (write_rr): Likewise.
> * transport-helper.c (get_helper, disconnect_helper): Likewise.
> (get_refs_list): Likewise.
> * upload-pack.c (receive_needs): Likewise.

Thanks.  I agree with the reasoning you wrote outside the proposed log
message.

We usually do not write these bullet points (iow, we are not GNU) in our
log message.  The names of the functions, call sites and files that are
involved are something anybody can see from the patch text,

I think the GNU convention was useful back when we were trapped in a
system with non-atomic commits, where it was very hard to see what files
were affected in a single logical changeset (i.e. CVS).

Luckily, we graduated those dark ages.

Instead, we prefer to have justifications (and methods), like what you
wrote at the beginning of your message.  These are not something people
can find in the patch text and they deserve to be recorded in the commit.

^ permalink raw reply

* Re: [PATCHv6 13/14] Allow flexible organization of notes trees, using both commit date and SHA1
From: Junio C Hamano @ 2009-09-12 23:37 UTC (permalink / raw)
  To: Johan Herland
  Cc: Junio C Hamano, git, Johannes.Schindelin, trast, tavestbo, git,
	chriscool, spearce
In-Reply-To: <200909130033.28666.johan@herland.net>

Johan Herland <johan@herland.net> writes:

> But as I said above, you may want to drop 13/14 and 14/14 completely, 
> instead.

Thanks.  Will do.

^ permalink raw reply

* Re: obnoxious CLI complaints
From: John Tapsell @ 2009-09-12 23:08 UTC (permalink / raw)
  To: Dmitry Potapov; +Cc: Brendan Miller, Jakub Narebski, git
In-Reply-To: <20090912224335.GC30385@dpotapov.dyndns.org>

2009/9/13 Dmitry Potapov <dpotapov@gmail.com>:
> On Sun, Sep 13, 2009 at 01:21:43AM +0300, John Tapsell wrote:
>>
>> Because I wouldn't call this just a few keystrokes to do the common case:
>>
>>     git archive --format=tar --prefix=HEAD/ HEAD | gzip > head.tar.gz
>>
>> I honestly don't understand the backlash against Brenden's point that
>> this could be made a bit simpler.
>
> You do not have to specify '--format=tar', because it is default. The
> prefix name is a matter of one's preferences. Brenden wanted it to be
> $myproject, while I have used three different versions. Now, you suggest
> some other. IMHO, having it empty by default makes much more sense when
> there is no obvious value on what most would agree. Finally, 'HEAD' is
> required, because we do not want 'git archive' being run without any
> parameter to write a binary file to the terminal. (Yes, it is foolish to
> run command that you do not know to see what it does, but some people do
> that, and we want all commands to be safe). BTW, I wonder whether use of
> HEAD is really common with git-archive. Normally, you would archive a
> tagged release, and then it is better to use the tag name to be sure
> that you have archived the right thing.

Ah, the manpage examples specifically give the --format=tar though.

Why not have  --format=tgz  then or something?  Or better yet, give
the filename on the command line and detect the format from the file
extension.

^ permalink raw reply

* [RFC/PATCH v4 2/2] gitweb: append short hash ids to snapshot files
From: Mark Rada @ 2009-09-12 23:04 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Jakub Narebski

Teach gitweb how to produce nicer snapshot names by only using the
short hash id. If clients make requests using a tree-ish that is not a
partial or full SHA-1 hash, then the short hash will also be appended
to whatever they asked for.

This also includes tests cases for t9502-gitweb-standalone-parse-output.

Signed-off-by: Mark Rada <marada@uwaterloo.ca>
---
 gitweb/gitweb.perl                        |   26 +++++++++++
 t/t9502-gitweb-standalone-parse-output.sh |   67 +++++++++++++++++++++++++++++
 2 files changed, 93 insertions(+), 0 deletions(-)
 create mode 100644 t/t9502-gitweb-standalone-parse-output.sh

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index e1beca5..fdecc3d 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -2006,6 +2006,26 @@ sub git_get_full_hash {
 	return $retval;
 }
 
+# try and get a shorter hash id
+sub git_get_short_hash {
+	my $project = shift;
+	my $hash = shift;
+	my $o_git_dir = $git_dir;
+	my $retval = undef;
+	$git_dir = "$projectroot/$project";
+	if (open my $fd, '-|', git_cmd(), 'rev-parse', '--short', $hash) {
+		$hash = <$fd>;
+		close $fd;
+		if (defined $hash && $hash =~ /^([0-9a-fA-F]{7,})$/) {
+			$retval = $1;
+		}
+	}
+	if (defined $o_git_dir) {
+		$git_dir = $o_git_dir;
+	}
+	return $retval;
+}
+
 # get type of given object
 sub git_get_type {
 	my $hash = shift;
@@ -5207,6 +5227,12 @@ sub git_snapshot {
 		die_error(404, 'Hash id was not valid');
 	}
 
+
+	if ($full_hash !~ /$hash/) {
+		$hash .= '-' . git_get_short_hash($project, $hash);
+	} else {
+		$hash = git_get_short_hash($project, $hash);
+	}
 	my $name = $project;
 	$name =~ s,([^/])/*\.git$,$1,;
 	$name = basename($name);
diff --git a/t/t9502-gitweb-standalone-parse-output.sh b/t/t9502-gitweb-standalone-parse-output.sh
new file mode 100644
index 0000000..1a2a27f
--- /dev/null
+++ b/t/t9502-gitweb-standalone-parse-output.sh
@@ -0,0 +1,67 @@
+#!/bin/sh
+#
+# Copyright (c) 2009 Mark Rada
+#
+
+test_description='gitweb as standalone script (parsing script output).
+
+This test runs gitweb (git web interface) as a CGI script from the
+commandline, and checks that it produces the correct output, either
+in the HTTP header or the actual script output.'
+
+
+. ./gitweb-lib.sh
+
+# ----------------------------------------------------------------------
+# snapshot file name
+
+test_commit \
+	'SnapshotFileTests' \
+	'i can has snapshot?'
+
+test_expect_success \
+	'snapshots: give full hash' \
+	'ID=`git rev-parse --verify HEAD` &&
+	gitweb_run "p=.git;a=snapshot;h=$ID;sf=tgz" &&
+	ID=`git rev-parse --short HEAD` &&
+	grep ".git-$ID.tar.gz" gitweb.output'
+test_debug 'cat gitweb.output'
+
+test_expect_success \
+	'snapshots: give short hash' \
+	'ID=`git rev-parse --short HEAD` &&
+	gitweb_run "p=.git;a=snapshot;h=$ID;sf=tgz" &&
+	grep ".git-$ID.tar.gz" gitweb.output'
+test_debug 'cat gitweb.output'
+
+test_expect_success \
+	'snapshots: give almost full hash' \
+	'ID=`git rev-parse --short=30 HEAD` &&
+	gitweb_run "p=.git;a=snapshot;h=$ID;sf=tgz" &&
+	ID=`git rev-parse --short HEAD` &&
+	grep ".git-$ID.tar.gz" gitweb.output'
+test_debug 'cat gitweb.output'
+
+test_expect_success \
+	'snapshots: give HEAD tree-ish' \
+	'gitweb_run "p=.git;a=snapshot;h=HEAD;sf=tgz" &&
+	ID=`git rev-parse --short HEAD` &&
+	grep ".git-HEAD-$ID.tar.gz" gitweb.output'
+test_debug 'cat gitweb.output'
+
+test_expect_success \
+	'snapshots: give branch name tree-ish' \
+	'gitweb_run "p=.git;a=snapshot;h=master;sf=tgz" &&
+	ID=`git rev-parse --short master` &&
+	grep ".git-master-$ID.tar.gz" gitweb.output'
+test_debug 'cat gitweb.output'
+
+test_expect_success \
+	'snapshots: give tag tree-ish' \
+	'gitweb_run "p=.git;a=snapshot;h=SnapshotFileTests;sf=tgz" &&
+	ID=`git rev-parse --short SnapshotFileTests` &&
+	grep ".git-SnapshotFileTests-$ID.tar.gz" gitweb.output'
+test_debug 'cat gitweb.output'
+
+
+test_done
-- 
1.6.4.2

^ permalink raw reply related

* [RFC/PATCH v4 1/2] gitweb: check given hash before trying to create snapshot
From: Mark Rada @ 2009-09-12 23:03 UTC (permalink / raw)
  To: git; +Cc: Jakub Narebski, Junio C Hamano

I changed some variable names to be nicer looking.

--
Mark Rada (ferrous26)
marada@uwaterloo.ca


--->8---
Makes things nicer in cases when you hand craft the snapshot URL but
make a typo in defining the hash variable (e.g. netx instead of next);
you will now get an error message instead of a broken tarball.

To maintain backwards compatibility, git_get_head_hash is now a wrapper
for git_get_full_hash, as suggested by Jakub Narebski.

Tests for t9501 are included to demonstrate added functionality.

Signed-off-by: Mark Rada <marada@uwaterloo.ca>
---
 gitweb/gitweb.perl                       |   19 +++++++++++++------
 t/t9501-gitweb-standalone-http-status.sh |   29 +++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+), 6 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 24b2193..e1beca5 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -1983,14 +1983,20 @@ sub quote_command {
 
 # get HEAD ref of given project as hash
 sub git_get_head_hash {
+	return git_get_full_hash(shift, 'HEAD');
+}
+
+# given a project and tree-ish, returns full hash
+sub git_get_full_hash {
 	my $project = shift;
+	my $hash = shift;
 	my $o_git_dir = $git_dir;
 	my $retval = undef;
 	$git_dir = "$projectroot/$project";
-	if (open my $fd, "-|", git_cmd(), "rev-parse", "--verify", "HEAD") {
-		my $head = <$fd>;
+	if (open my $fd, '-|', git_cmd(), 'rev-parse', '--verify', $hash) {
+		$hash = <$fd>;
 		close $fd;
-		if (defined $head && $head =~ /^([0-9a-fA-F]{40})$/) {
+		if (defined $hash && $hash =~ /^([0-9a-fA-F]{40})$/) {
 			$retval = $1;
 		}
 	}
@@ -5196,8 +5202,9 @@ sub git_snapshot {
 		die_error(403, "Unsupported snapshot format");
 	}
 
-	if (!defined $hash) {
-		$hash = git_get_head_hash($project);
+	my $full_hash = git_get_full_hash($project, $hash);
+	if (!$full_hash) {
+		die_error(404, 'Hash id was not valid');
 	}
 
 	my $name = $project;
@@ -5210,7 +5217,7 @@ sub git_snapshot {
 	$cmd = quote_command(
 		git_cmd(), 'archive',
 		"--format=$known_snapshot_formats{$format}{'format'}",
-		"--prefix=$name/", $hash);
+		"--prefix=$name/", $full_hash);
 	if (exists $known_snapshot_formats{$format}{'compressor'}) {
 		$cmd .= ' | ' . quote_command(@{$known_snapshot_formats{$format}{'compressor'}});
 	}
diff --git a/t/t9501-gitweb-standalone-http-status.sh b/t/t9501-gitweb-standalone-http-status.sh
index d0ff21d..632007e 100644
--- a/t/t9501-gitweb-standalone-http-status.sh
+++ b/t/t9501-gitweb-standalone-http-status.sh
@@ -75,4 +75,33 @@ test_expect_success \
 test_debug 'cat gitweb.output'
 
 
+# ----------------------------------------------------------------------
+# snapshot hash ids
+
+test_expect_success \
+	'snapshots: good treeish id' \
+	'gitweb_run "p=.git;a=snapshot;h=master;sf=tgz" &&
+	grep "Status: 200 OK" gitweb.output'
+test_debug 'cat gitweb.output'
+
+test_expect_success \
+	'snapshots: bad treeish id' \
+	'gitweb_run "p=.git;a=snapshot;h=frizzumFrazzum;sf=tgz" &&
+	grep "404 - Hash id was not valid" gitweb.output'
+test_debug 'cat gitweb.output'
+
+test_expect_success \
+	'snapshots: good object id' \
+	'ID=`git rev-parse --verify HEAD` &&
+	gitweb_run "p=.git;a=snapshot;h=$ID;sf=tgz" &&
+	grep "Status: 200 OK" gitweb.output'
+test_debug 'cat gitweb.output'
+
+test_expect_success \
+	'snapshots: bad object id' \
+	'gitweb_run "p=.git;a=snapshot;h=abcdef01234;sf=tgz" &&
+	grep "404 - Hash id was not valid" gitweb.output'
+test_debug 'cat gitweb.output'
+
+
 test_done
-- 
1.6.4.2

^ permalink raw reply related

* Re: obnoxious CLI complaints
From: Dmitry Potapov @ 2009-09-12 22:43 UTC (permalink / raw)
  To: John Tapsell; +Cc: Brendan Miller, Jakub Narebski, git
In-Reply-To: <43d8ce650909121521m3dbac12co7f5f2dcaf15190e7@mail.gmail.com>

On Sun, Sep 13, 2009 at 01:21:43AM +0300, John Tapsell wrote:
> 
> Because I wouldn't call this just a few keystrokes to do the common case:
> 
>     git archive --format=tar --prefix=HEAD/ HEAD | gzip > head.tar.gz
> 
> I honestly don't understand the backlash against Brenden's point that
> this could be made a bit simpler.

You do not have to specify '--format=tar', because it is default. The
prefix name is a matter of one's preferences. Brenden wanted it to be
$myproject, while I have used three different versions. Now, you suggest
some other. IMHO, having it empty by default makes much more sense when
there is no obvious value on what most would agree. Finally, 'HEAD' is
required, because we do not want 'git archive' being run without any
parameter to write a binary file to the terminal. (Yes, it is foolish to
run command that you do not know to see what it does, but some people do
that, and we want all commands to be safe). BTW, I wonder whether use of
HEAD is really common with git-archive. Normally, you would archive a
tagged release, and then it is better to use the tag name to be sure
that you have archived the right thing.


Dmitry

^ 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