From d48ffdbb0b2580c6ff58da7cedbf78785ba6121b Mon Sep 17 00:00:00 2001 From: Liu Yubao Date: Fri, 15 Sep 2006 13:46:07 -0700 Subject: [PATCH 1/7] Fix duplicate xmalloc in builtin-add [jc: patch came without sign-off but it was too obvious and trivial.] Signed-off-by: Junio C Hamano --- builtin-add.c | 1 - 1 file changed, 1 deletion(-) diff --git a/builtin-add.c b/builtin-add.c index 0cb9c81200..febb75ed99 100644 --- a/builtin-add.c +++ b/builtin-add.c @@ -70,7 +70,6 @@ static void fill_directory(struct dir_struct *dir, const char **pathspec) base = ""; if (baselen) { char *common = xmalloc(baselen + 1); - common = xmalloc(baselen + 1); memcpy(common, *pathspec, baselen); common[baselen] = 0; path = base = common; From 17fd965d215060a10911db99c2dacf9c3554787a Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 15 Sep 2006 18:37:01 -0700 Subject: [PATCH 2/7] Document git-grep -[Hh] Signed-off-by: Junio C Hamano --- Documentation/git-grep.txt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Documentation/git-grep.txt b/Documentation/git-grep.txt index 7545dd9a3e..d8af4d961b 100644 --- a/Documentation/git-grep.txt +++ b/Documentation/git-grep.txt @@ -11,7 +11,7 @@ SYNOPSIS [verse] 'git-grep' [--cached] [-a | --text] [-I] [-i | --ignore-case] [-w | --word-regexp] - [-v | --invert-match] [--full-name] + [-v | --invert-match] [-h|-H] [--full-name] [-E | --extended-regexp] [-G | --basic-regexp] [-F | --fixed-strings] [-n] [-l | --files-with-matches] [-L | --files-without-match] [-c | --count] @@ -47,6 +47,13 @@ OPTIONS -v | --invert-match:: Select non-matching lines. +-h | -H:: + By default, the command shows the filename for each + match. `-h` option is used to suppress this output. + `-H` is there for completeness and does not do anything + except it overrides `-h` given earlier on the command + line. + --full-name:: When run from a subdirectory, the command usually outputs paths relative to the current directory. This From d0c2449f7805ee35b97c5dcb22845f157da1cea4 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 15 Sep 2006 22:47:21 -0700 Subject: [PATCH 3/7] Define fallback PATH_MAX on systems that do not define one in Notably on GNU/Hurd, as reported by Gerrit Pape. Signed-off-by: Junio C Hamano --- builtin.h | 3 +-- git-compat-util.h | 7 +++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/builtin.h b/builtin.h index 25431d7081..398eafbf99 100644 --- a/builtin.h +++ b/builtin.h @@ -1,8 +1,7 @@ #ifndef BUILTIN_H #define BUILTIN_H -#include -#include +#include "git-compat-util.h" extern const char git_version_string[]; extern const char git_usage_string[]; diff --git a/git-compat-util.h b/git-compat-util.h index 552b8ec23a..0272d043d0 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -26,6 +26,13 @@ #include #include +/* On most systems would have given us this, but + * not on some systems (e.g. GNU/Hurd). + */ +#ifndef PATH_MAX +#define PATH_MAX 4096 +#endif + #ifdef __GNUC__ #define NORETURN __attribute__((__noreturn__)) #else From a1565c447d441234e227fa6881d26eaf227367e3 Mon Sep 17 00:00:00 2001 From: Jakub Narebski Date: Fri, 15 Sep 2006 19:30:34 +0200 Subject: [PATCH 4/7] gitweb: Allow for href() to be used for links without project param Make it possible to use href() subroutine to generate link with query string which does not include project ('p') parameter. href() used to add project=$project to its parameters, if it was not set (to be more exact if $params{'project'} was false). Now you can pass "project => undef" if you don't want for href() to add project parameter to query string in the generated link. Links to "project_list", "project_index" and "opml" (all related to list of all projects/all git repositories) doesn't need project parameter. Moreover "project_list" is default view (action) if project ('p') parameter is not set, just like "summary" is default view (action) if project is set; project list served as a kind of "home" page for gitweb instalation, and links to "project_list" view were done without specyfying it as an action. Convert remaining links (except $home_link and anchor links) to use href(); this required adding 'order => "o"' to @mapping in href(). This finishes consolidation of URL generation. Signed-off-by: Jakub Narebski Signed-off-by: Junio C Hamano --- gitweb/gitweb.perl | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index c43f4fe61f..f75fea5623 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -326,11 +326,12 @@ sub href(%) { hash_base => "hb", hash_parent_base => "hpb", page => "pg", + order => "o", searchtext => "s", ); my %mapping = @mapping; - $params{"project"} ||= $project; + $params{'project'} = $project unless exists $params{'project'}; my @result = (); for (my $i = 0; $i < @mapping; $i += 2) { @@ -1304,9 +1305,11 @@ sub git_footer_html { if (defined $descr) { print "\n"; } - print $cgi->a({-href => href(action=>"rss"), -class => "rss_logo"}, "RSS") . "\n"; + print $cgi->a({-href => href(action=>"rss"), + -class => "rss_logo"}, "RSS") . "\n"; } else { - print $cgi->a({-href => href(action=>"opml"), -class => "rss_logo"}, "OPML") . "\n"; + print $cgi->a({-href => href(project=>undef, action=>"opml"), + -class => "rss_logo"}, "OPML") . "\n"; } print "\n" . "\n" . @@ -2153,7 +2156,7 @@ sub git_project_list { print "Project\n"; } else { print "" . - $cgi->a({-href => "$my_uri?" . esc_param("o=project"), + $cgi->a({-href => href(project=>undef, order=>'project'), -class => "header"}, "Project") . "\n"; } @@ -2162,7 +2165,7 @@ sub git_project_list { print "Description\n"; } else { print "" . - $cgi->a({-href => "$my_uri?" . esc_param("o=descr"), + $cgi->a({-href => href(project=>undef, order=>'descr'), -class => "header"}, "Description") . "\n"; } @@ -2171,7 +2174,7 @@ sub git_project_list { print "Owner\n"; } else { print "" . - $cgi->a({-href => "$my_uri?" . esc_param("o=owner"), + $cgi->a({-href => href(project=>undef, order=>'owner'), -class => "header"}, "Owner") . "\n"; } @@ -2180,7 +2183,7 @@ sub git_project_list { print "Last Change\n"; } else { print "" . - $cgi->a({-href => "$my_uri?" . esc_param("o=age"), + $cgi->a({-href => href(project=>undef, order=>'age'), -class => "header"}, "Last Change") . "\n"; } From 9d0734ae49c8c0a5a2c6b6bf85011d095182e357 Mon Sep 17 00:00:00 2001 From: Jakub Narebski Date: Fri, 15 Sep 2006 11:11:33 +0200 Subject: [PATCH 5/7] gitweb: Add link to "project_index" view to "project_list" page Add link to "project_index" view as [TXT] beside link to "opml" view, (which is marked by [OPML]) to "project_list" page. While at it add alternate links for "opml" and "project_list" to HTML header for "project_list" view. Signed-off-by: Jakub Narebski Signed-off-by: Junio C Hamano --- gitweb/gitweb.perl | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index f75fea5623..a81c8d4cf2 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -1255,6 +1255,13 @@ EOF printf(''."\n", esc_param($project), href(action=>"rss")); + } else { + printf(''."\n", + $site_name, href(project=>undef, action=>"project_index")); + printf(''."\n", + $site_name, href(project=>undef, action=>"opml")); } if (defined $favicon) { print qq(\n); @@ -1309,7 +1316,9 @@ sub git_footer_html { -class => "rss_logo"}, "RSS") . "\n"; } else { print $cgi->a({-href => href(project=>undef, action=>"opml"), - -class => "rss_logo"}, "OPML") . "\n"; + -class => "rss_logo"}, "OPML") . " "; + print $cgi->a({-href => href(project=>undef, action=>"project_index"), + -class => "rss_logo"}, "TXT") . "\n"; } print "\n" . "\n" . From e7676d2f6454c9c99e600ee2ce3c7205a9fcfb5f Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Mon, 11 Sep 2006 12:03:15 -0700 Subject: [PATCH 6/7] Allow multiple "git_path()" uses This allows you to maintain a few filesystem pathnames concurrently, by simply replacing the single static "pathname" buffer with a LRU of four buffers. We did exactly the same thing with sha1_to_hex(), for pretty much exactly the same reason. Sometimes you want to use two pathnames, and while it's easy enough to xstrdup() them, why not just do the LU buffer thing. Signed-off-by: Linus Torvalds Signed-off-by: Junio C Hamano --- path.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/path.c b/path.c index db8905f3c3..bb89fb02dc 100644 --- a/path.c +++ b/path.c @@ -13,9 +13,15 @@ #include "cache.h" #include -static char pathname[PATH_MAX]; static char bad_path[] = "/bad-path/"; +static char *get_pathname(void) +{ + static char pathname_array[4][PATH_MAX]; + static int index; + return pathname_array[3 & ++index]; +} + static char *cleanup_path(char *path) { /* Clean it up */ @@ -31,6 +37,7 @@ char *mkpath(const char *fmt, ...) { va_list args; unsigned len; + char *pathname = get_pathname(); va_start(args, fmt); len = vsnprintf(pathname, PATH_MAX, fmt, args); @@ -43,6 +50,7 @@ char *mkpath(const char *fmt, ...) char *git_path(const char *fmt, ...) { const char *git_dir = get_git_dir(); + char *pathname = get_pathname(); va_list args; unsigned len; From c95b138985186992b222321f332cf92edbbd4141 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 15 Sep 2006 23:19:02 -0700 Subject: [PATCH 7/7] Fix git-am safety checks An earlier commit cbd64af added a check that prevents "git-am" to run without its standard input connected to a terminal while resuming operation. This was to catch a user error to try feeding a new patch from its standard input while recovery. The assumption of the check was that it is an indication that a new patch is being fed if the standard input is not connected to a terminal. It is however not quite correct (the standard input can be /dev/null if the user knows the operation does not need any input, for example). This broke t3403 when the test was run with its standard input connected to /dev/null. When git-am is given an explicit command such as --skip, there is no reason to insist that the standard input is a terminal; we are not going to read a new patch anyway. Credit goes to Gerrit Pape for noticing and reporting the problem with t3403-rebase-skip test. Signed-off-by: Junio C Hamano --- git-am.sh | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/git-am.sh b/git-am.sh index d0af786aec..afe322b20f 100755 --- a/git-am.sh +++ b/git-am.sh @@ -166,10 +166,25 @@ fi if test -d "$dotest" then - if test ",$#," != ",0," || ! tty -s - then - die "previous dotest directory $dotest still exists but mbox given." - fi + case "$#,$skip$resolved" in + 0,*t*) + # Explicit resume command and we do not have file, so + # we are happy. + : ;; + 0,) + # No file input but without resume parameters; catch + # user error to feed us a patch from standard input + # when there is already .dotest. This is somewhat + # unreliable -- stdin could be /dev/null for example + # and the caller did not intend to feed us a patch but + # wanted to continue unattended. + tty -s + ;; + *) + false + ;; + esac || + die "previous dotest directory $dotest still exists but mbox given." resume=yes else # Make sure we are not given --skip nor --resolved