Merge branch 'jc/am' into next

* jc/am:
  Fix git-am safety checks
  Allow multiple "git_path()" uses
  gitweb: Add link to "project_index" view to "project_list" page
  gitweb: Allow for href() to be used for links without project param
  Define fallback PATH_MAX on systems that do not define one in <limits.h>
  Document git-grep -[Hh]
  Fix duplicate xmalloc in builtin-add
This commit is contained in:
Junio C Hamano
2006-09-16 10:23:14 -07:00
7 changed files with 63 additions and 16 deletions

View File

@@ -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

View File

@@ -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;

View File

@@ -1,8 +1,7 @@
#ifndef BUILTIN_H
#define BUILTIN_H
#include <stdio.h>
#include <limits.h>
#include "git-compat-util.h"
extern const char git_version_string[];
extern const char git_usage_string[];

View File

@@ -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

View File

@@ -26,6 +26,13 @@
#include <sys/types.h>
#include <dirent.h>
/* On most systems <limits.h> 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

View File

@@ -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) {
@@ -1254,6 +1255,13 @@ EOF
printf('<link rel="alternate" title="%s log" '.
'href="%s" type="application/rss+xml"/>'."\n",
esc_param($project), href(action=>"rss"));
} else {
printf('<link rel="alternate" title="%s projects list" '.
'href="%s" type="text/plain; charset=utf-8"/>'."\n",
$site_name, href(project=>undef, action=>"project_index"));
printf('<link rel="alternate" title="%s projects logs" '.
'href="%s" type="text/x-opml"/>'."\n",
$site_name, href(project=>undef, action=>"opml"));
}
if (defined $favicon) {
print qq(<link rel="shortcut icon" href="$favicon" type="image/png"/>\n);
@@ -1304,9 +1312,13 @@ sub git_footer_html {
if (defined $descr) {
print "<div class=\"page_footer_text\">" . esc_html($descr) . "</div>\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") . " ";
print $cgi->a({-href => href(project=>undef, action=>"project_index"),
-class => "rss_logo"}, "TXT") . "\n";
}
print "</div>\n" .
"</body>\n" .
@@ -2153,7 +2165,7 @@ sub git_project_list {
print "<th>Project</th>\n";
} else {
print "<th>" .
$cgi->a({-href => "$my_uri?" . esc_param("o=project"),
$cgi->a({-href => href(project=>undef, order=>'project'),
-class => "header"}, "Project") .
"</th>\n";
}
@@ -2162,7 +2174,7 @@ sub git_project_list {
print "<th>Description</th>\n";
} else {
print "<th>" .
$cgi->a({-href => "$my_uri?" . esc_param("o=descr"),
$cgi->a({-href => href(project=>undef, order=>'descr'),
-class => "header"}, "Description") .
"</th>\n";
}
@@ -2171,7 +2183,7 @@ sub git_project_list {
print "<th>Owner</th>\n";
} else {
print "<th>" .
$cgi->a({-href => "$my_uri?" . esc_param("o=owner"),
$cgi->a({-href => href(project=>undef, order=>'owner'),
-class => "header"}, "Owner") .
"</th>\n";
}
@@ -2180,7 +2192,7 @@ sub git_project_list {
print "<th>Last Change</th>\n";
} else {
print "<th>" .
$cgi->a({-href => "$my_uri?" . esc_param("o=age"),
$cgi->a({-href => href(project=>undef, order=>'age'),
-class => "header"}, "Last Change") .
"</th>\n";
}

10
path.c
View File

@@ -13,9 +13,15 @@
#include "cache.h"
#include <pwd.h>
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;