Git development
 help / color / mirror / Atom feed
* 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

* Re: Confusing git pull error message
From: Sverre Rabbelier @ 2009-09-12 22:37 UTC (permalink / raw)
  To: Jeff King; +Cc: John Tapsell, Junio C Hamano, Git List
In-Reply-To: <20090912223137.GA8748@coredump.intra.peff.net>

Heya,

On Sun, Sep 13, 2009 at 00:31, Jeff King <peff@peff.net> wrote:
> Fair enough. I'll change it to "I was unable to fetch" in the re-roll.

Actually, from grepping through the source there's a lot of we-ing
going on already (although mostly in the comments), and fairly little
I-ing (not based on actual numbers, just what I could judge at a
glance), so maybe changing the ones above to "we" instead is more
appropriate?

-- 
Cheers,

Sverre Rabbelier

^ permalink raw reply

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

John Tapsell wrote:
> 2009/9/13 Dmitry Potapov <dpotapov@gmail.com>:
>> On Sat, Sep 12, 2009 at 09:32:09PM +0300, John Tapsell wrote:
>>> 2009/9/12 Dmitry Potapov <dpotapov@gmail.com>:
>>>> On Wed, Sep 09, 2009 at 05:09:31PM -0700, Brendan Miller wrote:
>>>>> On Wed, Sep 9, 2009 at 2:54 PM, Jakub Narebski <jnareb@gmail.com> wrote:
>>>>>> Brendan Miller <catphive@catphive.net> writes:
>>>>> Is the goal of interface design to make
>>>>> it difficult so I need to learn a lot of things, or easy so I can
>>>>> remain blissfully ignorant but still do what I want?
>>>> Neither. You cannot get what unless you have specified what you want,
>>>> and for that you have to learn how to say that. Having good defaults is
>>>> very important, but the problem with choosing them is that people have
>>>> different preferences about them. For instance, you wanted the default
>>>> prefix for git-archive to be $myproject. For me, a good default would be
>>>> either $tag_name, or $myproject-$tag_name, or empty (as it is now!). So,
>>>> what you propose is *never* a good default for me. Moreover, changing
>>>> any default will cause a lot of pain for other people who use Git now.
>>>> Besides, writing something like --prefix='' is very ugly. So, the
>>>> current default makes perfect sense.
>>> Ah, great logic.  You can't find a default that will suit everyone,
>>> therefore don't bother.
>> I did not say "don't bother". On contrary, I said that defaults are very
>> important, but, in this case, the current default makes far more sense
>> that what was proposed by Brendan.
>>
>>>>> Yeah, I've been reading them. I'm saying that the docs are a crutch.
>>>>> RTFM is the problem not the solution. It makes the user do more work
>>>>> to avoid fixing usability issues.
>>>> A usability issue exists when a person knows how to do that, but it is
>>>> inconvenient or error-prone; or when a learning curve is too steep.
>>>> But when someone cannot use, let's say, a compiler, because he or she
>>>> refuses to read to learn the language, it is not a usability issue.
>>> It's a usability issue when it doesn't just do the right thing in the
>>> majority of cases and lets you specify what you want it to do in the
>>> rest of the cases.
>> It does the right thing for me, and not just in most cases, it does so
>> in _all_ cases, because it does exactly it is told to do. And it is a
>> very important characteristics for any VCS, otherwise you can mess up
>> things easily. What is also good about Git is that it does not require
>> much keystrokes to do even rather complex stuff. And many defaults and
>> commands are configurable, so you can adjust it to your workflow. So,
>> I am not sure what your problem is.
> 
> 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.

Be made simpler for whom? The first rule of defaults is that they are 
never correct.

And, to every one, if you don;t think like the way <SOME_PROGRAM> has 
it's defaults set and the developer(s) don't agree to change the default 
for _everyone_ to what _you_ like, you can still use your shell's alias 
facility to fix the situation for your own use case.

To channel Junio, why are we still having this discussion?

^ permalink raw reply

* Re: [PATCHv6 13/14] Allow flexible organization of notes trees, using both commit date and SHA1
From: Johan Herland @ 2009-09-12 22:33 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: git, Johannes.Schindelin, trast, tavestbo, git, chriscool,
	spearce
In-Reply-To: <7viqfof1kc.fsf@alter.siamese.dyndns.org>

On Saturday 12 September 2009, Junio C Hamano wrote:
> Johan Herland <johan@herland.net> writes:
> > This is a major expansion of the notes lookup code to allow for
> > variations in the notes tree organization. The variations allowed
> > include mixing fanout schemes based on the commit dates of the
> > annotated commits (aka. date-based fanout) with fanout schemes based on
> > the SHA1 of the annotated commits (aka. SHA1-based fanout).

Note that this patch is about to be removed from this series, cf. today's 
discussion with Shawn elsewhere in this thread.

> Will squash this in.

I agree with the attempt, but not all of the hunks are good:

> @@ -281,20 +281,20 @@ static int note_tree_insert(struct int_node *tree,
>  unsigned char n, /* Free the entire notes data contained in the given
>  tree */
>  static void note_tree_free(struct int_node *tree)
>  {
> -	if (tree->magic == (void *) ~0) {
> -		if (tree->prev) {
> -			note_tree_free(tree->prev);
> -			free(tree->prev);
> +	if (tree->u.s.magic == (void *) ~0) {
> +		if (tree->u.s.prev) {
> +			note_tree_free(tree->u.s.prev);
> +			free(tree->u.s.prev);
>  		}
> -		if (tree->child) {
> -			note_tree_free(tree->child);
> -			free(tree->child);
> +		if (tree->u.s.magic) {
> +			note_tree_free(tree->u.s.magic);
> +			free(tree->u.s.magic);

Here, you are replacing tree->child with tree->u.s.magic. Shouldn't that be 
tree->u.s.child instead?

> @@ -439,12 +439,12 @@ static void load_date_subtree(struct tree_desc
>  *tree_desc, else  /* this is the last entry, store directly into node */
>  			new_node = node;
> 
> -		new_node->magic = (void *) ~0;
> -		new_node->child = NULL;
> -		new_node->prev = cur_node;
> -		new_node->parent = parent;
> -		hashcpy(new_node->tree_sha1, entry.sha1);
> -		strcpy(new_node->period, period);
> +		new_node->u.s.magic = (void *) ~0;
> +		new_node->u.s.magic = NULL;

Same as above: new_node->u.s.child

> +		new_node->u.s.prev = cur_node;
> +		new_node->u.s.parent = parent;
> +		hashcpy(new_node->u.s.tree_sha1, entry.sha1);
> +		strcpy(new_node->u.s.period, period);
>  		cur_node = new_node;
>  	}
>  	assert(!cur_node || cur_node == node);
> @@ -552,38 +552,38 @@ static unsigned char *lookup_notes(const struct
>  commit *commit) /* Convert commit->date to YYYY-MM-DD format */
>  	short_date = show_date(commit->date, 0, DATE_SHORT);
> 
> -	while (node->magic == (void *) ~0) {  /* date-based node */
> -		int cmp = SUBTREE_DATE_PREFIXCMP(short_date, node->period);
> +	while (node->u.s.magic == (void *) ~0) {  /* date-based node */
> +		int cmp = SUBTREE_DATE_PREFIXCMP(short_date, node->u.s.period);
>  		if (cmp == 0) {
>  			/* Search inside child node */
> -			if (!node->child) {
> +			if (!node->u.s.magic) {
>  				/* Must unpack child node first */
> -				node->child = (struct int_node *)
> +				node->u.s.magic = (struct int_node *)
>  					xcalloc(sizeof(struct int_node), 1);
> -				load_subtree(node->tree_sha1,
> -					(const unsigned char *) node->period,
> -					strlen(node->period), node->child,
> +				load_subtree(node->u.s.tree_sha1,
> +					(const unsigned char *) node->u.s.period,
> +					strlen(node->u.s.period), node->u.s.magic,
>  					node, -1);
>  			}
>  			seen_node = node;
> -			node = node->child;
> +			node = node->u.s.magic;

Same again, 4 times in the above hunk.

> @@ -591,15 +591,15 @@ static unsigned char *lookup_notes(const struct
>  commit *commit) }
>  	}
>  	while (cur_node &&
> -	       SUBTREE_DATE_PREFIXCMP(cur_node->period, seen_node->period) < 0)
> +	       SUBTREE_DATE_PREFIXCMP(cur_node->u.s.period,
>  seen_node->u.s.period) < 0) {
>  		/*
>  		 * We're about to move cur_node backwards in history. We are
>  		 * unlikely to need this cur_node in the future, so free() it.
>  		 */
> -		note_tree_free(cur_node->child);
> -		cur_node->child = NULL;
> -		cur_node = cur_node->parent;
> +		note_tree_free(cur_node->u.s.magic);
> +		cur_node->u.s.magic = NULL;

...and another one here.

> +		cur_node = cur_node->u.s.parent;
>  	}
>  	cur_node = seen_node;
> 


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


...Johan

-- 
Johan Herland, <johan@herland.net>
www.herland.net

^ permalink raw reply

* Re: Confusing git pull error message
From: Jeff King @ 2009-09-12 22:34 UTC (permalink / raw)
  To: John Tapsell; +Cc: Junio C Hamano, Git List
In-Reply-To: <43d8ce650909121431o382b9348q19ee7db5adbb4a72@mail.gmail.com>

On Sun, Sep 13, 2009 at 12:31:46AM +0300, John Tapsell wrote:

> 2009/9/13 Jeff King <peff@peff.net>:
> 
> > +       else
> > +               echo "Your configuration specified for us to pull the ref"
> > +               echo "'$upstream_short', but we were unable to fetch it from"
> > +               echo "the remote."
> 
> Thanks!
> 
> But why was it 'unable' ?  Are there cases other than it not existing?
>  Maybe something less cryptic:
> 
> "Attempted to pull from ref $upstream_short but this branch does not
> exist on remote."
> 
> Or something?

I'm not sure if there are other cases, so I left it unspecified. I think
that "does not exist" is probably the only one that should make it this
far, though, as any actual error would cause fetch to die, aborting the
pull.

And you can see that when you ask for a specific bogus ref, as in:

  $ git pull origin bogus
  fatal: Couldn't find remote ref bogus

I'll re-roll the patch with more specific wording.

-Peff

^ permalink raw reply

* Re: Confusing git pull error message
From: Jeff King @ 2009-09-12 22:31 UTC (permalink / raw)
  To: Sverre Rabbelier; +Cc: John Tapsell, Junio C Hamano, Git List
In-Reply-To: <fabb9a1e0909121437q4eb432e3idde98993ac552b5@mail.gmail.com>

On Sat, Sep 12, 2009 at 11:37:47PM +0200, Sverre Rabbelier wrote:

> > +               echo "Your configuration specified for us to pull the ref"
> > +               echo "'$upstream_short', but we were unable to fetch it from"
> > +               echo "the remote."
> >        fi
> >        exit 1
> >  }
> 
> Pretty bad case of multiple personality disorder here? At first
> there's a "me", then again a "me", and then all of a sudden a "we"?

Fair enough. I'll change it to "I was unable to fetch" in the re-roll.

-Peff

^ permalink raw reply

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

2009/9/13 Dmitry Potapov <dpotapov@gmail.com>:
> On Sat, Sep 12, 2009 at 09:32:09PM +0300, John Tapsell wrote:
>> 2009/9/12 Dmitry Potapov <dpotapov@gmail.com>:
>> > On Wed, Sep 09, 2009 at 05:09:31PM -0700, Brendan Miller wrote:
>> >> On Wed, Sep 9, 2009 at 2:54 PM, Jakub Narebski <jnareb@gmail.com> wrote:
>> >> > Brendan Miller <catphive@catphive.net> writes:
>> >> >>
>> >> Is the goal of interface design to make
>> >> it difficult so I need to learn a lot of things, or easy so I can
>> >> remain blissfully ignorant but still do what I want?
>> >
>> > Neither. You cannot get what unless you have specified what you want,
>> > and for that you have to learn how to say that. Having good defaults is
>> > very important, but the problem with choosing them is that people have
>> > different preferences about them. For instance, you wanted the default
>> > prefix for git-archive to be $myproject. For me, a good default would be
>> > either $tag_name, or $myproject-$tag_name, or empty (as it is now!). So,
>> > what you propose is *never* a good default for me. Moreover, changing
>> > any default will cause a lot of pain for other people who use Git now.
>> > Besides, writing something like --prefix='' is very ugly. So, the
>> > current default makes perfect sense.
>>
>> Ah, great logic.  You can't find a default that will suit everyone,
>> therefore don't bother.
>
> I did not say "don't bother". On contrary, I said that defaults are very
> important, but, in this case, the current default makes far more sense
> that what was proposed by Brendan.
>
>>
>> >> Yeah, I've been reading them. I'm saying that the docs are a crutch.
>> >> RTFM is the problem not the solution. It makes the user do more work
>> >> to avoid fixing usability issues.
>> >
>> > A usability issue exists when a person knows how to do that, but it is
>> > inconvenient or error-prone; or when a learning curve is too steep.
>> > But when someone cannot use, let's say, a compiler, because he or she
>> > refuses to read to learn the language, it is not a usability issue.
>>
>> It's a usability issue when it doesn't just do the right thing in the
>> majority of cases and lets you specify what you want it to do in the
>> rest of the cases.
>
> It does the right thing for me, and not just in most cases, it does so
> in _all_ cases, because it does exactly it is told to do. And it is a
> very important characteristics for any VCS, otherwise you can mess up
> things easily. What is also good about Git is that it does not require
> much keystrokes to do even rather complex stuff. And many defaults and
> commands are configurable, so you can adjust it to your workflow. So,
> I am not sure what your problem is.

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.

John

^ permalink raw reply

* Re: [PATCHv6 10/14] Teach notes code to free its internal data structures on request.
From: Johan Herland @ 2009-09-12 22:21 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: git, Johannes.Schindelin, trast, tavestbo, git, chriscool,
	spearce
In-Reply-To: <7vmy50f1mf.fsf@alter.siamese.dyndns.org>

On Saturday 12 September 2009, Junio C Hamano wrote:
> Johan Herland <johan@herland.net> writes:
> > There's no need to be rude to memory-concious callers...
> 
> Will squash this in.
> 
> -- >8 --
> From: Junio C Hamano <gitster@pobox.com>
> Date: Sat, 12 Sep 2009 11:34:24 -0700
> Subject: [PATCH] notes.[ch] fixup: avoid old-style declaration
> 
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
>  notes.c |    2 +-
>  notes.h |    2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/notes.c b/notes.c
> index 008c3d4..9ed2c87 100644
> --- a/notes.c
> +++ b/notes.c
> @@ -161,7 +161,7 @@ void get_commit_notes(const struct commit *commit,
>  struct strbuf *sb, free(msg);
>  }
> 
> -void free_commit_notes()
> +void free_commit_notes(void)
>  {
>  	free(hash_map.entries);
>  	memset(&hash_map, 0, sizeof(struct hash_map));
> diff --git a/notes.h b/notes.h
> index 41802e5..d1dd1d1 100644
> --- a/notes.h
> +++ b/notes.h
> @@ -7,6 +7,6 @@
>  void get_commit_notes(const struct commit *commit, struct strbuf *sb,
>  		const char *output_encoding, int flags);
> 
> -void free_commit_notes();
> +void free_commit_notes(void);
> 
>  #endif

Thanks,

Acked-by: Johan Herland <johan@herland.net>


...Johan

-- 
Johan Herland, <johan@herland.net>
www.herland.net

^ permalink raw reply

* Re: git push --confirm ?
From: Daniel Barkalow @ 2009-09-12 21:55 UTC (permalink / raw)
  To: Jeff King; +Cc: Owen Taylor, git, Colin Walters
In-Reply-To: <20090912204905.GA31427@coredump.intra.peff.net>

On Sat, 12 Sep 2009, Jeff King wrote:

> [cc'd Daniel; I think this proposal for a "confirm push" might interact
> with your foreign VCS work a bit. I'm not sure anymore what would be the
> right level for inserting this code.]
> 
> On Sat, Sep 12, 2009 at 04:11:06PM -0400, Owen Taylor wrote:
> 
> > The main UI advantage is that you can adjust the default with 'git
> > config' it on and leave it on. The time you screw up is not when you are
> > worried that you are going to push the wrong thing. It's when you are
> > you know exactly what 'git push' is going to do and it does something
> > different.
> 
> That makes sense. I would not want to use such a feature, but I see the
> use case you are talking about (see, I told you I was bad person to
> comment. ;) ).
> 
> It should be pretty straightforward to implement for the git protocol.
> Pushing goes something like:
> 
>   1. Get the list of refs from the remote.
> 
>   2. Using the desired refspecs (either configured or from the command
>      line), make a list of src/dst pairs of refs to be pushed.
> 
>   3. For each ref pair, send the "<old> <new> <name>" triple to the
>      remote (or not, if it is already up-to-date, a non-fast-forward,
>      etc).
> 
>   4. Send the packed objects.
> 
>   5. For each ref pair, print the status in a summary table.
> 
> So you would just want a "2.5" where you show something similar to the
> summary table and get some confirmation (or abort). An iterative "do you
> want to push this ref" strategy would be similar; just mark the refs you
> do and don't want to push.
> 
> The tricky thing will be handling different transports. Some of that
> code has been factored out, but I haven't looked at the details. On top
> of that, I think Daniel is working in this area for his support
> of foreign VCS helpers (and other transports like libcurl are getting
> pushed out into their own helpers). So he may have a better idea of how
> to go about this sanely.

The status used to be that each method of pushing implemented 
approximately the rules you give, but implemented it separately. Now 
there's a common implementation of those rules, with (1) being a method 
call, (3&4) being a method, and the rest being in transport_push(). 
However, rsync and curl have not yet been converted to the new style. When 
there is support for push with helpers, it will only use the new style 
(because it would be pointlessly annoying to implement the git rules for 
refspecs in the helpers).

So it should be easy to put something into transport_push to do a step 2.5 
confirmation, and a bit more work (which ought to get done anyway) to make 
it apply to rsync and http URLs.

(Furthermore, currently, http-push is a separate program from the fetch 
code, which is moving from the main git executable to git-remote-curl; the 
http push code should probably actually move to git-remote-curl, so that 
there is a single external program taking care of all operations on such 
URLs and there is less complexity in how the curl-using code is 
structured.)

	-Daniel
*This .sig left intentionally blank*

^ permalink raw reply

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

On Sat, Sep 12, 2009 at 09:32:09PM +0300, John Tapsell wrote:
> 2009/9/12 Dmitry Potapov <dpotapov@gmail.com>:
> > On Wed, Sep 09, 2009 at 05:09:31PM -0700, Brendan Miller wrote:
> >> On Wed, Sep 9, 2009 at 2:54 PM, Jakub Narebski <jnareb@gmail.com> wrote:
> >> > Brendan Miller <catphive@catphive.net> writes:
> >> >>
> >> Is the goal of interface design to make
> >> it difficult so I need to learn a lot of things, or easy so I can
> >> remain blissfully ignorant but still do what I want?
> >
> > Neither. You cannot get what unless you have specified what you want,
> > and for that you have to learn how to say that. Having good defaults is
> > very important, but the problem with choosing them is that people have
> > different preferences about them. For instance, you wanted the default
> > prefix for git-archive to be $myproject. For me, a good default would be
> > either $tag_name, or $myproject-$tag_name, or empty (as it is now!). So,
> > what you propose is *never* a good default for me. Moreover, changing
> > any default will cause a lot of pain for other people who use Git now.
> > Besides, writing something like --prefix='' is very ugly. So, the
> > current default makes perfect sense.
> 
> Ah, great logic.  You can't find a default that will suit everyone,
> therefore don't bother.

I did not say "don't bother". On contrary, I said that defaults are very
important, but, in this case, the current default makes far more sense
that what was proposed by Brendan.

> 
> >> Yeah, I've been reading them. I'm saying that the docs are a crutch.
> >> RTFM is the problem not the solution. It makes the user do more work
> >> to avoid fixing usability issues.
> >
> > A usability issue exists when a person knows how to do that, but it is
> > inconvenient or error-prone; or when a learning curve is too steep.
> > But when someone cannot use, let's say, a compiler, because he or she
> > refuses to read to learn the language, it is not a usability issue.
> 
> It's a usability issue when it doesn't just do the right thing in the
> majority of cases and lets you specify what you want it to do in the
> rest of the cases.

It does the right thing for me, and not just in most cases, it does so
in _all_ cases, because it does exactly it is told to do. And it is a
very important characteristics for any VCS, otherwise you can mess up
things easily. What is also good about Git is that it does not require
much keystrokes to do even rather complex stuff. And many defaults and
commands are configurable, so you can adjust it to your workflow. So,
I am not sure what your problem is.


Dmitry

^ permalink raw reply

* Re: Confusing git pull error message
From: Sverre Rabbelier @ 2009-09-12 21:37 UTC (permalink / raw)
  To: Jeff King; +Cc: John Tapsell, Junio C Hamano, Git List
In-Reply-To: <20090912211119.GA30966@coredump.intra.peff.net>

Heya,

On Sat, Sep 12, 2009 at 23:11, Jeff King <peff@peff.net> wrote:
>        if [ -z "$curr_branch" ]; then
>                echo "You are not currently on a branch, so I cannot use any"
> @@ -96,7 +99,7 @@ error_on_no_merge_candidates () {
>                echo "Please specify which branch you want to merge on the command"
>                echo "line and try again (e.g. 'git pull <repository> <refspec>')."
>                echo "See git-pull(1) for details."
> -       else
> +       elif [ -z "$upstream" ]; then
>                echo "You asked me to pull without telling me which branch you"
>                echo "want to merge with, and 'branch.${curr_branch}.merge' in"
>                echo "your configuration file does not tell me either.  Please"
> @@ -114,6 +117,10 @@ error_on_no_merge_candidates () {
>                echo "    remote.<nickname>.fetch = <refspec>"
>                echo
>                echo "See git-config(1) for details."
> +       else
> +               echo "Your configuration specified for us to pull the ref"
> +               echo "'$upstream_short', but we were unable to fetch it from"
> +               echo "the remote."
>        fi
>        exit 1
>  }

Pretty bad case of multiple personality disorder here? At first
there's a "me", then again a "me", and then all of a sudden a "we"?

-- 
Cheers,

Sverre Rabbelier

^ permalink raw reply

* Re: Confusing git pull error message
From: John Tapsell @ 2009-09-12 21:31 UTC (permalink / raw)
  To: Jeff King; +Cc: Junio C Hamano, Git List
In-Reply-To: <20090912211119.GA30966@coredump.intra.peff.net>

2009/9/13 Jeff King <peff@peff.net>:

> +       else
> +               echo "Your configuration specified for us to pull the ref"
> +               echo "'$upstream_short', but we were unable to fetch it from"
> +               echo "the remote."

Thanks!

But why was it 'unable' ?  Are there cases other than it not existing?
 Maybe something less cryptic:

"Attempted to pull from ref $upstream_short but this branch does not
exist on remote."

Or something?

John

^ 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