Merge branch 'jc/skip-count' into next

* jc/skip-count:
  revision: --skip=<n>
  GIT 1.4.4.3
  clarify some error messages wrt unknown object types
  simplify inclusion of system header files.
  index-pack usage of mmap() is unacceptably slower on many OSes other than Linux
  gitweb: Show '...' links in "summary" view only if there are more items
  config_rename_section: fix FILE* leak
  Remove COLLISION_CHECK from Makefile since it's not used.
  fix populate-filespec
  git-cvsserver: fix breakage when calling git merge-file
This commit is contained in:
Junio C Hamano
2006-12-20 11:26:19 -08:00
81 changed files with 168 additions and 245 deletions

View File

@@ -10,6 +10,7 @@ SYNOPSIS
--------
[verse]
'git-rev-list' [ \--max-count=number ]
[ \--skip=number ]
[ \--max-age=timestamp ]
[ \--min-age=timestamp ]
[ \--sparse ]
@@ -139,6 +140,10 @@ limiting may be applied.
Limit the number of commits output.
--skip='number'::
Skip 'number' commits before starting to show the commit output.
--since='date', --after='date'::
Show commits more recent than a specific date.

View File

@@ -1,7 +1,7 @@
#!/bin/sh
GVF=GIT-VERSION-FILE
DEF_VER=v1.4.4.1.GIT
DEF_VER=v1.4.4.GIT
LF='
'

View File

@@ -82,10 +82,6 @@ all:
# Define NO_ACCURATE_DIFF if your diff program at least sometimes misses
# a missing newline at the end of the file.
#
# Define COLLISION_CHECK below if you believe that SHA1's
# 1461501637330902918203684832716283019655932542976 hashes do not give you
# sufficient guarantee that no collisions between objects will ever happen.
#
# Define USE_NSEC below if you want git to care about sub-second file mtimes
# and ctimes. Note that you need recent glibc (at least 2.2.4) for this, and
# it will BREAK YOUR LOCAL DIFFS! show-diff and anything using it will likely

View File

@@ -1,7 +1,6 @@
/*
* Copyright (c) 2005, 2006 Rene Scharfe
*/
#include <time.h>
#include "cache.h"
#include "commit.h"
#include "strbuf.h"

View File

@@ -1,7 +1,6 @@
/*
* Copyright (c) 2006 Rene Scharfe
*/
#include <time.h>
#include "cache.h"
#include "commit.h"
#include "blob.h"

1
blob.c
View File

@@ -1,6 +1,5 @@
#include "cache.h"
#include "blob.h"
#include <stdlib.h>
const char *blob_type = "blob";

View File

@@ -3,8 +3,6 @@
*
* Copyright (C) 2006 Linus Torvalds
*/
#include <fnmatch.h>
#include "cache.h"
#include "builtin.h"
#include "dir.h"

View File

@@ -6,7 +6,6 @@
* This applies patches on top of some (arbitrary) version of the SCM.
*
*/
#include <fnmatch.h>
#include "cache.h"
#include "cache-tree.h"
#include "quote.h"

View File

@@ -2,7 +2,6 @@
* Copyright (c) 2006 Franck Bui-Huu
* Copyright (c) 2006 Rene Scharfe
*/
#include <time.h>
#include "cache.h"
#include "builtin.h"
#include "archive.h"

View File

@@ -15,10 +15,6 @@
#include "revision.h"
#include "xdiff-interface.h"
#include <time.h>
#include <sys/time.h>
#include <regex.h>
static char blame_usage[] =
"git-blame [-c] [-l] [-t] [-f] [-n] [-p] [-L n,m] [-S <revs-file>] [-M] [-C] [-C] [commit] [--] file\n"
" -c, --compatibility Use the same output mode as git-annotate (Default: off)\n"

View File

@@ -5,8 +5,8 @@
* Based on git-branch.sh by Junio C Hamano.
*/
#include "color.h"
#include "cache.h"
#include "color.h"
#include "refs.h"
#include "commit.h"
#include "builtin.h"

View File

@@ -6,7 +6,6 @@
#include "tree.h"
#include "blob.h"
#include "quote.h"
#include <fnmatch.h>
/* Quoting styles */
#define QUOTE_NONE 0

View File

@@ -10,10 +10,7 @@
#include "tag.h"
#include "tree-walk.h"
#include "builtin.h"
#include <regex.h>
#include "grep.h"
#include <fnmatch.h>
#include <sys/wait.h>
/*
* git grep pathspecs are somewhat different from diff-tree pathspecs;

View File

@@ -11,8 +11,6 @@
#include "log-tree.h"
#include "builtin.h"
#include "tag.h"
#include <time.h>
#include <sys/time.h>
static int default_show_root = 1;

View File

@@ -5,8 +5,6 @@
*
* Copyright (C) Linus Torvalds, 2005
*/
#include <fnmatch.h>
#include "cache.h"
#include "quote.h"
#include "dir.h"

View File

@@ -2,15 +2,6 @@
* Another stupid program, this one parsing the headers of an
* email to figure out authorship and subject
*/
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#ifndef NO_ICONV
#include <iconv.h>
#endif
#include "git-compat-util.h"
#include "cache.h"
#include "builtin.h"

View File

@@ -4,13 +4,6 @@
* It just splits a mbox into a list of files: "0001" "0002" ..
* so you can process them further from there.
*/
#include <unistd.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include <stdio.h>
#include "cache.h"
#include "builtin.h"

View File

@@ -3,8 +3,6 @@
*
* Copyright (C) 2006 Johannes Schindelin
*/
#include <fnmatch.h>
#include "cache.h"
#include "builtin.h"
#include "dir.h"

View File

@@ -1,4 +1,3 @@
#include <stdlib.h>
#include "builtin.h"
#include "cache.h"
#include "commit.h"

View File

@@ -12,8 +12,6 @@
#include "diff.h"
#include "revision.h"
#include "list-objects.h"
#include <sys/time.h>
#include <signal.h>
static const char pack_usage[] = "\
git-pack-objects [{ -q | --progress | --all-progress }] \n\

View File

@@ -1,6 +1,5 @@
#include "builtin.h"
#include "cache.h"
#include <regex.h>
static const char git_config_set_usage[] =
"git-repo-config [ --global ] [ --bool | --int ] [--get | --get-all | --get-regexp | --replace-all | --add | --unset | --unset-all] name [value [value_regex]] | --rename-section old_name new_name | --list";

View File

@@ -1,5 +1,5 @@
#include "wt-status.h"
#include "cache.h"
#include "wt-status.h"
extern int wt_status_use_color;

View File

@@ -4,7 +4,6 @@
#include "diff.h"
#include "path-list.h"
#include "revision.h"
#include <string.h>
static const char shortlog_usage[] =
"git-shortlog [-n] [-s] [<commit-id>... ]";

View File

@@ -1,5 +1,3 @@
#include <stdlib.h>
#include <fnmatch.h>
#include "cache.h"
#include "commit.h"
#include "refs.h"

View File

@@ -1,6 +1,3 @@
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "builtin.h"
/*

View File

@@ -1,7 +1,6 @@
/*
* Copyright (c) 2005, 2006 Rene Scharfe
*/
#include <time.h>
#include "cache.h"
#include "commit.h"
#include "tar.h"

View File

@@ -8,8 +8,6 @@
#include "tag.h"
#include "tree.h"
#include <sys/time.h>
static int dry_run, quiet, recover, has_errors;
static const char unpack_usage[] = "git-unpack-objects [-n] [-q] [-r] < pack-file";

View File

@@ -1,9 +1,6 @@
/*
* Copyright (c) 2006 Franck Bui-Huu
*/
#include <time.h>
#include <sys/wait.h>
#include <sys/poll.h>
#include "cache.h"
#include "builtin.h"
#include "archive.h"

View File

@@ -1,8 +1,5 @@
#include "color.h"
#include "cache.h"
#include "git-compat-util.h"
#include <stdarg.h>
#include "color.h"
#define COLOR_RESET "\033[m"

View File

@@ -1,7 +1,3 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include "../git-compat-util.h"
void *gitfakemmap(void *start, size_t length, int prot , int flags, int fd, off_t offset)

View File

@@ -1,5 +1,4 @@
#include <stdlib.h>
#include <string.h>
#include "../git-compat-util.h"
int gitsetenv(const char *name, const char *value, int replace)
{

View File

@@ -1,4 +1,4 @@
#include <string.h>
#include "../git-compat-util.h"
size_t gitstrlcpy(char *dest, const char *src, size_t size)
{

View File

@@ -1,5 +1,4 @@
#include <stdlib.h>
#include <string.h>
#include "../git-compat-util.h"
void gitunsetenv (const char *name)
{

View File

@@ -6,7 +6,6 @@
*
*/
#include "cache.h"
#include <regex.h>
#define MAXNAME (256)
@@ -749,7 +748,7 @@ out_free:
int git_config_rename_section(const char *old_name, const char *new_name)
{
int ret = 0;
const char *config_filename;
char *config_filename;
struct lock_file *lock = xcalloc(sizeof(struct lock_file), 1);
int out_fd;
char buf[1024];
@@ -762,11 +761,15 @@ int git_config_rename_section(const char *old_name, const char *new_name)
}
config_filename = xstrdup(config_filename);
out_fd = hold_lock_file_for_update(lock, config_filename, 0);
if (out_fd < 0)
return error("Could not lock config file!");
if (out_fd < 0) {
ret = error("Could not lock config file!");
goto out;
}
if (!(config_file = fopen(config_filename, "rb")))
return error("Could not open config file!");
if (!(config_file = fopen(config_filename, "rb"))) {
ret = error("Could not open config file!");
goto out;
}
while (fgets(buf, sizeof(buf), config_file)) {
int i;
@@ -806,8 +809,11 @@ int git_config_rename_section(const char *old_name, const char *new_name)
}
write(out_fd, buf, strlen(buf));
}
fclose(config_file);
if (close(out_fd) || commit_lock_file(lock) < 0)
return error("Cannot commit config file!");
ret = error("Cannot commit config file!");
out:
free(config_filename);
return ret;
}

View File

@@ -316,10 +316,6 @@ GIT_PARSE_WITH(iconv))
## --enable-FEATURE[=ARG] and --disable-FEATURE
#
# Define COLLISION_CHECK below if you believe that SHA1's
# 1461501637330902918203684832716283019655932542976 hashes do not give you
# sufficient guarantee that no collisions between objects will ever happen.
#
# Define USE_NSEC below if you want git to care about sub-second file mtimes
# and ctimes. Note that you need recent glibc (at least 2.2.4) for this, and
# it will BREAK YOUR LOCAL DIFFS! show-diff and anything using it will likely

View File

@@ -3,12 +3,6 @@
#include "pkt-line.h"
#include "quote.h"
#include "refs.h"
#include <sys/wait.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <signal.h>
static char *server_capabilities;

View File

@@ -1,7 +1,3 @@
#define _XOPEN_SOURCE 600 /* glibc2 and AIX 5.3L need 500, OpenBSD needs 600 for S_ISLNK() */
#define _XOPEN_SOURCE_EXTENDED 1 /* AIX 5.3L needs this */
#define _GNU_SOURCE
#include <time.h>
#include "cache.h"
#include "blob.h"
#include "commit.h"

View File

@@ -1,20 +1,10 @@
#include <signal.h>
#include <sys/wait.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/poll.h>
#include <netdb.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <syslog.h>
#include <pwd.h>
#include <grp.h>
#include <limits.h>
#include "pkt-line.h"
#include "cache.h"
#include "pkt-line.h"
#include "exec_cmd.h"
#include "interpolate.h"
#include <syslog.h>
#ifndef HOST_NAME_MAX
#define HOST_NAME_MAX 256
#endif

3
date.c
View File

@@ -4,9 +4,6 @@
* Copyright (C) Linus Torvalds, 2005
*/
#include <time.h>
#include <sys/time.h>
#include "cache.h"
static time_t my_mktime(struct tm *tm)

View File

@@ -18,11 +18,8 @@
* licensing gets turned into GPLv2 within this project.
*/
#include <stdlib.h>
#include <string.h>
#include "delta.h"
#include "git-compat-util.h"
#include "delta.h"
/* maximum hash entry list for the same hash bucket */
#define HASH_LIMIT 64

5
diff.c
View File

@@ -1,9 +1,6 @@
/*
* Copyright (C) 2005 Junio C Hamano
*/
#include <sys/types.h>
#include <sys/wait.h>
#include <signal.h>
#include "cache.h"
#include "quote.h"
#include "diff.h"
@@ -1237,7 +1234,7 @@ static int reuse_worktree_file(const char *name, const unsigned char *sha1, int
* objects however would tend to be slower as they need
* to be individually opened and inflated.
*/
if (FAST_WORKING_DIRECTORY && !want_file && has_sha1_pack(sha1, NULL))
if (!FAST_WORKING_DIRECTORY && !want_file && has_sha1_pack(sha1, NULL))
return 0;
len = strlen(name);

View File

@@ -4,7 +4,6 @@
#include "cache.h"
#include "diff.h"
#include "diffcore.h"
#include <fnmatch.h>
static char **order;
static int order_cnt;

View File

@@ -5,8 +5,6 @@
#include "diff.h"
#include "diffcore.h"
#include <regex.h>
static unsigned int contains(struct diff_filespec *one,
const char *needle, unsigned long len,
regex_t *regexp)

3
dir.c
View File

@@ -5,9 +5,6 @@
* Copyright (C) Linus Torvalds, 2005-2006
* Junio Hamano, 2005-2006
*/
#include <dirent.h>
#include <fnmatch.h>
#include "cache.h"
#include "dir.h"

View File

@@ -1,5 +1,3 @@
#include <sys/types.h>
#include <dirent.h>
#include "cache.h"
#include "blob.h"

View File

@@ -5,7 +5,6 @@
#include "tag.h"
#include "exec_cmd.h"
#include "sideband.h"
#include <sys/wait.h>
static int keep_pack;
static int quiet;

View File

@@ -1,6 +1,5 @@
#include "fetch.h"
#include "cache.h"
#include "fetch.h"
#include "commit.h"
#include "tree.h"
#include "tree-walk.h"

View File

@@ -1,6 +1,3 @@
#include <sys/types.h>
#include <dirent.h>
#include "cache.h"
#include "commit.h"
#include "tree.h"

View File

@@ -11,6 +11,11 @@
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
#define _XOPEN_SOURCE 600 /* glibc2 and AIX 5.3L need 500, OpenBSD needs 600 for S_ISLNK() */
#define _XOPEN_SOURCE_EXTENDED 1 /* AIX 5.3L needs this */
#define _GNU_SOURCE
#define _BSD_SOURCE
#include <unistd.h>
#include <stdio.h>
#include <sys/stat.h>
@@ -22,9 +27,27 @@
#include <errno.h>
#include <limits.h>
#include <sys/param.h>
#include <netinet/in.h>
#include <sys/types.h>
#include <dirent.h>
#include <sys/time.h>
#include <time.h>
#include <signal.h>
#include <sys/wait.h>
#include <fnmatch.h>
#include <sys/poll.h>
#include <sys/socket.h>
#include <assert.h>
#include <regex.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <pwd.h>
#include <grp.h>
#ifndef NO_ICONV
#include <iconv.h>
#endif
/* On most systems <limits.h> would have given us this, but
* not on some systems (e.g. GNU/Hurd).

View File

@@ -946,7 +946,7 @@ sub req_update
$log->debug("Temporary directory for merge is $dir");
my $return = system("git merge-file", $file_local, $file_old, $file_new);
my $return = system("git", "merge-file", $file_local, $file_old, $file_new);
$return >>= 8;
if ( $return == 0 )

14
git.c
View File

@@ -1,20 +1,8 @@
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <limits.h>
#include <stdarg.h>
#include "git-compat-util.h"
#include "builtin.h"
#include "exec_cmd.h"
#include "cache.h"
#include "quote.h"
#include "builtin.h"
const char git_usage_string[] =
"git [--version] [--exec-path[=GIT_EXEC_PATH]] [-p|--paginate] [--bare] [--git-dir=GIT_DIR] [--help] COMMAND [ARGS]";

View File

@@ -2915,8 +2915,10 @@ sub git_summary {
my $owner = git_get_project_owner($project);
my $refs = git_get_references();
my @taglist = git_get_tags_list(15);
my @headlist = git_get_heads_list(15);
# These get_*_list functions return one more to allow us to see if
# there are more ...
my @taglist = git_get_tags_list(16);
my @headlist = git_get_heads_list(16);
my @forklist;
my ($check_forks) = gitweb_check_feature('forks');
@@ -2952,6 +2954,8 @@ sub git_summary {
}
}
# we need to request one more than 16 (0..15) to check if
# those 16 are all
open my $fd, "-|", git_cmd(), "rev-list", "--max-count=17",
git_get_head_hash($project), "--"
or die_error(undef, "Open git-rev-list failed");
@@ -2959,17 +2963,20 @@ sub git_summary {
close $fd;
git_print_header_div('shortlog');
git_shortlog_body(\@revlist, 0, 15, $refs,
$#revlist <= 15 ? undef :
$cgi->a({-href => href(action=>"shortlog")}, "..."));
if (@taglist) {
git_print_header_div('tags');
git_tags_body(\@taglist, 0, 15,
$#taglist <= 15 ? undef :
$cgi->a({-href => href(action=>"tags")}, "..."));
}
if (@headlist) {
git_print_header_div('heads');
git_heads_body(\@headlist, $head, 0, 15,
$#headlist <= 15 ? undef :
$cgi->a({-href => href(action=>"heads")}, "..."));
}

1
grep.c
View File

@@ -1,5 +1,4 @@
#include "cache.h"
#include <regex.h>
#include "grep.h"
void append_grep_pattern(struct grep_opt *opt, const char *pat,

3
help.c
View File

@@ -3,12 +3,11 @@
*
* Builtin help-related commands (help, usage, version)
*/
#include <sys/ioctl.h>
#include "cache.h"
#include "builtin.h"
#include "exec_cmd.h"
#include "common-cmds.h"
#include <sys/ioctl.h>
/* most GUI terminals set COLUMNS (although some don't export it) */
static int term_columns(void)

View File

@@ -7,9 +7,6 @@
*/
#include "cache.h"
#include <pwd.h>
#include <netdb.h>
static char git_default_date[50];
static void copy_gecos(struct passwd *w, char *name, int sz)

View File

@@ -24,13 +24,6 @@
#include "cache.h"
#include <assert.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <netdb.h>
typedef struct store_conf {
char *name;
const char *path; /* should this be here? its interpretation is driver-specific */

View File

@@ -6,8 +6,6 @@
#include "commit.h"
#include "tag.h"
#include "tree.h"
#include <sys/time.h>
#include <signal.h>
static const char index_pack_usage[] =
"git-index-pack [-v] [-o <index-file>] [{ ---keep | --keep=<msg> }] { <pack-file> | --stdin [--fix-thin] [<pack-file>] }";
@@ -87,7 +85,7 @@ static unsigned display_progress(unsigned n, unsigned total, unsigned last_pc)
static unsigned char input_buffer[4096];
static unsigned long input_offset, input_len, consumed_bytes;
static SHA_CTX input_ctx;
static int input_fd, output_fd, mmap_fd;
static int input_fd, output_fd, pack_fd;
/* Discard current buffer used content. */
static void flush(void)
@@ -148,14 +146,14 @@ static const char *open_pack_file(const char *pack_name)
output_fd = open(pack_name, O_CREAT|O_EXCL|O_RDWR, 0600);
if (output_fd < 0)
die("unable to create %s: %s\n", pack_name, strerror(errno));
mmap_fd = output_fd;
pack_fd = output_fd;
} else {
input_fd = open(pack_name, O_RDONLY);
if (input_fd < 0)
die("cannot open packfile '%s': %s",
pack_name, strerror(errno));
output_fd = -1;
mmap_fd = input_fd;
pack_fd = input_fd;
}
SHA1_Init(&input_ctx);
return pack_name;
@@ -268,7 +266,7 @@ static void *unpack_raw_entry(struct object_entry *obj, union delta_base *delta_
case OBJ_TAG:
break;
default:
bad_object(obj->offset, "bad object type %d", obj->type);
bad_object(obj->offset, "unknown object type %d", obj->type);
}
obj->hdr_size = consumed_bytes - obj->offset;
@@ -279,27 +277,25 @@ static void *get_data_from_pack(struct object_entry *obj)
{
unsigned long from = obj[0].offset + obj[0].hdr_size;
unsigned long len = obj[1].offset - from;
unsigned pg_offset = from % getpagesize();
unsigned char *map, *data;
unsigned char *src, *data;
z_stream stream;
int st;
map = mmap(NULL, len + pg_offset, PROT_READ, MAP_PRIVATE,
mmap_fd, from - pg_offset);
if (map == MAP_FAILED)
die("cannot mmap pack file: %s", strerror(errno));
src = xmalloc(len);
if (pread(pack_fd, src, len, from) != len)
die("cannot pread pack file: %s", strerror(errno));
data = xmalloc(obj->size);
memset(&stream, 0, sizeof(stream));
stream.next_out = data;
stream.avail_out = obj->size;
stream.next_in = map + pg_offset;
stream.next_in = src;
stream.avail_in = len;
inflateInit(&stream);
while ((st = inflate(&stream, Z_FINISH)) == Z_OK);
inflateEnd(&stream);
if (st != Z_STREAM_END || stream.total_out != obj->size)
die("serious inflate inconsistency");
munmap(map, len + pg_offset);
free(src);
return data;
}

View File

@@ -2,8 +2,6 @@
* Copyright 2006 Jon Loeliger
*/
#include <string.h>
#include "git-compat-util.h"
#include "interpolate.h"

View File

@@ -1,7 +1,6 @@
/*
* Copyright (c) 2005, Junio C Hamano
*/
#include <signal.h>
#include "cache.h"
static struct lock_file *lock_file_list;

View File

@@ -1,4 +1,3 @@
#include <stdlib.h>
#include "cache.h"
#include "commit.h"

View File

@@ -1,7 +1,3 @@
#include <sys/types.h>
#include <sys/wait.h>
#include <signal.h>
#include "cache.h"
static const char *pgm;

View File

@@ -3,13 +3,6 @@
* Fredrik Kuivinen.
* The thieves were Alex Riesen and Johannes Schindelin, in June/July 2006
*/
#include <stdarg.h>
#include <string.h>
#include <assert.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <time.h>
#include "cache.h"
#include "cache-tree.h"
#include "commit.h"

View File

@@ -1,4 +1,3 @@
#include <stdio.h>
#include "cache.h"
#include "path-list.h"

1
path.c
View File

@@ -11,7 +11,6 @@
* which is what it's designed for.
*/
#include "cache.h"
#include <pwd.h>
static char bad_path[] = "/bad-path/";

View File

@@ -6,7 +6,6 @@
#include "exec_cmd.h"
#include "commit.h"
#include "object.h"
#include <sys/wait.h>
static const char receive_pack_usage[] = "git-receive-pack <git-dir>";

4
refs.c
View File

@@ -1,10 +1,8 @@
#include "refs.h"
#include "cache.h"
#include "refs.h"
#include "object.h"
#include "tag.h"
#include <errno.h>
/* ISSYMREF=01 and ISPACKED=02 are public interfaces */
#define REF_KNOWS_PEELED 04

View File

@@ -6,7 +6,6 @@
#include "diff.h"
#include "refs.h"
#include "revision.h"
#include <regex.h>
#include "grep.h"
static char *path_name(struct name_path *path, const char *name)
@@ -527,6 +526,7 @@ void init_revisions(struct rev_info *revs, const char *prefix)
revs->prefix = prefix;
revs->max_age = -1;
revs->min_age = -1;
revs->skip_count = -1;
revs->max_count = -1;
revs->prune_fn = NULL;
@@ -763,6 +763,10 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
revs->max_count = atoi(arg + 12);
continue;
}
if (!strncmp(arg, "--skip=", 7)) {
revs->skip_count = atoi(arg + 7);
continue;
}
/* accept -<digit>, like traditional "head" */
if ((*arg == '-') && isdigit(arg[1])) {
revs->max_count = atoi(arg + 1);
@@ -1130,23 +1134,11 @@ static int commit_match(struct commit *commit, struct rev_info *opt)
commit->buffer, strlen(commit->buffer));
}
struct commit *get_revision(struct rev_info *revs)
static struct commit *get_revision_1(struct rev_info *revs)
{
struct commit_list *list = revs->commits;
if (!list)
if (!revs->commits)
return NULL;
/* Check the max_count ... */
switch (revs->max_count) {
case -1:
break;
case 0:
return NULL;
default:
revs->max_count--;
}
do {
struct commit_list *entry = revs->commits;
struct commit *commit = entry->item;
@@ -1213,3 +1205,28 @@ struct commit *get_revision(struct rev_info *revs)
} while (revs->commits);
return NULL;
}
struct commit *get_revision(struct rev_info *revs)
{
struct commit *c = NULL;
if (0 < revs->skip_count) {
while ((c = get_revision_1(revs)) != NULL) {
if (revs->skip_count-- <= 0)
break;
}
}
/* Check the max_count ... */
switch (revs->max_count) {
case -1:
break;
case 0:
return NULL;
default:
revs->max_count--;
}
if (c)
return c;
return get_revision_1(revs);
}

View File

@@ -77,6 +77,7 @@ struct rev_info {
struct grep_opt *grep_filter;
/* special limits */
int skip_count;
int max_count;
unsigned long max_age;
unsigned long min_age;

6
rsh.c
View File

@@ -1,10 +1,6 @@
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include "cache.h"
#include "rsh.h"
#include "quote.h"
#include "cache.h"
#define COMMAND_SIZE 4096

View File

@@ -1,6 +1,5 @@
#include "cache.h"
#include "run-command.h"
#include <sys/wait.h>
#include "exec_cmd.h"
int run_command_v_opt(int argc, const char **argv, int flags)

View File

@@ -1013,7 +1013,7 @@ void packed_object_info_detail(struct packed_git *p,
for (;;) {
switch (kind) {
default:
die("corrupted pack file %s containing object of kind %d",
die("pack %s contains unknown object type %d",
p->pack_name, kind);
case OBJ_COMMIT:
case OBJ_TREE:
@@ -1063,7 +1063,7 @@ static int packed_object_info(struct packed_git *p, unsigned long offset,
strcpy(type, type_names[kind]);
break;
default:
die("corrupted pack file %s containing object of kind %d",
die("pack %s contains unknown object type %d",
p->pack_name, kind);
}
if (sizep)

View File

@@ -12,8 +12,6 @@
#include "rsh.h"
#include "refs.h"
#include <string.h>
static unsigned char local_version = 1;
static unsigned char remote_version;

View File

@@ -1,7 +1,5 @@
#include <stdio.h>
#include <stdlib.h>
#include "strbuf.h"
#include "cache.h"
#include "strbuf.h"
void strbuf_init(struct strbuf *sb) {
sb->buf = NULL;

51
t/t6005-rev-list-count.sh Executable file
View File

@@ -0,0 +1,51 @@
#!/bin/sh
test_description='git-rev-list --max-count and --skip test'
. ./test-lib.sh
test_expect_success 'setup' '
for n in 1 2 3 4 5 ; do \
echo $n > a ; \
git add a ; \
git commit -m "$n" ; \
done
'
test_expect_success 'no options' '
test $(git-rev-list HEAD | wc -l) = 5
'
test_expect_success '--max-count' '
test $(git-rev-list HEAD --max-count=0 | wc -l) = 0 &&
test $(git-rev-list HEAD --max-count=3 | wc -l) = 3 &&
test $(git-rev-list HEAD --max-count=5 | wc -l) = 5 &&
test $(git-rev-list HEAD --max-count=10 | wc -l) = 5
'
test_expect_success '--max-count all forms' '
test $(git-rev-list HEAD --max-count=1 | wc -l) = 1 &&
test $(git-rev-list HEAD -1 | wc -l) = 1 &&
test $(git-rev-list HEAD -n1 | wc -l) = 1 &&
test $(git-rev-list HEAD -n 1 | wc -l) = 1
'
test_expect_success '--skip' '
test $(git-rev-list HEAD --skip=0 | wc -l) = 5 &&
test $(git-rev-list HEAD --skip=3 | wc -l) = 2 &&
test $(git-rev-list HEAD --skip=5 | wc -l) = 0 &&
test $(git-rev-list HEAD --skip=10 | wc -l) = 0
'
test_expect_success '--skip --max-count' '
test $(git-rev-list HEAD --skip=0 --max-count=0 | wc -l) = 0 &&
test $(git-rev-list HEAD --skip=0 --max-count=10 | wc -l) = 5 &&
test $(git-rev-list HEAD --skip=3 --max-count=0 | wc -l) = 0 &&
test $(git-rev-list HEAD --skip=3 --max-count=1 | wc -l) = 1 &&
test $(git-rev-list HEAD --skip=3 --max-count=2 | wc -l) = 2 &&
test $(git-rev-list HEAD --skip=3 --max-count=10 | wc -l) = 2 &&
test $(git-rev-list HEAD --skip=5 --max-count=10 | wc -l) = 0 &&
test $(git-rev-list HEAD --skip=10 --max-count=10 | wc -l) = 0
'
test_done

View File

@@ -1,6 +1,3 @@
#include <stdio.h>
#include <time.h>
#include "cache.h"
int main(int argc, char **argv)

View File

@@ -8,13 +8,7 @@
* published by the Free Software Foundation.
*/
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include "git-compat-util.h"
#include "delta.h"
static const char usage[] =

1
tree.c
View File

@@ -4,7 +4,6 @@
#include "commit.h"
#include "tag.h"
#include "tree-walk.h"
#include <stdlib.h>
const char *tree_type = "tree";

View File

@@ -1,5 +1,3 @@
#include <signal.h>
#include <sys/time.h>
#include "cache.h"
#include "dir.h"
#include "tree.h"

View File

@@ -1,6 +1,3 @@
#include <signal.h>
#include <sys/wait.h>
#include <sys/poll.h>
#include "cache.h"
#include "refs.h"
#include "pkt-line.h"

3
var.c
View File

@@ -4,9 +4,6 @@
* Copyright (C) Eric Biederman, 2005
*/
#include "cache.h"
#include <stdio.h>
#include <errno.h>
#include <string.h>
static const char var_usage[] = "git-var [-l | <variable>]";

View File

@@ -1,6 +1,6 @@
#include "cache.h"
#include "wt-status.h"
#include "color.h"
#include "cache.h"
#include "object.h"
#include "dir.h"
#include "commit.h"