From fb6a9f93d39e4e5fdb83673a927f71a34e9fb7c0 Mon Sep 17 00:00:00 2001 From: Uwe Zeisberger Date: Thu, 8 Jun 2006 08:50:09 +0200 Subject: [PATCH 1/5] Document git-clone --use-separate-remote Signed-off-by: Uwe Zeisberger Signed-off-by: Junio C Hamano --- Documentation/git-clone.txt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Documentation/git-clone.txt b/Documentation/git-clone.txt index 94d9393372..7572e4b80d 100644 --- a/Documentation/git-clone.txt +++ b/Documentation/git-clone.txt @@ -11,7 +11,7 @@ SYNOPSIS [verse] 'git-clone' [--template=] [-l [-s]] [-q] [-n] [--bare] [-o ] [-u ] [--reference ] - [] + [--use-separate-remote] [] DESCRIPTION ----------- @@ -73,7 +73,7 @@ OPTIONS files in `/.git`, make the `` 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 :: 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. + :: The (possibly remote) repository to clone from. It can be any URL git-fetch supports. :: - 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 From c9bc159d7f41e2916830b05529c1ce06a81d975f Mon Sep 17 00:00:00 2001 From: Paul T Darga Date: Thu, 8 Jun 2006 14:14:47 -0400 Subject: [PATCH 2/5] check for error return from fork() Trivial fixup for fork() callsites which do not check for errors. Signed-off-by: Paul T Darga Signed-off-by: Junio C Hamano --- connect.c | 2 ++ imap-send.c | 6 +++++- rsh.c | 6 +++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/connect.c b/connect.c index eca94f7548..52d709e58d 100644 --- 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/imap-send.c b/imap-send.c index 52e2400b57..285ad29afb 100644 --- a/imap-send.c +++ b/imap-send.c @@ -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 d66526941f..07166addd9 100644 --- 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"; From 2048bb00ee3937808ce9f0c8f59d71a9b46ab56f Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 8 Jun 2006 01:17:01 -0700 Subject: [PATCH 3/5] git-clone: fix duplicated "master" in $GIT_DIR/remotes/origin Under --use-separate-remote we ended up duplicating the branch remote HEAD pointed at in $GIT_DIR/remotes/origin file. Signed-off-by: Junio C Hamano --- git-clone.sh | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/git-clone.sh b/git-clone.sh index de59904d56..64318b4dd3 100755 --- a/git-clone.sh +++ b/git-clone.sh @@ -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 From 7612a1efdb0c0806b43db10ce784707aae874340 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 8 Jun 2006 21:11:25 -0700 Subject: [PATCH 4/5] git-rm: honor -n flag. Even when invoked with -n flag, git-rm removed the matching paths anyway. Also includes the missing check spotted by SungHyun Nam, which caused it to segfault. Now we refuse to run without any paths. Signed-off-by: Junio C Hamano --- builtin-rm.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/builtin-rm.c b/builtin-rm.c index ef2f8b5d09..4d56a1f070 100644 --- a/builtin-rm.c +++ b/builtin-rm.c @@ -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 From 7122f82f56425d942bc5e892ed5e6b3bbd0a6724 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 8 Jun 2006 14:54:13 -0700 Subject: [PATCH 5/5] date.c: improve guess between timezone offset and year. When match_digit() guesses a four-digit string to tell if it is a year or a timezone, it did not consider that some real-world places have UTC offsets equal to +1400. $ date; TZ=UTC0 date; TZ=Pacific/Kiritimati date Wed Jun 7 23:25:42 PDT 2006 Thu Jun 8 06:25:42 UTC 2006 Thu Jun 8 20:25:42 LINT 2006 Signed-off-by: Paul Eggert Signed-off-by: Junio C Hamano --- date.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/date.c b/date.c index 365dc3b14e..66be23ab21 100644 --- 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;