Git development
 help / color / mirror / Atom feed
* Re: Stacked GIT 0.3 (now more Quilt-like)
From: Junio C Hamano @ 2005-07-08  1:24 UTC (permalink / raw)
  To: Peter Osterlund; +Cc: Catalin Marinas, git
In-Reply-To: <m31x6acdcl.fsf@telia.com>

>>>>> "PO" == Peter Osterlund <petero2@telia.com> writes:

PO> I think it would be good if it was possible to include diffstat output
PO> in exported patches, something like this:

PO> Added possibility to include diffstat output in exported patches.

And you wuold want to do things similarly to what others have
already done.  git-resolve-script uses "git-apply --stat" there,
instead of "diffstat", so people without diffstat installed can
still get the same information.

Even if you want to stick to "diffstat", at least I would
suggest giving -p1, not -p0, to it; otherwise you would see b/
like what you have there.

PO>  b/stgit/git.py  |   22 ++++++++++++++++++++++
PO>  b/stgit/main.py |    2 ++
PO>  2 files changed, 24 insertions(+)

Further, using "git-apply --stat --summary" would be nicer; this
is something you cannot do with plain "diffstat".

^ permalink raw reply

* Re: [PATCH] rev-list: add "--full-objects" flag.
From: Linus Torvalds @ 2005-07-08  1:33 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git
In-Reply-To: <7vvf3mds9c.fsf_-_@assigned-by-dhcp.cox.net>



On Thu, 7 Jul 2005, Junio C Hamano wrote:
> 
> Again you are right.  How about --full-objects instead?

I don't mind the "--objects=xxx" format per se, but it would need to 
verify that the "=xxx" was either valid or wasn't there at all. So what I 
objected to was not that it was easy to mis-spell, but that if misspelled, 
the program wouldn't point it out as an error, but silently just do the 
wrong thing.

		Linus

^ permalink raw reply

* Re: [PATCH] rev-list: add "--full-objects" flag.
From: Linus Torvalds @ 2005-07-08  1:46 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git
In-Reply-To: <7vvf3mds9c.fsf_-_@assigned-by-dhcp.cox.net>



On Thu, 7 Jul 2005, Junio C Hamano wrote:
>
> When --full-objects is specified instead of usual "--objects",
> rev-list shows all objects reachable from trees associated with
> the commits in its output.  This can be used to ensure that a
> single pack can be used to recreate the tree associated with
> every commit in it.

Hmm.. The more I think about it, the less I think this is about "full 
objects".

After all, we won't have all objects: the pack will still cut off any 
commits that may be reachable but not interesting.

So this is more specifically about full _trees_, not objects per se. So 
while the name of the option doesn't really matter all that much, I do 
think it would make more sense as "--whole-trees" or something like that.

However, I really don't think it's a very useful option in the first
place. Any dumb web-based thing that depends on "--whole-trees" would suck
horribly. For the kernel, it means that you'd be guaranteed 17,000+ files,
and there would be very few deltas in there, so you'd have this 40MB+
pack-file. Which is _not_ an acceptable way of getting updates.

		Linus

^ permalink raw reply

* Dumb servers (was: [ANNOUNCE] Cogito-0.12)
From: Kevin Smith @ 2005-07-08  1:54 UTC (permalink / raw)
  Cc: git
In-Reply-To: <m1vf3muwxw.fsf@ebiederm.dsl.xmission.com>

Eric W. Biederman wrote:
> Linus Torvalds <torvalds@osdl.org> writes:
> 
> 
>>That said, I really think the dumb protocols are useless anyway. No other 
>>system supports pure static object pulling anyway, and as far as I'm 
>>concerned, I want "rsync" to kind of work (but it won't be optimal, since 
>>re-packing will delete all the old objects and replace it with the new 
>>pack that is downloaded anew). But plain http? I'm not convinced.
> 
> 
> Have you not looked at tla/arch? tla does supports dumb servers.
> It's job is a little easier as it has one file per atomic commit
> I suspect once packs start working well that should not be an
> issue for git either.

In addition to GNU arch/tla, it it also supported by baz, ArX, darcs, 
and mercurial.

> For small projects this is a major benefit, as they can just push
> their files to a convenient http or ftp server.

Absolutely. For the kernel it might not make sense, but I view it as a 
really important feature for tiny projects around the world. Even a CGI 
requirement makes it impossible to serve a project from free or really 
cheap web hosts. Plain HTTP is the only protocol available to people who 
have no extra money to spend on hosting accounts.

This happens to be a hot button issue for me, in case you can't tell. 
Sorry if I'm ranting.

Kevin

^ permalink raw reply

* Re: [ANNOUNCE] Cogito-0.12
From: Eric W. Biederman @ 2005-07-08  2:11 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Junio C Hamano, Petr Baudis, git
In-Reply-To: <Pine.LNX.4.58.0507071520220.25104@g5.osdl.org>

Linus Torvalds <torvalds@osdl.org> writes:

> On Thu, 7 Jul 2005, Eric W. Biederman wrote:
>>
>> For optimizing network bandwidth that sounds like the way to go.  For
>> adhoc development I don't know.  For a central sever you still need
>> an authenticated way to push content, which makes it another dimension
>> of the problem.
>
> I'm convinced that "ssh" is the only sane way for pushing. If you don't 
> trust somebody enough to give him ssh access, you shouldn't trust him with 
> write access to your project in the first place.

Agreed, I brought that up only so I could dismiss it :)  

> So I don't worry about pushing. I think we've got that covered. It's 
> really the anonymous pulling that needs something.

So long as we remember there is a tradeoff between efficiency and
ease of setup for anonymous access and small projects.

Eric

^ permalink raw reply

* Re: [PATCH] rev-list: add "--full-objects" flag.
From: Junio C Hamano @ 2005-07-08  2:17 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: git
In-Reply-To: <Pine.LNX.4.58.0507071841010.25104@g5.osdl.org>

>>>>> "LT" == Linus Torvalds <torvalds@osdl.org> writes:

LT> However, I really don't think it's a very useful option in
LT> the first place.  Any dumb web-based thing that depends on
LT> "--whole-trees" would suck horribly.

I agree with these two sentences now.

However it does not automatically mean that the avenue I have
been pursuing would not work; the server side preparation needs
to be a bit more careful than what I sent, which unconditionally
runs "prune-packed".  It instead should leave the files that
"--whole-trees" would have packed as plain SHA1 files, so that
the bulk is obtained by statically generated packs and the rest
can be handled in the commit-chain walker as before.

So, the server side preparation needs be tweaked to do something
like:

  (1) Repack when necessary (no --whole-trees).

  (2) For each .git/objects/pack/ pack, make a list of trees and
      blobs that are missing from the commits that contained in
      the same pack.

  (3) Run "prune-packed" but do not prune objects on the list
      produced in the previous step.

  (4) Take inventory, rev-cache, and pack, as done by the posted
      patch.

The determination of (1) is a bit problematic since "when
necessary" is not "when .git/objects/?? grew too big" anymore,
due to the fact that (3) would deliberately leave plain SHA1
files there.

A completely different way would be to prepare packs of objects
based on age, and create an inventory of such packs.  Have
client download such an inventory, which essentially says "if
you have this commit, then slurp these packs and you are done."

^ permalink raw reply

* Re: Dumb servers (was: [ANNOUNCE] Cogito-0.12)
From: Linus Torvalds @ 2005-07-08  2:27 UTC (permalink / raw)
  To: Kevin Smith; +Cc: Git Mailing List
In-Reply-To: <42CDDCF0.9020906@qualitycode.com>



On Thu, 7 Jul 2005, Kevin Smith wrote:
> 
> Absolutely. For the kernel it might not make sense, but I view it as a 
> really important feature for tiny projects around the world. Even a CGI 
> requirement makes it impossible to serve a project from free or really 
> cheap web hosts. Plain HTTP is the only protocol available to people who 
> have no extra money to spend on hosting accounts.

Well, the http approach always works as well as an "rsync", ie you can 
always replace "rsync" with "wget -r -c" or similar.

But the end result will be a purely dumb mirror of what the other side 
had, ie it will have all the same problems rsync has with things like 
multiple branches etc (it will get all of them, not just the objects 
needed from the one branch you're trying to pull).

So it's not pretty. But it obviously does work: pack-files haven't changed
the fact that git is a append-only thing that lives entirely in the
filesystem space and doesn't have any "dynamic content" (ie nothing is 
hidden inside server state).

		Linus

^ permalink raw reply

* Re: [PATCH] rev-list: add "--full-objects" flag.
From: Linus Torvalds @ 2005-07-08  2:39 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git
In-Reply-To: <7vy88ica8e.fsf@assigned-by-dhcp.cox.net>



On Thu, 7 Jul 2005, Junio C Hamano wrote:
> 
> However it does not automatically mean that the avenue I have
> been pursuing would not work; the server side preparation needs
> to be a bit more careful than what I sent, which unconditionally
> runs "prune-packed".  It instead should leave the files that
> "--whole-trees" would have packed as plain SHA1 files, so that
> the bulk is obtained by statically generated packs and the rest
> can be handled in the commit-chain walker as before.

I really think the commit-chain walker needs to run locally (ie at the 
server end, or after fetching all the objects from the server).

I don't know how much you've tried out the git-http-pull and git-ssh-pull 
things, but their performance was quite horrid for anything half-way 
bigger, because of the totally synchronized IO.

The "fetch one object, parse it, fetch the next one, parse that.." 
approach is just horrible.

I ended up preferring the "rsync" thing even though rsync sucked badly on
big object stores too, if only because when rsync got working, it at least
nicely pipelined the transfers, and would transfer things ten times faster
than git-ssh-pull did (maybe I'm exaggerating, but I don't think so, it
really felt that way).

And the thing is, if you purely follow one tree (which is likely the
common case for a lot of users), then you are actually always likely
better off with the "mirror it" model. Which is _not_ a good model for
developers (for example, me rsync'ing from Jeff's kernel repository always
got me hundreds of useless objects), but it's fine for somebody who
actually just wants to track somebody else.

And then you really can use just rsync or wget or ncftpget or anything
else that has a "fetch recursively, optimizing existing objects" mode.

Now, re-packing ends up causing some double transmissions, but I bet the
cost of those are going to be less than the cost of the "ping-pong for
each object" approach. Especially as most of the repacked objects will be 
deltas if the repacking is done properly.

		Linus

^ permalink raw reply

* [PATCH] Make sq_expand() available as sq_quote().
From: Junio C Hamano @ 2005-07-08  6:55 UTC (permalink / raw)
  To: git; +Cc: Linus Torvalds
In-Reply-To: <7v64vnwrwg.fsf@assigned-by-dhcp.cox.net>

A useful shell safety helper sq_expand() was hidden as a static
function in diff.c.  Extract it out and make it available as
sq_quote().

Signed-off-by: Junio C Hamano <junkio@cox.net>
---
>>>>> "JCH" == Junio C Hamano <junkio@cox.net> writes:

JCH> I am not going to do it myself immediately so there is no worry
JCH> to race against me ;-).

Well, I ended up doing it myself just as a diversion from
thinking about pulls ;-).  As you said, one _must_ be very
careful when feeding a shell, but being careful does not
necessarily hard.

This is the first part; the next one will depend on it.

 Makefile |    3 +++
 diff.c   |   47 ++++++-----------------------------------------
 2 files changed, 9 insertions(+), 41 deletions(-)

0ab0d4c45dc7c531dd54f2d29a2199d4f4192018
diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -65,6 +65,9 @@ LIB_H=cache.h object.h blob.h tree.h com
 LIB_H += strbuf.h
 LIB_OBJS += strbuf.o
 
+LIB_H += quote.h
+LIB_OBJS += quote.o 
+
 LIB_H += diff.h count-delta.h
 LIB_OBJS += diff.o diffcore-rename.o diffcore-pickaxe.o diffcore-pathspec.o \
 	count-delta.o diffcore-break.o diffcore-order.o
diff --git a/diff.c b/diff.c
--- a/diff.c
+++ b/diff.c
@@ -5,6 +5,7 @@
 #include <sys/wait.h>
 #include <signal.h>
 #include "cache.h"
+#include "quote.h"
 #include "diff.h"
 #include "diffcore.h"
 
@@ -40,42 +41,6 @@ static const char *external_diff(void)
 	return external_diff_cmd;
 }
 
-/* Help to copy the thing properly quoted for the shell safety.
- * any single quote is replaced with '\'', and the caller is
- * expected to enclose the result within a single quote pair.
- *
- * E.g.
- *  original     sq_expand     result
- *  name     ==> name      ==> 'name'
- *  a b      ==> a b       ==> 'a b'
- *  a'b      ==> a'\''b    ==> 'a'\''b'
- */
-static char *sq_expand(const char *src)
-{
-	static char *buf = NULL;
-	int cnt, c;
-	const char *cp;
-	char *bp;
-
-	/* count bytes needed to store the quoted string. */
-	for (cnt = 1, cp = src; *cp; cnt++, cp++)
-		if (*cp == '\'')
-			cnt += 3;
-
-	buf = xmalloc(cnt);
-	bp = buf;
-	while ((c = *src++)) {
-		if (c != '\'')
-			*bp++ = c;
-		else {
-			bp = strcpy(bp, "'\\''");
-			bp += 4;
-		}
-	}
-	*bp = 0;
-	return buf;
-}
-
 static struct diff_tempfile {
 	const char *name; /* filename external diff should read from */
 	char hex[41];
@@ -167,16 +132,16 @@ static void builtin_diff(const char *nam
 			 int complete_rewrite)
 {
 	int i, next_at, cmd_size;
-	const char *diff_cmd = "diff -L'%s%s' -L'%s%s'";
-	const char *diff_arg  = "'%s' '%s'||:"; /* "||:" is to return 0 */
+	const char *diff_cmd = "diff -L%s%s -L%s%s";
+	const char *diff_arg  = "%s %s||:"; /* "||:" is to return 0 */
 	const char *input_name_sq[2];
 	const char *path0[2];
 	const char *path1[2];
 	const char *name_sq[2];
 	char *cmd;
 
-	name_sq[0] = sq_expand(name_a);
-	name_sq[1] = sq_expand(name_b);
+	name_sq[0] = sq_quote(name_a);
+	name_sq[1] = sq_quote(name_b);
 
 	/* diff_cmd and diff_arg have 6 %s in total which makes
 	 * the sum of these strings 12 bytes larger than required.
@@ -186,7 +151,7 @@ static void builtin_diff(const char *nam
 	cmd_size = (strlen(diff_cmd) + strlen(diff_opts) +
 			strlen(diff_arg) - 9);
 	for (i = 0; i < 2; i++) {
-		input_name_sq[i] = sq_expand(temp[i].name);
+		input_name_sq[i] = sq_quote(temp[i].name);
 		if (!strcmp(temp[i].name, "/dev/null")) {
 			path0[i] = "/dev/null";
 			path1[i] = "";

^ permalink raw reply

* [PATCH] Make sq_expand() available as sq_quote().
From: Junio C Hamano @ 2005-07-08  6:58 UTC (permalink / raw)
  To: git; +Cc: Linus Torvalds
In-Reply-To: <7v64vnwrwg.fsf@assigned-by-dhcp.cox.net>

A useful shell safety helper sq_expand() was hidden as a static
function in diff.c.  Extract it out and make it available as
sq_quote().

Signed-off-by: Junio C Hamano <junkio@cox.net>
---
>>>>> "JCH" == Junio C Hamano <junkio@cox.net> writes:

JCH> I am not going to do it myself immediately so there is no worry
JCH> to race against me ;-).

Well, I ended up doing it myself just as a diversion from
thinking about pulls ;-).  As you said, one _must_ be very
careful when feeding a shell, but being careful does not
necessarily hard.

This is the first part; the next one will depend on it.

 Makefile |    3 +++
 diff.c   |   47 ++++++-----------------------------------------
 quote.c  |   41 +++++++++++++++++++++++++++++++++++++++++
 quote.h  |   26 ++++++++++++++++++++++++++
 4 files changed, 76 insertions(+), 41 deletions(-)
 create mode 100644 quote.c
 create mode 100644 quote.h

500d2196566027419b1b8effc28f78eb9a60f086
diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -65,6 +65,9 @@ LIB_H=cache.h object.h blob.h tree.h com
 LIB_H += strbuf.h
 LIB_OBJS += strbuf.o
 
+LIB_H += quote.h
+LIB_OBJS += quote.o 
+
 LIB_H += diff.h count-delta.h
 LIB_OBJS += diff.o diffcore-rename.o diffcore-pickaxe.o diffcore-pathspec.o \
 	count-delta.o diffcore-break.o diffcore-order.o
diff --git a/diff.c b/diff.c
--- a/diff.c
+++ b/diff.c
@@ -5,6 +5,7 @@
 #include <sys/wait.h>
 #include <signal.h>
 #include "cache.h"
+#include "quote.h"
 #include "diff.h"
 #include "diffcore.h"
 
@@ -40,42 +41,6 @@ static const char *external_diff(void)
 	return external_diff_cmd;
 }
 
-/* Help to copy the thing properly quoted for the shell safety.
- * any single quote is replaced with '\'', and the caller is
- * expected to enclose the result within a single quote pair.
- *
- * E.g.
- *  original     sq_expand     result
- *  name     ==> name      ==> 'name'
- *  a b      ==> a b       ==> 'a b'
- *  a'b      ==> a'\''b    ==> 'a'\''b'
- */
-static char *sq_expand(const char *src)
-{
-	static char *buf = NULL;
-	int cnt, c;
-	const char *cp;
-	char *bp;
-
-	/* count bytes needed to store the quoted string. */
-	for (cnt = 1, cp = src; *cp; cnt++, cp++)
-		if (*cp == '\'')
-			cnt += 3;
-
-	buf = xmalloc(cnt);
-	bp = buf;
-	while ((c = *src++)) {
-		if (c != '\'')
-			*bp++ = c;
-		else {
-			bp = strcpy(bp, "'\\''");
-			bp += 4;
-		}
-	}
-	*bp = 0;
-	return buf;
-}
-
 static struct diff_tempfile {
 	const char *name; /* filename external diff should read from */
 	char hex[41];
@@ -167,16 +132,16 @@ static void builtin_diff(const char *nam
 			 int complete_rewrite)
 {
 	int i, next_at, cmd_size;
-	const char *diff_cmd = "diff -L'%s%s' -L'%s%s'";
-	const char *diff_arg  = "'%s' '%s'||:"; /* "||:" is to return 0 */
+	const char *diff_cmd = "diff -L%s%s -L%s%s";
+	const char *diff_arg  = "%s %s||:"; /* "||:" is to return 0 */
 	const char *input_name_sq[2];
 	const char *path0[2];
 	const char *path1[2];
 	const char *name_sq[2];
 	char *cmd;
 
-	name_sq[0] = sq_expand(name_a);
-	name_sq[1] = sq_expand(name_b);
+	name_sq[0] = sq_quote(name_a);
+	name_sq[1] = sq_quote(name_b);
 
 	/* diff_cmd and diff_arg have 6 %s in total which makes
 	 * the sum of these strings 12 bytes larger than required.
@@ -186,7 +151,7 @@ static void builtin_diff(const char *nam
 	cmd_size = (strlen(diff_cmd) + strlen(diff_opts) +
 			strlen(diff_arg) - 9);
 	for (i = 0; i < 2; i++) {
-		input_name_sq[i] = sq_expand(temp[i].name);
+		input_name_sq[i] = sq_quote(temp[i].name);
 		if (!strcmp(temp[i].name, "/dev/null")) {
 			path0[i] = "/dev/null";
 			path1[i] = "";
diff --git a/quote.c b/quote.c
new file mode 100644
--- /dev/null
+++ b/quote.c
@@ -0,0 +1,41 @@
+#include "cache.h"
+#include "quote.h"
+
+/* Help to copy the thing properly quoted for the shell safety.
+ * any single quote is replaced with '\'', and the caller is
+ * expected to enclose the result within a single quote pair.
+ *
+ * E.g.
+ *  original     sq_quote     result
+ *  name     ==> name      ==> 'name'
+ *  a b      ==> a b       ==> 'a b'
+ *  a'b      ==> a'\''b    ==> 'a'\''b'
+ */
+char *sq_quote(const char *src)
+{
+	static char *buf = NULL;
+	int cnt, c;
+	const char *cp;
+	char *bp;
+
+	/* count bytes needed to store the quoted string. */
+	for (cnt = 3, cp = src; *cp; cnt++, cp++)
+		if (*cp == '\'')
+			cnt += 3;
+
+	buf = xmalloc(cnt);
+	bp = buf;
+	*bp++ = '\'';
+	while ((c = *src++)) {
+		if (c != '\'')
+			*bp++ = c;
+		else {
+			bp = strcpy(bp, "'\\''");
+			bp += 4;
+		}
+	}
+	*bp++ = '\'';
+	*bp = 0;
+	return buf;
+}
+
diff --git a/quote.h b/quote.h
new file mode 100644
--- /dev/null
+++ b/quote.h
@@ -0,0 +1,26 @@
+#ifndef QUOTE_H
+#define QUOTE_H
+
+
+/* Help to copy the thing properly quoted for the shell safety.
+ * any single quote is replaced with '\'', and the whole thing
+ * is enclosed in a single quote pair.
+ *
+ * For example, if you are passing the result to system() as an
+ * argument:
+ *
+ * sprintf(cmd, "foobar %s %s", sq_quote(arg0), sq_quote(arg1))
+ *
+ * would be appropriate.  If the system() is going to call ssh to
+ * run the command on the other side:
+ *
+ * sprintf(cmd, "git-diff-tree %s %s", sq_quote(arg0), sq_quote(arg1));
+ * sprintf(rcmd, "ssh %s %s", sq_quote(host), sq_quote(cmd));
+ *
+ * Note that the above examples leak memory!  Remember to free result from
+ * sq_quote() in a real application.
+ */
+
+char *sq_quote(const char *src);
+
+#endif

^ permalink raw reply

* [PATCH] Use sq_quote() to properly quote the parameter to call shell.
From: Junio C Hamano @ 2005-07-08  7:02 UTC (permalink / raw)
  To: git; +Cc: Linus Torvalds
In-Reply-To: <7v3bqpdbs7.fsf@assigned-by-dhcp.cox.net>

This tries to be more lenient to the users and stricter to the
attackers by quoting the input properly for shell safety,
instead of forbidding certain characters from the input.

Things to note:

 - We do not quote "prog" parameter (which comes from --exec).
   The user should know what he is doing.  --exec='echo foo'
   will supply the first two parameters to the resulting
   command, while --exec="'echo foo'" will give the first
   parameter, a single string with a space inside.

 - We do not care too much about leaking the sq_quote() output
   just before running exec().

Signed-off-by: Junio C Hamano <junkio@cox.net>
---
This depends on the previous [PATCH] Make sq_expand() available as sq_quote().
Please discard the one I sent by mistake that lacks additions of
quote.[ch] files.

To verify the stuff is quoted properly, I used the following
command invocations.  They show that the metacharacters are
passed unmolested by the intervening shell and ssh commands:

    $ git-send-pack --exec=/bin/echo '0011 abc;d\ef g<h'
    fatal: protocol error: expected sha/ref, got ' abc;d\ef g<h'
    $ git-send-pack --exec=/bin/echo localhost:'0011 abc;d\ef g<h'
    fatal: protocol error: expected sha/ref, got ' abc;d\ef g<h'
    $ git-fetch-pack '0011 abc;d\ef g<h' a
    fatal: git-upload-pack unable to chdir to 0011 abc;d\ef g<h
    fatal: unexpected EOF
    $ git-fetch-pack localhost:'0011 abc;d\ef g<h' a
    fatal: git-upload-pack unable to chdir to 0011 abc;d\ef g<h
    fatal: unexpected EOF

Also by storing the following executable script in
/var/tmp/j0.sh and using git-send-pack --exec=/var/tmp/j0.sh
with the same parameters:

    #!/bin/sh
    o=/var/tmp/j0.out 
    echo $$ >>$o

    i=0
    echo "0: [$0]" >>$o
    for x
    do
	i=$(expr $i + 1)
	echo "$i: [$x]" >>$o
    done

it can be verified that the funny string is indeed passed as a
single parameter to it.

 connect.c |   33 +++------------------------------
 1 files changed, 3 insertions(+), 30 deletions(-)

e6e65f02919048f37467a9aca55ed19892dd2a7e
diff --git a/connect.c b/connect.c
--- a/connect.c
+++ b/connect.c
@@ -1,5 +1,6 @@
 #include "cache.h"
 #include "pkt-line.h"
+#include "quote.h"
 #include <sys/wait.h>
 
 int get_ack(int fd, unsigned char *result_sha1)
@@ -42,34 +43,6 @@ int path_match(const char *path, int nr,
 }
 
 /*
- * First, make it shell-safe.  We do this by just disallowing any
- * special characters. Somebody who cares can do escaping and let
- * through the rest. But since we're doing to feed this to ssh as
- * a command line, we're going to be pretty damn anal for now.
- */
-static char *shell_safe(char *url)
-{
-	char *n = url;
-	unsigned char c;
-	static const char flags[256] = {
-		['0'...'9'] = 1,
-		['a'...'z'] = 1,
-		['A'...'Z'] = 1,
-		['.'] = 1, ['/'] = 1,
-		['-'] = 1, ['+'] = 1,
-		[':'] = 1, ['_'] = 1,
-		['@'] = 1, [','] = 1,
-		['~'] = 1, ['^'] = 1,
-	};
-
-	while ((c = *n++) != 0) {
-		if (flags[c] != 1)
-			die("I don't like '%c'. Sue me.", c);
-	}
-	return url;
-}
-
-/*
  * Yeah, yeah, fixme. Need to pass in the heads etc.
  */
 int git_connect(int fd[2], char *url, const char *prog)
@@ -80,7 +53,6 @@ int git_connect(int fd[2], char *url, co
 	int pipefd[2][2];
 	pid_t pid;
 
-	url = shell_safe(url);
 	host = NULL;
 	path = url;
 	colon = strchr(url, ':');
@@ -89,11 +61,12 @@ int git_connect(int fd[2], char *url, co
 		host = url;
 		path = colon+1;
 	}
-	snprintf(command, sizeof(command), "%s %s", prog, path);
 	if (pipe(pipefd[0]) < 0 || pipe(pipefd[1]) < 0)
 		die("unable to create pipe pair for communication");
 	pid = fork();
 	if (!pid) {
+		snprintf(command, sizeof(command), "%s %s", prog,
+			 sq_quote(path));
 		dup2(pipefd[1][0], 0);
 		dup2(pipefd[0][1], 1);
 		close(pipefd[0][0]);

^ permalink raw reply

* pack-e3117bbaf6a59cb53c3f6f0d9b17b9433f0e4135.pack
From: Alexey Dobriyan @ 2005-07-08  7:49 UTC (permalink / raw)
  To: git

Being a happy user of

	$ cat ./rsync-linus
	#!/bin/sh -x

	cd linux-linus
	rsync -avz --progress \
	        rsync://rsync.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git/ \
	        .git/

I'm confused now. This pack file is ~60M in size. Will rsync download
another 60M next time? What command should I use now to a) get latest and
greatest and b) be nice with my traffic?

^ permalink raw reply

* Re: [ANNOUNCE] Cogito-0.12
From: Petr Baudis @ 2005-07-08  8:14 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Tony Luck, Junio C Hamano, Daniel Barkalow, git
In-Reply-To: <Pine.LNX.4.58.0507071706090.25104@g5.osdl.org>

Dear diary, on Fri, Jul 08, 2005 at 02:09:48AM CEST, I got a letter
where Linus Torvalds <torvalds@osdl.org> told me that...
> 
> 
> On Thu, 7 Jul 2005, Linus Torvalds wrote:
> > > 
> > > cg-update from a local repo that contains packs is broken though :-(
> > 
> > Is this with cg-0.12? The most recent release should be happy with packs.
> 
> Ahh, I see it. It's because it uses "git-local-pull", and yes, 
> git-local-pull does the old filename assumption. Right?
> 
> Ho humm.. That's a bug in local-pull.c, although I'm not sure how to fix
> it best.

It seems like the whole pull family is totally borked now, and I'm
getting desperate. Looks like this evening will be *pull.c fixing for
me.

Jul 04 Daniel Barkalow  [PATCH 0/2] Support for transferring pack files in git-ssh-*

is what brings some hope to my life, though. Daniel? Any chance we could
get the similar fixes for local-pull? (I didn't actually look at the
patch but briefly.) I'll try to review the ssh patchset ASAP - I still
prefer it much to the fetch-pack things since its protocol is actually
extensible.

> The _simplest_ fix is to use git-fetch-pack. It doesn't give you the 
> convenient hard-linking, though.

Hard-linking is an absolute must for local repositories (well, either
that for people who want safety, or symlinking for the rest who want
speed - I want to make that one possible in Cogito ASAP but it requires
some non-trivial changes to some of its assumptions).

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
<Espy> be careful, some twit might quote you out of context..

^ permalink raw reply

* Re: Stacked GIT 0.3 (now more Quilt-like)
From: Peter Osterlund @ 2005-07-08  8:14 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Catalin Marinas, git
In-Reply-To: <7vk6k2dr8i.fsf@assigned-by-dhcp.cox.net>

Junio C Hamano <junkio@cox.net> writes:

> >>>>> "PO" == Peter Osterlund <petero2@telia.com> writes:
> 
> PO> I think it would be good if it was possible to include diffstat output
> PO> in exported patches, something like this:
> 
> PO> Added possibility to include diffstat output in exported patches.
> 
> And you wuold want to do things similarly to what others have
> already done.  git-resolve-script uses "git-apply --stat" there,
> instead of "diffstat", so people without diffstat installed can
> still get the same information.

Thanks for the hint. Here is a replacement patch that uses git-apply
instead.


Added possibility to include diffstat output in exported patches.

Signed-off-by: Peter Osterlund <petero2@telia.com>
---

 stgit/git.py  |   23 +++++++++++++++++++++++
 stgit/main.py |    2 ++
 2 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/stgit/git.py b/stgit/git.py
--- a/stgit/git.py
+++ b/stgit/git.py
@@ -345,6 +345,29 @@ def diff(files = [], rev1 = 'HEAD', rev2
                      % (rev1, files_str, extra_args)) != 0:
             raise GitException, 'git-diff-cache failed'
 
+def diffstat(files = [], rev1 = 'HEAD', rev2 = None):
+    """Return the diffstat between rev1 and rev2
+    """
+    files_str = reduce(lambda x, y: x + ' ' + y, files, '')
+
+    os.system('git-update-cache --refresh > /dev/null')
+    ds_cmd = '| git-apply --stat --summary'
+
+    if rev2:
+        f = os.popen('git-diff-tree -p %s %s %s %s'
+                     % (rev1, rev2, files_str, ds_cmd), 'r')
+        str = f.read()
+        if f.close():
+            raise GitException, 'git-diff-tree failed'
+        return str
+    else:
+        f = os.popen('git-diff-cache -p %s %s %s'
+                     % (rev1, files_str, ds_cmd), 'r')
+        str = f.read()
+        if f.close():
+            raise GitException, 'git-diff-cache failed'
+        return str
+
 def checkout(files = [], force = False):
     """Check out the given or all files
     """
diff --git a/stgit/main.py b/stgit/main.py
--- a/stgit/main.py
+++ b/stgit/main.py
@@ -659,6 +659,8 @@ def export(parser, options, args):
         patch = crt_series.get_patch(p)
 
         tmpl_dict = {'description': patch.get_description().rstrip(),
+                     'diffstat': git.diffstat(rev1 = __git_id('%s/bottom' % p),
+                                              rev2 = __git_id('%s/top' % p)),
                      'authname': patch.get_authname(),
                      'authemail': patch.get_authemail(),
                      'authdate': patch.get_authdate(),

-- 
Peter Osterlund - petero2@telia.com
http://web.telia.com/~u89404340

^ permalink raw reply

* Re: pack-e3117bbaf6a59cb53c3f6f0d9b17b9433f0e4135.pack
From: Ryan Anderson @ 2005-07-08  8:18 UTC (permalink / raw)
  To: Alexey Dobriyan; +Cc: git
In-Reply-To: <200507081149.45344.adobriyan@gmail.com>

On Fri, Jul 08, 2005 at 11:49:45AM +0400, Alexey Dobriyan wrote:
> Being a happy user of
> 
> 	$ cat ./rsync-linus
> 	#!/bin/sh -x
> 
> 	cd linux-linus
> 	rsync -avz --progress \
> 	        rsync://rsync.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git/ \
> 	        .git/
> 
> I'm confused now. This pack file is ~60M in size. Will rsync download
> another 60M next time? What command should I use now to a) get latest and
> greatest and b) be nice with my traffic?

You won't need to download another 60M next time.

Run this:
	cd linux-linus
	du -sh .
	git-prune-packed
	du -sh .

You should see a nice drop i space used, as that one big "pack" file is
now taking the place of almost every object in the kernel repository.

In the future, you'll just download new packs as Linus generates them.
I suspect objects will trickle in as well, but an occassional
git-prune-packed will tidy things back up.

The packs internally use a delta-based algorithm to save huge amounts of
space, and for speed of daily use, the standalone objects are still in
use.

-- 

Ryan Anderson
  sometimes Pug Majere

^ permalink raw reply

* Re: Stacked GIT 0.3 (now more Quilt-like)
From: Catalin Marinas @ 2005-07-08  9:32 UTC (permalink / raw)
  To: Peter Osterlund; +Cc: Junio C Hamano, git
In-Reply-To: <m3d5ptlnoi.fsf@telia.com>

Peter Osterlund <petero2@telia.com> wrote:
> Added possibility to include diffstat output in exported patches.

Great. I had a plan to do this but I was busy with the push and
resolved commands. I will apply this patch.

Thanks.

-- 
Catalin

^ permalink raw reply

* [PATCH] add --no-check option to git-write-tree
From: Bryan Larsen @ 2005-07-08 10:37 UTC (permalink / raw)
  To: git

Add --no-check option to git-write-tree.

Signed-off-by: Bryan Larsen <bryan.larsen@gmail.com>
---

  Documentation/git-write-tree.txt |    6 ++++++
  write-tree.c                     |   14 +++++++++++++-
  2 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/Documentation/git-write-tree.txt 
b/Documentation/git-write-tree.txt
--- a/Documentation/git-write-tree.txt
+++ b/Documentation/git-write-tree.txt
@@ -10,6 +10,7 @@ git-write-tree - Creates a tree from the
  SYNOPSIS
  --------
  'git-write-tree'
+		[--no-check]

  DESCRIPTION
  -----------
@@ -23,6 +24,11 @@ In order to have that match what is actu
  now, you need to have done a "git-update-cache" phase before you did the
  "git-write-tree".

+OPTIONS
+-------
+--no-check::
+	Normally "git-write-tree" ensures that the objects referenced by the
+	directory exist in the object database.  This option disabled this check.



diff --git a/write-tree.c b/write-tree.c
--- a/write-tree.c
+++ b/write-tree.c
@@ -5,6 +5,8 @@
   */
  #include "cache.h"

+static int no_check = 0;
+
  static int check_valid_sha1(unsigned char *sha1)
  {
  	int ret;
@@ -61,7 +63,7 @@ static int write_tree(struct cache_entry
  			sha1 = subdir_sha1;
  		}

-		if (check_valid_sha1(sha1) < 0)
+		if (!no_check && check_valid_sha1(sha1) < 0)
  			exit(1);

  		entrylen = pathlen - baselen;
@@ -86,6 +88,16 @@ int main(int argc, char **argv)
  	int i, funny;
  	int entries = read_cache();
  	unsigned char sha1[20];
+	
+	if (argc==2) {
+		if (!strcmp(argv[1], "--no-check"))
+			no_check = 1;
+		else
+			die("unknown option %s", argv[1]);
+	}
+	
+	if (argc>2)
+		die("too many options");

  	if (entries < 0)
  		die("git-write-tree: error reading cache");


\f

^ permalink raw reply

* patches to support working without the object database
From: Bryan Larsen @ 2005-07-08 10:37 UTC (permalink / raw)
  To: git

Sometimes you may wish to keep an audit trail of what changed, where, 
and by whom.  You do not need to know the exact details of the change, 
and the files are so large that keeping an extra copy of the data in the 
object database cache is prohibitively expensive.

Git is (almost) ideally suited for this.  There's very little out there 
that is faster than git-diff-cache.

The design of git also facilitates this.  git-update-cache --cacheinfo 
allows the index to be updated without an object in the database, and 
operations can then be performed around the index.  However, there are 
some things that are inconvenient and one show stopper.

I will separately mail a series of patches.  The first will address the 
show stopper, the rest the inconveniences.  Once applied, cg-init, 
cg-commit and cg-add will all take the "-N" option to update the index 
without moving the objects into the database.  Operations that don't 
require the database such as cg-status and cg-log -f work fine and are 
very useful.

I don't expect the patches to be accepted as is.  One was designed to be 
minimally intrusive, but I suspect that there is a better way to do it: 
suggestions are welcome.  The controversial one switches 
git-update-cache --refresh to rely on the SHA1 being unique rather than 
doing a byte comparison against the (possibly missing) object database. 
  It could be made an option, but I think that's ugly.

All patches are against cogito-0.12.

cheers,
Bryan

^ permalink raw reply

* [PATCH] 3/7 Add --info-only option to git-update-cache.
From: Bryan Larsen @ 2005-07-08 10:54 UTC (permalink / raw)
  To: git



Add --info-only option to git-update-cache.

Signed-off-by: Bryan Larsen <bryan.larsen@gmail.com>
---

  Documentation/git-update-cache.txt |   23 +++++++++++++++++++----
  update-cache.c                     |   14 +++++++++++---
  2 files changed, 30 insertions(+), 7 deletions(-)

diff --git a/Documentation/git-update-cache.txt 
b/Documentation/git-update-cache.txt
--- a/Documentation/git-update-cache.txt
+++ b/Documentation/git-update-cache.txt
@@ -14,6 +14,7 @@ SYNOPSIS
  	     [--ignore-missing]
  	     [--force-remove]
  	     [--cacheinfo <mode> <object> <file>]\*
+	     [--info-only]
  	     [--] [<file>]\*

  DESCRIPTION
@@ -47,6 +48,9 @@ OPTIONS
  --cacheinfo <mode> <object> <path>::
  	Directly insert the specified info into the cache.
  	
+--info-only::
+	All <file> arguments behave like --cacheinfo.
+	
  --force-remove::
  	Remove the file from the index even when the working directory
  	still has such a file. (Implies --remove.)
@@ -80,15 +84,26 @@ the stat entry is out of date.
  For example, you'd want to do this after doing a "git-read-tree", to link
  up the stat cache details with the proper files.

-Using --cacheinfo
------------------
-'--cacheinfo' is used to register a file that is not in the current
-working directory.  This is useful for minimum-checkout merging.
+Using --cacheinfo or --info-only
+--------------------------------
+'--cacheinfo' is used to register a file that is not in the current 
working
+directory.  This is useful for minimum-checkout merging.

  To pretend you have a file with mode and sha1 at path, say:

   $ git-update-cache --cacheinfo mode sha1 path
+
+'--info-only' is used to register a file without placing it in the object
+database.  This is useful for status-only repositories.
+
+Both '--cacheinfo' and '--info-only' behave similarly: the index is updated
+but the object database isn't.  '--cacheinfo' is useful when the object is
+in the database but the file isn't available locally.  '--info-only' is
+useful when the file is available, but you do not wish to update the 
object
+database.

+Examples
+--------
  To update and refresh only the files already checked out:

     git-checkout-cache -n -f -a && git-update-cache --ignore-missing 
--refresh
diff --git a/update-cache.c b/update-cache.c
--- a/update-cache.c
+++ b/update-cache.c
@@ -12,7 +12,7 @@
   * like "git-update-cache *" and suddenly having all the object
   * files be revision controlled.
   */
-static int allow_add = 0, allow_remove = 0, allow_replace = 0, not_new 
= 0, quiet = 0;
+static int allow_add = 0, allow_remove = 0, allow_replace = 0, not_new 
= 0, quiet = 0, info_only = 0;
  static int force_remove;

  /* Three functions to allow overloaded pointer return; see linux/err.h */
@@ -68,7 +68,7 @@ static int add_file_to_cache(char *path)
  		fd = open(path, O_RDONLY);
  		if (fd < 0)
  			return -1;
-		if (index_fd(ce->sha1, fd, &st, 0) < 0)
+		if (index_fd(ce->sha1, fd, &st, info_only) < 0)
  			return -1;
  		break;
  	case S_IFLNK:
@@ -77,7 +77,11 @@ static int add_file_to_cache(char *path)
  			free(target);
  			return -1;
  		}
-		if (write_sha1_file(target, st.st_size, "blob", ce->sha1))
+		if (info_only) {
+			unsigned char hdr[50];
+			int hdrlen;
+			write_sha1_file_prepare(target, st.st_size, "blob", ce->sha1, hdr, 
&hdrlen);
+		} else if (write_sha1_file(target, st.st_size, "blob", ce->sha1))
  			return -1;
  		free(target);
  		break;
@@ -382,6 +386,10 @@ int main(int argc, char **argv)
  				i += 3;
  				continue;
  			}
+			if (!strcmp(path, "--info-only")) {
+				info_only = 1;
+				continue;
+			}
  			if (!strcmp(path, "--force-remove")) {
  				force_remove = 1;
  				continue;


\f

^ permalink raw reply

* [PATCH] 4/7 Use SHA1 for git-update-cache --refresh
From: Bryan Larsen @ 2005-07-08 10:54 UTC (permalink / raw)
  To: git



Change git-update-cache --refresh behaviour to use sha1's rather than
comparing byte by byte.

Signed-off-by: Bryan Larsen <bryan.larsen@gmail.com>
---

  update-cache.c |   31 +++++--------------------------
  1 files changed, 5 insertions(+), 26 deletions(-)

diff --git a/update-cache.c b/update-cache.c
--- a/update-cache.c
+++ b/update-cache.c
@@ -93,37 +93,16 @@ static int add_file_to_cache(char *path)
  	return add_cache_entry(ce, option);
  }

-static int match_data(int fd, void *buffer, unsigned long size)
-{
-	while (size) {
-		char compare[1024];
-		int ret = read(fd, compare, sizeof(compare));
-
-		if (ret <= 0 || ret > size || memcmp(buffer, compare, ret))
-			return -1;
-		size -= ret;
-		buffer += ret;
-	}
-	return 0;
-}
-
-static int compare_data(struct cache_entry *ce, unsigned long 
expected_size)
+static int compare_data(struct cache_entry *ce, struct stat *st)
  {
  	int match = -1;
  	int fd = open(ce->name, O_RDONLY);

  	if (fd >= 0) {
-		void *buffer;
-		unsigned long size;
-		char type[20];
-
-		buffer = read_sha1_file(ce->sha1, type, &size);
-		if (buffer) {
-			if (size == expected_size && !strcmp(type, "blob"))
-				match = match_data(fd, buffer, size);
-			free(buffer);
+		unsigned char sha1[20];
+		if(!index_fd(sha1, fd, st, 1)) {
+			match = memcmp(sha1, ce->sha1, 20);
  		}
-		close(fd);
  	}
  	return match;
  }
@@ -188,7 +167,7 @@ static struct cache_entry *refresh_entry

  	switch (st.st_mode & S_IFMT) {
  	case S_IFREG:
-		if (compare_data(ce, st.st_size))
+		if (compare_data(ce, &st))
  			return ERR_PTR(-EINVAL);
  		break;
  	case S_IFLNK:


\f

^ permalink raw reply

* [PATCH] 7/7 add -N option to cg-init
From: Bryan Larsen @ 2005-07-08 10:54 UTC (permalink / raw)
  To: git

add -N option to cg-init

Signed-off-by: Bryan Larsen <bryan.larsen@gmail.com>
---

  cg-init |   22 +++++++++++++++++++---
  1 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/cg-init b/cg-init
--- a/cg-init
+++ b/cg-init
@@ -10,13 +10,29 @@
  #
  # If `cg-init` is run in a non-empty directory files in the top and
  # sub directory will automatically be added.
+#
+# OPTIONS
+# -------
+# -N::
+#   Only update the cache: do not copy the data into the object database.
+#

-USAGE="cg-init"
+USAGE="cg-init [-N]"
  _git_repo_unneeded=1

  . ${COGITO_LIB}cg-Xlib

-uri=$1
+
+infoonly=
+while optparse; do
+       if optparse -N; then
+               infoonly=-N
+       else
+               optfail
+       fi
+done
+
+uri=$ARGV

  [ -e $_git ] && die "$_git already exists"

@@ -38,7 +54,7 @@ if [ "$uri" ]; then
         echo "Cloned (origin $uri available as branch \"origin\")"
  else
         git-read-tree # Seed the dircache
-       find * \( -type f -o -type l \) -print0 | xargs -0r cg-add
+       find * \( -type f -o -type l \) -print0 | xargs -0r cg-add 
${infoonly}
         cg-commit -C -m"Initial commit" -E
  fi

^ permalink raw reply

* [PATCH] 2/7 Prepare for the next two patches
From: Bryan Larsen @ 2005-07-08 10:54 UTC (permalink / raw)
  To: git



Prepare for the next two patches.  This patch makes the first half of
write_sha1_file() and index_fd() externally visible.  The first half of
these two functions is basically just an SHA1 calculation, so there is
probably a better way to do this.  However, doing things this way makes
this patch and the subsequent patches minimally intrusive.

Signed-off-by: Bryan Larsen <bryan.larsen@gmail.com>
---

  cache.h        |    3 ++-
  sha1_file.c    |   13 +++++++++----
  update-cache.c |    2 +-
  write-blob.c   |    2 +-
  4 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/cache.h b/cache.h
--- a/cache.h
+++ b/cache.h
@@ -139,7 +139,7 @@ extern int remove_cache_entry_at(int pos
  extern int remove_file_from_cache(char *path);
  extern int ce_same_name(struct cache_entry *a, struct cache_entry *b);
  extern int ce_match_stat(struct cache_entry *ce, struct stat *st);
-extern int index_fd(unsigned char *sha1, int fd, struct stat *st);
+extern int index_fd(unsigned char *sha1, int fd, struct stat *st, int 
info_only);
  extern void fill_stat_cache_info(struct cache_entry *ce, struct stat *st);

  struct cache_file {
@@ -169,6 +169,7 @@ extern int sha1_object_info(const unsign
  extern void * unpack_sha1_file(void *map, unsigned long mapsize, char 
*type, unsigned long *size);
  extern void * read_sha1_file(const unsigned char *sha1, char *type, 
unsigned long *size);
  extern int write_sha1_file(void *buf, unsigned long len, const char 
*type, unsigned char *return_sha1);
+extern char *write_sha1_file_prepare(void *buf, unsigned long len, 
const char *type, unsigned char *sha1, unsigned char *hdr, int *hdrlen);

  extern int check_sha1_signature(const unsigned char *sha1, void *buf, 
unsigned long size, const char *type);

diff --git a/sha1_file.c b/sha1_file.c
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -1084,7 +1084,7 @@ void *read_object_with_reference(const u
  	}
  }

-static char *write_sha1_file_prepare(void *buf,
+char *write_sha1_file_prepare(void *buf,
  				     unsigned long len,
  				     const char *type,
  				     unsigned char *sha1,
@@ -1283,12 +1283,14 @@ int has_sha1_file(const unsigned char *s
  	return find_pack_entry(sha1, &e);
  }

-int index_fd(unsigned char *sha1, int fd, struct stat *st)
+int index_fd(unsigned char *sha1, int fd, struct stat *st, int info_only)
  {
  	unsigned long size = st->st_size;
  	void *buf;
  	int ret;
-
+	unsigned char hdr[50];
+	int hdrlen;
+	
  	buf = "";
  	if (size)
  		buf = mmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);
@@ -1296,7 +1298,10 @@ int index_fd(unsigned char *sha1, int fd
  	if ((int)(long)buf == -1)
  		return -1;

-	ret = write_sha1_file(buf, size, "blob", sha1);
+	if (info_only) {
+		(void) write_sha1_file_prepare(buf, size, "blob", sha1, hdr, &hdrlen);
+		ret = 0;
+	} else ret = write_sha1_file(buf, size, "blob", sha1);
  	if (size)
  		munmap(buf, size);
  	return ret;
diff --git a/update-cache.c b/update-cache.c
--- a/update-cache.c
+++ b/update-cache.c
@@ -68,7 +68,7 @@ static int add_file_to_cache(char *path)
  		fd = open(path, O_RDONLY);
  		if (fd < 0)
  			return -1;
-		if (index_fd(ce->sha1, fd, &st) < 0)
+		if (index_fd(ce->sha1, fd, &st, 0) < 0)
  			return -1;
  		break;
  	case S_IFLNK:
diff --git a/write-blob.c b/write-blob.c
--- a/write-blob.c
+++ b/write-blob.c
@@ -17,7 +17,7 @@ int main(int argc, char **argv)
  		fd = open(path, O_RDONLY);
  		if (fd < 0 ||
  		    fstat(fd, &st) < 0 ||
-		    index_fd(sha1, fd, &st) < 0)
+		    index_fd(sha1, fd, &st, 0) < 0)
  			die("Unable to add blob %s to database", path);
  		printf("%s\n", sha1_to_hex(sha1));
  	}


\f

^ permalink raw reply

* [PATCH] 6/7 Add the -N option to cg-commit.
From: Bryan Larsen @ 2005-07-08 10:54 UTC (permalink / raw)
  To: git



Add the -N option to cg-commit.

Signed-off-by: Bryan Larsen <bryan.larsen@gmail.com>
---


  cg-commit |   15 ++++++++++++---
  1 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/cg-commit b/cg-commit
--- a/cg-commit
+++ b/cg-commit
@@ -39,6 +39,10 @@
  #	the tree is the same as the last time you committed, no changes
  #	happenned.
  #
+# -N::
+#   Don't add the files to the object database, just update the caches
+#   and the commit information.
+#
  # FILES
  # -----
  # $GIT_DIR/author::
@@ -103,11 +107,16 @@ fi
  force=
  forceeditor=
  ignorecache=
+infoonly=
  commitalways=
+nocheck=
  msgs=()
  while optparse; do
  	if optparse -C; then
  		ignorecache=1
+	elif optparse -N; then
+		nocheck=--no-check
+		infoonly=--info-only
  	elif optparse -e; then
  		forceeditor=1
  	elif optparse -E; then
@@ -278,9 +287,9 @@ precommit_update () {
  		eval "queue$op[\${#queue$op[@]}]=\"\$fname\""
  	done
  	# XXX: Do we even need to do the --add and --remove update-caches?
-	[ "$queueN" ] && { git-update-cache --add -- "${queueN[@]}" || return 1; }
+	[ "$queueN" ] && { git-update-cache --add ${infoonly} -- 
"${queueN[@]}" || return 1; }
  	[ "$queueD" ] && { git-update-cache --force-remove -- "${queueD[@]}" 
|| return 1; }
-	[ "$queueM" ] && { git-update-cache -- "${queueM[@]}" || return 1; }
+	[ "$queueM" ] && { git-update-cache ${infoonly} -- "${queueM[@]}" || 
return 1; }
  	return 0
  }

@@ -300,7 +309,7 @@ if [ -s "$_git/HEAD" ]; then
  	oldheadstr="-p $oldhead"
  fi

-treeid=$(git-write-tree)
+treeid=$(git-write-tree ${nocheck})
  [ "$treeid" ] || die "git-write-tree failed"
  if [ ! "$force" ] && [ ! "$merging" ] && [ "$oldhead" ] &&
     [ "$treeid" = "$(tree-id)" ]; then


\f

^ permalink raw reply

* [PATCH] 5/7 Add the -N option to cg-add.
From: Bryan Larsen @ 2005-07-08 10:54 UTC (permalink / raw)
  To: git



Add the -N option to cg-add.

Signed-off-by: Bryan Larsen <bryan.larsen@gmail.com>
---

  cg-add |   21 ++++++++++++++++++---
  1 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/cg-add b/cg-add
--- a/cg-add
+++ b/cg-add
@@ -13,20 +13,35 @@
  # is that 'Cogito' manages content and empty directories have no content.
  # Instead, directories are added automatically when adding files inside
  # them.
+#
+# OPTIONS
+# -------
+# -N::
+#   Only update the cache: do not copy the data into the object database.
+#

-USAGE="cg-add FILE..."
+USAGE="cg-add [-N] FILE..."

  . ${COGITO_LIB}cg-Xlib

  [ "$1" ] || usage

+infoonly=
+while optparse; do
+	if optparse -N; then
+		infoonly=--info-only
+	else
+		optfail
+	fi
+done
+
  TMPFILE=$(mktemp -t gitadd.XXXXXX) || exit 1
-find "$@" -type f -print0 > $TMPFILE || {
+find "${ARGS[@]}" -type f -print0 > $TMPFILE || {
  	die "not all files exist, nothing added"
  	rm $TMPFILE
  }

  cat $TMPFILE | tr '\0' '\n' | sed 's/^/Adding file /'
-cat $TMPFILE | xargs -0r git-update-cache --add --
+cat $TMPFILE | xargs -0r git-update-cache --add ${infoonly} --

  rm $TMPFILE


\f

^ permalink raw reply

* git and commiting
From: Mateusz Berezecki @ 2005-07-08 14:07 UTC (permalink / raw)
  To: git

Hi list readers,

How to commit and check-in changes done to the checked-out source code?
The "git commit" command seems to only commit the changes locally
without pushing them via rsync.
Is there any way I can push commits via rsync? Am I missing the point
and git commit is not enough?

please CC me with the answer as I am not subscribed to the list.


regards
/mb

^ permalink raw reply


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