Git development
 help / color / mirror / Atom feed
* [RFC PATCH 3/4] Add smart-http options to upload-pack, receive-pack
From: Shawn O. Pearce @ 2009-10-09  5:22 UTC (permalink / raw)
  To: git
In-Reply-To: <1255065768-10428-3-git-send-email-spearce@spearce.org>

When --smart-http is passed as a command line parameter to
upload-pack or receive-pack the programs now assume they may
perform only a single read-write cycle with stdin and stdout.
This fits with the HTTP POST request processing model where a
program may read the request, write a response, and must exit.

When --advertise-refs is passed as a command line parameter only
the initial ref advertisement is output, and the program exits
immediately.  This fits with the HTTP GET request model, where
no request content is received but a response must be produced.

HTTP headers and/or environment are not processed here, but
instead are assumed to be handled by the program invoking
either service backend.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 builtin-receive-pack.c |   26 ++++++++++++++++++++------
 upload-pack.c          |   40 ++++++++++++++++++++++++++++++++++++----
 2 files changed, 56 insertions(+), 10 deletions(-)

diff --git a/builtin-receive-pack.c b/builtin-receive-pack.c
index b771fe9..a075785 100644
--- a/builtin-receive-pack.c
+++ b/builtin-receive-pack.c
@@ -615,6 +615,8 @@ static void add_alternate_refs(void)
 
 int cmd_receive_pack(int argc, const char **argv, const char *prefix)
 {
+	int advertise_refs = 0;
+	int smart_http = 0;
 	int i;
 	char *dir = NULL;
 
@@ -623,7 +625,15 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
 		const char *arg = *argv++;
 
 		if (*arg == '-') {
-			/* Do flag handling here */
+			if (!strcmp(arg, "--advertise-refs")) {
+				advertise_refs = 1;
+				continue;
+			}
+			if (!strcmp(arg, "--smart-http")) {
+				smart_http = 1;
+				continue;
+			}
+
 			usage(receive_pack_usage);
 		}
 		if (dir)
@@ -652,12 +662,16 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
 		" report-status delete-refs ofs-delta " :
 		" report-status delete-refs ";
 
-	add_alternate_refs();
-	write_head_info();
-	clear_extra_refs();
+	if (advertise_refs || !smart_http) {
+		add_alternate_refs();
+		write_head_info();
+		clear_extra_refs();
 
-	/* EOF */
-	packet_flush(1);
+		/* EOF */
+		packet_flush(1);
+	}
+	if (advertise_refs)
+		return 0;
 
 	read_head_info();
 	if (commands) {
diff --git a/upload-pack.c b/upload-pack.c
index 38ddac2..ae67039 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -39,6 +39,8 @@ static unsigned int timeout;
  */
 static int use_sideband;
 static int debug_fd;
+static int advertise_refs;
+static int smart_http;
 
 static void reset_timeout(void)
 {
@@ -509,6 +511,8 @@ static int get_common_commits(void)
 		if (!len) {
 			if (have_obj.nr == 0 || multi_ack)
 				packet_write(1, "NAK\n");
+			if (smart_http)
+				exit(0);
 			continue;
 		}
 		strip(line, len);
@@ -705,12 +709,32 @@ static int send_ref(const char *refname, const unsigned char *sha1, int flag, vo
 	return 0;
 }
 
+static int mark_our_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data)
+{
+	struct object *o = parse_object(sha1);
+	if (!o)
+		die("git upload-pack: cannot find object %s:", sha1_to_hex(sha1));
+	if (!(o->flags & OUR_REF)) {
+		o->flags |= OUR_REF;
+		nr_our_refs++;
+	}
+	return 0;
+}
+
 static void upload_pack(void)
 {
-	reset_timeout();
-	head_ref(send_ref, NULL);
-	for_each_ref(send_ref, NULL);
-	packet_flush(1);
+	if (advertise_refs || !smart_http) {
+		reset_timeout();
+		head_ref(send_ref, NULL);
+		for_each_ref(send_ref, NULL);
+		packet_flush(1);
+	} else {
+		head_ref(mark_our_ref, NULL);
+		for_each_ref(mark_our_ref, NULL);
+	}
+	if (advertise_refs)
+		return;
+
 	receive_needs();
 	if (want_obj.nr) {
 		get_common_commits();
@@ -732,6 +756,14 @@ int main(int argc, char **argv)
 
 		if (arg[0] != '-')
 			break;
+		if (!strcmp(arg, "--advertise-refs")) {
+			advertise_refs = 1;
+			continue;
+		}
+		if (!strcmp(arg, "--smart-http")) {
+			smart_http = 1;
+			continue;
+		}
 		if (!strcmp(arg, "--strict")) {
 			strict = 1;
 			continue;
-- 
1.6.5.rc3.193.gdf7a

^ permalink raw reply related

* Re: [RFC PATCH 2/4] Git-aware CGI to provide dumb HTTP transport
From: J.H. @ 2009-10-09  5:52 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: git
In-Reply-To: <1255065768-10428-3-git-send-email-spearce@spearce.org>

I dunno I kinda object to it being called http-backend, personally I'd 
rather it be called git-smart since this is the smart http protocol ;-)

- John 'Warthog9' Hawley

Shawn O. Pearce wrote:
> The git-http-backend CGI can be configured into any Apache server
> using ScriptAlias, such as with the following configuration:
> 
>   LoadModule cgi_module /usr/libexec/apache2/mod_cgi.so
>   LoadModule alias_module /usr/libexec/apache2/mod_alias.so
>   ScriptAlias /git/ /usr/libexec/git-core/git-http-backend/
> 
> Repositories are accessed via the translated PATH_INFO.
> 
> The CGI is backwards compatible with the dumb client, allowing all
> older HTTP clients to continue to download repositories which are
> managed by the CGI.
> 
> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
> ---
>  .gitignore     |    1 +
>  Makefile       |    1 +
>  http-backend.c |  261 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 263 insertions(+), 0 deletions(-)
>  create mode 100644 http-backend.c
> 
> diff --git a/.gitignore b/.gitignore
> index 51a37b1..353d22f 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -55,6 +55,7 @@ git-get-tar-commit-id
>  git-grep
>  git-hash-object
>  git-help
> +git-http-backend
>  git-http-fetch
>  git-http-push
>  git-imap-send
> diff --git a/Makefile b/Makefile
> index dd3d520..c80fb56 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -361,6 +361,7 @@ PROGRAMS += git-show-index$X
>  PROGRAMS += git-unpack-file$X
>  PROGRAMS += git-upload-pack$X
>  PROGRAMS += git-var$X
> +PROGRAMS += git-http-backend$X
>  
>  # List built-in command $C whose implementation cmd_$C() is not in
>  # builtin-$C.o but is linked in as part of some other command.
> diff --git a/http-backend.c b/http-backend.c
> new file mode 100644
> index 0000000..39cfd25
> --- /dev/null
> +++ b/http-backend.c
> @@ -0,0 +1,261 @@
> +#include "cache.h"
> +#include "refs.h"
> +#include "pkt-line.h"
> +#include "object.h"
> +#include "tag.h"
> +#include "exec_cmd.h"
> +#include "run-command.h"
> +
> +static const char content_type[] = "Content-Type";
> +static const char content_length[] = "Content-Length";
> +
> +static char buffer[1024];
> +
> +static const char *http_date(unsigned long time)
> +{
> +	return show_date(time, 0, DATE_RFC2822);
> +}
> +
> +static void format_write(const char *fmt, ...)
> +{
> +	va_list args;
> +	unsigned n;
> +
> +	va_start(args, fmt);
> +	n = vsnprintf(buffer, sizeof(buffer), fmt, args);
> +	va_end(args);
> +	if (n >= sizeof(buffer))
> +		die("protocol error: impossibly long line");
> +
> +	safe_write(1, buffer, n);
> +}
> +
> +static void write_status(unsigned code, const char *msg)
> +{
> +	format_write("Status: %u %s\r\n", code, msg);
> +}
> +
> +static void write_header(const char *name, const char *value)
> +{
> +	format_write("%s: %s\r\n", name, value);
> +}
> +
> +static void end_headers(void)
> +{
> +	safe_write(1, "\r\n", 2);
> +}
> +
> +static void write_nocache(void)
> +{
> +	write_header("Expires", "Fri, 01 Jan 1980 00:00:00 GMT");
> +	write_header("Pragma", "no-cache");
> +	write_header("Cache-Control", "no-cache, max-age=0, must-revalidate");
> +}
> +
> +static void write_cache_forever(void)
> +{
> +	unsigned long now = time(NULL);
> +	write_header("Date", http_date(now));
> +	write_header("Expires", http_date(now + 31536000));
> +	write_header("Cache-Control", "public, max-age=31536000");
> +}
> +
> +static NORETURN void not_found(const char *err, ...)
> +{
> +	va_list params;
> +
> +	write_status(404, "Not Found");
> +	write_nocache();
> +	end_headers();
> +
> +	va_start(params, err);
> +	if (err && *err) {
> +		vsnprintf(buffer, sizeof(buffer), err, params);
> +		fprintf(stderr, "%s\n", buffer);
> +	}
> +	va_end(params);
> +	exit(0);
> +}
> +
> +static void write_file(const char *the_type, const char *name)
> +{
> +	const char *p = git_path("%s", name);
> +	int fd;
> +	struct stat sb;
> +	uintmax_t remaining;
> +
> +	fd = open(p, O_RDONLY);
> +	if (fd < 0)
> +		not_found("Cannot open '%s': %s", p, strerror(errno));
> +	if (fstat(fd, &sb) < 0)
> +		die_errno("Cannot stat '%s'", p);
> +	remaining = (uintmax_t)sb.st_size;
> +
> +	write_header(content_type, the_type);
> +	write_header("Last-Modified", http_date(sb.st_mtime));
> +	format_write("Content-Length: %" PRIuMAX "\r\n", remaining);
> +	end_headers();
> +
> +	while (remaining) {
> +		ssize_t n = xread(fd, buffer, sizeof(buffer));
> +		if (n < 0)
> +			die_errno("Cannot read '%s'", p);
> +		n = safe_write(1, buffer, n);
> +		if (n <= 0)
> +			break;
> +	}
> +	close(fd);
> +}
> +
> +static void get_text_file(char *name)
> +{
> +	write_nocache();
> +	write_file("text/plain; charset=utf-8", name);
> +}
> +
> +static void get_loose_object(char *name)
> +{
> +	write_cache_forever();
> +	write_file("application/x-git-loose-object", name);
> +}
> +
> +static void get_pack_file(char *name)
> +{
> +	write_cache_forever();
> +	write_file("application/x-git-packed-objects", name);
> +}
> +
> +static void get_idx_file(char *name)
> +{
> +	write_cache_forever();
> +	write_file("application/x-git-packed-objects-toc", name);
> +}
> +
> +static int show_text_ref(const char *name, const unsigned char *sha1,
> +	int flag, void *cb_data)
> +{
> +	struct object *o = parse_object(sha1);
> +	if (!o)
> +		return 0;
> +
> +	format_write("%s\t%s\n", sha1_to_hex(sha1), name);
> +	if (o->type == OBJ_TAG) {
> +		o = deref_tag(o, name, 0);
> +		if (!o)
> +			return 0;
> +		format_write("%s\t%s^{}\n", sha1_to_hex(o->sha1), name);
> +	}
> +
> +	return 0;
> +}
> +
> +static void get_info_refs(char *arg)
> +{
> +	write_nocache();
> +	write_header(content_type, "text/plain; charset=utf-8");
> +	end_headers();
> +
> +	for_each_ref(show_text_ref, NULL);
> +}
> +
> +static void get_info_packs(char *arg)
> +{
> +	size_t objdirlen = strlen(get_object_directory());
> +	struct packed_git *p;
> +
> +	write_nocache();
> +	write_header(content_type, "text/plain; charset=utf-8");
> +	end_headers();
> +
> +	prepare_packed_git();
> +	for (p = packed_git; p; p = p->next) {
> +		if (!p->pack_local)
> +			continue;
> +		format_write("P %s\n", p->pack_name + objdirlen + 6);
> +	}
> +	safe_write(1, "\n", 1);
> +}
> +
> +static NORETURN void die_webcgi(const char *err, va_list params)
> +{
> +	write_status(500, "Internal Server Error");
> +	write_nocache();
> +	end_headers();
> +
> +	vsnprintf(buffer, sizeof(buffer), err, params);
> +	fprintf(stderr, "fatal: %s\n", buffer);
> +	exit(0);
> +}
> +
> +static struct service_cmd {
> +	const char *method;
> +	const char *pattern;
> +	void (*imp)(char *);
> +} services[] = {
> +	{"GET", "/HEAD$", get_text_file},
> +	{"GET", "/info/refs$", get_info_refs},
> +	{"GET", "/objects/info/packs$", get_info_packs},
> +	{"GET", "/objects/info/[^/]*$", get_text_file},
> +	{"GET", "/objects/[0-9a-f]{2}/[0-9a-f]{38}$", get_loose_object},
> +	{"GET", "/objects/pack/pack-[0-9a-f]{40}\\.pack$", get_pack_file},
> +	{"GET", "/objects/pack/pack-[0-9a-f]{40}\\.idx$", get_idx_file}
> +};
> +
> +int main(int argc, char **argv)
> +{
> +	char *dir = getenv("PATH_TRANSLATED");
> +	char *input_method = getenv("REQUEST_METHOD");
> +	struct service_cmd *cmd = NULL;
> +	char *cmd_arg = NULL;
> +	int i;
> +
> +	set_die_routine(die_webcgi);
> +
> +	if (!dir)
> +		die("No PATH_TRANSLATED from server");
> +	if (!input_method)
> +		die("No REQUEST_METHOD from server");
> +	if (!strcmp(input_method, "HEAD"))
> +		input_method = "GET";
> +
> +	for (i = 0; i < ARRAY_SIZE(services); i++) {
> +		struct service_cmd *c = &services[i];
> +		regex_t re;
> +		regmatch_t out[1];
> +
> +		if (regcomp(&re, c->pattern, REG_EXTENDED))
> +			die("Bogus regex in service table: %s", c->pattern);
> +		if (!regexec(&re, dir, 1, out, 0)) {
> +			size_t n = out[0].rm_eo - out[0].rm_so;
> +
> +			if (strcmp(input_method, c->method)) {
> +				const char *proto = getenv("SERVER_PROTOCOL");
> +				if (proto && !strcmp(proto, "HTTP/1.1"))
> +					write_status(405, "Method Not Allowed");
> +				else
> +					write_status(400, "Bad Request");
> +				write_nocache();
> +				end_headers();
> +				return 0;
> +			}
> +
> +			cmd = c;
> +			cmd_arg = xmalloc(n);
> +			strncpy(cmd_arg, dir + out[0].rm_so + 1, n);
> +			cmd_arg[n] = '\0';
> +			dir[out[0].rm_so] = 0;
> +			break;
> +		}
> +		regfree(&re);
> +	}
> +
> +	if (!cmd)
> +		not_found("Request not supported: '%s'", dir);
> +
> +	setup_path();
> +	if (!enter_repo(dir, 0))
> +		not_found("Not a git repository: '%s'", dir);
> +
> +	cmd->imp(cmd_arg);
> +	return 0;
> +}

^ permalink raw reply

* Re: combine git repo historically
From: Johannes Sixt @ 2009-10-09  6:02 UTC (permalink / raw)
  To: bill lam; +Cc: git
In-Reply-To: <20091009012254.GA3980@debian.b2j>

bill lam schrieb:
> I have two git repos, no branches.
> 
> repo 1.
>   emptyrootcommit -- A ... M 
> 
> repo 2.
>   emptyrootcommit -- N ... Z
> 
> N was evolved from M but the time gap is large, how can I combine them
> into one repo
> 
> emptyrootcommit -- A ... M -- N ... Z
> 
> so that snapshots N .. Z will not be changed.

$ echo $(git rev-parse N) $(git rev-parse M) >> .git/info/grafts
$ git filter-branch --tag-name-filter cat -- --all --not M

i.e. you graft the older history right before the younger history, then
you use git filter-branch to rewrite the parentship of the younger commits.

-- Hannes

^ permalink raw reply

* [PATCHv2 2/2] completion: fix alias listings with newlines
From: Stephen Boyd @ 2009-10-09  6:21 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: Junio C Hamano, git, Johannes Sixt
In-Reply-To: <1255069304-8953-1-git-send-email-bebarino@gmail.com>

Aliases with newlines have been a problem since commit 56fc25f (Bash
completion support for remotes in .git/config., 2006-11-05). The chance
of the problem occurring has been slim at best, until commit 518ef8f
(completion: Replace config --list with --get-regexp, 2009-09-11)
removed the case statement introduced by commit 56fc25f. Before removing
the case statement, most aliases with newlines would work unless they
were specially crafted as follows

[alias]
	foo = "log -1 --pretty='format:%s\nalias.error=broken'"

After removing the case statement, a more benign alias like

[alias]
	whowhat = "log -1 --pretty='format:%an <%ae>\n%s'"
	wont-complete = ...

would cause the completion to break badly.

For now, revert the removal of the case statement until someone comes up
with a better way to get keys from git-config.

Signed-off-by: Stephen Boyd <bebarino@gmail.com>
---

This is an alternate fix to my previous 1/3 patch.

Hannes has convinced me to go this route. I don't really see a problem, it
basically reverts to broken behavior that nobody's complained about in 3
years. At least it's less broken?

 contrib/completion/git-completion.bash |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 652a47c..e482c8d 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -602,8 +602,12 @@ __git_aliases ()
 {
 	local i IFS=$'\n'
 	for i in $(git --git-dir="$(__gitdir)" config --get-regexp "alias\..*" 2>/dev/null); do
-		i="${i#alias.}"
-		echo "${i/ */}"
+		case "$i" in
+		alias.*)
+			i="${i#alias.}"
+			echo "${i/ */}"
+			;;
+		esac
 	done
 }
 
-- 
1.6.5.rc3

^ permalink raw reply related

* [PATCH 1/2] completion: fix completion of git <TAB><TAB>
From: Stephen Boyd @ 2009-10-09  6:21 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: Junio C Hamano, git, Johannes Sixt

After commit 511a3fc (wrap git's main usage string., 2009-09-12), the
bash completion for git commands includes COMMAND and [ARGS] when it
shouldn't. Fix this by grepping more strictly for a line with git
commands. It's doubtful whether git will ever have commands starting
with anything besides numbers and letters so this should be fine. At
least by being stricter we'll know when we break the completion earlier.

Signed-off-by: Stephen Boyd <bebarino@gmail.com>
---

 contrib/completion/git-completion.bash |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 88b1b3c..652a47c 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -496,7 +496,7 @@ __git_all_commands ()
 		return
 	fi
 	local i IFS=" "$'\n'
-	for i in $(git help -a|egrep '^ ')
+	for i in $(git help -a|egrep '^  [a-zA-Z0-9]')
 	do
 		case $i in
 		*--*)             : helper pattern;;
-- 
1.6.5.rc3

^ permalink raw reply related

* Re: What's cooking in git.git (Oct 2009, #01; Wed, 07)
From: Junio C Hamano @ 2009-10-09  6:46 UTC (permalink / raw)
  To: Jakub Narebski; +Cc: git
In-Reply-To: <m3iqepgxcc.fsf@localhost.localdomain>

Jakub Narebski <jnareb@gmail.com> writes:

> Junio C Hamano <gitster@pobox.com> writes:
>
>> --------------------------------------------------
>> [New Topics]
>
>> * jn/gitweb-patch (2009-09-30) 1 commit
>>  - gitweb: Do not show 'patch' link in 'commit' view for merges
>> 
>> jk: After some comments with Jakub, I think the code is right but he
>> promised a re-roll with more in the commit message.
>
> Not only better commit message, but a more complete patch as well.

Ok; I'll wait.

>> * mr/gitweb-snapshot (2009-09-26) 2 commits
>>  - gitweb: append short hash ids to snapshot files
>>  - gitweb: check given hash before trying to create snapshot
>> 
>> jk: He posted a v5 of his series. I didn't look at it closely, but Jakub
>> ack'd it.
> ...
> In short: first patch is a go, second needs more work.

Ok; I'll merge fdb0c36 (gitweb: check given hash before trying to create
snapshot, 2009-09-26) to 'next'.

>> * jc/pretty-lf (2009-10-04) 1 commit
>>  - Pretty-format: %[+-]x to tweak inter-item newlines
>> 
>> I am not happy with this one yet.  I am contemplating to introduce a new
>> syntax "%[magic(param)<anything>%]" to generalize expressions of this and
>> line wrapping features in an extensible way.
>> ...
> So... it is magic %[...%] or %{...} or %{...%}?

The escape does not matter. %() is fine, too.  It is non-essential for the
purpose of the upcoming release so I have backburnered coming up with and
thinking the details through.

>> --------------------------------------------------
>> [Cooking]
>
>> * jn/gitweb-show-size (2009-09-07) 1 commit
>>  - gitweb: Add 'show-sizes' feature to show blob sizes in tree view
>
> What this one requires (beside better name for a feature)?

Name before 'next', and then the usual cooking, I guess.

>> * jn/gitweb-blame (2009-09-01) 5 commits
>> ...
>> Ajax-y blame.
>
> I reordered patches so JSMIN one is first (as it is less
> controversial), but the 'create blame_incremental links' one needs
> more work.

Ok; I'll wait.

Thanks.

^ permalink raw reply

* Re: What's cooking in git.git (Oct 2009, #01; Wed, 07)
From: Junio C Hamano @ 2009-10-09  6:47 UTC (permalink / raw)
  To: Erik Faye-Lund; +Cc: Marius Storm-Olsen, git
In-Reply-To: <40aa078e0910081115q1bf924e8s22f3ee11dbe7c8b7@mail.gmail.com>

Erik Faye-Lund <kusmabite@googlemail.com> writes:

> On Thu, Oct 8, 2009 at 8:58 AM, Marius Storm-Olsen <mstormo@gmail.com> wrote:
>> Junio C Hamano said the following on 08.10.2009 08:33:
>>>
>>> * ef/msys-imap (2009-10-03) 7 commits
>> ...
>> Don't forget about the MSVC patch ontop of this series:
>> Message-ID: <18cd41840910031300i32c74b15t74eb9eee23ff8469@mail.gmail.com>
>> Subject: [PATCH] MSVC: Enable OpenSSL, and translate -lcrypto
>
> I will include it in the next round I send out (unless someone objects)

Thanks.

^ permalink raw reply

* Re: [PATCH] Fix MSVC build on cygwin
From: Junio C Hamano @ 2009-10-09  6:48 UTC (permalink / raw)
  To: Ramsay Jones; +Cc: mstormo, GIT Mailing-list
In-Reply-To: <4ACE0388.6070706@ramsay1.demon.co.uk>

Ramsay Jones <ramsay@ramsay1.demon.co.uk> writes:

> In the MSVC section of the Makefile, BASIC_CFLAGS is set to a
> value which contains the string "-DWIN32-D_CONSOLE". This results
> in a (single) malformed -Define being passed to the compiler.
> At least on my cygwin installation, the msvc compiler seems to
> ignore this parameter, without issuing an error or warning, and
> results in the WIN32 and _CONSOLE macros being undefined. This
> breaks the build.
>
> In order to fix the build, we simply insert a space between the
> two -Define parameters, "-DWIN32" and "-D_CONSOLE", as originally
> intended.
>
> Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>

Thanks; that's quite a detailed description to explain why -DFOO-DBAR is
bad when -DFOO -DBAR was wanted ;-)

^ permalink raw reply

* Re: [PATCH] Fix the exit code of MSVC build scripts on cygwin
From: Junio C Hamano @ 2009-10-09  6:49 UTC (permalink / raw)
  To: Alex Riesen; +Cc: Ramsay Jones, Junio C Hamano, mstormo, GIT Mailing-list
In-Reply-To: <81b0412b0910081313x31f72916p6fddd1a23df154df@mail.gmail.com>

Alex Riesen <raa.lkml@gmail.com> writes:

> On Thu, Oct 8, 2009 at 17:33, Ramsay Jones <ramsay@ramsay1.demon.co.uk> wrote:
>> diff --git a/compat/vcbuild/scripts/clink.pl b/compat/vcbuild/scripts/clink.pl
>> index 0ffd59f..26aec61 100644
>> --- a/compat/vcbuild/scripts/clink.pl
>> +++ b/compat/vcbuild/scripts/clink.pl
>> @@ -45,4 +45,6 @@ if ($is_linking) {
>>        push(@args, @cflags);
>>  }
>>  #printf("**** @args\n");
>> -exit system(@args);
>> +system(@args) == 0
>> +       or exit 1;
>> +exit 0;
>
> exit(system(@args) != 0);
>
> Yours looks a little verbose...

Thanks, will queue with a fixup.

^ permalink raw reply

* Re: [PATCH v2] git-send-email.perl: fold multiple entry "Cc:" and multiple single line "RCPT TO:"s
From: Junio C Hamano @ 2009-10-09  6:50 UTC (permalink / raw)
  To: Joe Perches; +Cc: Junio C Hamano, git, Jay Soffian
In-Reply-To: <1255021406.2056.122.camel@Joe-Laptop.home>

Joe Perches <joe@perches.com> writes:

> Some MTAs reject Cc: lines longer than 78 chars.
> Avoid this by using the same join as "To:" ",\n\t"
> so each subsequent Cc entry is on a new line.
>
> RCPT TO: should have a single entry per line.
> see: http://www.ietf.org/rfc/rfc2821.txt
>
> Signed-off-by: Joe Perches <joe@perches.com>

Thanks.

^ permalink raw reply

* Re: Git archive and trailing "/" in prefix
From: Junio C Hamano @ 2009-10-09  6:50 UTC (permalink / raw)
  To: René Scharfe; +Cc: Sergio Callegari, git, Junio C Hamano
In-Reply-To: <4ACE177E.209@lsrfire.ath.cx>

René Scharfe <rene.scharfe@lsrfire.ath.cx> writes:

> Sergio Callegari schrieb:
> ...
>> As a matter of fact, the archiver behaves quite strangely if that slash is
>> missing. Files in the root of the working dir are added to the archive with
>> their own name modified by the prefix and the same happens for working dir
>> sub-directories. However, no file present in the sub-directories, nor
>> sub-sub-directories are added.
>
> The latter is a bug.
> ...
> The following patch fixes...

Thanks.  Applied with a trivial test.

^ permalink raw reply

* Re: [PATCH v2] perl/Makefile.PL: detect MakeMaker versions incompatible with DESTDIR
From: Junio C Hamano @ 2009-10-09  6:51 UTC (permalink / raw)
  To: Brandon Casey; +Cc: Johannes Sixt, gitster, git, c, Brandon Casey
In-Reply-To: <F3v6_n7wtTFWz8nzE5EpqB8ZsobXLax0nn_ghA5foHOvOJEMjHl0Qw@cipher.nrlssc.navy.mil>

Brandon Casey <brandon.casey.ctr@nrlssc.navy.mil> writes:

> I think we're safe.

Thanks.

^ permalink raw reply

* Re: [PATCH] Makefile: enable THREADED_DELTA_SEARCH on IRIX and IRIX64
From: Junio C Hamano @ 2009-10-09  6:52 UTC (permalink / raw)
  To: Brandon Casey; +Cc: git, Brandon Casey
In-Reply-To: <Zyq66vleW7YI5l2liyEIAK1O_rnknZ4_xci4KmS3Proua7JfnWyaAyyk1ww9sknBMukmwGErv7slPEl71tr1Lg@cipher.nrlssc.navy.mil>

Thanks; both IRIX patches applied, as it did not look wrong and I do not
have an environment to test myself.

^ permalink raw reply

* Re: [PATCH] ls-files: die instead of fprintf/exit in -i error
From: Junio C Hamano @ 2009-10-09  6:53 UTC (permalink / raw)
  To: Ben Walton; +Cc: bebarino, git
In-Reply-To: <1255053215-14059-1-git-send-email-bwalton@artsci.utoronto.ca>

Ben Walton <bwalton@artsci.utoronto.ca> writes:

> This is the alternate solution to this bug as proposed earlier today.
> I don't have a preference either way for which solution is better or
> more inline with the 'git way,' so please choose the most appropriate.

I think die() is better for consistency reasons if nothing else.

Thanks.

^ permalink raw reply

* [PATCH] git-svn: Avoid spurious errors when rewriteRoot is used.
From: Alexander Gavrilov @ 2009-10-09  7:01 UTC (permalink / raw)
  To: Eric Wong; +Cc: git

After doing a rebase, git-svn checks that the SVN URL
is what it expects. However, it does not account for
rewriteRoot, which is a legitimate way for the URL
to change. This produces a lot of spurious errors.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
---
 git-svn.perl |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/git-svn.perl b/git-svn.perl
index e0ec258..e9030ff 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -603,8 +603,12 @@ sub cmd_dcommit {
 					  "\nBefore dcommitting";
 				}
 				if ($url_ ne $expect_url) {
-					fatal "URL mismatch after rebase: ",
-					      "$url_ != $expect_url";
+					if ($url_ eq $gs->metadata_url) {
+						print "Accepting rewritten URL: $url_\n";
+					} else {
+						fatal "URL mismatch after rebase: ",
+						      "$url_ != $expect_url";
+					}
 				}
 				if ($uuid_ ne $uuid) {
 					fatal "uuid mismatch after rebase: ",
-- 
1.6.3.2.13.g94af7

^ permalink raw reply related

* Re: combine git repo historically
From: Christian Couder @ 2009-10-09  7:40 UTC (permalink / raw)
  To: bill lam; +Cc: Johannes Sixt, git
In-Reply-To: <4ACED204.3000907@viscovery.net>

On Fri, Oct 9, 2009 at 8:02 AM, Johannes Sixt <j.sixt@viscovery.net> wrote:
> bill lam schrieb:
>> I have two git repos, no branches.
>>
>> repo 1.
>>   emptyrootcommit -- A ... M
>>
>> repo 2.
>>   emptyrootcommit -- N ... Z
>>
>> N was evolved from M but the time gap is large, how can I combine them
>> into one repo
>>
>> emptyrootcommit -- A ... M -- N ... Z
>>
>> so that snapshots N .. Z will not be changed.
>
> $ echo $(git rev-parse N) $(git rev-parse M) >> .git/info/grafts
> $ git filter-branch --tag-name-filter cat -- --all --not M
>
> i.e. you graft the older history right before the younger history, then
> you use git filter-branch to rewrite the parentship of the younger commits.

If you cannot create a new history, using "git replace" could be
better than using grafts.
("git replace" is in the "master" branch in the git repository. It
will be in git 1.6.5 that should be released soon.)

Regards,
Christian

^ permalink raw reply

* Re: Confusing git pull error message
From: Junio C Hamano @ 2009-10-09  7:38 UTC (permalink / raw)
  To: Nanako Shiraishi; +Cc: Jeff King, Johannes Sixt, John Tapsell, Git List
In-Reply-To: <20091009070122.6117@nanako3.lavabit.com>

Nanako Shiraishi <nanako3@lavabit.com> writes:

> Quoting Jeff King <peff@peff.net>
>
>> Subject: [PATCH] pull: improve advice for unconfigured error case
>> ...
> Junio, may I ask what happened to this patch?

Thanks for prodding.  Unfortunately I lost track.  Will look at it again
but probably not tonight.

^ permalink raw reply

* Re: [RFC PATCH 1/4] Document the HTTP transport protocol
From: Sverre Rabbelier @ 2009-10-09  8:01 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: git
In-Reply-To: <1255065768-10428-2-git-send-email-spearce@spearce.org>

Heya,

I had some spare time, I hope these comments from someone that is not
too familiar with the protocol are helpful :).

On Fri, Oct 9, 2009 at 07:22, Shawn O. Pearce <spearce@spearce.org> wrote:
> +Compatible clients must expand
> +'$GIT_URL/info/refs' as 'foo/info/refs' and not 'foo//info/refs'.

Does this not need s/must/MUST/

> +       S: ....# service=git-upload-pack
> +       S: ....95dcfa3633004da0049d3d0fa03f80589cbcaf31 refs/heads/maint\0 multi_ack
> +       S: ....d049f6c27a2244e12041955e262a404c7faba355 refs/heads/master
> +       S: ....2cb58b79488a98d2721cea644875a8dd0026b115 refs/tags/v1.0
> +       S: ....a3c2e2402b99163d1d59756e5f207ae21cccba4c refs/tags/v1.0^{}

Shouldn't this contain HEAD as the first ref?

> +       ref_list       = empty_list | populated_list
> +
> +       empty_list     = PKT-LINE(id SP "capabilities^{}" NUL cap_list LF)
> +
> +       non_empty_list = PKT-LINE(id SP name NUL cap_list LF)
> +                        *ref_record

Does this need a s/non_empty_list/populated_list/ ?

> +       cap_list      = *(SP capability) SP

You never define capability.

> + (c) Send one $GIT_URL/git-upload-pack request:

I don't think you documented what $GIT_URL/git-upload-pack means.

> +     If the client has sent 256 HAVE commits and has not yet
> +     received one of those back from S_COMMON, or the client has
> +     emptied C_PENDING it should include a "done" command to let
> +     the server know it won't proceed:
> +
> +       C: 0009done

This should probably move down to after you define what S_COMMON is in
the first place.


> +     Here a "closed set of objects" is defined to have at least
> +     one path from every WANT to at least one COMMON object.

A 'path from' is perhaps a bit unclear.

-- 
Cheers,

Sverre Rabbelier

^ permalink raw reply

* Re: [RFC PATCH 1/4] Document the HTTP transport protocol
From: Sverre Rabbelier @ 2009-10-09  8:09 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: git
In-Reply-To: <fabb9a1e0910090101g2de58824p6cfdea86c98e0191@mail.gmail.com>

Heya,

On Fri, Oct 9, 2009 at 10:01, Sverre Rabbelier <srabbelier@gmail.com> wrote:
>> + (c) Send one $GIT_URL/git-upload-pack request:
>
> I don't think you documented what $GIT_URL/git-upload-pack means.

Ah, I didn't realize until I read 4/4 that this is just a regular
request to the 'http://<host>:<port>/git-upload-pack' url, I was
confused by the need to query
"http://<host>:<port>/info/refs?service=git-upload-pack".

-- 
Cheers,

Sverre Rabbelier

^ permalink raw reply

* Re: [PATCH] git-svn: Avoid spurious errors when rewriteRoot is used.
From: Eric Wong @ 2009-10-09  8:34 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Alexander Gavrilov
In-Reply-To: <200910091101.04116.angavrilov@gmail.com>

Alexander Gavrilov <angavrilov@gmail.com> wrote:
> After doing a rebase, git-svn checks that the SVN URL
> is what it expects. However, it does not account for
> rewriteRoot, which is a legitimate way for the URL
> to change. This produces a lot of spurious errors.
> 
> Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>

Thanks Alexander,

Acked-by: Eric Wong <normalperson@yhbt.net>

Fixed some line wrapping and pushed out to
  git://git.bogomips.org/git-svn

-- 
Eric Wong

^ permalink raw reply

* Re: [RFC PATCH 1/4] Document the HTTP transport protocol
From: Alex Blewitt @ 2009-10-09  8:54 UTC (permalink / raw)
  To: git
In-Reply-To: <1255065768-10428-2-git-send-email-spearce@spearce.org>

Shawn O. Pearce <spearce <at> spearce.org> writes:

> +URL Format
> +----------
> +
> +URLs for Git repositories accessed by HTTP use the standard HTTP
> +URL syntax documented by RFC 1738, so they are of the form:
> +
> +  http://<host>:<port>/<path>
> +
> +Within this documentation the placeholder $GIT_URL will stand for
> +the http:// repository URL entered by the end-user.

It's worth making clear here that $GIT_URL will be the path to the repository,
rather than necessarily just the host upon which the server sits. Perhaps
including an example, like http://example:8080/repos/example.git
would make it clearer that there can be a path (and so leading to
a request like http://example:8080/repos/example.git/info/refs?service=...

It's also worth clarifying, therefore, that multiple repositories can be served
by the same process (as with the git server today) by using different path(s).
And for those that are interested in submodules, it's worth confirming that
http://example/repos/master.git/child.git/info/refs?service= will ensure 
that the repository is the 'child' git rather than anything else.

> HEX = [0-9a-f]

Is there any reason not to support A-F as well in the hex spec, even if they
SHOULD use a-f? This may limit the appeal for some case-insensitive systems.

It would also be good to document, like with the git daemon, whether all
repositories under a path are exported or only those that have the magic
setting in the config like git-daemon-export-ok.

Lastly, it would be good to clarify when the result of this GET/POST exchange
is a text-based (and encoded in UTF-8) vs when binary data is returned; we 
don't want to get into the state where we're returning binary data and 
pretending that it's UTF-8.

Alex

^ permalink raw reply

* Re: git log -S not finding all commits?
From: Matthieu Moy @ 2009-10-09  8:55 UTC (permalink / raw)
  To: Randal L. Schwartz; +Cc: Daniel, Andreas Ericsson, git
In-Reply-To: <86tyy9qz08.fsf@blue.stonehenge.com>

merlyn@stonehenge.com (Randal L. Schwartz) writes:

>>>>>> "Matthieu" == Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:
>
> Matthieu> Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:
>>> git log -p --format="%s\n%x00"  | perl -0 -ne 'print if(/whatever-you-search/);'
>
> That "if" is noisier than it needs to be:
>
>   perl -0 -ne 'print if /this/'

Thanks,

Also, this seems to actually print the \0 character. Perhaps a perl
guru can give a simple solution to replace the \0 by a \n?

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

^ permalink raw reply

* Re: [PATCH] Speedup bash completion loading
From: Kirill Smelkov @ 2009-10-09  9:09 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: Ted Pavlic, git
In-Reply-To: <20091008150206.GD9261@spearce.org>

On Thu, Oct 08, 2009 at 08:02:06AM -0700, Shawn O. Pearce wrote:
> Kirill Smelkov <kirr@mns.spb.ru> wrote:
> > diff --git a/contrib/completion/Makefile b/contrib/completion/Makefile
> > new file mode 100644
> > index 0000000..a0fbb66
> > --- /dev/null
> > +++ b/contrib/completion/Makefile
> > @@ -0,0 +1,11 @@
> > +all	: git-completion.bash
> > +
> > +
> > +git-completion.bash: git-completion.bash.in git-completion.bash.generate
> > +	# Generate completions for binaries we have just built
> > +	PATH="$(shell pwd)/..:$$PATH" ./git-completion.bash.generate
> 
> Is only one .. enough?  Isn't that putting us into the contrib
> directory, and therefore not finding the 'git' we just compiled?

Fixed, thanks.

> I'm also concerned that git-completion.bash.generate requires
> bash to compile the completion for bash.  IMHO, if we are building
> this code at compile time we shouldn't assume bash is available.
> What if this is a sandboxed build environment using another shell
> and /bin/bash isn't installed?
> 
> I think the git-completion.bash.generate code needs to be a bit
> more sh agnostic than the completion routines themselves are.

I've reworked it not to depend on bash in 2nd patch.

> > +# pregenerated stuff (to save load time)
> > +__git_merge_strategylist=__GIT_MERGE_STRATEGYLIST
> > +__git_all_commandlist=__GIT_ALL_COMMANDLIST
> > +__git_porcelain_commandlist=__GIT_PORCELAIN_COMMANDLIST
> 
> This also makes testing the completion a bit more difficult, now
> we have to build it before we can load it, making the testing cycle
> actually be:
> 
>   make && . git-completion.bash
> 
> We probably should place a quick comment here to remind folks that
> they need to build the script in order to test it properly.

I've added some sort of protection, so that git-completion.bash.in can't
be sourced at all. Is it ok?

(interdiff for patch 1)

diff --git a/contrib/completion/Makefile b/contrib/completion/Makefile
index a0fbb66..90aa225 100644
--- a/contrib/completion/Makefile
+++ b/contrib/completion/Makefile
@@ -3,7 +3,7 @@ all	: git-completion.bash
 
 git-completion.bash: git-completion.bash.in git-completion.bash.generate
 	# Generate completions for binaries we have just built
-	PATH="$(shell pwd)/..:$$PATH" ./git-completion.bash.generate
+	PATH="$(shell pwd)/../..:$$PATH" ./git-completion.bash.generate
 
 
 clean:
diff --git a/contrib/completion/git-completion.bash.in b/contrib/completion/git-completion.bash.in
index cf1b5fd..e1ab612 100644
--- a/contrib/completion/git-completion.bash.in
+++ b/contrib/completion/git-completion.bash.in
@@ -54,6 +54,21 @@
 #       git@vger.kernel.org
 #
 
+
+# pregenerated stuff (to save load time)
+__git_merge_strategylist=__GIT_MERGE_STRATEGYLIST
+__git_all_commandlist=__GIT_ALL_COMMANDLIST
+__git_porcelain_commandlist=__GIT_PORCELAIN_COMMANDLIST
+
+# remind folks that git-completion.bash.in can't be sourced
+case "$__git_merge_strategylist" in
+__GIT*)
+	echo "E: git-completion.bash.in can't be sourced"
+	return 1 ;;
+esac
+
+
+
 case "$COMP_WORDBREAKS" in
 *:*) : great ;;
 *)   COMP_WORDBREAKS="$COMP_WORDBREAKS:"
@@ -79,12 +94,6 @@ __gitdir ()
 }
 
 
-# pregenerated stuff (to save load time)
-__git_merge_strategylist=__GIT_MERGE_STRATEGYLIST
-__git_all_commandlist=__GIT_ALL_COMMANDLIST
-__git_porcelain_commandlist=__GIT_PORCELAIN_COMMANDLIST
-
-
 
 # __git_ps1 accepts 0 or 1 arguments (i.e., format string)
 # returns text to add to bash PS1 prompt (includes branch name)



Here are new patches themselves:


---- 8< ----

From: Kirill Smelkov <kirr@mns.spb.ru>
Date: Mon, 5 Oct 2009 13:36:15 +0400
Subject: [PATCH v3 1/2] Speedup bash completion loading

On my slow laptop (P3 700MHz), system-wide bash completions take too
much time to load (> 1s), and significant fraction of this time is spent
loading git-completion.bash:

    $ time bash -c '. git-completion.bash'  # before this patch

    real    0m0.317s
    user    0m0.250s
    sys     0m0.060s

I've tracked down that the most time is spent warming up merge_strategy,
all_command & porcelain_command caches.

Initially I thought that since git is not used in each and every
interactive xterm, it would be perfectly ok to load completion support
with cold caches, and then load needed thing lazily.

But for me this strategy turned out to be difficult to implement in
simple and maintainable way -- bash does not provide a way to return values
from inside functions, so one will have to use e.g.

    ${__git_all_commandlist:=$(__git_all_commands)}

everywhere in place where $(__git_all_commands) we used before, so as
also Ted Pavlic suggested let's pregenerate everything at build time so
that we have nothing to compute at runtime when git-completion.bash
script is loaded.

The result is that loading completion is significantly faster now:

    $ time bash -c '. git-completion.bash'  # after this patch

    real    0m0.068s
    user    0m0.060s
    sys     0m0.010s

Cc: Ted Pavlic <ted@tedpavlic.com>
Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru>
---
 contrib/completion/.gitignore                      |    1 +
 contrib/completion/Makefile                        |   11 ++
 contrib/completion/git-completion.bash.generate    |  128 ++++++++++++++++
 ...{git-completion.bash => git-completion.bash.in} |  161 +++-----------------
 4 files changed, 162 insertions(+), 139 deletions(-)
 create mode 100644 contrib/completion/.gitignore
 create mode 100644 contrib/completion/Makefile
 create mode 100755 contrib/completion/git-completion.bash.generate
 rename contrib/completion/{git-completion.bash => git-completion.bash.in} (90%)
 mode change 100755 => 100644

diff --git a/contrib/completion/.gitignore b/contrib/completion/.gitignore
new file mode 100644
index 0000000..578e6a8
--- /dev/null
+++ b/contrib/completion/.gitignore
@@ -0,0 +1 @@
+git-completion.bash
diff --git a/contrib/completion/Makefile b/contrib/completion/Makefile
new file mode 100644
index 0000000..90aa225
--- /dev/null
+++ b/contrib/completion/Makefile
@@ -0,0 +1,11 @@
+all	: git-completion.bash
+
+
+git-completion.bash: git-completion.bash.in git-completion.bash.generate
+	# Generate completions for binaries we have just built
+	PATH="$(shell pwd)/../..:$$PATH" ./git-completion.bash.generate
+
+
+clean:
+	rm -f git-completion.bash
+
diff --git a/contrib/completion/git-completion.bash.generate b/contrib/completion/git-completion.bash.generate
new file mode 100755
index 0000000..fa998dc
--- /dev/null
+++ b/contrib/completion/git-completion.bash.generate
@@ -0,0 +1,128 @@
+#!/bin/bash
+#
+# Generate bash completion for git.
+#
+# Precompute everything that can be known in advance at build time, so that
+# actual bash completion script is loaded faster.
+
+__git_merge_strategies ()
+{
+	git merge -s help 2>&1 |
+	sed -n -e '/[Aa]vailable strategies are: /,/^$/{
+		s/\.$//
+		s/.*://
+		s/^[ 	]*//
+		s/[ 	]*$//
+		p
+	}'
+}
+
+__git_all_commands ()
+{
+	local i IFS=" "$'\n'
+	for i in $(git help -a|egrep '^ ')
+	do
+		case $i in
+		*--*)             : helper pattern;;
+		*) echo $i;;
+		esac
+	done
+}
+
+
+__git_porcelain_commands ()
+{
+	local i IFS=" "$'\n'
+	for i in "help" $(__git_all_commands)
+	do
+		case $i in
+		*--*)             : helper pattern;;
+		applymbox)        : ask gittus;;
+		applypatch)       : ask gittus;;
+		archimport)       : import;;
+		cat-file)         : plumbing;;
+		check-attr)       : plumbing;;
+		check-ref-format) : plumbing;;
+		checkout-index)   : plumbing;;
+		commit-tree)      : plumbing;;
+		count-objects)    : infrequent;;
+		cvsexportcommit)  : export;;
+		cvsimport)        : import;;
+		cvsserver)        : daemon;;
+		daemon)           : daemon;;
+		diff-files)       : plumbing;;
+		diff-index)       : plumbing;;
+		diff-tree)        : plumbing;;
+		fast-import)      : import;;
+		fast-export)      : export;;
+		fsck-objects)     : plumbing;;
+		fetch-pack)       : plumbing;;
+		fmt-merge-msg)    : plumbing;;
+		for-each-ref)     : plumbing;;
+		hash-object)      : plumbing;;
+		http-*)           : transport;;
+		index-pack)       : plumbing;;
+		init-db)          : deprecated;;
+		local-fetch)      : plumbing;;
+		lost-found)       : infrequent;;
+		ls-files)         : plumbing;;
+		ls-remote)        : plumbing;;
+		ls-tree)          : plumbing;;
+		mailinfo)         : plumbing;;
+		mailsplit)        : plumbing;;
+		merge-*)          : plumbing;;
+		mktree)           : plumbing;;
+		mktag)            : plumbing;;
+		pack-objects)     : plumbing;;
+		pack-redundant)   : plumbing;;
+		pack-refs)        : plumbing;;
+		parse-remote)     : plumbing;;
+		patch-id)         : plumbing;;
+		peek-remote)      : plumbing;;
+		prune)            : plumbing;;
+		prune-packed)     : plumbing;;
+		quiltimport)      : import;;
+		read-tree)        : plumbing;;
+		receive-pack)     : plumbing;;
+		reflog)           : plumbing;;
+		repo-config)      : deprecated;;
+		rerere)           : plumbing;;
+		rev-list)         : plumbing;;
+		rev-parse)        : plumbing;;
+		runstatus)        : plumbing;;
+		sh-setup)         : internal;;
+		shell)            : daemon;;
+		show-ref)         : plumbing;;
+		send-pack)        : plumbing;;
+		show-index)       : plumbing;;
+		ssh-*)            : transport;;
+		stripspace)       : plumbing;;
+		symbolic-ref)     : plumbing;;
+		tar-tree)         : deprecated;;
+		unpack-file)      : plumbing;;
+		unpack-objects)   : plumbing;;
+		update-index)     : plumbing;;
+		update-ref)       : plumbing;;
+		update-server-info) : daemon;;
+		upload-archive)   : plumbing;;
+		upload-pack)      : plumbing;;
+		write-tree)       : plumbing;;
+		var)              : infrequent;;
+		verify-pack)      : infrequent;;
+		verify-tag)       : plumbing;;
+		*) echo $i;;
+		esac
+	done
+}
+
+
+__git_merge_strategylist=$(__git_merge_strategies | tr '\n' ' ')
+__git_all_commandlist="$(__git_all_commands | tr '\n' ' ')"
+__git_porcelain_commandlist="$(__git_porcelain_commands | tr '\n' ' ')"
+
+
+sed -e "s/__GIT_MERGE_STRATEGYLIST/\"$__git_merge_strategylist\"/"	\
+    -e "s/__GIT_ALL_COMMANDLIST/\"$__git_all_commandlist\"/"	\
+    -e "s/__GIT_PORCELAIN_COMMANDLIST/\"$__git_porcelain_commandlist\"/"	\
+    git-completion.bash.in > git-completion.bash
+
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash.in
old mode 100755
new mode 100644
similarity index 90%
rename from contrib/completion/git-completion.bash
rename to contrib/completion/git-completion.bash.in
index 88b1b3c..67d03c3
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash.in
@@ -21,13 +21,7 @@
 #    2) Added the following line to your .bashrc:
 #        source ~/.git-completion.sh
 #
-#    3) You may want to make sure the git executable is available
-#       in your PATH before this script is sourced, as some caching
-#       is performed while the script loads.  If git isn't found
-#       at source time then all lookups will be done on demand,
-#       which may be slightly slower.
-#
-#    4) Consider changing your PS1 to also show the current branch:
+#    3) Consider changing your PS1 to also show the current branch:
 #        PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
 #
 #       The argument to __git_ps1 will be displayed only if you
@@ -60,6 +54,21 @@
 #       git@vger.kernel.org
 #
 
+
+# pregenerated stuff (to save load time)
+__git_merge_strategylist=__GIT_MERGE_STRATEGYLIST
+__git_all_commandlist=__GIT_ALL_COMMANDLIST
+__git_porcelain_commandlist=__GIT_PORCELAIN_COMMANDLIST
+
+# remind folks that git-completion.bash.in can't be sourced
+case "$__git_merge_strategylist" in
+__GIT*)
+	echo "E: git-completion.bash.in can't be sourced"
+	return 1 ;;
+esac
+
+
+
 case "$COMP_WORDBREAKS" in
 *:*) : great ;;
 *)   COMP_WORDBREAKS="$COMP_WORDBREAKS:"
@@ -324,23 +333,6 @@ __git_remotes ()
 	done
 }
 
-__git_merge_strategies ()
-{
-	if [ -n "${__git_merge_strategylist-}" ]; then
-		echo "$__git_merge_strategylist"
-		return
-	fi
-	git merge -s help 2>&1 |
-	sed -n -e '/[Aa]vailable strategies are: /,/^$/{
-		s/\.$//
-		s/.*://
-		s/^[ 	]*//
-		s/[ 	]*$//
-		p
-	}'
-}
-__git_merge_strategylist=
-__git_merge_strategylist=$(__git_merge_strategies 2>/dev/null)
 
 __git_complete_file ()
 {
@@ -476,128 +468,19 @@ __git_complete_strategy ()
 {
 	case "${COMP_WORDS[COMP_CWORD-1]}" in
 	-s|--strategy)
-		__gitcomp "$(__git_merge_strategies)"
+		__gitcomp "$__git_merge_strategylist"
 		return 0
 	esac
 	local cur="${COMP_WORDS[COMP_CWORD]}"
 	case "$cur" in
 	--strategy=*)
-		__gitcomp "$(__git_merge_strategies)" "" "${cur##--strategy=}"
+		__gitcomp "$__git_merge_strategylist" "" "${cur##--strategy=}"
 		return 0
 		;;
 	esac
 	return 1
 }
 
-__git_all_commands ()
-{
-	if [ -n "${__git_all_commandlist-}" ]; then
-		echo "$__git_all_commandlist"
-		return
-	fi
-	local i IFS=" "$'\n'
-	for i in $(git help -a|egrep '^ ')
-	do
-		case $i in
-		*--*)             : helper pattern;;
-		*) echo $i;;
-		esac
-	done
-}
-__git_all_commandlist=
-__git_all_commandlist="$(__git_all_commands 2>/dev/null)"
-
-__git_porcelain_commands ()
-{
-	if [ -n "${__git_porcelain_commandlist-}" ]; then
-		echo "$__git_porcelain_commandlist"
-		return
-	fi
-	local i IFS=" "$'\n'
-	for i in "help" $(__git_all_commands)
-	do
-		case $i in
-		*--*)             : helper pattern;;
-		applymbox)        : ask gittus;;
-		applypatch)       : ask gittus;;
-		archimport)       : import;;
-		cat-file)         : plumbing;;
-		check-attr)       : plumbing;;
-		check-ref-format) : plumbing;;
-		checkout-index)   : plumbing;;
-		commit-tree)      : plumbing;;
-		count-objects)    : infrequent;;
-		cvsexportcommit)  : export;;
-		cvsimport)        : import;;
-		cvsserver)        : daemon;;
-		daemon)           : daemon;;
-		diff-files)       : plumbing;;
-		diff-index)       : plumbing;;
-		diff-tree)        : plumbing;;
-		fast-import)      : import;;
-		fast-export)      : export;;
-		fsck-objects)     : plumbing;;
-		fetch-pack)       : plumbing;;
-		fmt-merge-msg)    : plumbing;;
-		for-each-ref)     : plumbing;;
-		hash-object)      : plumbing;;
-		http-*)           : transport;;
-		index-pack)       : plumbing;;
-		init-db)          : deprecated;;
-		local-fetch)      : plumbing;;
-		lost-found)       : infrequent;;
-		ls-files)         : plumbing;;
-		ls-remote)        : plumbing;;
-		ls-tree)          : plumbing;;
-		mailinfo)         : plumbing;;
-		mailsplit)        : plumbing;;
-		merge-*)          : plumbing;;
-		mktree)           : plumbing;;
-		mktag)            : plumbing;;
-		pack-objects)     : plumbing;;
-		pack-redundant)   : plumbing;;
-		pack-refs)        : plumbing;;
-		parse-remote)     : plumbing;;
-		patch-id)         : plumbing;;
-		peek-remote)      : plumbing;;
-		prune)            : plumbing;;
-		prune-packed)     : plumbing;;
-		quiltimport)      : import;;
-		read-tree)        : plumbing;;
-		receive-pack)     : plumbing;;
-		reflog)           : plumbing;;
-		repo-config)      : deprecated;;
-		rerere)           : plumbing;;
-		rev-list)         : plumbing;;
-		rev-parse)        : plumbing;;
-		runstatus)        : plumbing;;
-		sh-setup)         : internal;;
-		shell)            : daemon;;
-		show-ref)         : plumbing;;
-		send-pack)        : plumbing;;
-		show-index)       : plumbing;;
-		ssh-*)            : transport;;
-		stripspace)       : plumbing;;
-		symbolic-ref)     : plumbing;;
-		tar-tree)         : deprecated;;
-		unpack-file)      : plumbing;;
-		unpack-objects)   : plumbing;;
-		update-index)     : plumbing;;
-		update-ref)       : plumbing;;
-		update-server-info) : daemon;;
-		upload-archive)   : plumbing;;
-		upload-pack)      : plumbing;;
-		write-tree)       : plumbing;;
-		var)              : infrequent;;
-		verify-pack)      : infrequent;;
-		verify-tag)       : plumbing;;
-		*) echo $i;;
-		esac
-	done
-}
-__git_porcelain_commandlist=
-__git_porcelain_commandlist="$(__git_porcelain_commands 2>/dev/null)"
-
 __git_aliases ()
 {
 	local i IFS=$'\n'
@@ -1077,7 +960,7 @@ _git_help ()
 		return
 		;;
 	esac
-	__gitcomp "$(__git_all_commands)
+	__gitcomp "$__git_all_commandlist
 		attributes cli core-tutorial cvs-migration
 		diffcore gitk glossary hooks ignore modules
 		repository-layout tutorial tutorial-2
@@ -1423,7 +1306,7 @@ _git_config ()
 		return
 		;;
 	pull.twohead|pull.octopus)
-		__gitcomp "$(__git_merge_strategies)"
+		__gitcomp "$__git_merge_strategylist"
 		return
 		;;
 	color.branch|color.diff|color.interactive|\
@@ -1524,7 +1407,7 @@ _git_config ()
 	pager.*)
 		local pfx="${cur%.*}."
 		cur="${cur#*.}"
-		__gitcomp "$(__git_all_commands)" "$pfx" "$cur"
+		__gitcomp "$__git_all_commandlist" "$pfx" "$cur"
 		return
 		;;
 	remote.*.*)
@@ -2116,7 +1999,7 @@ _git ()
 			--help
 			"
 			;;
-		*)     __gitcomp "$(__git_porcelain_commands) $(__git_aliases)" ;;
+		*)     __gitcomp "$__git_porcelain_commandlist $(__git_aliases)" ;;
 		esac
 		return
 	fi
-- 
1.6.5.rc2.18.g84f98.dirty



From: Kirill Smelkov <kirr@mns.spb.ru>
Date: Fri, 9 Oct 2009 12:45:30 +0400
Subject: [PATCH 2/2] bash: make git-completion.bash.generate bash agnostic

We've just moved some code from git-completion.bash into
git-completion.bash.generate, but as Shawn O. Pearce notes, this code is
now used at compile time, so we shouldn't assume bash is avalable.

In more details: we used IFS=" "$'\n' which works in bash, but not e.g.
in dash, but it turns out that we can avoid setting IFS at all, look:

    $ ./git help -a | egrep '^ '
               [-p|--paginate|--no-pager]
               [--bare] [--git-dir=GIT_DIR] [--work-tree=GIT_WORK_TREE]
               [--help] COMMAND [ARGS]
      add                    get-tar-commit-id      rebase
      add--interactive       grep                   rebase--interactive
      am                     gui                    receive-pack
      ...

First, there are some unneedded lines, with e.g. [--bare], and this does
produce noise, since e.g. in bash

    $ for i in "[--bare]"; do echo $i ; done
    a b

so we kill it though grepping more explicitely:

    $ ./git help -a | egrep '^  [^ ]'
      add                    get-tar-commit-id      rebase
      add--interactive       grep                   rebase--interactive
      am                     gui                    receive-pack
      ...

And then, plain "for in in $(git help -a|egrep '^ [^ ]')" works in both
bash and dash, which was the goal.

Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru>
---
 contrib/completion/git-completion.bash.generate |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/contrib/completion/git-completion.bash.generate b/contrib/completion/git-completion.bash.generate
index fa998dc..04460eb 100755
--- a/contrib/completion/git-completion.bash.generate
+++ b/contrib/completion/git-completion.bash.generate
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 #
 # Generate bash completion for git.
 #
@@ -19,8 +19,8 @@ __git_merge_strategies ()
 
 __git_all_commands ()
 {
-	local i IFS=" "$'\n'
-	for i in $(git help -a|egrep '^ ')
+	local i
+	for i in $(git help -a|egrep '^  [^ ]')
 	do
 		case $i in
 		*--*)             : helper pattern;;
@@ -32,7 +32,7 @@ __git_all_commands ()
 
 __git_porcelain_commands ()
 {
-	local i IFS=" "$'\n'
+	local i
 	for i in "help" $(__git_all_commands)
 	do
 		case $i in
-- 
1.6.5.rc2.18.g84f98.dirty

^ permalink raw reply related

* [PATCH 0/9] Documentation tweaks
From: Jonathan Nieder @ 2009-10-09 10:14 UTC (permalink / raw)
  To: git

Hi gitsters,

Here are some small documentation patches that have been sitting in
my tree for a while.  Most important is the first one, which makes it
easier to find the appropriate options for building documentation
from source on a new machine.

Perhaps they could be of some use.  I look forward to your thoughts.

Jonathan Nieder (9):
  Describe DOCBOOK_XSL_172, ASCIIDOC_NO_ROFF options in Makefile
  Documentation: git fmt-merge-message is not a script
  Documentation: fix singular/plural mismatch
  Documentation: say "the same" instead of "equal"
  Documentation: clone: clarify discussion of initial branch
  Documentation: branch: update --merged description
  Documentation: clarify branch creation
  Documentation: clarify "working tree" definition
  racy-git.txt: explain nsec problem in more detail

 Documentation/config.txt             |    2 +-
 Documentation/git-branch.txt         |   27 ++++++++++++++++-----------
 Documentation/git-clone.txt          |    3 ++-
 Documentation/git-fmt-merge-msg.txt  |    2 +-
 Documentation/git-merge.txt          |   11 ++++++-----
 Documentation/glossary-content.txt   |    6 +++---
 Documentation/technical/racy-git.txt |   10 ++++++----
 Makefile                             |    6 +++++-
 8 files changed, 40 insertions(+), 27 deletions(-)

^ permalink raw reply

* [PATCH 2/9] Documentation: git fmt-merge-message is not a script
From: Jonathan Nieder @ 2009-10-09 10:16 UTC (permalink / raw)
  To: git
In-Reply-To: <20091009101400.GA16549@progeny.tock>

The fmt-merge-message builtin is usually invoked as
"git fmt-merge-message" rather than through the hard link in
GIT_EXEC_PATH.  Although this is unlikely to confuse most script
writers, it should not hurt to make the documentation a little
clearer anyway.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
 Documentation/git-fmt-merge-msg.txt |    2 +-
 Documentation/git-merge.txt         |    7 ++++---
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/Documentation/git-fmt-merge-msg.txt b/Documentation/git-fmt-merge-msg.txt
index 1c24796..0067805 100644
--- a/Documentation/git-fmt-merge-msg.txt
+++ b/Documentation/git-fmt-merge-msg.txt
@@ -18,7 +18,7 @@ Takes the list of merged objects on stdin and produces a suitable
 commit message to be used for the merge commit, usually to be
 passed as the '<merge-message>' argument of 'git-merge'.
 
-This script is intended mostly for internal use by scripts
+This command is intended mostly for internal use by scripts
 automatically invoking 'git-merge'.
 
 OPTIONS
diff --git a/Documentation/git-merge.txt b/Documentation/git-merge.txt
index af68d69..354e9d9 100644
--- a/Documentation/git-merge.txt
+++ b/Documentation/git-merge.txt
@@ -28,9 +28,10 @@ OPTIONS
 include::merge-options.txt[]
 
 -m <msg>::
-	The commit message to be used for the merge commit (in case
-	it is created). The 'git-fmt-merge-msg' script can be used
-	to give a good default for automated 'git-merge' invocations.
+	Set the commit message to be used for the merge commit (in
+	case one is created). The 'fmt-merge-msg' Git command can be
+	used to give a good default for automated 'git-merge'
+	invocations.
 
 <remote>...::
 	Other branch heads to merge into our branch.  You need at
-- 
1.6.5.rc1.199.g596ec

^ permalink raw reply related


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