* Re: How to get bash to shut up about SIGPIPE?
From: Paul Jackson @ 2005-04-30 0:22 UTC (permalink / raw)
To: Linus Torvalds; +Cc: git, pasky
In-Reply-To: <Pine.LNX.4.58.0504281121430.18901@ppc970.osdl.org>
> bash is being an ass about SIGPIPE
You have a multiprocessor, don't you.
The following silly little shell script will provoke the bash SIGPIPE
complaint reliably on a multiprocessor. It writes a big file, twice,
from a for-loop in a separate bash subshell through a pipe to a command
that exits after seeing one line.
Code Sample 1:
#!/bin/bash
for x in 1 2
do
cat /etc/termcap # a big text file
done | sed 1q
Adding a right trap _inside_ the shell loop that is _before_ the pipe
will reduce the verbosity of the complaint substantially (not show the
line number and text for each command inside the loop that is killed by
the SIGPIPE; rather just show the simple "Broken pipe" error message):
Code Sample 2:
#!/bin/bash
for x in 1 2
do
trap continue PIPE # reduce broken pipe screeching
cat /etc/termcap # a big text file
done | sed 1q
Then wrapping the entire pipeline (now that the bogus output is a
constant "Broken pipe" string) in the following manner will filter out
just that noise, leaving whatever else was on stdout and/or stderr
unscathed:
Code Sample 3:
#!/bin/bash
( ( (
for x in 1 2
do
trap continue PIPE # reduce broken pipe screeching
cat /etc/termcap # a big text file
done | sed 1q
) 1>&3 ) 2>&1 | grep -vxF 'Broken pipe' 1>&2 ) 3>&1
The following patch to bash jobs.c will enable "Code Sample 2" to do the
right thing, without depending (so much) on the DONT_REPORT_SIGPIPE
compile time flag. With this patch, you don't have to go all the way to
the baroque code in "Code Sample 3" to shut bash up. Just a well placed
trap is sufficient.
Whether or not this is actually worth persuing (or was even worth
reading ;) I don't know.
--- jobs.c.orig 2001-03-26 10:08:24.000000000 -0800
+++ jobs.c 2005-04-29 17:09:44.294763496 -0700
@@ -2686,11 +2686,8 @@ notify_of_job_status ()
}
else if (IS_FOREGROUND (job))
{
-#if !defined (DONT_REPORT_SIGPIPE)
- if (termsig && WIFSIGNALED (s) && termsig != SIGINT)
-#else
- if (termsig && WIFSIGNALED (s) && termsig != SIGINT && termsig != SIGPIPE)
-#endif
+ if (termsig && WIFSIGNALED (s) && termsig != SIGINT &&
+ (termsig != SIGPIPE || signal_is_trapped (termsig) == 0))
{
fprintf (stderr, "%s", strsignal (termsig));
--
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson <pj@engr.sgi.com> 1.650.933.1373, 1.925.600.0401
^ permalink raw reply
* [PATCH] git-fsck-cache: Gracefully handle non-commit IDs
From: Jonas Fonseca @ 2005-04-30 0:28 UTC (permalink / raw)
To: Linus Torvalds; +Cc: git
Gracefully handle non-commit IDs instead of segfaulting.
Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
--- 09465be469eef9711e93b583f4cd1092baa58f90/fsck-cache.c (mode:100644 sha1:280a104050b665515418c00c33af8e6b0b0e2101)
+++ uncommitted/fsck-cache.c (mode:100644)
@@ -174,7 +216,14 @@
continue;
if (!get_sha1_hex(arg, head_sha1)) {
- struct object *obj = &lookup_commit(head_sha1)->object;
+ struct commit *commit = lookup_commit(head_sha1);
+ struct object *obj;
+
+ /* Error is printed by lookup_commit(). */
+ if (!commit)
+ continue;
+
+ obj = &commit->object;
obj->used = 1;
mark_reachable(obj, REACHABLE);
heads++;
--
Jonas Fonseca
^ permalink raw reply
* questions about cg-update, cg-pull, and cg-clone.
From: Zack Brown @ 2005-04-30 0:53 UTC (permalink / raw)
To: Git Mailing List
Hi,
I'm trying to figure out the new Cogito syntax. What is the difference between
cg-update and cg-pull? Here is my take so far, please correct me:
'cg-update branch-name' grabs any new changes from the upstream repository and
merges them into my local repository. If I've been editing files in my local
repository, the update attempts to merge the changes cleanly.
Now, if the update is clean, a cg-commit is invoked automatically, and if the
update is not clean, I then have to resolve any conflicts and give the cg-commit
command by hand. But: what is the significance of either of these cg-commit
commands? Why should I have to write a changelog entry recording this merge? All
I'm doing is updating my tree to be current. Why should I have to 'commit' that
update?
Now I look at 'cg-pull'. What does this do? The readme says something about
printing two ids, and being useful for diffs. But can't I do a diff after a
cg-update and get the same result? I'm very confused about cg-pull right now.
Also, the README says that cg-clone and cg-init are identical, except that
cg-clone creates a new directory for the repository. Is that really the only
difference? Why do we have cg-clone then?
Be well,
Zack
--
Zack Brown
^ permalink raw reply
* Re: Linus' directory is gone?!
From: Jonas Fonseca @ 2005-04-30 1:21 UTC (permalink / raw)
To: Horst von Brand; +Cc: git
In-Reply-To: <200504300041.j3U0fkpV003901@laptop11.inf.utfsm.cl>
Horst von Brand <vonbrand@inf.utfsm.cl> wrote Fri, Apr 29, 2005:
> rsync://rsync.kernel.org/pub/linux/kernel/people/torvalds looks empty...
Moved to rsync://www.kernel.org/pub/scm/git/git.git as mentioned in
another thread.
--
Jonas Fonseca
^ permalink raw reply
* Linus' directory is gone?!
From: Horst von Brand @ 2005-04-30 0:41 UTC (permalink / raw)
To: git
rsync://rsync.kernel.org/pub/linux/kernel/people/torvalds looks empty...
--
Dr. Horst H. von Brand User #22616 counter.li.org
Departamento de Informatica Fono: +56 32 654431
Universidad Tecnica Federico Santa Maria +56 32 654239
Casilla 110-V, Valparaiso, Chile Fax: +56 32 797513
^ permalink raw reply
* Re: [PATCH] GIT: Create tar archives of tree on the fly
From: Rene Scharfe @ 2005-04-30 1:22 UTC (permalink / raw)
To: Linus Torvalds; +Cc: git
In-Reply-To: <Pine.LNX.4.58.0504291522250.18901@ppc970.osdl.org>
On Fri, Apr 29, 2005 at 03:26:14PM -0700, Linus Torvalds wrote:
>
>
> Having just done the git-0.7.tar.gz file with git-tar-tree, I started
> wondering if there is some nice way to encode the commit version that got
> tarred up into the tar archive itself.
... and here is the patch that changes git-tar-tree to add the commit ID
as a comment in a global pax header to the tar file. Archivers ignore
this field. A little sample program is included to read the ID from a
previously prepared archive.
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Write commit ID to global extended pax header at the beginning of the tar
file, if possible. get-tar-commit-id.c is an example program to get the
ID back out of such a tar archive.
---
commit 716d21c45ba1c329fb88febf4704a4ab629a3933
tree 72f4d42eac2cd9099a663c16cb8201f90a8ff9c9
parent 0fc65a4572625405ff6dd9d8c16d835f2b1ebd49
author Rene Scharfe <rene.scharfe@lsrfire.ath.cx> 1114812895 +0200
committer Rene Scharfe <rene.scharfe@lsrfire.ath.cx> 1114812895 +0200
Index: get-tar-commit-id.c
===================================================================
--- /dev/null (tree:c1546808797f6a3c4e6ae82069cee3dc316fbf24)
+++ 72f4d42eac2cd9099a663c16cb8201f90a8ff9c9/get-tar-commit-id.c (mode:100644 sha1:a1a17e53d29136df431d2a128292d7aefefaea41)
@@ -0,0 +1,27 @@
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+#define HEADERSIZE 1024
+
+int main(int argc, char **argv)
+{
+ char buffer[HEADERSIZE];
+ ssize_t n;
+
+ n = read(0, buffer, HEADERSIZE);
+ if (n < HEADERSIZE) {
+ fprintf(stderr, "read error\n");
+ return 3;
+ }
+ if (buffer[156] != 'g')
+ return 1;
+ if (memcmp(&buffer[512], "52 comment=", 11))
+ return 1;
+ n = write(1, &buffer[523], 41);
+ if (n < 41) {
+ fprintf(stderr, "write error\n");
+ return 2;
+ }
+ return 0;
+}
Index: tar-tree.c
===================================================================
--- c1546808797f6a3c4e6ae82069cee3dc316fbf24/tar-tree.c (mode:100644 sha1:5cc7cfef6db1269d81589b82255537fb64ba02fa)
+++ 72f4d42eac2cd9099a663c16cb8201f90a8ff9c9/tar-tree.c (mode:100644 sha1:ea7ea91add54532c38dde9e343efe34d56805341)
@@ -160,7 +160,7 @@
return len;
}
-static void write_header(const char *, const char *, struct path_prefix *,
+static void write_header(const char *, char, const char *, struct path_prefix *,
const char *, unsigned int, unsigned long);
/* stores a pax extended header directly in the block buffer */
@@ -169,7 +169,7 @@
struct path_prefix *prefix,
const char *path, unsigned int namelen)
{
- char *records, *p;
+ char *p;
unsigned int size = 1 + 6 + namelen + 1;
if (size > 9)
size++;
@@ -177,12 +177,10 @@
size++;
if (size > RECORDSIZE)
die("tar-tree: extended header too big, wtf?");
- write_header(NULL, NULL, NULL, headerfilename, 0100600, size);
-
- records = block + offset;
- memset(records, 0, RECORDSIZE);
+ write_header(NULL, 'x', NULL, NULL, headerfilename, 0100600, size);
+ p = block + offset;
+ memset(p, 0, RECORDSIZE);
offset += RECORDSIZE;
- p = records;
append_long(&p, size);
append_string(&p, " path=");
append_path(&p, is_dir, basepath, prefix, path);
@@ -190,8 +188,22 @@
write_if_needed();
}
+static void write_global_extended_header(const char *sha1)
+{
+ char *p;
+ write_header(NULL, 'g', NULL, NULL, "pax_global_header", 0, 52);
+ p = block + offset;
+ memset(p, 0, RECORDSIZE);
+ offset += RECORDSIZE;
+ append_long(&p, 52); /* 2 + 9 + 40 + 1 */
+ append_string(&p, " comment=");
+ append_string(&p, sha1_to_hex(sha1));
+ append_char(&p, '\n');
+ write_if_needed();
+}
+
/* stores a ustar header directly in the block buffer */
-static void write_header(const char *sha1, const char *basepath,
+static void write_header(const char *sha1, char typeflag, const char *basepath,
struct path_prefix *prefix, const char *path,
unsigned int mode, unsigned long size)
{
@@ -236,11 +248,7 @@
sprintf(&header[124], "%011lo", S_ISDIR(mode) ? 0 : size);
sprintf(&header[136], "%011lo", archive_time);
- /* typeflag */
- if (!sha1)
- header[156] = 'x'; /* extended header */
- else
- header[156] = S_ISDIR(mode) ? '5' : '0';
+ header[156] = typeflag;
memcpy(&header[257], "ustar", 6);
memcpy(&header[263], "00", 2);
@@ -279,7 +287,8 @@
eltbuf = read_sha1_file(sha1, elttype, &eltsize);
if (!eltbuf)
die("cannot read %s", sha1_to_hex(sha1));
- write_header(sha1, basedir, prefix, path, mode, eltsize);
+ write_header(sha1, S_ISDIR(mode) ? '5' : '0', basedir,
+ prefix, path, mode, eltsize);
if (!strcmp(elttype, "tree")) {
this_prefix.name = path;
traverse_tree(eltbuf, eltsize, &this_prefix);
@@ -320,6 +329,7 @@
int main(int argc, char **argv)
{
unsigned char sha1[20];
+ unsigned char commit_sha1[20];
void *buffer;
unsigned long size;
@@ -339,8 +349,9 @@
if (!sha1_file_directory)
sha1_file_directory = DEFAULT_DB_ENVIRONMENT;
- buffer = read_object_with_reference(sha1, "commit", &size, NULL);
+ buffer = read_object_with_reference(sha1, "commit", &size, commit_sha1);
if (buffer) {
+ write_global_extended_header(commit_sha1);
archive_time = commit_time(buffer, size);
free(buffer);
}
@@ -351,7 +362,7 @@
if (!archive_time)
archive_time = time(NULL);
if (basedir)
- write_header("0", NULL, NULL, basedir, 040755, 0);
+ write_header("0", '5', NULL, NULL, basedir, 040755, 0);
traverse_tree(buffer, size, NULL);
free(buffer);
write_trailer();
^ permalink raw reply
* [PATCH] Rename usage and error message strings + rpull/rpush commands
From: Jonas Fonseca @ 2005-04-30 1:49 UTC (permalink / raw)
To: Linus Torvalds; +Cc: git
[ Sorry for the resend. Forgot to sign off and CC the ML. ]
Don't know if renaming the program identification strings are desirable.
However, the remote command used by rpull/rpush should probably be
changed.
cat-file.c | 10 +++++-----
commit-tree.c | 2 +-
convert-cache.c | 2 +-
diff-cache.c | 2 +-
diff-files.c | 2 +-
diff-tree-helper.c | 2 +-
diff-tree.c | 4 ++--
fsck-cache.c | 4 ++--
http-pull.c | 2 +-
ls-tree.c | 2 +-
merge-base.c | 2 +-
merge-cache.c | 8 ++++----
read-tree.c | 2 +-
rev-list.c | 2 +-
rev-tree.c | 4 ++--
rpull.c | 4 ++--
rpush.c | 4 ++--
show-files.c | 2 +-
tar-tree.c | 10 +++++-----
unpack-file.c | 2 +-
20 files changed, 36 insertions(+), 36 deletions(-)
Index: cat-file.c
===================================================================
--- c1546808797f6a3c4e6ae82069cee3dc316fbf24/cat-file.c (mode:100644 sha1:3c47d79a16305d326a65768fe9f37ee25928510b)
+++ uncommitted/cat-file.c (mode:100644)
@@ -13,17 +13,17 @@
unsigned long size;
if (argc != 3 || get_sha1_hex(argv[2], sha1))
- usage("cat-file [-t | tagname] <sha1>");
+ usage("git-cat-file [-t | tagname] <sha1>");
buf = read_sha1_file(sha1, type, &size);
if (!buf)
- die("cat-file %s: bad file", argv[2]);
+ die("git-cat-file %s: bad file", argv[2]);
if (!strcmp("-t", argv[1])) {
buf = type;
size = strlen(type);
type[size] = '\n';
size++;
} else if (strcmp(type, argv[1])) {
- die("cat-file %s: bad tag", argv[2]);
+ die("git-cat-file %s: bad tag", argv[2]);
}
while (size > 0) {
@@ -34,9 +34,9 @@
/* Ignore epipe */
if (errno == EPIPE)
break;
- die("cat-file: %s", strerror(errno));
+ die("git-cat-file: %s", strerror(errno));
} else if (!ret) {
- die("cat-file: disk full?");
+ die("git-cat-file: disk full?");
}
size -= ret;
buf += ret;
Index: commit-tree.c
===================================================================
--- c1546808797f6a3c4e6ae82069cee3dc316fbf24/commit-tree.c (mode:100644 sha1:23de13361944ad7ba7c5320cf7cdd04e81842c60)
+++ uncommitted/commit-tree.c (mode:100644)
@@ -240,7 +240,7 @@
*/
#define MAXPARENT (16)
-static char *commit_tree_usage = "commit-tree <sha1> [-p <sha1>]* < changelog";
+static char *commit_tree_usage = "git-commit-tree <sha1> [-p <sha1>]* < changelog";
int main(int argc, char **argv)
{
Index: convert-cache.c
===================================================================
--- c1546808797f6a3c4e6ae82069cee3dc316fbf24/convert-cache.c (mode:100644 sha1:631d1aa910e7328c99642495f93908c749074f91)
+++ uncommitted/convert-cache.c (mode:100644)
@@ -304,7 +304,7 @@
struct entry *entry;
if (argc != 2 || get_sha1_hex(argv[1], sha1))
- usage("convert-cache <sha1>");
+ usage("git-convert-cache <sha1>");
entry = convert_entry(sha1);
printf("new sha1: %s\n", sha1_to_hex(entry->new_sha1));
Index: diff-cache.c
===================================================================
--- c1546808797f6a3c4e6ae82069cee3dc316fbf24/diff-cache.c (mode:100644 sha1:899e37361e5d34a38e4746b3cd290d9b96a6c8f8)
+++ uncommitted/diff-cache.c (mode:100644)
@@ -143,7 +143,7 @@
}
static char *diff_cache_usage =
-"diff-cache [-r] [-z] [-p] [--cached] <tree sha1>";
+"git-diff-cache [-r] [-z] [-p] [--cached] <tree sha1>";
int main(int argc, char **argv)
{
Index: diff-files.c
===================================================================
--- c1546808797f6a3c4e6ae82069cee3dc316fbf24/diff-files.c (mode:100644 sha1:fdd7dd4b0cc8c92a18ddaf0bcf8c9675fcab303b)
+++ uncommitted/diff-files.c (mode:100644)
@@ -7,7 +7,7 @@
#include "diff.h"
static const char *show_diff_usage =
-"show-diff [-p] [-q] [-r] [-z] [paths...]";
+"git-show-diff [-p] [-q] [-r] [-z] [paths...]";
static int generate_patch = 0;
static int line_termination = '\n';
Index: diff-tree-helper.c
===================================================================
--- c1546808797f6a3c4e6ae82069cee3dc316fbf24/diff-tree-helper.c (mode:100644 sha1:282b649f318cf3fa19c7f01da94ba590126f5443)
+++ uncommitted/diff-tree-helper.c (mode:100644)
@@ -104,7 +104,7 @@
}
static const char *diff_tree_helper_usage =
-"diff-tree-helper [-R] [-z] paths...";
+"git-diff-tree-helper [-R] [-z] paths...";
int main(int ac, const char **av) {
struct strbuf sb;
Index: diff-tree.c
===================================================================
--- c1546808797f6a3c4e6ae82069cee3dc316fbf24/diff-tree.c (mode:100644 sha1:e7a5b7cc76f5d80e602184f1ef12f502d53a552b)
+++ uncommitted/diff-tree.c (mode:100644)
@@ -227,7 +227,7 @@
update_tree_entry(&tree2, &size2);
continue;
}
- die("diff-tree: internal error");
+ die("git-diff-tree: internal error");
}
return 0;
}
@@ -250,7 +250,7 @@
return retval;
}
-static char *diff_tree_usage = "diff-tree [-r] [-z] <tree sha1> <tree sha1>";
+static char *diff_tree_usage = "git-diff-tree [-r] [-z] <tree sha1> <tree sha1>";
int main(int argc, char **argv)
{
Index: fsck-cache.c
===================================================================
--- c1546808797f6a3c4e6ae82069cee3dc316fbf24/fsck-cache.c (mode:100644 sha1:280a104050b665515418c00c33af8e6b0b0e2101)
+++ uncommitted/fsck-cache.c (mode:100644)
@@ -51,7 +51,7 @@
static int fsck_tree(struct tree *item)
{
if (item->has_full_path) {
- fprintf(stderr, "warning: fsck-cache: tree %s "
+ fprintf(stderr, "warning: git-fsck-cache: tree %s "
"has full pathnames in it\n",
sha1_to_hex(item->object.sha1));
}
@@ -156,7 +156,7 @@
continue;
}
if (*arg == '-')
- usage("fsck-cache [--tags] [[--unreachable] <head-sha1>*]");
+ usage("git-fsck-cache [--tags] [[--unreachable] <head-sha1>*]");
}
sha1_dir = getenv(DB_ENVIRONMENT) ? : DEFAULT_DB_ENVIRONMENT;
Index: http-pull.c
===================================================================
--- c1546808797f6a3c4e6ae82069cee3dc316fbf24/http-pull.c (mode:100644 sha1:192dcc370dee47c52c72915394bb6f2a79f64e12)
+++ uncommitted/http-pull.c (mode:100644)
@@ -180,7 +180,7 @@
arg++;
}
if (argc < arg + 2) {
- usage("http-pull [-c] [-t] [-a] commit-id url");
+ usage("git-http-pull [-c] [-t] [-a] commit-id url");
return 1;
}
commit_id = argv[arg];
Index: ls-tree.c
===================================================================
--- c1546808797f6a3c4e6ae82069cee3dc316fbf24/ls-tree.c (mode:100644 sha1:d2ab02e3484efaf851c50574e603c785d713bc87)
+++ uncommitted/ls-tree.c (mode:100644)
@@ -80,7 +80,7 @@
return 0;
}
-static const char *ls_tree_usage = "ls-tree [-r] [-z] <key>";
+static const char *ls_tree_usage = "git-ls-tree [-r] [-z] <key>";
int main(int argc, char **argv)
{
Index: merge-base.c
===================================================================
--- c1546808797f6a3c4e6ae82069cee3dc316fbf24/merge-base.c (mode:100644 sha1:2c40881302e586366f03ae6ac6e7c0035847e2f0)
+++ uncommitted/merge-base.c (mode:100644)
@@ -60,7 +60,7 @@
if (argc != 3 ||
get_sha1_hex(argv[1], rev1key) ||
get_sha1_hex(argv[2], rev2key)) {
- usage("merge-base <commit-id> <commit-id>");
+ usage("git-merge-base <commit-id> <commit-id>");
}
rev1 = lookup_commit(rev1key);
rev2 = lookup_commit(rev2key);
Index: merge-cache.c
===================================================================
--- c1546808797f6a3c4e6ae82069cee3dc316fbf24/merge-cache.c (mode:100644 sha1:11079b1cda9c50856a636a19bc41204903f1b522)
+++ uncommitted/merge-cache.c (mode:100644)
@@ -33,7 +33,7 @@
int found;
if (pos >= active_nr)
- die("merge-cache: %s not in the cache", path);
+ die("git-merge-cache: %s not in the cache", path);
arguments[0] = pgm;
arguments[1] = "";
arguments[2] = "";
@@ -58,7 +58,7 @@
arguments[stage + 4] = ownbuf[stage];
} while (++pos < active_nr);
if (!found)
- die("merge-cache: %s not in the cache", path);
+ die("git-merge-cache: %s not in the cache", path);
run_program();
return found;
}
@@ -91,7 +91,7 @@
int i, force_file = 0;
if (argc < 3)
- usage("merge-cache <merge-program> (-a | <filename>*)");
+ usage("git-merge-cache <merge-program> (-a | <filename>*)");
read_cache();
@@ -107,7 +107,7 @@
merge_all();
continue;
}
- die("merge-cache: unknown option %s", arg);
+ die("git-merge-cache: unknown option %s", arg);
}
merge_file(arg);
}
Index: read-tree.c
===================================================================
--- c1546808797f6a3c4e6ae82069cee3dc316fbf24/read-tree.c (mode:100644 sha1:604884a983e087e25afccc1c52beff3883036e58)
+++ uncommitted/read-tree.c (mode:100644)
@@ -156,7 +156,7 @@
}
}
-static char *read_tree_usage = "read-tree (<sha> | -m <sha1> [<sha2> <sha3>])";
+static char *read_tree_usage = "git-read-tree (<sha> | -m <sha1> [<sha2> <sha3>])";
int main(int argc, char **argv)
{
Index: rev-list.c
===================================================================
--- c1546808797f6a3c4e6ae82069cee3dc316fbf24/rev-list.c (mode:100644 sha1:77bfc29db1aad08ba9d7d87ce08d33d4a88e74e3)
+++ uncommitted/rev-list.c (mode:100644)
@@ -8,7 +8,7 @@
struct commit *commit;
if (argc != 2 || get_sha1_hex(argv[1], sha1))
- usage("rev-list <commit-id>");
+ usage("git-rev-list <commit-id>");
commit = lookup_commit(sha1);
if (!commit || parse_commit(commit) < 0)
Index: rev-tree.c
===================================================================
--- c1546808797f6a3c4e6ae82069cee3dc316fbf24/rev-tree.c (mode:100644 sha1:03c900f459c0e6ae7fc9455589be00375f44eac8)
+++ uncommitted/rev-tree.c (mode:100644)
@@ -69,7 +69,7 @@
}
/*
- * Usage: rev-tree [--edges] [--cache <cache-file>] <commit-id> [<commit-id2>]
+ * Usage: git-rev-tree [--edges] [--cache <cache-file>] <commit-id> [<commit-id2>]
*
* The cache-file can be quite important for big trees. This is an
* expensive operation if you have to walk the whole chain of
@@ -103,7 +103,7 @@
basemask |= 1<<nr;
}
if (nr >= MAX_COMMITS || get_sha1_hex(arg, sha1[nr]))
- usage("rev-tree [--edges] [--cache <cache-file>] <commit-id> [<commit-id>]");
+ usage("git-rev-tree [--edges] [--cache <cache-file>] <commit-id> [<commit-id>]");
process_commit(sha1[nr]);
nr++;
}
Index: rpull.c
===================================================================
--- c1546808797f6a3c4e6ae82069cee3dc316fbf24/rpull.c (mode:100644 sha1:c27af2c2464de28732b8ad1fff3ed8a0804250d6)
+++ uncommitted/rpull.c (mode:100644)
@@ -108,13 +108,13 @@
arg++;
}
if (argc < arg + 2) {
- usage("rpull [-c] [-t] [-a] commit-id url");
+ usage("git-rpull [-c] [-t] [-a] commit-id url");
return 1;
}
commit_id = argv[arg];
url = argv[arg + 1];
- if (setup_connection(&fd_in, &fd_out, "rpush", url, arg, argv + 1))
+ if (setup_connection(&fd_in, &fd_out, "git-rpush", url, arg, argv + 1))
return 1;
get_sha1_hex(commit_id, sha1);
Index: rpush.c
===================================================================
--- c1546808797f6a3c4e6ae82069cee3dc316fbf24/rpush.c (mode:100644 sha1:0293a1a46311d7e20b13177143741ab9d6d0d201)
+++ uncommitted/rpush.c (mode:100644)
@@ -56,12 +56,12 @@
arg++;
}
if (argc < arg + 2) {
- usage("rpush [-c] [-t] [-a] commit-id url");
+ usage("git-rpush [-c] [-t] [-a] commit-id url");
return 1;
}
commit_id = argv[arg];
url = argv[arg + 1];
- if (setup_connection(&fd_in, &fd_out, "rpull", url, arg, argv + 1))
+ if (setup_connection(&fd_in, &fd_out, "git-rpull", url, arg, argv + 1))
return 1;
service(fd_in, fd_out);
Index: show-files.c
===================================================================
--- c1546808797f6a3c4e6ae82069cee3dc316fbf24/show-files.c (mode:100644 sha1:d4061f83031447aa9ee8ad16544e7bc084908838)
+++ uncommitted/show-files.c (mode:100644)
@@ -207,7 +207,7 @@
}
static const char *show_files_usage =
- "show-files [-z] (--[cached|deleted|others|stage|unmerged])* "
+ "git-show-files [-z] (--[cached|deleted|others|stage|unmerged])* "
"[ --ignored [--exclude=<pattern>] [--exclude-from=<file>) ]";
int main(int argc, char **argv)
Index: tar-tree.c
===================================================================
--- c1546808797f6a3c4e6ae82069cee3dc316fbf24/tar-tree.c (mode:100644 sha1:5cc7cfef6db1269d81589b82255537fb64ba02fa)
+++ uncommitted/tar-tree.c (mode:100644)
@@ -4,7 +4,7 @@
#define RECORDSIZE (512)
#define BLOCKSIZE (RECORDSIZE * 20)
-static const char *tar_tree_usage = "tar-tree <key> [basedir]";
+static const char *tar_tree_usage = "git-tar-tree <key> [basedir]";
static char block[BLOCKSIZE];
static unsigned long offset;
@@ -27,9 +27,9 @@
continue;
if (errno == EPIPE)
exit(0);
- die("tar-tree: %s", strerror(errno));
+ die("git-tar-tree: %s", strerror(errno));
} else if (!ret) {
- die("tar-tree: disk full?");
+ die("git-tar-tree: disk full?");
}
size -= ret;
buf += ret;
@@ -176,7 +176,7 @@
if (size > 99)
size++;
if (size > RECORDSIZE)
- die("tar-tree: extended header too big, wtf?");
+ die("git-tar-tree: extended header too big, wtf?");
write_header(NULL, NULL, NULL, headerfilename, 0100600, size);
records = block + offset;
@@ -202,7 +202,7 @@
namelen = path_len(S_ISDIR(mode), basepath, prefix, path);
if (namelen > 500) {
- die("tar-tree: name too log of object %s\n", sha1_to_hex(sha1));
+ die("git-tar-tree: name too log of object %s\n", sha1_to_hex(sha1));
} else if (namelen > 100) {
char *sha1_hex = sha1_to_hex(sha1);
char headerfilename[51];
Index: unpack-file.c
===================================================================
--- c1546808797f6a3c4e6ae82069cee3dc316fbf24/unpack-file.c (mode:100644 sha1:6ff3d51c182627f42b104932ecea9b95d6225a5d)
+++ uncommitted/unpack-file.c (mode:100644)
@@ -27,7 +27,7 @@
unsigned char sha1[20];
if (argc != 2 || get_sha1_hex(argv[1], sha1))
- usage("unpack-file.c <sha1>");
+ usage("git-unpack-file <sha1>");
puts(create_temp_file(sha1));
return 0;
--
Jonas Fonseca
^ permalink raw reply
* Re: Linus' directory is gone?!
From: Jonas Fonseca @ 2005-04-30 1:35 UTC (permalink / raw)
To: Horst von Brand, git
In-Reply-To: <20050430012113.GD32339@diku.dk>
Jonas Fonseca <fonseca@diku.dk> wrote Sat, Apr 30, 2005:
> Horst von Brand <vonbrand@inf.utfsm.cl> wrote Fri, Apr 29, 2005:
> > rsync://rsync.kernel.org/pub/linux/kernel/people/torvalds looks empty...
>
> Moved to rsync://www.kernel.org/pub/scm/git/git.git as mentioned in
> another thread.
Or rather to directories under rsync://rsync.kernel.org/pub/scm/ ..
--
Jonas Fonseca
^ permalink raw reply
* Re: questions about cg-update, cg-pull, and cg-clone.
From: David A. Wheeler @ 2005-04-30 2:37 UTC (permalink / raw)
To: Zack Brown; +Cc: Git Mailing List, Petr Baudis, xpasky
In-Reply-To: <20050430005322.GA5408@tumblerings.org>
Zack Brown wrote:
> Hi,
>
> I'm trying to figure out the new Cogito syntax. What is the difference between
> cg-update and cg-pull? Here is my take so far, please correct me:
>
> 'cg-update branch-name' grabs any new changes from the upstream repository and
> merges them into my local repository. If I've been editing files in my local
> repository, the update attempts to merge the changes cleanly.
Yes. "cg-update branch-name" is EXACTLY the same as
cg-pull branch-name && cg-merge branch-name
You can see this by examining the last lines of the cg-update script.
Because updating is one of the single most common operations for an SCM,
it makes sense to have a single command that does it.
Currently cg-update without a branch name does "recover deleted files"
instead, but I think that's a wart & Petr agrees (that will probably
get moved to a different command, see separate discussion).
> Now, if the update is clean, a cg-commit is invoked automatically,
Correct; cg-merge calls "cg-commit -C" (ignore cache)
if the merge is clean.
> and if the
> update is not clean, I then have to resolve any conflicts and give the cg-commit
> command by hand.
Correct.
> But: what is the significance of either of these cg-commit
> commands? Why should I have to write a changelog entry recording this merge? All
> I'm doing is updating my tree to be current. Why should I have to 'commit' that
> update?
I can't speak Petr, but I would guess that he's doing that because
he's trying to avoid data loss.
> Now I look at 'cg-pull'. What does this do? The readme says something about
> printing two ids, and being useful for diffs. But can't I do a diff after a
> cg-update and get the same result? I'm very confused about cg-pull right now.
cg-pull BRANCH copies any changes from the named branch into your
repository. You could do a diff afterwards, yes, to get the
same results as long as the data is in your repository. However,
after a successful merge the HEAD will be different from before
a successful merge, so the DEFAULT answers from a
diff will be different.
> Also, the README says that cg-clone and cg-init are identical, except that
> cg-clone creates a new directory for the repository. Is that really the only
> difference? Why do we have cg-clone then?
You'll have to ask Petr. My guess is that he has bigger plans
for cg-clone, what you're seeing is just the current stub.
Anyway, hope my guessing helps.
--- David A. Wheeler
^ permalink raw reply
* Re: Mercurial 0.4b vs git patchbomb benchmark
From: Andrea Arcangeli @ 2005-04-30 2:52 UTC (permalink / raw)
To: Matt Mackall; +Cc: Linus Torvalds, linux-kernel, git
In-Reply-To: <20050429203959.GC21897@waste.org>
On Fri, Apr 29, 2005 at 01:39:59PM -0700, Matt Mackall wrote:
> Mercurial is ammenable to rsync provided you devote a read-only
> repository to it on the client side. In other words, you rsync from
> kernel.org/mercurial/linus to local/linus and then you merge from
> local/linus to your own branch. Mercurial's hashing hierarchy is
> similar to git's (and Monotone's), so you can sign a single hash of
> the tree as well.
Ok fine. It's also interesting how you already enabled partial transfers
through http.
Please apply this patch so it doesn't fail on my setup ;)
--- mercurial-0.4b/hg.~1~ 2005-04-29 02:52:52.000000000 +0200
+++ mercurial-0.4b/hg 2005-04-30 00:53:02.000000000 +0200
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python
#
# mercurial - a minimal scalable distributed SCM
# v0.4b "oedipa maas"
On a bit more technical side, one thing I'm wondering about is the
compression. If I change mercurial like this:
--- revlog.py.~1~ 2005-04-29 01:33:14.000000000 +0200
+++ revlog.py 2005-04-30 03:54:12.000000000 +0200
@@ -11,9 +11,11 @@
import zlib, struct, mdiff, sha, binascii, os, tempfile
def compress(text):
+ return text
return zlib.compress(text)
def decompress(bin):
+ return text
return zlib.decompress(bin)
def hash(text):
the .hg directory sizes changes from 167M to 302M _BUT_ the _compressed_
size of the .hg directory (i.e. like in a full network transfer with
rsync -z or a tar.gz backup) changes from 55M to 38M:
andrea@opteron:~/devel/kernel> du -sm hg-orig hg-aa hg-orig.tar.bz2 hg-aa.tar.bz2
167 hg-orig
302 hg-aa
55 hg-orig.tar.bz2
38 hg-aa.tar.bz2
^^^^^^^^^^^^^^^^^^^^^ 38M backup and network transfer is what I want
So I don't really see an huge benefit in compression, other than to
slowdown the checkins measurably [i.e. what Linus doesn't want] (the
time of compression is a lot higher than the time of python runtime during
checkin, so it's hard to believe your 100% boost with psyco in the hg file,
sometime psyco doesn't make any difference infact, I'd rather prefer people to
work on the real thing of generating native bytecode at compile time, rather
than at runtime, like some haskell compiler can do).
mercurial is already good at decreasing the entropy by using an efficient
storage format, it doesn't need to cheat by putting compression on each blob
that can only leads to bad ratios when doing backups and while transferring
more than one blob through the network.
So I suggest to try disabling compression optionally, perhaps it'll be even
faster than git in the initial checkin that way! No need of compressing or
decompressing anything with mercurial (unlike with git that would explode
without control w/o compression).
My time measurements follows:
w/o compression:
9.52user 73.11system 1:30.49elapsed 91%CPU (0avgtext+0avgdata 0maxresident)k
^
0inputs+0outputs (0major+80109minor)pagefaults 0swaps
w/ compression (i.e. official package):
26.78user 75.90system 1:44.87elapsed 97%CPU (0avgtext+0avgdata 0maxresident)k
^^
0inputs+0outputs (0major+484522minor)pagefaults 0swaps
The user time is by far the most important reliable number here, 17 seconds of
difference wasted in compression time. The 1:30 time w/o cache didn't fit
completely in cache, but still it was faster (only 14 sec faster instead of 17
sec faster due some minor I/O that happened due the larger pagecache size that
was recycled a bit).
Without compression the time is 90% system time, very little time is spent in
userland, and of course I made sure very little time is spent in I/O. vmstat
looks like this:
1 0 107008 61320 31964 546076 0 0 0 7860 1095 1147 5 46 41 9
1 0 107008 59336 31972 547564 0 0 0 0 1074 1093 6 46 48 0
1 0 107008 57544 31988 549044 0 0 0 0 1095 1239 5 45 50 0
1 0 107008 55304 32000 550936 0 0 0 0 1064 1041 5 46 50 0
1 0 107008 53384 32012 552488 0 0 0 0 1080 1081 5 45 50 0
1 0 107008 51592 32032 553964 0 0 0 8260 1087 1018 3 48 40 10
1 0 107008 49144 32040 555180 0 0 0 0 1099 1090 5 48 47 0
1 0 107008 47432 32048 556532 0 0 0 0 1086 1014 4 46 50 0
1 0 107008 45632 32060 557676 0 0 0 0 1102 1073 4 47 49 0
2 0 107008 44032 32068 558892 0 0 0 0 1088 1044 4 46 49 0
1 0 107008 42864 32116 560204 0 0 8 6672 1136 1265 5 47 41 7
1 0 107008 41008 32124 561420 0 0 0 484 1182 1078 5 43 49 3
(5 = user, 43 system, 49 idle is the second cpu doing nothing, 3 is io-wait
time)
While with compression (default) the user time goes up, a lot higher than
what python wasted in the above trace:
1 0 107008 282688 26756 346396 0 0 0 12064 1122 997 20 32 38 12
1 0 107008 279936 26776 348552 0 0 0 0 1074 938 15 36 50 0
1 0 107008 277296 26780 350656 0 0 0 0 1087 1070 15 36 50 0
1 0 107008 274672 26796 352816 0 0 4 28 1060 1021 15 36 49 1
1 0 107008 272176 26824 354828 0 0 0 52 1092 1082 19 32 50 0
1 1 107008 269616 26844 356780 0 0 0 10856 1106 1019 16 36 36 13
1 0 107008 267312 26864 358936 0 0 0 4 1081 1068 27 24 49 0
1 0 107008 265072 26876 360760 0 0 0 0 1068 1073 23 27 50 0
1 0 107008 263024 26888 362516 0 0 0 2764 1224 1457 18 29 49 5
1 0 107008 260928 26900 364408 0 0 0 20 1060 969 21 29 50 0
1 0 107008 258752 26928 366216 0 0 0 9768 1098 916 18 32 37 12
1 0 107008 256640 26940 367972 0 0 0 0 1058 1093 13 37 50 0
1 0 107008 254384 26952 369796 0 0 0 0 1089 1259 18 33 50 0
1 0 107008 252016 26972 371680 0 0 0 0 1063 1040 29 22 50 0
The difference in time may be even higher than the above since the pass w/o
compression may have done some read I/O too sometime, since I've 1G and
it didn't fit completely in cache (I made sure the second pass was completely
from cache instead, by running twice and verifying the free memory never went
lower than 100M).
Http is not intended for maximal efficiency, it's there just to make
life easy. special protocol with zlib is required for maximum
efficiency.
My suggestion is to leave compression optional by storing a bit in the .hg
directory (a global bit) to know if the blob is compressed or not... so if
people have problems and runs out of pagecache they can use it, but Linus
definitely must keep compression off to run the checkin at max speed (i.e.
potentially much faster than git, especially on big files). The cost of one
branch in python to know if compression is enabled or not shouldn't be an issue.
Compression should be a parameter to "hg init", perhaps hg -z, so in the future
we can add -j to add bzip2 too.
You also should move the .py into a hg directory, so that they won't
pollute the site-packages.
Matt, very great work with mercurial. The small mercurial size is striking, 1037
lines total excluding the classes you rightfully shared from other python
projects. That's less than 1/7 of the size of cogito (ok perhaps it's not as
mature as cogito but anyway). Great choice for the language too (but
perhaps I'm biased ;).
^ permalink raw reply
* Re: How to get bash to shut up about SIGPIPE?
From: Linus Torvalds @ 2005-04-30 2:59 UTC (permalink / raw)
To: Paul Jackson; +Cc: git, pasky
In-Reply-To: <20050429172235.21c1af10.pj@sgi.com>
On Fri, 29 Apr 2005, Paul Jackson wrote:
>
> > bash is being an ass about SIGPIPE
>
> You have a multiprocessor, don't you.
Yes.
> The following silly little shell script will provoke the bash SIGPIPE
> complaint reliably on a multiprocessor.
Yup:
t: line 5: 3853 Broken pipe cat /etc/termcap
t: line 5: 3855 Broken pipe cat /etc/termcap
> Adding a right trap _inside_ the shell loop that is _before_ the pipe
> will reduce the verbosity of the complaint substantially (not show the
> line number and text for each command inside the loop that is killed by
> the SIGPIPE; rather just show the simple "Broken pipe" error message):
>
> Code Sample 2:
>
> #!/bin/bash
> for x in 1 2
> do
> trap continue PIPE # reduce broken pipe screeching
> cat /etc/termcap # a big text file
> done | sed 1q
Didn't change anything for me. Same thing.
> Then wrapping the entire pipeline (now that the bogus output is a
> constant "Broken pipe" string) in the following manner will filter out
> just that noise, leaving whatever else was on stdout and/or stderr
> unscathed:
It will also grep out any occurrence of "Broken pipe", so if we're talking
about a kernel changelog, where we fix a pipe bug...
> Whether or not this is actually worth persuing (or was even worth
> reading ;) I don't know.
I don't know why the bash people have that stupid pipe reporting in the
first place, considering that no other shell seems to do it, and everybody
just wants to shut it up..
Linus
^ permalink raw reply
* Re: Trying to use AUTHOR_DATE
From: Edgar Toernig @ 2005-04-30 3:23 UTC (permalink / raw)
To: tony.luck; +Cc: H. Peter Anvin, git
In-Reply-To: <200504300021.j3U0La023762@unix-os.sc.intel.com>
tony.luck@intel.com wrote:
>
> > There was a time-parsing bug somewhere, where mktime() got invoked on a
> > UTC date. I proposed changing it to curl_gettime() instead.
>
> Here's a patch to switch to using curl_getdate():
Another dependency :-( I can live without http-pull but not
without commit-tree.
What's wrong with the patch I sent to fix this:
http://marc.theaimsgroup.com/?m=111446501003389
> + /* find the timezone at the end */
> + p = date + strlen(date);
> + while (p > date && isdigit(*--p))
> + ;
> + if ((*p == '+' || *p == '-') && strlen(p) == 5)
> + snprintf(result, maxlen, "%lu %5.5s", then, p);
This will choke on dates from Linus which have a trailing comment:
Date: Fri, 29 Apr 2005 15:26:14 -0700 (PDT)
Ciao, ET.
^ permalink raw reply
* RE: Trying to use AUTHOR_DATE
From: Luck, Tony @ 2005-04-30 3:44 UTC (permalink / raw)
To: Edgar Toernig; +Cc: H. Peter Anvin, git
>Another dependency :-( I can live without http-pull but not
>without commit-tree.
Yes, the extra dependency sucks ... libcurl is missing from one of
the systems that I'd like to use GIT on ... so I'd prefer a solution
that doesn't involve libcurl.
>What's wrong with the patch I sent to fix this:
>
> http://marc.theaimsgroup.com/?m=111446501003389
>
I missed it ... there is a problem that you drop the timezone. When I
used this patch, I ended up with a commit that said:
author Keith Owens <kaos@sgi.com> 1114239900
committer Tony Luck <tony.luck@intel.com> 1114832076 -0700
See the missing timezone on the author line :-) This is most upsetting
to cg-log. It prints "expr: syntax error" and then
author Keith Owens <kaos@sgi.com> Thu, 01 Jan 1970 00:00:01
>> + /* find the timezone at the end */
>> + p = date + strlen(date);
>> + while (p > date && isdigit(*--p))
>> + ;
>> + if ((*p == '+' || *p == '-') && strlen(p) == 5)
>> + snprintf(result, maxlen, "%lu %5.5s", then, p);
>
>This will choke on dates from Linus which have a trailing comment:
>
> Date: Fri, 29 Apr 2005 15:26:14 -0700 (PDT)
You are right ... that's what comes from only looking at one e-mail
message to determine that pattern to match :-)
I'd much rather see your version fixed up to preserve the timezone
than have the libcurl dependency.
-Tony
^ permalink raw reply
* Re: Trying to use AUTHOR_DATE
From: H. Peter Anvin @ 2005-04-30 3:47 UTC (permalink / raw)
To: Edgar Toernig; +Cc: tony.luck, git
In-Reply-To: <20050430052318.1bd4b189.froese@gmx.de>
Edgar Toernig wrote:
>
> Another dependency :-( I can live without http-pull but not
> without commit-tree.
>
Then feel free to rip curl_getdate out of the libcurl sources and making
them standalone.
-hpa
^ permalink raw reply
* Re: Trying to use AUTHOR_DATE
From: H. Peter Anvin @ 2005-04-30 3:49 UTC (permalink / raw)
To: Luck, Tony; +Cc: Edgar Toernig, git
In-Reply-To: <B8E391BBE9FE384DAA4C5C003888BE6F035EDE2C@scsmsx401.amr.corp.intel.com>
Luck, Tony wrote:
>>Another dependency :-( I can live without http-pull but not
>>without commit-tree.
>
> Yes, the extra dependency sucks ... libcurl is missing from one of
> the systems that I'd like to use GIT on ... so I'd prefer a solution
> that doesn't involve libcurl.
...
> I'd much rather see your version fixed up to preserve the timezone
> than have the libcurl dependency.
For gawd's sake people, just grab a copy of the working code in libcurl,
and turn it into a standalone .c file. It'll even let you merge in
future fixes, and you could even use autoconf to use libcurl or the
standalone code depending on what's available.
-hpa
^ permalink raw reply
* Re: Trying to use AUTHOR_DATE
From: Linus Torvalds @ 2005-04-30 4:02 UTC (permalink / raw)
To: H. Peter Anvin; +Cc: Luck, Tony, Edgar Toernig, git
In-Reply-To: <42730061.5010106@zytor.com>
On Fri, 29 Apr 2005, H. Peter Anvin wrote:
>
> For gawd's sake people, just grab a copy of the working code in libcurl,
> and turn it into a standalone .c file. It'll even let you merge in
> future fixes, and you could even use autoconf to use libcurl or the
> standalone code depending on what's available.
I'll happily depend on libcurl, but I put my foot down on that tool of the
devil called "autoconf".
Any package that starts using autoconf eventually becomes a total mess.
Don't do it.
Linus
^ permalink raw reply
* Re: Trying to use AUTHOR_DATE
From: Linus Torvalds @ 2005-04-30 4:22 UTC (permalink / raw)
To: H. Peter Anvin; +Cc: Luck, Tony, Edgar Toernig, git
In-Reply-To: <Pine.LNX.4.58.0504292101230.2296@ppc970.osdl.org>
On Fri, 29 Apr 2005, Linus Torvalds wrote:
>
> I'll happily depend on libcurl, but I put my foot down on that tool of the
> devil called "autoconf".
Btw, looking at curl's "getdate.c", it doesn't seem to be _that_ much more
different from the date parsing we used to have. In particular, it
actually uses "mktime()" twice and subtracts out the difference.
It also seems to do so in a particularly stupid way, and David Woodhouses
suggestion of just using mktime() on Jan 1st, 1970, seems to be much
simpler than what curl does.
(Actually, it might make sense to modify David's version to use "Jan 2nd,
1970" and subtract 24 hours, in case some mktime() implementation decides
that underflow is a problem...)
Of course, I think we might as well go with Edgars version after all.
Edgar, willing to create a separate "parse-date.c" with your "my_mktime()"
thing and move the old date parsing there? That way we'll just use that
instead of libcurl..
Linus
^ permalink raw reply
* Re: Trying to use AUTHOR_DATE
From: Russ Allbery @ 2005-04-30 4:32 UTC (permalink / raw)
To: Linus Torvalds, git
In-Reply-To: <Pine.LNX.4.58.0504292114580.2296@ppc970.osdl.org>
Linus Torvalds <torvalds@osdl.org> writes:
> It also seems to do so in a particularly stupid way, and David
> Woodhouses suggestion of just using mktime() on Jan 1st, 1970, seems to
> be much simpler than what curl does.
Because of daylight savings time, this doesn't actually work. I know from
personal experience; this is the tactic that I took at first when writing
INN's date parser and was educated by test failures.
--
Russ Allbery (rra@stanford.edu) <http://www.eyrie.org/~eagle/>
^ permalink raw reply
* Re: Trying to use AUTHOR_DATE
From: Edgar Toernig @ 2005-04-30 4:50 UTC (permalink / raw)
To: Luck, Tony; +Cc: H. Peter Anvin, git
In-Reply-To: <B8E391BBE9FE384DAA4C5C003888BE6F035EDE2C@scsmsx401.amr.corp.intel.com>
Luck, Tony wrote:
>
> >What's wrong with the patch I sent to fix this:
>
> I missed it ... there is a problem that you drop the timezone.
Upps, sorry.
> I'd much rather see your version fixed up to preserve the timezone
> than have the libcurl dependency.
Fixed version below.
--- x/commit-tree.c Thu Apr 21 19:58:47 2005
+++ y/commit-tree.c Sat Apr 30 06:24:19 2005
@@ -113,6 +113,25 @@
}
}
+static time_t my_mktime(struct tm *tm)
+{
+ static const int mdays[] = {
+ 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334
+ };
+ int year = tm->tm_year - 70;
+ int month = tm->tm_mon;
+ int day = tm->tm_mday;
+
+ if (year < 0 || year > 129) /* algo only works for 1970-2099 */
+ return -1;
+ if (month < 0 || month > 11) /* array bounds */
+ return -1;
+ if (month < 2 || (year + 2) % 4)
+ day--;
+ return (year * 365 + (year + 1) / 4 + mdays[month] + day) * 24*60*60UL +
+ tm->tm_hour * 60*60 + tm->tm_min * 60 + tm->tm_sec;
+}
+
static const char *month_names[] = {
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
@@ -136,7 +155,7 @@
static void parse_rfc2822_date(char *date, char *result, int maxlen)
{
struct tm tm;
- char *p;
+ char *p, *tz;
int i, offset;
time_t then;
@@ -194,7 +213,7 @@
return;
tm.tm_hour = strtoul(p, &p, 10);
- if (!tm.tm_hour > 23)
+ if (tm.tm_hour > 23)
return;
if (*p != ':')
@@ -206,14 +225,11 @@
return;
tm.tm_min = strtoul(p, &p, 10);
- if (!tm.tm_min > 59)
+ if (tm.tm_min > 59)
return;
- if (isspace(*p))
- goto zone;
-
if (*p != ':')
- return; /* Error -- bad time */
+ goto zone;
p++;
/* second */
@@ -221,13 +237,13 @@
return;
tm.tm_sec = strtoul(p, &p, 10);
- if (!tm.tm_sec > 59)
+ if (tm.tm_sec > 59)
return;
+ zone:
if (!isspace(*p))
return;
- zone:
p = skipfws(p);
if (*p == '-')
@@ -240,19 +256,21 @@
if (!isdigit(p[1]) || !isdigit(p[2]) || !isdigit(p[3]) || !isdigit(p[4]))
return;
+ tz = p;
i = strtoul(p+1, NULL, 10);
offset *= ((i % 100) + ((i / 100) * 60));
- if (*(skipfws(p + 5)))
+ p = skipfws(p + 5);
+ if (*p && *p != '(') /* trailing comment like (EDT) is ok */
return;
- then = mktime(&tm); /* mktime appears to ignore the GMT offset, stupidly */
+ then = my_mktime(&tm); /* mktime uses local timezone */
if (then == -1)
return;
then -= offset;
- snprintf(result, maxlen, "%lu %5.5s", then, p);
+ snprintf(result, maxlen, "%lu %5.5s", then, tz);
}
static void check_valid(unsigned char *sha1, const char *expect)
Ciao, ET.
^ permalink raw reply
* RE: Trying to use AUTHOR_DATE
From: Luck, Tony @ 2005-04-30 5:28 UTC (permalink / raw)
To: Edgar Toernig; +Cc: H. Peter Anvin, git
>Fixed version below.
Yup ... that fixes it for my initial test cases. Thanks.
-Tony
P.S. The libcurl that I found (curl-7.12.1-3.src.rpm) has curl_getdate()
implemented as >1000 lines of yacc. Which seems like overkill (unless
I really need to set AUTHOR_DATE="a week ago last tuesday" :-)
^ permalink raw reply
* [PATCH] Split out "pull" from particular methods
From: Daniel Barkalow @ 2005-04-30 5:36 UTC (permalink / raw)
To: Junio C Hamano, Linus Torvalds
Cc: Ryan Anderson, Petr Baudis, Russell King, git
In-Reply-To: <7vy8b12qg1.fsf@assigned-by-dhcp.cox.net>
The method for deciding what to pull is useful separately from any of the
ways of actually fetching the objects.
Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
Split out "pull" functionality from http-pull and rpull
Index: Makefile
===================================================================
--- 8602fe7cb4bf668fd021ab3bfb2082ac7d535e57/Makefile (mode:100644 sha1:ef9a9fae88a1ac438c22beb50790f0f0e37ffc3c)
+++ 41f4697d0ada8e79a2f262aa9b6357a45194f31d/Makefile (mode:100644 sha1:87fe8fef5ebd315f370af882bd3172632b850c02)
@@ -82,9 +82,9 @@
git-export: export.c
git-diff-cache: diff-cache.c
git-convert-cache: convert-cache.c
-git-http-pull: http-pull.c
+git-http-pull: http-pull.c pull.c
git-rpush: rsh.c
-git-rpull: rsh.c
+git-rpull: rsh.c pull.c
git-rev-list: rev-list.c
git-mktag: mktag.c
git-diff-tree-helper: diff-tree-helper.c
Index: http-pull.c
===================================================================
--- 8602fe7cb4bf668fd021ab3bfb2082ac7d535e57/http-pull.c (mode:100644 sha1:192dcc370dee47c52c72915394bb6f2a79f64e12)
+++ 41f4697d0ada8e79a2f262aa9b6357a45194f31d/http-pull.c (mode:100644 sha1:d877c4abe3ff7766d858bfeac5c9a0eaf1385b65)
@@ -7,6 +7,8 @@
#include <errno.h>
#include <stdio.h>
+#include "pull.h"
+
#include <curl/curl.h>
#include <curl/easy.h>
@@ -14,10 +16,6 @@
static char *base;
-static int tree = 0;
-static int commits = 0;
-static int all = 0;
-
static SHA_CTX c;
static z_stream stream;
@@ -47,7 +45,7 @@
return size;
}
-static int fetch(unsigned char *sha1)
+int fetch(unsigned char *sha1)
{
char *hex = sha1_to_hex(sha1);
char *filename = sha1_file_name(sha1);
@@ -105,77 +103,21 @@
return 0;
}
-static int process_tree(unsigned char *sha1)
-{
- struct tree *tree = lookup_tree(sha1);
- struct tree_entry_list *entries;
-
- if (parse_tree(tree))
- return -1;
-
- for (entries = tree->entries; entries; entries = entries->next) {
- if (fetch(entries->item.tree->object.sha1))
- return -1;
- if (entries->directory) {
- if (process_tree(entries->item.tree->object.sha1))
- return -1;
- }
- }
- return 0;
-}
-
-static int process_commit(unsigned char *sha1)
-{
- struct commit *obj = lookup_commit(sha1);
-
- if (fetch(sha1))
- return -1;
-
- if (parse_commit(obj))
- return -1;
-
- if (tree) {
- if (fetch(obj->tree->object.sha1))
- return -1;
- if (process_tree(obj->tree->object.sha1))
- return -1;
- if (!all)
- tree = 0;
- }
- if (commits) {
- struct commit_list *parents = obj->parents;
- for (; parents; parents = parents->next) {
- if (has_sha1_file(parents->item->object.sha1))
- continue;
- if (fetch(parents->item->object.sha1)) {
- /* The server might not have it, and
- * we don't mind.
- */
- continue;
- }
- if (process_commit(parents->item->object.sha1))
- return -1;
- }
- }
- return 0;
-}
-
int main(int argc, char **argv)
{
char *commit_id;
char *url;
int arg = 1;
- unsigned char sha1[20];
while (arg < argc && argv[arg][0] == '-') {
if (argv[arg][1] == 't') {
- tree = 1;
+ get_tree = 1;
} else if (argv[arg][1] == 'c') {
- commits = 1;
+ get_history = 1;
} else if (argv[arg][1] == 'a') {
- all = 1;
- tree = 1;
- commits = 1;
+ get_all = 1;
+ get_tree = 1;
+ get_history = 1;
}
arg++;
}
@@ -186,17 +128,13 @@
commit_id = argv[arg];
url = argv[arg + 1];
- get_sha1_hex(commit_id, sha1);
-
curl_global_init(CURL_GLOBAL_ALL);
curl = curl_easy_init();
base = url;
- if (fetch(sha1))
- return 1;
- if (process_commit(sha1))
+ if (pull(commit_id))
return 1;
curl_global_cleanup();
Index: pull.c
===================================================================
--- /dev/null (tree:8602fe7cb4bf668fd021ab3bfb2082ac7d535e57)
+++ 41f4697d0ada8e79a2f262aa9b6357a45194f31d/pull.c (mode:100644 sha1:86a7b6901fe69a82c12c3470b456982ef52cebd0)
@@ -0,0 +1,77 @@
+#include "pull.h"
+
+#include "cache.h"
+#include "commit.h"
+#include "tree.h"
+
+int get_tree = 0;
+int get_history = 0;
+int get_all = 0;
+
+static int process_tree(unsigned char *sha1)
+{
+ struct tree *tree = lookup_tree(sha1);
+ struct tree_entry_list *entries;
+
+ if (parse_tree(tree))
+ return -1;
+
+ for (entries = tree->entries; entries; entries = entries->next) {
+ if (fetch(entries->item.tree->object.sha1))
+ return -1;
+ if (entries->directory) {
+ if (process_tree(entries->item.tree->object.sha1))
+ return -1;
+ }
+ }
+ return 0;
+}
+
+static int process_commit(unsigned char *sha1)
+{
+ struct commit *obj = lookup_commit(sha1);
+
+ if (fetch(sha1))
+ return -1;
+
+ if (parse_commit(obj))
+ return -1;
+
+ if (get_tree) {
+ if (fetch(obj->tree->object.sha1))
+ return -1;
+ if (process_tree(obj->tree->object.sha1))
+ return -1;
+ if (!get_all)
+ get_tree = 0;
+ }
+ if (get_history) {
+ struct commit_list *parents = obj->parents;
+ for (; parents; parents = parents->next) {
+ if (has_sha1_file(parents->item->object.sha1))
+ continue;
+ if (fetch(parents->item->object.sha1)) {
+ /* The server might not have it, and
+ * we don't mind.
+ */
+ continue;
+ }
+ if (process_commit(parents->item->object.sha1))
+ return -1;
+ }
+ }
+ return 0;
+}
+
+int pull(char *target)
+{
+ int retval;
+ unsigned char sha1[20];
+ retval = get_sha1_hex(target, sha1);
+ if (retval)
+ return retval;
+ retval = fetch(sha1);
+ if (retval)
+ return retval;
+ return process_commit(sha1);
+}
Index: pull.h
===================================================================
--- /dev/null (tree:8602fe7cb4bf668fd021ab3bfb2082ac7d535e57)
+++ 41f4697d0ada8e79a2f262aa9b6357a45194f31d/pull.h (mode:100644 sha1:314bc7e95ab1a73634f6a96a8a3782fda91ea261)
@@ -0,0 +1,18 @@
+#ifndef PULL_H
+#define PULL_H
+
+/** To be provided by the particular implementation. **/
+extern int fetch(unsigned char *sha1);
+
+/** Set to fetch the target tree. */
+extern int get_tree;
+
+/** Set to fetch the commit history. */
+extern int get_history;
+
+/** Set to fetch the trees in the commit history. **/
+extern int get_all;
+
+extern int pull(char *target);
+
+#endif /* PULL_H */
Index: rpull.c
===================================================================
--- 8602fe7cb4bf668fd021ab3bfb2082ac7d535e57/rpull.c (mode:100644 sha1:c27af2c2464de28732b8ad1fff3ed8a0804250d6)
+++ 41f4697d0ada8e79a2f262aa9b6357a45194f31d/rpull.c (mode:100644 sha1:6624440d5ad24854e1bd1a8dff628427581198e0)
@@ -7,15 +7,12 @@
#include <errno.h>
#include <stdio.h>
#include "rsh.h"
-
-static int tree = 0;
-static int commits = 0;
-static int all = 0;
+#include "pull.h"
static int fd_in;
static int fd_out;
-static int fetch(unsigned char *sha1)
+int fetch(unsigned char *sha1)
{
if (has_sha1_file(sha1))
return 0;
@@ -23,87 +20,21 @@
return write_sha1_from_fd(sha1, fd_in);
}
-static int process_tree(unsigned char *sha1)
-{
- struct tree *tree = lookup_tree(sha1);
- struct tree_entry_list *entries;
-
- if (parse_tree(tree))
- return -1;
-
- for (entries = tree->entries; entries; entries = entries->next) {
- /*
- fprintf(stderr, "Tree %s ", sha1_to_hex(sha1));
- fprintf(stderr, "needs %s\n",
- sha1_to_hex(entries->item.tree->object.sha1));
- */
- if (fetch(entries->item.tree->object.sha1)) {
- return error("Missing item %s",
- sha1_to_hex(entries->item.tree->object.sha1));
- }
- if (entries->directory) {
- if (process_tree(entries->item.tree->object.sha1))
- return -1;
- }
- }
- return 0;
-}
-
-static int process_commit(unsigned char *sha1)
-{
- struct commit *obj = lookup_commit(sha1);
-
- if (fetch(sha1)) {
- return error("Fetching %s", sha1_to_hex(sha1));
- }
-
- if (parse_commit(obj))
- return -1;
-
- if (tree) {
- if (fetch(obj->tree->object.sha1))
- return -1;
- if (process_tree(obj->tree->object.sha1))
- return -1;
- if (!all)
- tree = 0;
- }
- if (commits) {
- struct commit_list *parents = obj->parents;
- for (; parents; parents = parents->next) {
- if (has_sha1_file(parents->item->object.sha1))
- continue;
- if (fetch(parents->item->object.sha1)) {
- /* The server might not have it, and
- * we don't mind.
- */
- error("Missing tree %s; continuing",
- sha1_to_hex(parents->item->object.sha1));
- continue;
- }
- if (process_commit(parents->item->object.sha1))
- return -1;
- }
- }
- return 0;
-}
-
int main(int argc, char **argv)
{
char *commit_id;
char *url;
int arg = 1;
- unsigned char sha1[20];
while (arg < argc && argv[arg][0] == '-') {
if (argv[arg][1] == 't') {
- tree = 1;
+ get_tree = 1;
} else if (argv[arg][1] == 'c') {
- commits = 1;
+ get_history = 1;
} else if (argv[arg][1] == 'a') {
- all = 1;
- tree = 1;
- commits = 1;
+ get_all = 1;
+ get_tree = 1;
+ get_history = 1;
}
arg++;
}
@@ -117,11 +48,7 @@
if (setup_connection(&fd_in, &fd_out, "rpush", url, arg, argv + 1))
return 1;
- get_sha1_hex(commit_id, sha1);
-
- if (fetch(sha1))
- return 1;
- if (process_commit(sha1))
+ if (pull(commit_id))
return 1;
return 0;
^ permalink raw reply
* Re: Trying to use AUTHOR_DATE
From: Junio C Hamano @ 2005-04-30 5:43 UTC (permalink / raw)
To: Linus Torvalds; +Cc: H. Peter Anvin, Luck, Tony, Edgar Toernig, git
In-Reply-To: <Pine.LNX.4.58.0504292114580.2296@ppc970.osdl.org>
>>>>> "LT" == Linus Torvalds <torvalds@osdl.org> writes:
LT> On Fri, 29 Apr 2005, Linus Torvalds wrote:
>>
>> I'll happily depend on libcurl, but I put my foot down on that tool of the
>> devil called "autoconf".
LT> Btw, looking at curl's "getdate.c", it doesn't seem to be _that_ much more
LT> different from the date parsing we used to have. In particular, it
LT> actually uses "mktime()" twice and subtracts out the difference.
If we are going to lift code from somewhere, why don't we steal
from a pro who knows what he is doing?
One careful implementation of my-mktime() I know of is the one
by Paul Eggert, found in patch (maketime.c::tm2time).
^ permalink raw reply
* Re: How to get bash to shut up about SIGPIPE?
From: Paul Jackson @ 2005-04-30 6:29 UTC (permalink / raw)
To: Linus Torvalds; +Cc: git, pasky
In-Reply-To: <Pine.LNX.4.58.0504291956030.2296@ppc970.osdl.org>
Linus replied to pj:
> > Code Sample 2:
> > ...
> Didn't change anything for me. Same thing.
I don't believe you did what I did.
The source code for bash, both 2.x and 3.x versions, clearly displays a
simpler error message (no line number or redisplay of your script
commands) in the case that you set a trap. And I tested both shells on
a multiprocessor, to verify that they behaved as I expected, running
these silly little scripts.
To labour the point, just now on a multiprocessor near me, the following
six line script:
======================== begin ========================
#!/usr/people/pj/etc/bash/bash-3.0/bash
for x in 1 2
do
trap continue PIPE # reduce broken pipe screeching
cat /etc/termcap # a big text file
done | sed 1q
========================= end =========================
produced the following three lines of output:
======================== begin ========================
######## TERMINAL TYPE DESCRIPTIONS SOURCE FILE
Broken pipe
Broken pipe
========================= end =========================
whereas the following five line script (no trap):
======================== begin ========================
#!/usr/people/pj/etc/bash/bash-3.0/bash
for x in 1 2
do
cat /etc/termcap # a big text file
done | sed 1q
========================= end =========================
produced the following three __noisier__ lines of output:
======================== begin ========================
######## TERMINAL TYPE DESCRIPTIONS SOURCE FILE
foo: line 2: 11663 Broken pipe cat /etc/termcap
foo: line 2: 11665 Broken pipe cat /etc/termcap
========================= end =========================
> > just that noise, leaving whatever else was on stdout and/or stderr
> > unscathed:
>
> It will also grep out any occurrence of "Broken pipe", so if we're talking
> about a kernel changelog, where we fix a pipe bug...
No no no. You didn't read the code or the comment ;). That or my code
and comment were both unclear ... far more likely.
The following line noise is not plagarized from last years Obfuscated
Perl Contest:
( ( (
...
) 1>&3 ) 2>&1 | grep -vxF 'Broken pipe' 1>&2 ) 3>&1
It's the magic shell incantation to run grep only on the stderr stream,
while passing through the stdout stream untouched. Even on the stderr
stream, it only zaps lines that are exactly the eleven characters
'Broken pipe' (plus newline).
> I don't know why the bash people have that stupid pipe reporting in the
Now there we agree. I might speculate that they were trying to get an
early lead in the Linus Git of the Year contest. But this is relatively
mild compared to some of the crap I've seen on other projects I won't
name here. So I too am at a loss to know why.
--
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson <pj@engr.sgi.com> 1.650.933.1373, 1.925.600.0401
^ permalink raw reply
* Re: Trying to use AUTHOR_DATE
From: David Woodhouse @ 2005-04-30 8:02 UTC (permalink / raw)
To: Russ Allbery; +Cc: Linus Torvalds, git
In-Reply-To: <87zmvganq9.fsf@windlord.stanford.edu>
On Fri, 2005-04-29 at 21:32 -0700, Russ Allbery wrote:
> Linus Torvalds <torvalds@osdl.org> writes:
> > It also seems to do so in a particularly stupid way, and David
> > Woodhouses suggestion of just using mktime() on Jan 1st, 1970, seems to
> > be much simpler than what curl does.
>
> Because of daylight savings time, this doesn't actually work. I know from
> personal experience; this is the tactic that I took at first when writing
> INN's date parser and was educated by test failures.
Eww. The time functions we have to play with _really_ suck, don't they?
How about this...
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
commit-tree.c: needs update
Index: commit-tree.c
===================================================================
--- c3aa1e6b53cc59d5fbe261f3f859584904ae3a63/commit-tree.c (mode:100644 sha1:23de13361944ad7ba7c5320cf7cdd04e81842c60)
+++ uncommitted/commit-tree.c (mode:100644)
@@ -213,10 +213,18 @@
if (*(skipfws(p + 5)))
return;
- then = mktime(&tm); /* mktime appears to ignore the GMT offset, stupidly */
+ tm.tm_gmtoff = 0;
+ tm.tm_isdst = -1;
+
+ then = mktime(&tm);
if (then == -1)
return;
+ /* mktime always uses localtime, regardless of the tm_gmtoff field.
+ It does, however, honour 'tm_isdst'; stupidly. Thankfully, it does
+ at least tell us the offset it decided to use, so we can compensate
+ for it */
+ then += tm.tm_gmtoff;
then -= offset;
snprintf(result, maxlen, "%lu %5.5s", then, p);
--
dwmw2
^ permalink raw reply
* Re: Trying to use AUTHOR_DATE
From: Edgar Toernig @ 2005-04-30 10:40 UTC (permalink / raw)
To: David Woodhouse; +Cc: Russ Allbery, Linus Torvalds, git
In-Reply-To: <1114848175.24014.35.camel@localhost.localdomain>
David Woodhouse wrote:
>
> Eww. The time functions we have to play with _really_ suck, don't they?
> How about this...
>
> + then += tm.tm_gmtoff;
tm_gmtoff is not available everywhere - POSIX doesn't even mention it (BSD?).
Oh btw, when we are about sucking time functions: the %s and %z strftime-
sequences used further down are also non-standard (POSIX has no %s, old
libc has neither %s nor %z).
A possible workaround:
void make_datestamp(char *buf)
{
time_t now;
struct tm *tm;
int tz;
time(&now);
tm = localtime(&now); /* get timezone and tm_isdst */
tz = -timezone / 60;
if (tm->tm_isdst > 0)
tz += 60;
sprintf(buf, "%lu %+05d", now, tz/60*100+tz%60);
}
That *should* work on any POSIX system but who knows ...
Ciao, ET.
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox