Git development
 help / color / mirror / Atom feed
* Re: git hooks to run something
From: Jeff King @ 2009-03-25 11:25 UTC (permalink / raw)
  To: Alf Clement; +Cc: git
In-Reply-To: <556d90580903250333l496520ao5fde64fb08faf9ae@mail.gmail.com>

[re-adding git@vger to cc; please keep questions on-list so that others
can also help to answer]

On Wed, Mar 25, 2009 at 11:33:39AM +0100, Alf Clement wrote:

> is there a way to push a modified hook script with the repository when
> I push it to a server?
> And how to get it with pull?

No; for security reasons, no code (including hooks) from remote
repositories is automatically run. The usual method is to include the
hook in your repository and copy it into place after cloning.

-Peff

^ permalink raw reply

* Re: [TopGit PATCH] tg-tred: Print the transitive reduction of the  dependecies
From: Bert Wesarg @ 2009-03-25 11:24 UTC (permalink / raw)
  To: Uwe Kleine-König; +Cc: Petr Baudis, git, martin f krafft
In-Reply-To: <36ca99e90903250420l42a46718x91263b4adb7da45f@mail.gmail.com>

>> if master is redundant.  Is this asserted?
> I asked this myself, I haven't looked very deeply but I think it is
> stable. And some tests showed this.
BTW: Because of this uncertainty I implemented it so, that it just
shows the reduced dep list not alter the current one. Anyway, you can
always check what changed with my diff example.

^ permalink raw reply

* Re: [TopGit PATCH] tg-tred: Print the transitive reduction of the  dependecies
From: Bert Wesarg @ 2009-03-25 11:20 UTC (permalink / raw)
  To: Uwe Kleine-König; +Cc: Petr Baudis, git, martin f krafft
In-Reply-To: <20090325105841.GB27803@pengutronix.de>

2009/3/25 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>:
> Hello,
>
> On Wed, Mar 25, 2009 at 11:35:41AM +0100, Bert Wesarg wrote:
>> +$tg summary --graphviz |
>> +     tred |
>> +     gvpr -a "\"${name}\"" '
>> +BEG_G {
>> +    node_t  ctr;
>> +    edge_t  e;
>> +
>> +    ctr = isNode($, ARGV[0]);
>> +    for (e = fstedge(ctr); e; e = nxtedge(e,ctr)) {
>> +        if (e.head.name != ARGV[0])
>> +            printf("%s\n", e.head.name);
>> +    }
>> +    exit(0);
>> +}
> I don't know tred and gvpr, just looked shortly over the manpages.
> Anyhow what I consider important is that the order of .topdeps is
> stable.  That is
>
>        t/topic1
>        master
>        t/topic2
>
> must not be rewritten to
>
>        t/topic2
>        t/topic1
>
> if master is redundant.  Is this asserted?
I asked this myself, I haven't looked very deeply but I think it is
stable. And some tests showed this.

>
> And note that I intend to change the semantic of tg summary s.t. it only
> recurses on the current branch instead of all branches.  I think this
> doesn't hurt here, though.
I don't understand and can't confirm this. tg summary calls 'git
for-each-ref refs/top-bases' so all TopGit controlled branches should
be reached.

While I was adding a 'reduce' subcommand to tg-depend (which calls
tg-tred and updates .topdeps) I saw that it is immposible to add a
none TopGit controlled branch to the dependency list, which looks
wrong. Dependencies don't need to be TopGit controlled, like master.

Bert

>
> Best regards and thanks for your contribution,
> Uwe

^ permalink raw reply

* [PATCH 2/2] init: support --fast-import using "git fast-import" as backend
From: Nguyễn Thái Ngọc Duy @ 2009-03-25 11:01 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

I was curious to see how git-import script performed in C version.
The result is quite good (only tried once so might be incorrect).
The patch is not ready for submission though. Sorry for patch numbering,
forgot to add "-n".

Tests were performed with "echo 3 > /proc/sys/vm/drop_caches". Test repo is
gentoo-x86, which consists of ~11k small text files.

~/t/gentoo-x86 $ time ~/git/git/git init -M
Initialized empty Git repository in /home/pclouds/t/gentoo-x86/.git/

real    7m30.663s
user    0m33.171s
sys     3m31.599s
~/t/gentoo-x86 $ du -s .git
73700   .git
~/t/gentoo-x86 $ find .git/|wc -l
31
~/t/gentoo-x86 $ git ls-files|wc -l
113012

~/t/gentoo-x86 $ rm .git/ -rf
~/t/gentoo-x86 $ time ~/git/git/git init -m
Initialized empty Git repository in /home/pclouds/t/gentoo-x86/.git/

real    10m5.114s
user    0m13.718s
sys     3m50.317s
~/t/gentoo-x86 $ du -s .git
521960  .git
~/t/gentoo-x86 $ find .git/|wc -l
123275

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin-init-db.c |  108 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 105 insertions(+), 3 deletions(-)

diff --git a/builtin-init-db.c b/builtin-init-db.c
index 3ace4ca..42c126c 100644
--- a/builtin-init-db.c
+++ b/builtin-init-db.c
@@ -386,6 +386,105 @@ static int import_files(const char *import_message)
 	return run_command_v_opt(args, RUN_GIT_CMD);
 }
 
+static void fast_import_recursive(int fdo, const char *path)
+{
+	DIR *fdir;
+	char fullname[PATH_MAX + 1];
+	int len, dtype, fdi;
+	struct dirent *de;
+	struct stat st;
+	const char *fdir_path;
+	char buf[4096];
+	int buflen;
+	struct strbuf s;
+
+	fdir_path = path ? path : ".";
+	fdir = opendir(fdir_path);
+	if (!fdir)
+		die("Could not open directory %s", fdir_path);
+
+	if (path) {
+		len = strlen(path);
+		memcpy(fullname, path, len);
+		fullname[len++] = '/';
+	}
+	else
+		len = 0;
+	strbuf_init(&s, 32);
+	while ((de = readdir(fdir)) != NULL) {
+		if (!strcmp(de->d_name, ".") ||
+		    !strcmp(de->d_name, "..") ||
+		    !strcmp(de->d_name, ".git"))
+			continue;
+		dtype = DTYPE(de);
+		memcpy(fullname+len, de->d_name, de->d_reclen+1);
+		if (lstat(fullname, &st))
+			die("Could not stat %s", fullname);
+		if (dtype == DT_UNKNOWN) {
+			if (S_ISREG(st.st_mode))
+				dtype = DT_REG;
+			if (S_ISDIR(st.st_mode))
+				dtype = DT_DIR;
+			if (S_ISLNK(st.st_mode))
+				dtype = DT_LNK;
+		}
+		switch (dtype) {
+		case DT_DIR:
+			fast_import_recursive(fdo, fullname);
+			break;
+		case DT_LNK:
+		case DT_REG:
+			fdi = open(fullname, O_RDONLY);
+			if (fdi == -1)
+				die("Could not open %s", fullname);
+			strbuf_setlen(&s, 0);
+			strbuf_addf(&s,"M 100644 inline %s\n", fullname);
+			strbuf_addf(&s, "data %u\n", (unsigned int)st.st_size); /* FIXME: large file */
+			write_or_die(fdo, s.buf, s.len);
+			while ((buflen = xread(fdi, buf, sizeof(buf))) > 0)
+				write_or_die(fdo, buf, buflen);
+			close(fdi);
+			write_or_die(fdo, "\n", 1);
+			break;
+		}
+	}
+	strbuf_release(&s);
+	closedir(fdir);
+}
+
+#define FAST_IMPORT_DEBUG 0
+
+static int fast_import_files(const char *import_message)
+{
+	struct child_process p;
+	const char *argv[4] = {"fast-import", "--quiet", "--date-format=raw", NULL};
+	struct strbuf s;
+
+	memset(&p, 0, sizeof(p));
+	p.argv = argv;
+	p.in = -1;
+	p.git_cmd = 1;
+#if FAST_IMPORT_DEBUG
+	p.in = 1;
+#else
+	if (start_command(&p))
+		die("Could not spawn fast-import");
+#endif
+	strbuf_init(&s, 64);
+	strbuf_addstr(&s, "commit refs/heads/master\n");
+	strbuf_addf(&s,   "committer %s\n", git_committer_info(0));
+	strbuf_addf(&s,   "data <<MSGEND\n%s\nMSGEND\n", import_message);
+	write_or_die(p.in, s.buf, s.len);
+	strbuf_release(&s);
+	fast_import_recursive(p.in, NULL);
+#if !FAST_IMPORT_DEBUG
+	close(p.in);
+	if (finish_command(&p))
+		die("fast-import died");
+#endif
+	return 0;
+}
+
 static const char init_db_usage[] =
 "git init [-q | --quiet] [--bare] [--template=<template-directory>] [--shared[=<permissions>]] [-m|--import [<message>]]";
 
@@ -401,7 +500,7 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
 	const char *template_dir = NULL;
 	unsigned int flags = 0;
 	const char *import_message = NULL;
-	int ret, i;
+	int ret, i, fast_import = 0;
 
 	for (i = 1; i < argc; i++, argv++) {
 		const char *arg = argv[1];
@@ -416,7 +515,10 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
 			init_shared_repository = PERM_GROUP;
 		else if (!prefixcmp(arg, "--shared="))
 			init_shared_repository = git_config_perm("arg", arg+9);
-		else if (!strcmp(arg, "--import") || !strcmp(arg, "-m")) {
+		else if (!strcmp(arg, "--import") || !strcmp(arg, "-m") ||
+			 !strcmp(arg, "--fast-import") || !strcmp(arg, "-M")) {
+			if (!strcmp(arg, "--fast-import") || !strcmp(arg, "-M"))
+				fast_import = 1;
 			if (i+1 >= argc)
 				import_message = "Initial commit";
 			else {
@@ -481,5 +583,5 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
 		return ret;
 	if (reinit)
 		die("--import does not work with already initialized repository");
-	return import_files(import_message);
+	return fast_import ? fast_import_files(import_message) : import_files(import_message);
 }
-- 
1.6.1.446.gc7851

^ permalink raw reply related

* [PATCH 1/2] init: support --import to add all files and commit right after init
From: Nguyễn Thái Ngọc Duy @ 2009-03-25 10:58 UTC (permalink / raw)
  To: git, Johannes Schindelin, Jeff King; +Cc: Nguyễn Thái Ngọc Duy

This is equivalent to "git init;git add .;git commit -q -m blah".
I find myself doing that too many times, hence this shortcut.

In future, --fast-import support would also be nice if the import
directory has a lot of files.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 Documentation/git-init.txt |   17 ++++++++++++++-
 builtin-init-db.c          |   49 ++++++++++++++++++++++++++++++++++++++++---
 t/t0001-init.sh            |   44 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 105 insertions(+), 5 deletions(-)

diff --git a/Documentation/git-init.txt b/Documentation/git-init.txt
index 71749c0..ab75c10 100644
--- a/Documentation/git-init.txt
+++ b/Documentation/git-init.txt
@@ -8,7 +8,8 @@ git-init - Create an empty git repository or reinitialize an existing one
 
 SYNOPSIS
 --------
-'git init' [-q | --quiet] [--bare] [--template=<template_directory>] [--shared[=<permissions>]]
+'git init' [-q | --quiet] [--bare] [--template=<template_directory>]
+           [--shared[=<permissions>]] [-m|--import [<message>]]
 
 
 OPTIONS
@@ -68,6 +69,20 @@ By default, the configuration flag receive.denyNonFastForwards is enabled
 in shared repositories, so that you cannot force a non fast-forwarding push
 into it.
 
+-m <message>::
+--import <message>::
+
+Commit everything to the newly initialized repository. This is equivalent to:
+
+----------------
+$ git init
+$ git add .
+$ git commit -q -m <message>
+----------------
+
+If no message is given, "Initial commit" will be used.
+This option does not work with `--bare` nor already initialized repository.
+
 --
 
 
diff --git a/builtin-init-db.c b/builtin-init-db.c
index ee3911f..3ace4ca 100644
--- a/builtin-init-db.c
+++ b/builtin-init-db.c
@@ -6,6 +6,7 @@
 #include "cache.h"
 #include "builtin.h"
 #include "exec_cmd.h"
+#include "run-command.h"
 
 #ifndef DEFAULT_GIT_TEMPLATE_DIR
 #define DEFAULT_GIT_TEMPLATE_DIR "/usr/share/git-core/templates"
@@ -19,6 +20,7 @@
 
 static int init_is_bare_repository = 0;
 static int init_shared_repository = -1;
+static int reinit;
 
 static void safe_create_dir(const char *dir, int share)
 {
@@ -279,7 +281,7 @@ int init_db(const char *template_dir, unsigned int flags)
 {
 	const char *sha1_dir;
 	char *path;
-	int len, reinit;
+	int len;
 
 	safe_create_dir(get_git_dir(), 0);
 
@@ -363,8 +365,29 @@ static int guess_repository_type(const char *git_dir)
 	return 1;
 }
 
+static int import_files(const char *import_message)
+{
+	const char *args[6];
+	int i = 0;
+	int ret;
+
+	args[i++] = "add";
+	args[i++] = ".";
+	args[i] = NULL;
+	ret = run_command_v_opt(args, RUN_GIT_CMD);
+	if (ret)
+		return ret;
+	i = 0;
+	args[i++] = "commit";
+	args[i++] = "-q";
+	args[i++] = "-m";
+	args[i++] = import_message;
+	args[i] = NULL;
+	return run_command_v_opt(args, RUN_GIT_CMD);
+}
+
 static const char init_db_usage[] =
-"git init [-q | --quiet] [--bare] [--template=<template-directory>] [--shared[=<permissions>]]";
+"git init [-q | --quiet] [--bare] [--template=<template-directory>] [--shared[=<permissions>]] [-m|--import [<message>]]";
 
 /*
  * If you want to, you can share the DB area with any number of branches.
@@ -377,7 +400,8 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
 	const char *git_dir;
 	const char *template_dir = NULL;
 	unsigned int flags = 0;
-	int i;
+	const char *import_message = NULL;
+	int ret, i;
 
 	for (i = 1; i < argc; i++, argv++) {
 		const char *arg = argv[1];
@@ -392,12 +416,24 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
 			init_shared_repository = PERM_GROUP;
 		else if (!prefixcmp(arg, "--shared="))
 			init_shared_repository = git_config_perm("arg", arg+9);
+		else if (!strcmp(arg, "--import") || !strcmp(arg, "-m")) {
+			if (i+1 >= argc)
+				import_message = "Initial commit";
+			else {
+				import_message = argv[2];
+				i++;
+				argv++;
+			}
+		}
 		else if (!strcmp(arg, "-q") || !strcmp(arg, "--quiet"))
 			flags |= INIT_DB_QUIET;
 		else
 			usage(init_db_usage);
 	}
 
+	if (import_message && is_bare_repository_cfg == 1)
+		die("--import does not work with --bare");
+
 	/*
 	 * GIT_WORK_TREE makes sense only in conjunction with GIT_DIR
 	 * without --bare.  Catch the error early.
@@ -440,5 +476,10 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
 
 	set_git_dir(make_absolute_path(git_dir));
 
-	return init_db(template_dir, flags);
+	ret = init_db(template_dir, flags);
+	if (ret || !import_message)
+		return ret;
+	if (reinit)
+		die("--import does not work with already initialized repository");
+	return import_files(import_message);
 }
diff --git a/t/t0001-init.sh b/t/t0001-init.sh
index 5ac0a27..83a9e06 100755
--- a/t/t0001-init.sh
+++ b/t/t0001-init.sh
@@ -199,4 +199,48 @@ test_expect_success 'init honors global core.sharedRepository' '
 	x`git config -f shared-honor-global/.git/config core.sharedRepository`
 '
 
+test_expect_success 'init --import does not work with --bare' '
+	(
+		unset GIT_DIR GIT_WORK_TREE GIT_CONFIG
+		mkdir init-import-bare.git &&
+		cd init-import-bare.git &&
+		! git init --bare --import test
+	)
+
+'
+
+test_expect_success 'init --import no message' '
+	(
+		test_tick
+		unset GIT_DIR GIT_WORK_TREE GIT_CONFIG
+		mkdir init-import-nomsg &&
+		cd init-import-nomsg &&
+		touch foo bar &&
+		git init --import &&
+		test "$(git rev-parse HEAD)" = 4ff955458fd61a7b5d798b81e28c9249e8ebb5df
+	)
+'
+
+test_expect_success 'init --import' '
+	(
+		test_tick
+		unset GIT_DIR GIT_WORK_TREE GIT_CONFIG
+		mkdir init-import &&
+		cd init-import &&
+		touch foo bar &&
+		git init --import test &&
+		test "$(git rev-parse HEAD)" = 758aa5a579e42200a6fd4e4964c7e1dc1875d67d
+	)
+'
+
+test_expect_success 'init --import on already init(ed) should fail' '
+	(
+		test_tick
+		unset GIT_DIR GIT_WORK_TREE GIT_CONFIG
+		cd init-import &&
+		! git init --import testagain &&
+		test "$(git rev-parse HEAD)" = 758aa5a579e42200a6fd4e4964c7e1dc1875d67d
+	)
+'
+
 test_done
-- 
1.6.1.446.gc7851

^ permalink raw reply related

* Re: [TopGit PATCH] tg-tred: Print the transitive reduction of the dependecies
From: Uwe Kleine-König @ 2009-03-25 10:58 UTC (permalink / raw)
  To: Bert Wesarg; +Cc: Petr Baudis, git, martin f krafft
In-Reply-To: <1237977341-32173-1-git-send-email-bert.wesarg@googlemail.com>

Hello,

On Wed, Mar 25, 2009 at 11:35:41AM +0100, Bert Wesarg wrote:
> +$tg summary --graphviz |
> +	tred |
> +	gvpr -a "\"${name}\"" '
> +BEG_G {
> +    node_t  ctr;
> +    edge_t  e;
> +
> +    ctr = isNode($, ARGV[0]);
> +    for (e = fstedge(ctr); e; e = nxtedge(e,ctr)) {
> +        if (e.head.name != ARGV[0])
> +            printf("%s\n", e.head.name);
> +    }
> +    exit(0);
> +}
I don't know tred and gvpr, just looked shortly over the manpages.
Anyhow what I consider important is that the order of .topdeps is
stable.  That is

	t/topic1
	master
	t/topic2

must not be rewritten to

	t/topic2
	t/topic1

if master is redundant.  Is this asserted?

Moreover I wonder if the gvpr program could be optimized when E is used
instead of BEG_G, but as I said above, I don't know how gvpr works.

And note that I intend to change the semantic of tg summary s.t. it only
recurses on the current branch instead of all branches.  I think this
doesn't hurt here, though.

Best regards and thanks for your contribution,
Uwe

-- 
Pengutronix e.K.                              | Uwe Kleine-König            |
Industrial Linux Solutions                    | http://www.pengutronix.de/  |

^ permalink raw reply

* Re: fatal: unable to write sha1 file git 1.6.2.1
From: Peter @ 2009-03-25 10:52 UTC (permalink / raw)
  To: Linus Torvalds, git
In-Reply-To: <alpine.LFD.2.00.0903241510010.3032@localhost.localdomain>


>
> Here's an idea: if this is reproducible for you, does the behavior change 
> if you do
>
> 	[core]
> 		core.fsyncobjectfiles = true
>
>   
Yes, that works !
Thanks a lot !

Peter

^ permalink raw reply

* [TopGit PATCH] tg-tred: Print the transitive reduction of the dependecies
From: Bert Wesarg @ 2009-03-25 10:35 UTC (permalink / raw)
  To: Petr Baudis; +Cc: Bert Wesarg, git, martin f krafft, u.kleine-koenig

This uses the tred(1) and gvpr(1) program from the graphviz package to reduce
the dependencies of the given TopGit branch.

Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>

---
 .gitignore |    2 ++
 README     |   22 ++++++++++++++++++++++
 tg-tred.sh |   47 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 71 insertions(+), 0 deletions(-)

diff --git a/.gitignore b/.gitignore
index eb56446..1061d93 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,6 +13,8 @@
 /tg-patch.txt
 /tg-summary
 /tg-summary.txt
+/tg-tred
+/tg-tred.txt
 /tg-update
 /tg-update.txt
 /tg-export
diff --git a/README b/README
index d2f095d..a941cb6 100644
--- a/README
+++ b/README
@@ -480,6 +480,28 @@ tg update
 
 	TODO: tg update -a for updating all topic branches
 
+tg tred
+~~~~~~~
+	Prints the transitive reduction of the dependecies for the current
+	or named TopGit branch.
+
+	To actually use this reduced dependencies list, feed the output into
+	the .topdeps file, commit and run tg update, like:
+
+	$ tg tred > .topdeps
+	$ tg add -f .topdeps
+	$ git commit -m "transitive reduce TopGit dependencies"
+	$ tg update
+
+	If you want to see the differences to the current dependencies, run
+	this:
+
+	$ diff -u -L current -L tred <(git show :.topdeps) <(tg tred)
+
+	TODO: tg tred -a for reducing all branches
+	TODO: tg tred -r for reducing recursive all from the current/named
+	      branch
+
 TODO: tg rename
 
 
diff --git a/tg-tred.sh b/tg-tred.sh
new file mode 100644
index 0000000..f41e051
--- /dev/null
+++ b/tg-tred.sh
@@ -0,0 +1,47 @@
+#!/bin/sh
+# TopGit - A different patch queue manager
+# (c) Petr Baudis <pasky@suse.cz>              2008
+# (c) Bert Wesarg <bert.wesarg@googlemail.com> 2009
+# GPLv2
+
+name=
+
+
+## Parse options
+
+while [ -n "$1" ]; do
+	arg="$1"; shift
+	case "$arg" in
+	-*)
+		echo "Usage: tg [...] tred [NAME]" >&2
+		exit 1;;
+	*)
+		[ -z "$name" ] || die "name already specified ($name)"
+		name="$arg";;
+	esac
+done
+
+[ -n "$name" ] || name="$(git symbolic-ref HEAD | sed 's#^refs/\(heads\|top-bases\)/##')"
+base_rev="$(git rev-parse --short --verify "refs/top-bases/$name" 2>/dev/null)" ||
+	die "not a TopGit-controlled branch"
+
+type tred >/dev/null 2>&1 ||
+	die "need the tred(1) tool from the graphviz package"
+type gvpr >/dev/null 2>&1 ||
+	die "need the gvpr(1) tool from the graphviz package"
+
+$tg summary --graphviz |
+	tred |
+	gvpr -a "\"${name}\"" '
+BEG_G {
+    node_t  ctr;
+    edge_t  e;
+
+    ctr = isNode($, ARGV[0]);
+    for (e = fstedge(ctr); e; e = nxtedge(e,ctr)) {
+        if (e.head.name != ARGV[0])
+            printf("%s\n", e.head.name);
+    }
+    exit(0);
+}
+'
-- 
tg: (fcb488d..) bw/tred (depends on: master)

^ permalink raw reply related

* Re: [StGit PATCH] Add the --merged option to goto
From: Catalin Marinas @ 2009-03-25 10:24 UTC (permalink / raw)
  To: Karl Hasselström; +Cc: git
In-Reply-To: <20090325090541.GA24889@diana.vm.bytemark.co.uk>

2009/3/25 Karl Hasselström <kha@treskal.com>:
> On 2009-03-24 15:40:10 +0000, Catalin Marinas wrote:
>> Whatever is in the index after the check_merged() function doesn't
>> correspond to any tree so it would need to be re-read.
>
> It does correspond to _some_ tree, but as we have no particular reason
> to expect that it might be a tree that we're going to need again
> immediately, we can set temp_index_tree to None to force re-reading,
> rather than pay the cost of write_tree.

Yes, that's what I meant by "doesn't correspond to any tree".

BTW, why don't we keep the tree information directly in the Index
object? Since this object is modified only via its own interface, it
can do all the checks and avoid the managing of temp_index_tree in the
Transaction object.

>> +    def check_merged(self, patches):
>> +        """Return a subset of patches already merged."""
>> +        merged = []
>> +        self.temp_index.read_tree(self.stack.head.data.tree)
>> +        # The self.temp_index is modified by apply_treediff() so force
>> +        # read_tree() the next time merge() is used.
>> +        self.temp_index_tree = None
>> +        for pn in reversed(patches):
>> +            # check whether patch changes can be reversed in the current index
>> +            cd = self.patches[pn].data
>> +            if cd.is_nochange():
>> +                continue
>> +            try:
>> +                self.temp_index.apply_treediff(cd.tree, cd.parent.data.tree,
>> +                                               quiet = True)
>> +                merged.append(pn)
>> +            except git.MergeException:
>> +                pass
>> +        return merged
>
> Some points here:
>
>  1. Check if temp_index_tree already contains the tree you want
>     instead of doing read_tree unconditionally. That is, change
>
>       self.temp_index.read_tree(self.stack.head.data.tree)
>
>     to
>
>       if self.stack.head.data.tree != self.temp_index_tree:
>           self.temp_index.read_tree(self.stack.head.data.tree)
>           self.temp_index_tree = self.stack.head.data.tree
>
>  2. If apply_treediff fails (raises MergeException), the index wasn't
>     modified at all (but I guess you knew that, since your code
>     relies on that fact), so there's no reason to set temp_index_tree
>     to None in that case. So in order to not clear temp_index_tree
>     unnecessarily in case none of the patches reverse-apply (a case I
>     personally encounter frequently, since I leave the -m flag on all
>     the time), move
>
>       self.temp_index_tree = None
>
>     to just after (or just before) "merged.append(pn)".

Yes. But it may be even better to do this in Index.
Index.apply_treediff() would set the tree to None and read_tree or
write_tree would set it to the corresponding tree.

>  3. Why are empty patches considered not merged?

They would be reported as empty anyway and in general you don't submit
empty patches for upstream merging.

-- 
Catalin

^ permalink raw reply

* Re: [PATCH] Documentation: minor consistency fixes in   git-difftool.txt.
From: Michael J Gruber @ 2009-03-25 10:21 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: David Aguilar, git
In-Reply-To: <7vocvq842a.fsf@gitster.siamese.dyndns.org>

Junio C Hamano venit, vidit, dixit 25.03.2009 08:17:
> David Aguilar <davvid@gmail.com> writes:
> 
>> Signed-off-by: David Aguilar <davvid@gmail.com>
>> ---
>>  Documentation/git-difftool.txt |    6 +++---
>>  1 files changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/Documentation/git-difftool.txt b/Documentation/git-difftool.txt
>> index 5ae02f8..23070c1 100644
>> --- a/Documentation/git-difftool.txt
>> +++ b/Documentation/git-difftool.txt
>> @@ -12,7 +12,7 @@ SYNOPSIS
>>  DESCRIPTION
>>  -----------
>>  'git-difftool' is a git command that allows you to compare and edit files
>> -between revisions using common diff tools.  'git difftool' is a frontend
>> +between revisions using common diff tools.  'git-difftool' is a frontend
> 
> I thought that the recent trend is to spell these as 'git difftool' (two
> separate words), although I didn't follow the discussion on quoting styles
> closely, so I do not know which of sq, dq or backtick is preferred.
> 
> Can somebody help me out here?
> 

I'd say it's backticks for commands/code, but I think discussion about a
style guide is still on.

Michael

^ permalink raw reply

* Re: [PATCH 1/2] Documentation/Makefile: make most operations "quiet"
From: Chris Johnsen @ 2009-03-25  9:55 UTC (permalink / raw)
  To: Jeff King; +Cc: git, Chris Johnsen
In-Reply-To: <20090325042842.GB15498@coredump.intra.peff.net>

On 2009 Mar 24, at 23:28, Jeff King wrote:
> On Tue, Mar 24, 2009 at 11:21:39PM -0500, Chris Johnsen wrote:
>
> >  technical/api-index.txt: technical/api-index-skel.txt \
> > -	technical/api-index.sh $(patsubst %,%.txt,$(API_DOCS))
> > +	$(QUIET_GEN)technical/api-index.sh $(patsubst %,%.txt,$(API_DOCS)) && \
> >  	cd technical && sh ./api-index.sh
>
> What's going on here? The line you remove is part of the dependencies,
> but you replace it with a line of build instructions (and make barfs, of
> course).

Yes, I botched that one. The QUIET_GEN should have been on the
next line. Thanks for catching it. I fixed it along with error
propagation and initially-also-botched "&& chaining" for
gitman.texi. I also added QUIET_XSLTPROC for user-manual.html.

I tested the man, html, info, and git-add.texi targets
(previously I only ran man and info targets; git-add.texi
exercises a rule not otherwise used in the usual targets).

An interdiff from "v1" to what I have now follows (it include
parts that would be in 1/2 and 2/2 from "v1").

-- >8 --
 Documentation/Makefile |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git c/Documentation/Makefile w/Documentation/Makefile
index 373a2cc..d145372 100644
--- c/Documentation/Makefile
+++ w/Documentation/Makefile
@@ -92,6 +92,7 @@ ifndef V
 	QUIET_DB2TEXI	= @echo '   ' DB2TEXI $@;
 	QUIET_MAKEINFO	= @echo '   ' MAKEINFO $@;
 	QUIET_DBLATEX	= @echo '   ' DBLATEX $@;
+	QUIET_XSLTPROC	= @echo '   ' XSLTPROC $@;
 	QUIET_GEN	= @echo '   ' GEN $@;
 	QUIET_STDERR	= 2> /dev/null
 	QUIET_SUBDIR0	= +@subdir=
@@ -202,8 +203,8 @@ user-manual.xml: user-manual.txt user-manual.conf
 	$(QUIET_ASCIIDOC)$(ASCIIDOC) -b docbook -d book $<
 
 technical/api-index.txt: technical/api-index-skel.txt \
-	$(QUIET_GEN)technical/api-index.sh $(patsubst %,%.txt,$(API_DOCS)) && \
-	cd technical && sh ./api-index.sh
+	technical/api-index.sh $(patsubst %,%.txt,$(API_DOCS))
+	$(QUIET_GEN)cd technical && sh ./api-index.sh
 
 $(patsubst %,%.html,$(API_DOCS) technical/api-index): %.html : %.txt
 	$(QUIET_ASCIIDOC)$(ASCIIDOC) -b xhtml11 -f asciidoc.conf \
@@ -213,7 +214,7 @@ XSLT = docbook.xsl
 XSLTOPTS = --xinclude --stringparam html.stylesheet docbook-xsl.css
 
 user-manual.html: user-manual.xml
-	xsltproc $(XSLTOPTS) -o $@ $(XSLT) $<
+	$(QUIET_XSLTPROC)xsltproc $(XSLTOPTS) -o $@ $(XSLT) $<
 
 git.info: user-manual.texi
 	$(QUIET_MAKEINFO)$(MAKEINFO) --no-split -o $@ user-manual.texi
@@ -233,7 +234,7 @@ user-manual.pdf: user-manual.xml
 gitman.texi: $(MAN_XML) cat-texi.perl
 	$(QUIET_DB2TEXI)$(RM) $@+ $@ && \
 	($(foreach xml,$(MAN_XML),$(DOCBOOK2X_TEXI) --encoding=UTF-8 \
-		--to-stdout $(xml) &&) true) > $@++
+		--to-stdout $(xml) &&) true) > $@++ && \
 	$(PERL_PATH) cat-texi.perl $@ <$@++ >$@+ && \
 	rm $@++ && \
 	mv $@+ $@

^ permalink raw reply related

* [BUG] Infinite loop in git send-email if ran non-interactively.
From: Matthieu Moy @ 2009-03-25  9:36 UTC (permalink / raw)
  To: git, Jay Soffian

Hi,

I've been hit by c1f2aa45b (send-email: add --confirm option and
configuration setting) running git send-email from a cron job.

The problem is that the cron job is ran non-interactively, and
therefore the confirmation question in git-send-email.perl goes
infinite loop:

		while (1) {
			chomp ($_ = $term->readline(
				"Send this email? ([y]es|[n]o|[q]uit|[a]ll): "
			));
                        print "answer=$_.\n";
			last if /^(?:yes|y|no|n|quit|q|all|a)/i;
			print "\n";
		}

Infinite loop is bad, but it gets even worse since this prints error
messages to stdout, and therefore to a log file in the case of my
script. In short, I woke up this morning with a file filling my disk
with

print() on closed filehandle FOUT at /usr/share/perl/5.8/Term/ReadLine.pm line 193.
readline() on closed filehandle FIN at /usr/share/perl/5.8/Term/ReadLine.pm line 395.
print() on closed filehandle FOUT at /usr/share/perl/5.8/Term/ReadLine.pm line 203.
Use of uninitialized value in scalar chomp at /home/moy/local/usr/libexec/git-core//git-send-email line 856.
Use of uninitialized value in pattern match (m//) at /home/moy/local/usr/libexec/git-core//git-send-email line 859.
print() on closed filehandle FOUT at /usr/share/perl/5.8/Term/ReadLine.pm line 193.
readline() on closed filehandle FIN at /usr/share/perl/5.8/Term/ReadLine.pm line 395.
print() on closed filehandle FOUT at /usr/share/perl/5.8/Term/ReadLine.pm line 203.
Use of uninitialized value in scalar chomp at /home/moy/local/usr/libexec/git-core//git-send-email line 856.
Use of uninitialized value in pattern match (m//) at /home/moy/local/usr/libexec/git-core//git-send-email line 859.
...

I think, non-interactive runs of send-email should assume "yes"
instead of prompting. In any case, it should not do infinite loop (I
guess I don't have to argue for this ;-) )

Can someone more fluent in perl than me add a

if(session-is-interactive) {
...
}

around this confirmation prompt?

(side-note : there is indeed some code to handle the cases where the
terminal doesn't work with readline, added by Junio in 280242d1, but
the FakeTerm part doesn't seem to be executed in my case:

my $term = eval {
	$ENV{"GIT_SEND_EMAIL_NOTTY"}
		? new Term::ReadLine 'git-send-email', \*STDIN, \*STDOUT
		: new Term::ReadLine 'git-send-email';
};
if ($@) {
	$term = new FakeTerm "$@: going non-interactive";
}
)

(in the meantime, I'll add --confirm never to my script)

Thanks,

--
Matthieu

^ permalink raw reply

* Re: [StGit PATCH] Add the --merged option to goto
From: Karl Hasselström @ 2009-03-25  9:05 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: git
In-Reply-To: <b0943d9e0903240840m3f22b702qd48293caad4187e3@mail.gmail.com>

On 2009-03-24 15:40:10 +0000, Catalin Marinas wrote:

> Anyway, with apply_treedif() there is no need for the
> temp_index_tree. In the updated patch below, I don't even call
> write_tree() as it isn't needed (to my understanding).

Yes. You're not interested in the result of the patch application, you
just want to know if it succeeded or not.

> Whatever is in the index after the check_merged() function doesn't
> correspond to any tree so it would need to be re-read.

It does correspond to _some_ tree, but as we have no particular reason
to expect that it might be a tree that we're going to need again
immediately, we can set temp_index_tree to None to force re-reading,
rather than pay the cost of write_tree.

When pushing patches, on the other hand, we have good reasons to
believe that the next tree we'll need in the index is the same (or at
least very close to) the one produced in the last merge. Consider the
case of popping a few patches, changing the message on the top patch,
and then pushing the patches back, for example.

> +    def check_merged(self, patches):
> +        """Return a subset of patches already merged."""
> +        merged = []
> +        self.temp_index.read_tree(self.stack.head.data.tree)
> +        # The self.temp_index is modified by apply_treediff() so force
> +        # read_tree() the next time merge() is used.
> +        self.temp_index_tree = None
> +        for pn in reversed(patches):
> +            # check whether patch changes can be reversed in the current index
> +            cd = self.patches[pn].data
> +            if cd.is_nochange():
> +                continue
> +            try:
> +                self.temp_index.apply_treediff(cd.tree, cd.parent.data.tree,
> +                                               quiet = True)
> +                merged.append(pn)
> +            except git.MergeException:
> +                pass
> +        return merged

Some points here:

  1. Check if temp_index_tree already contains the tree you want
     instead of doing read_tree unconditionally. That is, change

       self.temp_index.read_tree(self.stack.head.data.tree)

     to

       if self.stack.head.data.tree != self.temp_index_tree:
           self.temp_index.read_tree(self.stack.head.data.tree)
           self.temp_index_tree = self.stack.head.data.tree

  2. If apply_treediff fails (raises MergeException), the index wasn't
     modified at all (but I guess you knew that, since your code
     relies on that fact), so there's no reason to set temp_index_tree
     to None in that case. So in order to not clear temp_index_tree
     unnecessarily in case none of the patches reverse-apply (a case I
     personally encounter frequently, since I leave the -m flag on all
     the time), move

       self.temp_index_tree = None

     to just after (or just before) "merged.append(pn)".

  3. Why are empty patches considered not merged?

Other than that, this logic looks fine.

-- 
Karl Hasselström, kha@treskal.com
      www.treskal.com/kalle

^ permalink raw reply

* Re: Project With Reusable Libraries
From: Andreas Ericsson @ 2009-03-25  8:13 UTC (permalink / raw)
  To: John Dlugosz; +Cc: git
In-Reply-To: <450196A1AAAE4B42A00A8B27A59278E70A5597A8@EXCHANGE.trad.tradestation.com>

John Dlugosz wrote:
> Consider a directory tree something like this:
> 
> 	...
> 	foo\
> 	  bar\
> 	   project-root\
> 	     app1\
> 	         contents of app1
> 	     app2\
> 	         contents of app2
> 	     lib1\
> 	         contents of library 1
> 	     lib2\
> 	         contents of library 2
> 
> 
> Each project, whether application or library, has its own git repository
> already.  A program, say app1, is now dependant on the libraries.  The
> libraries are meant to be used in multiple applications.
> 
> This is not like what is described under subprojects, since the libs are
> not "under" the application, but are peers in the directory structure.
> It would be wrong to put lib1 and lib2 as subdirectories of app1 because
> they are also used by app2, right?
> 
> Then again... if app1 and app2 are not always built as part of the same
> set, they might have different versions of the libs specified.  I
> understand that the newer versions of msysgit do hard linking so having
> multiple repositories for the same thing won't waste disk space, but
> still requires fetching to keep them in sync?
> 
> Anyway, how would you do it?
> 

If app1 and app2 requires different versions of the same library, I'd
make them separate git projects entirely.

If they have to stay in the same project, I'd put their respective
libraries as a submodule under each app. You could get away without
having to fetch them if you stash the lib projects in the super
project and then link the app project's lib-submodules to the one
in the super-project, but it gets messy when you try to explain
that without some simple means of drawing things, so if you can't
write a "sync-submodules" script, I guess it's not really worth
the problem. Especially if the lib-repositories aren't huge.

-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

Considering the successes of the wars on alcohol, poverty, drugs and
terror, I think we should give some serious thought to declaring war
on peace.

^ permalink raw reply

* Re: [PATCH] Documentation: git-format-patch.txt rewordings and  cleanups
From: Junio C Hamano @ 2009-03-25  7:26 UTC (permalink / raw)
  To: Stephen Boyd; +Cc: J. Bruce Fields, git
In-Reply-To: <780e0a6b0903242321q252c4b44k3909bd79003ded6b@mail.gmail.com>

Stephen Boyd <bebarino@gmail.com> writes:

> On Tue, Mar 24, 2009 at 4:55 PM, Junio C Hamano <gitster@pobox.com> wrote:
>> Stephen Boyd <bebarino@gmail.com> writes:
>>
>>> How about a sentence with no negation?
>>>
>>> "Note that the leading dot is required if you want a dot between the
>>> patch name and the suffix."
>>
>> How about a sentence that does not sound requirement but freedom?
>>
>> "The leading character does not have to be a dot; for example, you
>> can use --suffix=-patch to get 0001-description-of-my-change-patch".
>
> Looks even better. Do we still want to start off by saying "Note that the..." ?

Perhaps; I wasn't paying much attention to the whole sentence, but was
primarily interested about giving the description less negative
connotation.

^ permalink raw reply

* Re: [PATCH] Documentation: minor consistency fixes in git-difftool.txt.
From: Junio C Hamano @ 2009-03-25  7:17 UTC (permalink / raw)
  To: David Aguilar; +Cc: git
In-Reply-To: <1237961655-29147-1-git-send-email-davvid@gmail.com>

David Aguilar <davvid@gmail.com> writes:

> Signed-off-by: David Aguilar <davvid@gmail.com>
> ---
>  Documentation/git-difftool.txt |    6 +++---
>  1 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/Documentation/git-difftool.txt b/Documentation/git-difftool.txt
> index 5ae02f8..23070c1 100644
> --- a/Documentation/git-difftool.txt
> +++ b/Documentation/git-difftool.txt
> @@ -12,7 +12,7 @@ SYNOPSIS
>  DESCRIPTION
>  -----------
>  'git-difftool' is a git command that allows you to compare and edit files
> -between revisions using common diff tools.  'git difftool' is a frontend
> +between revisions using common diff tools.  'git-difftool' is a frontend

I thought that the recent trend is to spell these as 'git difftool' (two
separate words), although I didn't follow the discussion on quoting styles
closely, so I do not know which of sq, dq or backtick is preferred.

Can somebody help me out here?

^ permalink raw reply

* Re: [PATCH 4/5] Draft of API for git-vcs-*, transport.c code to use it.
From: Junio C Hamano @ 2009-03-25  7:11 UTC (permalink / raw)
  To: Daniel Barkalow; +Cc: git
In-Reply-To: <alpine.LNX.1.00.0903242303410.19665@iabervon.org>

Daniel Barkalow <barkalow@iabervon.org> writes:

> +'capabilities'::
> +	Prints the capabilities of the helper, one per line. These are:
> +	 - import: the basic import command
> +	 - marks: import should be done with a saved marks file
> +	 - find-new-branches: detect new branches
> +	 - export: the general export command
> +	 - fork: create a new branch and export to it
> +	 - anonymous-fork: make commits on a branch without an inherent name
> +	 - merge: merge branches (of whatever type the system supports)
> +
> +	If the helper doesn't support "merge", the default for pull is
> +	to rebase instead of merging.
> +
> +'list'::
> +	Takes the remote name, and outputs the names of refs. These
> +	may be followed, after a single space, by "changed" or
> +	"unchanged", indicating whether the foreign repository has
> +	changed from the state in the ref. If the helper doesn't know,
> +	it doesn't have to provide a value. (In particular, it
> +	shouldn't do expensive operations, such as importing the
> +	content, to see whether it matches.)

Does this roughly corresponds to get_remote_refs(), with "unchanged"
return turned into the current value of the ref while "changed" returned
as 0{40} in old_sha1 value?

For a vcs backend that lacks find-new-branches capability, when does the
set of refnames returned by this operation change?  Can the end user
request an expensive operation to make the list up-to-date?  Does the end
user need to?

> +'import'::
> +	Takes the remote name and a list of names of refs, and imports
> +	whatever it describes, by outputting it in git-fast-import
> +	format.
> +
> +'export'::
> +	Sends the branch to the foreign system and reimports it in
> +	fast-import format.

The above two description is inconsistent; say "git-fast-import" for both.

This seems to follow the model of git-svn in that we treat our history as
throw-away, export the history and give the authority to the other system
by discarding and replacing our history with whatever the other end gives
back to us by re-importing.  Because git is more flexible than anything
else, we could afford to do so, but I wonder if it is the right model and
mentality.

One downside is that you end up rebasing the git side by operating this
way, and a topology where multiple developers use one git repository as a
synchronization point and use that git repository to interface with the
foreign system becomes impossible.  Instead, these multiple developers
need to treat the foreign system as the central repository, and interface
with it individually.

^ permalink raw reply

* Re: [PATCH 3/5] Add option for using a foreign VCS
From: Junio C Hamano @ 2009-03-25  6:49 UTC (permalink / raw)
  To: Daniel Barkalow; +Cc: git
In-Reply-To: <alpine.LNX.1.00.0903242303330.19665@iabervon.org>

Daniel Barkalow <barkalow@iabervon.org> writes:

> This simply configures the remote to use a transport that doesn't have
> any methods at all and is therefore unable to do anything yet.
>
> Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
> ---
>  Documentation/config.txt |    4 ++++
>  remote.c                 |    2 ++
>  remote.h                 |    2 ++
>  transport.c              |    3 ++-
>  4 files changed, 10 insertions(+), 1 deletions(-)
>
> diff --git a/Documentation/config.txt b/Documentation/config.txt
> index 089569a..14b0e07 100644
> --- a/Documentation/config.txt
> +++ b/Documentation/config.txt
> @@ -1305,6 +1305,10 @@ remote.<name>.tagopt::
>  	Setting this value to \--no-tags disables automatic tag following when
>  	fetching from remote <name>
>  
> +remote.<name>.vcs::
> +	Setting this to a value <vcs> will cause git to interact with
> +	the remote with the git-vcs-<vcs> helper.
> +

Nice.

> diff --git a/remote.h b/remote.h
> index de3d21b..e77dc1b 100644
> --- a/remote.h
> +++ b/remote.h
> @@ -11,6 +11,8 @@ struct remote {
>  	const char *name;
>  	int origin;
>  
> +	const char *foreign_vcs;
> +
>  	const char **url;
>  	int url_nr;
>  	int url_alloc;

What are these extra blank lines for?  Isn't it pretty much part of the
URL group that immediately follows it?

> diff --git a/transport.c b/transport.c
> index 26c578e..8a37db5 100644
> --- a/transport.c
> +++ b/transport.c
> @@ -939,7 +939,8 @@ struct transport *transport_get(struct remote *remote, const char *url)
>  	ret->remote = remote;
>  	ret->url = url;
>  
> -	if (!prefixcmp(url, "rsync:")) {
> +	if (remote && remote->foreign_vcs) {
> +	} else if (!prefixcmp(url, "rsync:")) {

	if (...) {
        	; /* empty */
	} else ...

>  		ret->get_refs_list = get_refs_via_rsync;
>  		ret->fetch = fetch_objs_via_rsync;
>  		ret->push = rsync_transport_push;
> -- 
> 1.6.2.1.476.g9bf04b

^ permalink raw reply

* Re: [PATCH 2/5] Document details of transport function APIs
From: Junio C Hamano @ 2009-03-25  6:47 UTC (permalink / raw)
  To: Daniel Barkalow; +Cc: git
In-Reply-To: <alpine.LNX.1.00.0903242303250.19665@iabervon.org>

Daniel Barkalow <barkalow@iabervon.org> writes:

> In particular, explain which of the fields of struct ref is used for
> what purpose in the input to and output from each function.
>
> Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
> ---
>  transport.h |   38 ++++++++++++++++++++++++++++++++++++++
>  1 files changed, 38 insertions(+), 0 deletions(-)
>
> diff --git a/transport.h b/transport.h
> index 489e96a..2e1650a 100644
> --- a/transport.h
> +++ b/transport.h
> @@ -18,11 +18,49 @@ struct transport {
>  	int (*set_option)(struct transport *connection, const char *name,
>  			  const char *value);
>  
> +	/**
> +	 * Returns a list of the remote side's refs. In order to allow
> +	 * the transport to try to share connections, for_push is a
> +	 * hint as to whether the ultimate operation is a push or a fetch.
> +	 *

It is unclear what this "hint" is intended to be used for, what the
transport is and isn't allowed to use it for, and what existing transports
typically use it for.

> +	/**
> +	 * Push the objects and refs. Send the necessary objects, and
> +	 * then tell the remote side to update each ref in the list
> +	 * from old_sha1 to new_sha1.
> +	 *
> +	 * Where possible, set the status for each ref appropriately.
> +	 *
> +	 * If, in the process, the transport determines that the
> +	 * remote side actually responded to the push by updating the
> +	 * ref to a different value, the transport should modify the
> +	 * new_sha1 in the ref. (Note that this is a matter of the
> +	 * remote accepting but rewriting the change, not rejecting it
> +	 * and reporting that a different update had already taken
> +	 * place)
> +	 **/

It this even a sane thing to allow?  How would it interact with the
"pretend we immediately turned around and fetched them into the remote
tracking branches" local updates we usually do?

>  	int (*push_refs)(struct transport *transport, struct ref *refs, int flags);
>  	int (*push)(struct transport *connection, int refspec_nr, const char **refspec, int flags);
>  
> +	/** get_refs_list(), fetch(), and push_refs() can keep
> +	 * resources (such as a connection) reserved for futher
> +	 * use. disconnect() releases these resources.
> +	 **/
>  	int (*disconnect)(struct transport *connection);
>  	char *pack_lockfile;
>  	signed verbose : 2;

It is just a style thing, but all of our multi-line comments are

   /*
    * of
    * this
    * form
    */

and these new comments are formatted slightly differently with double
asterisks on only the first and the last lines.  In addition, th last
comment block uses a yet another different style, which is a bit of
eyesore.

^ permalink raw reply

* [PATCH] difftool: add a -y shortcut for --no-prompt
From: David Aguilar @ 2009-03-25  6:29 UTC (permalink / raw)
  To: gitster; +Cc: git, David Aguilar

This is another consistency cleanup to make git-difftool's options
match git-mergetool.

Signed-off-by: David Aguilar <davvid@gmail.com>
---

This also fixes the style used for the -h option which I should
have caught in my previous patch.  Doh!

 Documentation/git-difftool.txt |    3 ++-
 git-difftool.perl              |    6 +++---
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/Documentation/git-difftool.txt b/Documentation/git-difftool.txt
index 23070c1..be1020d 100644
--- a/Documentation/git-difftool.txt
+++ b/Documentation/git-difftool.txt
@@ -7,7 +7,7 @@ git-difftool - Show changes using common diff tools
 
 SYNOPSIS
 --------
-'git difftool' [--tool=<tool>] [--no-prompt] [<'git diff' options>]
+'git difftool' [--tool=<tool>] [-y|--no-prompt] [<'git diff' options>]
 
 DESCRIPTION
 -----------
@@ -17,6 +17,7 @@ to 'git-diff' and accepts the same options and arguments.
 
 OPTIONS
 -------
+-y::
 --no-prompt::
 	Do not prompt before launching a diff tool.
 
diff --git a/git-difftool.perl b/git-difftool.perl
index 207dd50..5bc64d5 100755
--- a/git-difftool.perl
+++ b/git-difftool.perl
@@ -18,7 +18,7 @@ my $DIR = abs_path(dirname($0));
 sub usage
 {
 	print << 'USAGE';
-usage: git difftool [--tool=<tool>] [--no-prompt] ["git diff" options]
+usage: git difftool [--tool=<tool>] [-y|--no-prompt] ["git diff" options]
 USAGE
 	exit 1;
 }
@@ -60,11 +60,11 @@ sub generate_command
 			$ENV{GIT_DIFF_TOOL} = substr($arg, 7);
 			next;
 		}
-		if ($arg eq '--no-prompt') {
+		if ($arg eq '-y' || '--no-prompt') {
 			$ENV{GIT_DIFFTOOL_NO_PROMPT} = 'true';
 			next;
 		}
-		if ($arg eq '-h' or $arg eq '--help') {
+		if ($arg eq '-h' || $arg eq '--help') {
 			usage();
 		}
 		push @command, $arg;
-- 
1.6.2.1.303.g63699

^ permalink raw reply related

* [PATCH JGIT 2/2] Test case for pack index CRC
From: Daniel Cheng (aka SDiZ) @ 2009-03-25  6:21 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: git, Daniel Cheng (aka SDiZ)
In-Reply-To: <1237962115-22709-1-git-send-email-j16sdiz+freenet@gmail.com>


Signed-off-by: Daniel Cheng (aka SDiZ) <j16sdiz+freenet@gmail.com>
---
 .../tst/org/spearce/jgit/lib/PackWriterTest.java   |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/PackWriterTest.java b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/PackWriterTest.java
index f7139fc..9a5513f 100644
--- a/org.spearce.jgit.test/tst/org/spearce/jgit/lib/PackWriterTest.java
+++ b/org.spearce.jgit.test/tst/org/spearce/jgit/lib/PackWriterTest.java
@@ -354,6 +354,15 @@ public class PackWriterTest extends RepositoryTestCase {
 		assertTrue(sizePack4 > sizePack4Thin);
 	}
 
+	public void testWriteIndex() throws Exception {
+		writer.setIndexVersion(2);
+		writeVerifyPack4(true);
+		
+		PackIndex idx = PackIndex.open(indexFile);
+		assertEquals(0x4743F1E4L, idx.findCRC32(ObjectId
+				.fromString("82c6b885ff600be425b4ea96dee75dca255b69e7")));
+	}
+
 	// TODO: testWritePackDeltasCycle()
 	// TODO: testWritePackDeltasDepth()
 
@@ -470,6 +479,7 @@ public class PackWriterTest extends RepositoryTestCase {
 		final IndexPack indexer = new IndexPack(db, is, packBase);
 		indexer.setKeepEmpty(true);
 		indexer.setFixThin(thin);
+		indexer.setIndexVersion(2);
 		indexer.index(new TextProgressMonitor());
 		pack = new PackFile(indexFile, packFile);
 	}
-- 
1.6.2

^ permalink raw reply related

* [PATCH JGIT 1/2] Calculate CRC32 on Pack Index v2
From: Daniel Cheng (aka SDiZ) @ 2009-03-25  6:21 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: git, Daniel Cheng (aka SDiZ)
In-Reply-To: <ff6a9c820903231953q29a5ccbk8e5b54c9afdb8abd@mail.gmail.com>


Signed-off-by: Daniel Cheng (aka SDiZ) <j16sdiz+freenet@gmail.com>
---
 .../src/org/spearce/jgit/lib/PackWriter.java       |    2 +
 .../spearce/jgit/util/CountingOutputStream.java    |   32 +++++++++++++++++++-
 2 files changed, 33 insertions(+), 1 deletions(-)

diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/PackWriter.java b/org.spearce.jgit/src/org/spearce/jgit/lib/PackWriter.java
index 601ce71..d8b50e6 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/PackWriter.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/PackWriter.java
@@ -687,11 +687,13 @@ public class PackWriter {
 
 		assert !otp.isWritten();
 
+		countingOut.resetCRC32();
 		otp.setOffset(countingOut.getCount());
 		if (otp.isDeltaRepresentation())
 			writeDeltaObject(otp);
 		else
 			writeWholeObject(otp);
+		otp.setCRC((int) countingOut.getCRC32());
 
 		writeMonitor.update(1);
 	}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/util/CountingOutputStream.java b/org.spearce.jgit/src/org/spearce/jgit/util/CountingOutputStream.java
index b0b5f7d..b4ae915 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/util/CountingOutputStream.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/util/CountingOutputStream.java
@@ -40,12 +40,16 @@ package org.spearce.jgit.util;
 import java.io.FilterOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
+import java.util.zip.CRC32;
 
 /**
- * Counting output stream decoration. Counts bytes written to stream.
+ * Counting output stream decoration. Counts bytes written to stream and 
+ * calculate CRC32 checksum.
  */
 public class CountingOutputStream extends FilterOutputStream {
 	private long count;
+	
+	private CRC32 crc;
 
 	/**
 	 * Create counting stream being decorated to provided real output stream.
@@ -55,6 +59,7 @@ public class CountingOutputStream extends FilterOutputStream {
 	 */
 	public CountingOutputStream(OutputStream out) {
 		super(out);
+		crc = new CRC32();
 	}
 
 	@Override
@@ -79,10 +84,35 @@ public class CountingOutputStream extends FilterOutputStream {
 		return count;
 	}
 
+    /**
+     * Resets CRC-32 to initial value.
+     */
+	public void resetCRC32() {
+		crc.reset();
+	}
+
+    /**
+     * Returns CRC-32 value.
+     * @return CRC32
+     */
+	public long getCRC32() {
+		return crc.getValue();
+	}
+
+
 	/**
 	 * Reset counter to zero value.
 	 */
 	public void reset() {
 		count = 0;
+		crc.reset();
+	}
+	
+	/**
+	 * {@inheritDoc}
+	 */
+	public void close() throws IOException {
+		crc = null;
+		super.close();
 	}
 }
-- 
1.6.2

^ permalink raw reply related

* Re: [PATCH] Documentation: git-format-patch.txt rewordings and  cleanups
From: Stephen Boyd @ 2009-03-25  6:21 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: J. Bruce Fields, git
In-Reply-To: <7vskl2tr00.fsf@gitster.siamese.dyndns.org>

On Tue, Mar 24, 2009 at 4:55 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Stephen Boyd <bebarino@gmail.com> writes:
>
>> How about a sentence with no negation?
>>
>> "Note that the leading dot is required if you want a dot between the
>> patch name and the suffix."
>
> How about a sentence that does not sound requirement but freedom?
>
> "The leading character does not have to be a dot; for example, you
> can use --suffix=-patch to get 0001-description-of-my-change-patch".

Looks even better. Do we still want to start off by saying "Note that the..." ?

^ permalink raw reply

* [PATCH] Documentation: minor consistency fixes in git-difftool.txt.
From: David Aguilar @ 2009-03-25  6:14 UTC (permalink / raw)
  To: gitster; +Cc: git, David Aguilar

Signed-off-by: David Aguilar <davvid@gmail.com>
---
 Documentation/git-difftool.txt |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/Documentation/git-difftool.txt b/Documentation/git-difftool.txt
index 5ae02f8..23070c1 100644
--- a/Documentation/git-difftool.txt
+++ b/Documentation/git-difftool.txt
@@ -12,7 +12,7 @@ SYNOPSIS
 DESCRIPTION
 -----------
 'git-difftool' is a git command that allows you to compare and edit files
-between revisions using common diff tools.  'git difftool' is a frontend
+between revisions using common diff tools.  'git-difftool' is a frontend
 to 'git-diff' and accepts the same options and arguments.
 
 OPTIONS
@@ -23,7 +23,7 @@ OPTIONS
 -t <tool>::
 --tool=<tool>::
 	Use the diff tool specified by <tool>.
-	Valid merge tools are:
+	Valid diff tools are:
 	kdiff3, kompare, tkdiff, meld, xxdiff, emerge,
 	vimdiff, gvimdiff, ecmerge, and opendiff
 +
@@ -50,7 +50,7 @@ variables available: `$LOCAL` is set to the name of the temporary
 file containing the contents of the diff pre-image and `$REMOTE`
 is set to the name of the temporary file containing the contents
 of the diff post-image.  `$BASE` is provided for compatibility
-with custom merge tool commands and has the same value as `$LOCAL`.
+with custom 'git-mergetool' commands and has the same value as `$LOCAL`.
 
 See linkgit:git-diff[1] for the full list of supported options.
 
-- 
1.6.2.1.303.g63699

^ permalink raw reply related

* [PATCH] difftool: use perl built-ins when testing for msys
From: David Aguilar @ 2009-03-25  6:13 UTC (permalink / raw)
  To: gitster; +Cc: git, David Aguilar

I don't even know what $COMSPEC means so let's be safe and use the
same perly $^O test add--interactive uses.  While we're at it, make
git-difftool match the prevalent git-perl style.

Signed-off-by: David Aguilar <davvid@gmail.com>
---
 git-difftool.perl |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/git-difftool.perl b/git-difftool.perl
index 0deda3a..207dd50 100755
--- a/git-difftool.perl
+++ b/git-difftool.perl
@@ -33,7 +33,10 @@ sub setup_environment
 sub exe
 {
 	my $exe = shift;
-	return defined $ENV{COMSPEC} ? "$exe.exe" : $exe;
+	if ($^O eq 'MSWin32' || $^O eq 'msys') {
+		return "$exe.exe";
+	}
+	return $exe;
 }
 
 sub generate_command
@@ -47,7 +50,7 @@ sub generate_command
 			$skip_next = 0;
 			next;
 		}
-		if ($arg eq '-t' or $arg eq '--tool') {
+		if ($arg eq '-t' || $arg eq '--tool') {
 			usage() if $#ARGV <= $idx;
 			$ENV{GIT_DIFF_TOOL} = $ARGV[$idx + 1];
 			$skip_next = 1;
-- 
1.6.2.1.303.g63699

^ 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