Merge branch 'pe/date' into next
authorJunio C Hamano <junkio@cox.net>
Fri, 9 Jun 2006 04:23:35 +0000 (21:23 -0700)
committerJunio C Hamano <junkio@cox.net>
Fri, 9 Jun 2006 04:23:35 +0000 (21:23 -0700)
* pe/date:
  date.c: improve guess between timezone offset and year.
  git-rm: honor -n flag.
  git-clone: fix duplicated "master" in $GIT_DIR/remotes/origin
  check for error return from fork()
  Document git-clone --use-separate-remote

Documentation/git-clone.txt
builtin-rm.c
connect.c
date.c
git-clone.sh
imap-send.c
rsh.c

index 94d9393..7572e4b 100644 (file)
@@ -11,7 +11,7 @@ SYNOPSIS
 [verse]
 'git-clone' [--template=<template_directory>] [-l [-s]] [-q] [-n] [--bare]
          [-o <name>] [-u <upload-pack>] [--reference <repository>]
-         <repository> [<directory>]
+         [--use-separate-remote] <repository> [<directory>]
 
 DESCRIPTION
 -----------
@@ -73,7 +73,7 @@ OPTIONS
        files in `<directory>/.git`, make the `<directory>`
        itself the `$GIT_DIR`. This implies `-n` option.  When
        this option is used, neither the `origin` branch nor the
-       default `remotes/origin` file is created.
+       default `remotes/origin` file is created.
 
 -o <name>::
        Instead of using the branch name 'origin' to keep track
@@ -94,12 +94,17 @@ OPTIONS
        if unset the templates are taken from the installation
        defined default, typically `/usr/share/git-core/templates`.
 
+--use-separate-remote::
+       Save remotes heads under `$GIT_DIR/remotes/origin/' instead
+       of `$GIT_DIR/refs/heads/'.  Only the master branch is saved
+       in the latter.
+
 <repository>::
        The (possibly remote) repository to clone from.  It can
        be any URL git-fetch supports.
 
 <directory>::
-       The name of a new directory to clone into.  The "humanish"
+       The name of a new directory to clone into.  The "humanish"
        part of the source repository is used if no directory is
        explicitly given ("repo" for "/path/to/repo.git" and "foo"
        for "host.xz:foo/.git").  Cloning into an existing directory
index ef2f8b5..4d56a1f 100644 (file)
@@ -83,15 +83,15 @@ int cmd_rm(int argc, const char **argv, char **envp)
                }
                die(builtin_rm_usage);
        }
-       pathspec = get_pathspec(prefix, argv + i);
+       if (argc <= i)
+               usage(builtin_rm_usage);
 
+       pathspec = get_pathspec(prefix, argv + i);
        seen = NULL;
-       if (pathspec) {
-               for (i = 0; pathspec[i] ; i++)
-                       /* nothing */;
-               seen = xmalloc(i);
-               memset(seen, 0, i);
-       }
+       for (i = 0; pathspec[i] ; i++)
+               /* nothing */;
+       seen = xmalloc(i);
+       memset(seen, 0, i);
 
        for (i = 0; i < active_nr; i++) {
                struct cache_entry *ce = active_cache[i];
@@ -121,6 +121,9 @@ int cmd_rm(int argc, const char **argv, char **envp)
                cache_tree_invalidate_path(active_cache_tree, path);
        }
 
+       if (show_only)
+               return 0;
+
        /*
         * Then, if we used "-f", remove the filenames from the
         * workspace. If we fail to remove the first one, we
index eca94f7..52d709e 100644 (file)
--- a/connect.c
+++ b/connect.c
@@ -657,6 +657,8 @@ int git_connect(int fd[2], char *url, const char *prog)
        if (pipe(pipefd[0]) < 0 || pipe(pipefd[1]) < 0)
                die("unable to create pipe pair for communication");
        pid = fork();
+       if (pid < 0)
+               die("unable to fork");
        if (!pid) {
                snprintf(command, sizeof(command), "%s %s", prog,
                         sq_quote(path));
diff --git a/date.c b/date.c
index 365dc3b..66be23a 100644 (file)
--- a/date.c
+++ b/date.c
@@ -369,7 +369,7 @@ static int match_digit(const char *date, struct tm *tm, int *offset, int *tm_gmt
 
        /* Four-digit year or a timezone? */
        if (n == 4) {
-               if (num <= 1200 && *offset == -1) {
+               if (num <= 1400 && *offset == -1) {
                        unsigned int minutes = num % 100;
                        unsigned int hours = num / 100;
                        *offset = hours*60 + minutes;
index de59904..64318b4 100755 (executable)
@@ -391,11 +391,16 @@ Pull: refs/heads/$head_points_at:$origin_track" &&
                (cd "$GIT_DIR/$remote_top" && find . -type f -print) |
                while read dotslref
                do
-                       name=`expr "$dotslref" : './\(.*\)'` &&
-                       test "$use_separate_remote" = '' && {
-                               test "$head_points_at" = "$name" ||
-                               test "$origin" = "$name"
-                       } ||
+                       name=`expr "$dotslref" : './\(.*\)'`
+                       if test "z$head_points_at" = "z$name"
+                       then
+                               continue
+                       fi
+                       if test "$use_separate_remote" = '' &&
+                          test "z$origin" = "z$name"
+                       then
+                               continue
+                       fi
                        echo "Pull: refs/heads/${name}:$remote_top/${name}"
                done >>"$GIT_DIR/remotes/$origin" &&
                case "$use_separate_remote" in
index 52e2400..285ad29 100644 (file)
@@ -924,6 +924,7 @@ imap_open_store( imap_server_conf_t *srvc )
        struct hostent *he;
        struct sockaddr_in addr;
        int s, a[2], preauth;
+       pid_t pid;
 
        ctx = xcalloc( sizeof(*ctx), 1 );
 
@@ -941,7 +942,10 @@ imap_open_store( imap_server_conf_t *srvc )
                        exit( 1 );
                }
 
-               if (fork() == 0) {
+               pid = fork();
+               if (pid < 0)
+                       _exit( 127 );
+               if (!pid) {
                        if (dup2( a[0], 0 ) == -1 || dup2( a[0], 1 ) == -1)
                                _exit( 127 );
                        close( a[0] );
diff --git a/rsh.c b/rsh.c
index d665269..07166ad 100644 (file)
--- a/rsh.c
+++ b/rsh.c
@@ -48,6 +48,7 @@ int setup_connection(int *fd_in, int *fd_out, const char *remote_prog,
        int sizen;
        int of;
        int i;
+       pid_t pid;
 
        if (!strcmp(url, "-")) {
                *fd_in = 0;
@@ -91,7 +92,10 @@ int setup_connection(int *fd_in, int *fd_out, const char *remote_prog,
        if (socketpair(AF_UNIX, SOCK_STREAM, 0, sv))
                return error("Couldn't create socket");
 
-       if (!fork()) {
+       pid = fork();
+       if (pid < 0)
+               return error("Couldn't fork");
+       if (!pid) {
                const char *ssh, *ssh_basename;
                ssh = getenv("GIT_SSH");
                if (!ssh) ssh = "ssh";