]> asedeno.scripts.mit.edu Git - git.git/commitdiff
Merge branches 'lt/show' and 'lt/revlist'
authorJunio C Hamano <junkio@cox.net>
Mon, 6 Feb 2006 07:55:09 +0000 (23:55 -0800)
committerJunio C Hamano <junkio@cox.net>
Mon, 6 Feb 2006 07:55:09 +0000 (23:55 -0800)
* lt/show:
  git-show

* lt/revlist:
  rev-parse lstat() workaround cleanup.

Documentation/git-daemon.txt
Documentation/git-send-email.txt
daemon.c
git-send-email.perl
http-fetch.c
http.c
rev-parse.c

index a20e0533fcfc1ed2c9940021ab65ef2967f16856..2cc6075fb0b316f4254273caa4fe184fdc5afb35 100644 (file)
@@ -10,7 +10,8 @@ SYNOPSIS
 [verse]
 'git-daemon' [--verbose] [--syslog] [--inetd | --port=n] [--export-all]
              [--timeout=n] [--init-timeout=n] [--strict-paths]
-             [--base-path=path] [directory...]
+             [--base-path=path] [--user-path | --user-path=path]
+            [directory...]
 
 DESCRIPTION
 -----------
@@ -42,8 +43,7 @@ OPTIONS
        This is sort of "GIT root" - if you run git-daemon with
        '--base-path=/srv/git' on example.com, then if you later try to pull
        'git://example.com/hello.git', `git-daemon` will interpret the path
-       as '/srv/git/hello.git'. Home directories (the '~login' notation)
-       access is disabled.
+       as '/srv/git/hello.git'.
 
 --export-all::
        Allow pulling from all directories that look like GIT repositories
@@ -70,6 +70,15 @@ OPTIONS
        Log to syslog instead of stderr. Note that this option does not imply
        --verbose, thus by default only error conditions will be logged.
 
+--user-path, --user-path=path::
+       Allow ~user notation to be used in requests.  When
+       specified with no parameter, requests to
+       git://host/~alice/foo is taken as a request to access
+       'foo' repository in the home directory of user `alice`.
+       If `--user-path=path` is specified, the same request is
+       taken as a request to access `path/foo` repository in
+       the home directory of user `alice`.
+
 --verbose::
        Log details about the incoming connections and requested files.
 
index b9bec55e53ad191e4cb0b052551aa7e45049013e..00537d8907872aa25c39f07513ef661b1bef1f17 100644 (file)
@@ -24,25 +24,23 @@ OPTIONS
 -------
 The options available are:
 
---to::
-       Specify the primary recipient of the emails generated.
-       Generally, this will be the upstream maintainer of the
-       project involved.
+--chain-reply-to, --no-chain-reply-to::
+       If this is set, each email will be sent as a reply to the previous
+       email sent.  If disabled with "--no-chain-reply-to", all emails after
+       the first will be sent as replies to the first email sent.  When using
+       this, it is recommended that the first file given be an overview of the
+       entire patch series.
+       Default is --chain-reply-to
+
+--compose::
+       Use $EDITOR to edit an introductory message for the
+       patch series.
 
 --from::
        Specify the sender of the emails.  This will default to
        the value GIT_COMMITTER_IDENT, as returned by "git-var -l".
        The user will still be prompted to confirm this entry.
 
---compose::
-       Use \$EDITOR to edit an introductory message for the
-       patch series.
-
---subject::
-       Specify the initial subject of the email thread.
-       Only necessary if --compose is also set.  If --compose
-       is not set, this will be prompted for.
-
 --in-reply-to::
        Specify the contents of the first In-Reply-To header.
        Subsequent emails will refer to the previous email 
@@ -50,18 +48,24 @@ The options available are:
        Only necessary if --compose is also set.  If --compose
        is not set, this will be prompted for.
 
---chain-reply-to, --no-chain-reply-to::
-       If this is set, each email will be sent as a reply to the previous
-       email sent.  If disabled with "--no-chain-reply-to", all emails after
-       the first will be sent as replies to the first email sent.  When using
-       this, it is recommended that the first file given be an overview of the
-       entire patch series.
-       Default is --chain-reply-to
+--quiet::
+       Make git-send-email less verbose.  One line per email should be
+       all that is output.
 
 --smtp-server::
        If set, specifies the outgoing SMTP server to use.  Defaults to
        localhost.
 
+--subject::
+       Specify the initial subject of the email thread.
+       Only necessary if --compose is also set.  If --compose
+       is not set, this will be prompted for.
+
+--to::
+       Specify the primary recipient of the emails generated.
+       Generally, this will be the upstream maintainer of the
+       project involved.
+
 
 Author
 ------
index 532bb0c325fd07e13360389297807a19a11ee33e..a1ccda30e2211368c66c1186437891f548f0e338 100644 (file)
--- a/daemon.c
+++ b/daemon.c
 
 static int log_syslog;
 static int verbose;
+static int reuseaddr;
 
 static const char daemon_usage[] =
 "git-daemon [--verbose] [--syslog] [--inetd | --port=n] [--export-all]\n"
 "           [--timeout=n] [--init-timeout=n] [--strict-paths]\n"
-"           [--base-path=path] [directory...]";
+"           [--base-path=path] [--user-path | --user-path=path]\n"
+"           [--reuseaddr] [directory...]";
 
 /* List of acceptable pathname prefixes */
 static char **ok_paths = NULL;
@@ -29,6 +31,12 @@ static int export_all_trees = 0;
 /* Take all paths relative to this one if non-NULL */
 static char *base_path = NULL;
 
+/* If defined, ~user notation is allowed and the string is inserted
+ * after ~user/.  E.g. a request to git://host/~alice/frotz would
+ * go to /home/alice/pub_git/frotz with --user-path=pub_git.
+ */
+static char *user_path = NULL;
+
 /* Timeout, and initial timeout */
 static unsigned int timeout = 0;
 static unsigned int init_timeout = 0;
@@ -136,6 +144,7 @@ static int avoid_alias(char *p)
 
 static char *path_ok(char *dir)
 {
+       static char rpath[PATH_MAX];
        char *path;
 
        if (avoid_alias(dir)) {
@@ -143,15 +152,38 @@ static char *path_ok(char *dir)
                return NULL;
        }
 
-       if (base_path) {
-               static char rpath[PATH_MAX];
+       if (*dir == '~') {
+               if (!user_path) {
+                       logerror("'%s': User-path not allowed", dir);
+                       return NULL;
+               }
+               if (*user_path) {
+                       /* Got either "~alice" or "~alice/foo";
+                        * rewrite them to "~alice/%s" or
+                        * "~alice/%s/foo".
+                        */
+                       int namlen, restlen = strlen(dir);
+                       char *slash = strchr(dir, '/');
+                       if (!slash)
+                               slash = dir + restlen;
+                       namlen = slash - dir;
+                       restlen -= namlen;
+                       loginfo("userpath <%s>, request <%s>, namlen %d, restlen %d, slash <%s>", user_path, dir, namlen, restlen, slash);
+                       snprintf(rpath, PATH_MAX, "%.*s/%s%.*s",
+                                namlen, dir, user_path, restlen, slash);
+                       dir = rpath;
+               }
+       }
+       else if (base_path) {
                if (*dir != '/') {
-                       /* Forbid possible base-path evasion using ~paths. */
+                       /* Allow only absolute */
                        logerror("'%s': Non-absolute path denied (base-path active)", dir);
                        return NULL;
                }
-               snprintf(rpath, PATH_MAX, "%s%s", base_path, dir);
-               dir = rpath;
+               else {
+                       snprintf(rpath, PATH_MAX, "%s%s", base_path, dir);
+                       dir = rpath;
+               }
        }
 
        path = enter_repo(dir, strict_paths);
@@ -447,6 +479,16 @@ static void child_handler(int signo)
        }
 }
 
+static int set_reuse_addr(int sockfd)
+{
+       int on = 1;
+
+       if (!reuseaddr)
+               return 0;
+       return setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR,
+                         &on, sizeof(on));
+}
+
 #ifndef NO_IPV6
 
 static int socksetup(int port, int **socklist_p)
@@ -491,6 +533,11 @@ static int socksetup(int port, int **socklist_p)
                }
 #endif
 
+               if (set_reuse_addr(sockfd)) {
+                       close(sockfd);
+                       return 0;       /* not fatal */
+               }
+
                if (bind(sockfd, ai->ai_addr, ai->ai_addrlen) < 0) {
                        close(sockfd);
                        continue;       /* not fatal */
@@ -533,6 +580,11 @@ static int socksetup(int port, int **socklist_p)
        sin.sin_addr.s_addr = htonl(INADDR_ANY);
        sin.sin_port = htons(port);
 
+       if (set_reuse_addr(sockfd)) {
+               close(sockfd);
+               return 0;
+       }
+
        if ( bind(sockfd, (struct sockaddr *)&sin, sizeof sin) < 0 ) {
                close(sockfd);
                return 0;
@@ -659,6 +711,18 @@ int main(int argc, char **argv)
                        base_path = arg+12;
                        continue;
                }
+               if (!strcmp(arg, "--reuseaddr")) {
+                       reuseaddr = 1;
+                       continue;
+               }
+               if (!strcmp(arg, "--user-path")) {
+                       user_path = "";
+                       continue;
+               }
+               if (!strncmp(arg, "--user-path=", 12)) {
+                       user_path = arg + 12;
+                       continue;
+               }
                if (!strcmp(arg, "--")) {
                        ok_paths = &argv[i+1];
                        break;
index 2977b9adebff3180f156327622a9a11067e01696..3f1b3ca78897ef1eb85dea266eea6afcc404a1db 100755 (executable)
@@ -186,7 +186,9 @@ for my $f (@ARGV) {
 }
 
 if (@files) {
-       print $_,"\n" for @files;
+       unless ($quiet) {
+               print $_,"\n" for (@files);
+       }
 } else {
        print <<EOT;
 git-send-email [options] <file | directory> [... file | directory ]
@@ -213,6 +215,10 @@ Options:
    --smtp-server  If set, specifies the outgoing SMTP server to use.
                   Defaults to localhost.
 
+   --quiet     Make git-send-email less verbose.  One line per email should be
+               all that is output.
+
+
 Error: Please specify a file or a directory on the command line.
 EOT
        exit(1);
@@ -268,7 +274,9 @@ sub send_message
 
        sendmail(%mail) or die $Mail::Sendmail::error;
 
-       unless ($quiet) {
+       if ($quiet) {
+               printf "Sent %s\n", $subject;
+       } else {
                print "OK. Log says:\n", $Mail::Sendmail::log;
                print "\n\n"
        }
@@ -280,7 +288,6 @@ make_message_id();
 $subject = $initial_subject;
 
 foreach my $t (@files) {
-       my $F = $t;
        open(F,"<",$t) or die "can't open file $t";
 
        @cc = ();
@@ -298,7 +305,7 @@ foreach my $t (@files) {
 
                                } elsif (/^(Cc|From):\s+(.*)$/) {
                                        printf("(mbox) Adding cc: %s from line '%s'\n",
-                                               $2, $_);
+                                               $2, $_) unless $quiet;
                                        push @cc, $2;
                                }
 
@@ -310,7 +317,7 @@ foreach my $t (@files) {
                                # So let's support that, too.
                                if (@cc == 0) {
                                        printf("(non-mbox) Adding cc: %s from line '%s'\n",
-                                               $_, $_);
+                                               $_, $_) unless $quiet;
 
                                        push @cc, $_;
 
@@ -330,7 +337,7 @@ foreach my $t (@files) {
                                chomp $c;
                                push @cc, $c;
                                printf("(sob) Adding cc: %s from line '%s'\n",
-                                       $c, $_);
+                                       $c, $_) unless $quiet;
                        }
                }
        }
index 72edf28b0010ad107bae16a7330bad34f4bb5bca..bddbd6b10068edfa7786266feb276a404a9551e2 100644 (file)
@@ -311,7 +311,7 @@ void fill_active_slots(void)
        while (active_requests < max_requests && obj_req != NULL) {
                if (obj_req->state == WAITING) {
                        if (has_sha1_file(obj_req->sha1))
-                               release_object_request(obj_req);
+                               obj_req->state = COMPLETE;
                        else
                                start_object_request(obj_req);
                        curl_multi_perform(curlm, &num_transfers);
@@ -468,13 +468,11 @@ static void process_alternates_response(void *callback_data)
                                         alt_req->url);
                        active_requests++;
                        slot->in_use = 1;
-                       if (start_active_slot(slot)) {
-                               return;
-                       } else {
+                       if (!start_active_slot(slot)) {
                                got_alternates = -1;
                                slot->in_use = 0;
-                               return;
                        }
+                       return;
                }
        } else if (slot->curl_result != CURLE_OK) {
                if (slot->http_code != 404 &&
@@ -822,9 +820,8 @@ static int fetch_object(struct alt_base *repo, unsigned char *sha1)
        } else if (memcmp(obj_req->sha1, obj_req->real_sha1, 20)) {
                ret = error("File %s has bad hash\n", hex);
        } else if (obj_req->rename < 0) {
-               ret = error("unable to write sha1 filename %s: %s",
-                           obj_req->filename,
-                           strerror(obj_req->rename));
+               ret = error("unable to write sha1 filename %s",
+                           obj_req->filename);
        }
 
        release_object_request(obj_req);
diff --git a/http.c b/http.c
index eefb0f03d2f7ac30163e69b842f6943987cf9351..632c2c5c2fcf2ef51092aa72d8c2dee64efbde49 100644 (file)
--- a/http.c
+++ b/http.c
@@ -192,6 +192,9 @@ static CURL* get_curl_handle(void)
 
        curl_easy_setopt(result, CURLOPT_FOLLOWLOCATION, 1);
 
+       if (getenv("GIT_CURL_VERBOSE"))
+               curl_easy_setopt(result, CURLOPT_VERBOSE, 1);
+
        return result;
 }
 
index 9cec33b8c00c322d6acde3e588a5c1dfe53f948d..b82f294a78994e512c4f30da5bb4ba3eca3f95b4 100644 (file)
@@ -150,11 +150,14 @@ static void show_datestring(const char *flag, const char *datestr)
        show(buffer);
 }
 
-static void show_file(const char *arg)
+static int show_file(const char *arg)
 {
        show_default();
-       if ((filter & (DO_NONFLAGS|DO_NOREV)) == (DO_NONFLAGS|DO_NOREV))
+       if ((filter & (DO_NONFLAGS|DO_NOREV)) == (DO_NONFLAGS|DO_NOREV)) {
                show(arg);
+               return 1;
+       }
+       return 0;
 }
 
 int main(int argc, char **argv)
@@ -329,14 +332,13 @@ int main(int argc, char **argv)
                        show_rev(REVERSED, sha1, arg+1);
                        continue;
                }
+               as_is = 1;
+               if (!show_file(arg))
+                       continue;
                if (verify)
                        die("Needed a single revision");
-               if ((filter & DO_REVS) &&
-                   (filter & DO_NONFLAGS) && /* !def && */
-                   lstat(arg, &st) < 0)
+               if (lstat(arg, &st) < 0)
                        die("'%s': %s", arg, strerror(errno));
-               as_is = 1;
-               show_file(arg);
        }
        show_default();
        if (verify && revs_count != 1)