summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Documentation/config.txt6
-rw-r--r--Documentation/git-cvsimport.txt2
-rw-r--r--Documentation/git-grep.txt20
-rw-r--r--Documentation/git-push.txt2
-rw-r--r--Makefile19
-rw-r--r--alloc.c15
-rw-r--r--builtin-diff.c7
-rw-r--r--builtin-fmt-merge-msg.c3
-rw-r--r--builtin-help.c54
-rw-r--r--builtin-prune-packed.c (renamed from prune-packed.c)5
-rw-r--r--builtin-push.c4
-rw-r--r--builtin-read-tree.c2
-rw-r--r--builtin-repo-config.c (renamed from repo-config.c)3
-rw-r--r--builtin.h14
-rw-r--r--diff.c6
-rw-r--r--diffcore-rename.c1
-rw-r--r--diffcore.h3
-rwxr-xr-xgit-annotate.perl1
-rwxr-xr-xgit-clone.sh5
-rwxr-xr-xgit-push.sh87
-rw-r--r--git.c9
-rwxr-xr-xgitk2
-rw-r--r--mktag.c43
-rw-r--r--t/annotate-tests.sh3
-rwxr-xr-xt/t1003-read-tree-prefix.sh27
-rwxr-xr-xt/t1020-subdirectory.sh109
-rwxr-xr-xt/t3800-mktag.sh227
-rwxr-xr-xt/t9100-git-svn-basic.sh7
-rw-r--r--templates/Makefile12
29 files changed, 503 insertions, 195 deletions
diff --git a/Documentation/config.txt b/Documentation/config.txt
index e669003f72..d89916bea7 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -223,14 +223,14 @@ showbranch.default::
See gitlink:git-show-branch[1].
tar.umask::
- By default, git-link:git-tar-tree[1] sets file and directories modes
+ By default, gitlink:git-tar-tree[1] sets file and directories modes
to 0666 or 0777. While this is both useful and acceptable for projects
such as the Linux Kernel, it might be excessive for other projects.
With this variable, it becomes possible to tell
- git-link:git-tar-tree[1] to apply a specific umask to the modes above.
+ gitlink:git-tar-tree[1] to apply a specific umask to the modes above.
The special value "user" indicates that the user's current umask will
be used. This should be enough for most projects, as it will lead to
- the same permissions as git-link:git-checkout[1] would use. The default
+ the same permissions as gitlink:git-checkout[1] would use. The default
value remains 0, which means world read-write.
user.email::
diff --git a/Documentation/git-cvsimport.txt b/Documentation/git-cvsimport.txt
index b0c6d7c303..d21d66bfeb 100644
--- a/Documentation/git-cvsimport.txt
+++ b/Documentation/git-cvsimport.txt
@@ -116,7 +116,7 @@ file each time git-cvsimport is run.
+
It is not recommended to use this feature if you intend to
export changes back to CVS again later with
-git-link[1]::git-cvsexportcommit.
+gitlink:git-cvsexportcommit[1].
OUTPUT
------
diff --git a/Documentation/git-grep.txt b/Documentation/git-grep.txt
index 62a8e7f222..dc7683383c 100644
--- a/Documentation/git-grep.txt
+++ b/Documentation/git-grep.txt
@@ -16,7 +16,7 @@ SYNOPSIS
[-n] [-l | --files-with-matches] [-L | --files-without-match]
[-c | --count]
[-A <post-context>] [-B <pre-context>] [-C <context>]
- [-f <file>] [-e] <pattern>
+ [-f <file>] [-e] <pattern> [--and|--or|--not|(|)|-e <pattern>...]
[<tree>...]
[--] [<path>...]
@@ -74,16 +74,30 @@ OPTIONS
-e::
The next parameter is the pattern. This option has to be
used for patterns starting with - and should be used in
- scripts passing user input to grep.
+ scripts passing user input to grep. Multiple patterns are
+ combined by 'or'.
+
+--and | --or | --not | ( | )::
+ Specify how multiple patterns are combined using boolean
+ expressions. `--or` is the default operator. `--and` has
+ higher precedence than `--or`. `-e` has to be used for all
+ patterns.
`<tree>...`::
Search blobs in the trees for specified patterns.
-`--`::
+\--::
Signals the end of options; the rest of the parameters
are <path> limiters.
+Example
+-------
+
+git grep -e \'#define\' --and \( -e MAX_PATH -e PATH_MAX \)::
+ Looks for a line that has `#define` and either `MAX_PATH` or
+ `PATH_MAX`.
+
Author
------
Originally written by Linus Torvalds <torvalds@osdl.org>, later
diff --git a/Documentation/git-push.txt b/Documentation/git-push.txt
index 56afd64f42..d4ae99fa53 100644
--- a/Documentation/git-push.txt
+++ b/Documentation/git-push.txt
@@ -8,7 +8,7 @@ git-push - Update remote refs along with associated objects
SYNOPSIS
--------
-'git-push' [--all] [--tags] [--force] <repository> <refspec>...
+'git-push' [--all] [--tags] [-f | --force] <repository> <refspec>...
DESCRIPTION
-----------
diff --git a/Makefile b/Makefile
index 15864e23bd..700c77f564 100644
--- a/Makefile
+++ b/Makefile
@@ -24,6 +24,11 @@ all:
# Define NO_D_TYPE_IN_DIRENT if your platform defines DT_UNKNOWN but lacks
# d_type in struct dirent (latest Cygwin -- will be fixed soonish).
#
+# Define NO_C99_FORMAT if your formatted IO functions (printf/scanf et.al.)
+# do not support the 'size specifiers' introduced by C99, namely ll, hh,
+# j, z, t. (representing long long int, char, intmax_t, size_t, ptrdiff_t).
+# some c compilers supported these specifiers prior to C99 as an extension.
+#
# Define NO_STRCASESTR if you don't have strcasestr.
#
# Define NO_STRLCPY if you don't have strlcpy.
@@ -173,14 +178,14 @@ PROGRAMS = \
git-hash-object$X git-index-pack$X git-local-fetch$X \
git-merge-base$X \
git-merge-index$X git-mktag$X git-mktree$X git-pack-objects$X git-patch-id$X \
- git-peek-remote$X git-prune-packed$X git-receive-pack$X \
+ git-peek-remote$X git-receive-pack$X \
git-send-pack$X git-shell$X \
git-show-index$X git-ssh-fetch$X \
git-ssh-upload$X git-unpack-file$X \
git-unpack-objects$X git-update-server-info$X \
git-upload-pack$X git-verify-pack$X \
git-symbolic-ref$X \
- git-name-rev$X git-pack-redundant$X git-repo-config$X git-var$X \
+ git-name-rev$X git-pack-redundant$X git-var$X \
git-describe$X git-merge-tree$X git-blame$X git-imap-send$X
BUILT_INS = git-log$X git-whatchanged$X git-show$X git-update-ref$X \
@@ -192,7 +197,8 @@ BUILT_INS = git-log$X git-whatchanged$X git-show$X git-update-ref$X \
git-read-tree$X git-commit-tree$X git-write-tree$X \
git-apply$X git-show-branch$X git-diff-files$X git-update-index$X \
git-diff-index$X git-diff-stages$X git-diff-tree$X git-cat-file$X \
- git-fmt-merge-msg$X git-prune$X git-mv$X
+ git-fmt-merge-msg$X git-prune$X git-mv$X git-prune-packed$X \
+ git-repo-config$X
# what 'all' will build and 'install' will install, in gitexecdir
ALL_PROGRAMS = $(PROGRAMS) $(SIMPLE_PROGRAMS) $(SCRIPTS)
@@ -249,7 +255,7 @@ BUILTIN_OBJS = \
builtin-diff-index.o builtin-diff-stages.o builtin-diff-tree.o \
builtin-cat-file.o builtin-mailsplit.o builtin-stripspace.o \
builtin-update-ref.o builtin-fmt-merge-msg.o builtin-prune.o \
- builtin-mv.o
+ builtin-mv.o builtin-prune-packed.o builtin-repo-config.o
GITLIBS = $(LIB_FILE) $(XDIFF_LIB)
LIBS = $(GITLIBS) -lz
@@ -432,6 +438,9 @@ endif
ifdef NO_D_INO_IN_DIRENT
ALL_CFLAGS += -DNO_D_INO_IN_DIRENT
endif
+ifdef NO_C99_FORMAT
+ ALL_CFLAGS += -DNO_C99_FORMAT
+endif
ifdef NO_SYMLINK_HEAD
ALL_CFLAGS += -DNO_SYMLINK_HEAD
endif
@@ -712,7 +721,7 @@ install: all
$(INSTALL) -d -m755 '$(DESTDIR_SQ)$(gitexecdir_SQ)'
$(INSTALL) $(ALL_PROGRAMS) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
$(INSTALL) git$X gitk '$(DESTDIR_SQ)$(bindir_SQ)'
- $(MAKE) -C templates install
+ $(MAKE) -C templates DESTDIR='$(DESTDIR_SQ)' install
$(INSTALL) -d -m755 '$(DESTDIR_SQ)$(GIT_PYTHON_DIR_SQ)'
$(INSTALL) $(PYMODULES) '$(DESTDIR_SQ)$(GIT_PYTHON_DIR_SQ)'
if test 'z$(bindir_SQ)' != 'z$(gitexecdir_SQ)'; \
diff --git a/alloc.c b/alloc.c
index e3b22f4322..460db192d5 100644
--- a/alloc.c
+++ b/alloc.c
@@ -39,8 +39,21 @@ DEFINE_ALLOCATOR(tree)
DEFINE_ALLOCATOR(commit)
DEFINE_ALLOCATOR(tag)
+#ifdef NO_C99_FORMAT
+#define SZ_FMT "%u"
+#else
+#define SZ_FMT "%zu"
+#endif
+
+static void report(const char* name, unsigned int count, size_t size)
+{
+ fprintf(stderr, "%10s: %8u (" SZ_FMT " kB)\n", name, count, size);
+}
+
+#undef SZ_FMT
+
#define REPORT(name) \
- fprintf(stderr, "%10s: %8u (%zu kB)\n", #name, name##_allocs, name##_allocs*sizeof(struct name) >> 10)
+ report(#name, name##_allocs, name##_allocs*sizeof(struct name) >> 10)
void alloc_report(void)
{
diff --git a/builtin-diff.c b/builtin-diff.c
index 48d2fd03b7..cb4216eb8a 100644
--- a/builtin-diff.c
+++ b/builtin-diff.c
@@ -125,9 +125,6 @@ static int builtin_diff_blobs(struct rev_info *revs,
int argc, const char **argv,
struct blobinfo *blob)
{
- /* Blobs: the arguments are reversed when setup_revisions()
- * picked them up.
- */
unsigned mode = canon_mode(S_IFREG | 0644);
if (argc > 1)
@@ -135,8 +132,8 @@ static int builtin_diff_blobs(struct rev_info *revs,
stuff_change(&revs->diffopt,
mode, mode,
- blob[1].sha1, blob[0].sha1,
- blob[0].name, blob[0].name);
+ blob[0].sha1, blob[1].sha1,
+ blob[0].name, blob[1].name);
diffcore_std(&revs->diffopt);
diff_flush(&revs->diffopt);
return 0;
diff --git a/builtin-fmt-merge-msg.c b/builtin-fmt-merge-msg.c
index c84224ee84..485ede7cad 100644
--- a/builtin-fmt-merge-msg.c
+++ b/builtin-fmt-merge-msg.c
@@ -1,3 +1,4 @@
+#include "builtin.h"
#include "cache.h"
#include "commit.h"
#include "diff.h"
@@ -242,7 +243,7 @@ static void shortlog(const char *name, unsigned char *sha1,
free_list(&subjects);
}
-int cmd_fmt_merge_msg(int argc, char **argv, const char *prefix)
+int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix)
{
int limit = 20, i = 0;
char line[1024];
diff --git a/builtin-help.c b/builtin-help.c
index bb0b03f1ae..fb731cc934 100644
--- a/builtin-help.c
+++ b/builtin-help.c
@@ -9,8 +9,6 @@
#include "exec_cmd.h"
#include "common-cmds.h"
-static const char git_usage[] =
- "Usage: git [--version] [--exec-path[=GIT_EXEC_PATH]] [--help] COMMAND [ ARGS ]";
/* most GUI terminals set COLUMNS (although some don't export it) */
static int term_columns(void)
@@ -178,31 +176,6 @@ static void list_common_cmds_help(void)
puts("(use 'git help -a' to get a list of all installed git commands)");
}
-void cmd_usage(int show_all, const char *exec_path, const char *fmt, ...)
-{
- if (fmt) {
- va_list ap;
-
- va_start(ap, fmt);
- printf("git: ");
- vprintf(fmt, ap);
- va_end(ap);
- putchar('\n');
- }
- else
- puts(git_usage);
-
- if (exec_path) {
- putchar('\n');
- if (show_all)
- list_commands(exec_path, "git-*");
- else
- list_common_cmds_help();
- }
-
- exit(1);
-}
-
static void show_man_page(const char *git_cmd)
{
const char *page;
@@ -221,6 +194,13 @@ static void show_man_page(const char *git_cmd)
execlp("man", "man", page, NULL);
}
+void help_unknown_cmd(const char *cmd)
+{
+ printf("git: '%s' is not a git-command\n\n", cmd);
+ list_common_cmds_help();
+ exit(1);
+}
+
int cmd_version(int argc, const char **argv, const char *prefix)
{
printf("git version %s\n", git_version_string);
@@ -230,12 +210,24 @@ int cmd_version(int argc, const char **argv, const char *prefix)
int cmd_help(int argc, const char **argv, const char *prefix)
{
const char *help_cmd = argc > 1 ? argv[1] : NULL;
- if (!help_cmd)
- cmd_usage(0, git_exec_path(), NULL);
- else if (!strcmp(help_cmd, "--all") || !strcmp(help_cmd, "-a"))
- cmd_usage(1, git_exec_path(), NULL);
+ const char *exec_path = git_exec_path();
+
+ if (!help_cmd) {
+ printf("usage: %s\n\n", git_usage_string);
+ list_common_cmds_help();
+ exit(1);
+ }
+
+ else if (!strcmp(help_cmd, "--all") || !strcmp(help_cmd, "-a")) {
+ printf("usage: %s\n\n", git_usage_string);
+ if(exec_path)
+ list_commands(exec_path, "git-*");
+ exit(1);
+ }
+
else
show_man_page(help_cmd);
+
return 0;
}
diff --git a/prune-packed.c b/builtin-prune-packed.c
index d24b097114..d3dd94d9ef 100644
--- a/prune-packed.c
+++ b/builtin-prune-packed.c
@@ -1,3 +1,4 @@
+#include "builtin.h"
#include "cache.h"
static const char prune_packed_usage[] =
@@ -54,12 +55,10 @@ static void prune_packed_objects(void)
}
}
-int main(int argc, char **argv)
+int cmd_prune_packed(int argc, const char **argv, const char *prefix)
{
int i;
- setup_git_directory();
-
for (i = 1; i < argc; i++) {
const char *arg = argv[i];
diff --git a/builtin-push.c b/builtin-push.c
index a824171066..c39dd1e092 100644
--- a/builtin-push.c
+++ b/builtin-push.c
@@ -8,7 +8,7 @@
#define MAX_URI (16)
-static const char push_usage[] = "git push [--all] [--tags] [--force] <repository> [<refspec>...]";
+static const char push_usage[] = "git push [--all] [--tags] [-f | --force] <repository> [<refspec>...]";
static int all = 0, tags = 0, force = 0, thin = 1;
static const char *execute = NULL;
@@ -291,7 +291,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)
tags = 1;
continue;
}
- if (!strcmp(arg, "--force")) {
+ if (!strcmp(arg, "--force") || !strcmp(arg, "-f")) {
force = 1;
continue;
}
diff --git a/builtin-read-tree.c b/builtin-read-tree.c
index 49c10bf221..b30160a5b3 100644
--- a/builtin-read-tree.c
+++ b/builtin-read-tree.c
@@ -870,7 +870,7 @@ static const char read_tree_usage[] = "git-read-tree (<sha> | [[-m [--aggressive
static struct lock_file lock_file;
-int cmd_read_tree(int argc, const char **argv, const char *prefix)
+int cmd_read_tree(int argc, const char **argv, const char *unused_prefix)
{
int i, newfd, stage = 0;
unsigned char sha1[20];
diff --git a/repo-config.c b/builtin-repo-config.c
index 743f02b7de..c821e22717 100644
--- a/repo-config.c
+++ b/builtin-repo-config.c
@@ -1,3 +1,4 @@
+#include "builtin.h"
#include "cache.h"
#include <regex.h>
@@ -128,7 +129,7 @@ free_strings:
return ret;
}
-int main(int argc, const char **argv)
+int cmd_repo_config(int argc, const char **argv, const char *prefix)
{
int nongit = 0;
setup_git_directory_gently(&nongit);
diff --git a/builtin.h b/builtin.h
index 1c8637ae22..26ebcaf213 100644
--- a/builtin.h
+++ b/builtin.h
@@ -2,18 +2,12 @@
#define BUILTIN_H
#include <stdio.h>
-
-#ifndef PATH_MAX
-# define PATH_MAX 4096
-#endif
+#include <limits.h>
extern const char git_version_string[];
+extern const char git_usage_string[];
-void cmd_usage(int show_all, const char *exec_path, const char *fmt, ...)
-#ifdef __GNUC__
- __attribute__((__format__(__printf__, 3, 4), __noreturn__))
-#endif
- ;
+extern void help_unknown_cmd(const char *cmd);
extern int cmd_help(int argc, const char **argv, const char *prefix);
extern int cmd_version(int argc, const char **argv, const char *prefix);
@@ -26,6 +20,7 @@ extern int cmd_format_patch(int argc, const char **argv, const char *prefix);
extern int cmd_count_objects(int argc, const char **argv, const char *prefix);
extern int cmd_prune(int argc, const char **argv, const char *prefix);
+extern int cmd_prune_packed(int argc, const char **argv, const char *prefix);
extern int cmd_push(int argc, const char **argv, const char *prefix);
extern int cmd_grep(int argc, const char **argv, const char *prefix);
@@ -53,6 +48,7 @@ extern int cmd_update_index(int argc, const char **argv, const char *prefix);
extern int cmd_update_ref(int argc, const char **argv, const char *prefix);
extern int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix);
extern int cmd_mv(int argc, const char **argv, const char *prefix);
+extern int cmd_repo_config(int argc, const char **argv, const char *prefix);
extern int cmd_write_tree(int argc, const char **argv, const char *prefix);
extern int write_tree(unsigned char *sha1, int missing_ok, const char *prefix);
diff --git a/diff.c b/diff.c
index 607c357f5a..895c137655 100644
--- a/diff.c
+++ b/diff.c
@@ -1786,13 +1786,9 @@ struct diff_filepair *diff_queue(struct diff_queue_struct *queue,
struct diff_filespec *one,
struct diff_filespec *two)
{
- struct diff_filepair *dp = xmalloc(sizeof(*dp));
+ struct diff_filepair *dp = xcalloc(1, sizeof(*dp));
dp->one = one;
dp->two = two;
- dp->score = 0;
- dp->status = 0;
- dp->source_stays = 0;
- dp->broken_pair = 0;
if (queue)
diff_q(queue, dp);
return dp;
diff --git a/diffcore-rename.c b/diffcore-rename.c
index 1de8d32502..0ec488a903 100644
--- a/diffcore-rename.c
+++ b/diffcore-rename.c
@@ -205,6 +205,7 @@ static void record_rename_pair(int dst_index, int src_index, int score)
fill_filespec(two, dst->sha1, dst->mode);
dp = diff_queue(NULL, one, two);
+ dp->renamed_pair = 1;
if (!strcmp(src->path, dst->path))
dp->score = rename_src[src_index].score;
else
diff --git a/diffcore.h b/diffcore.h
index 73c7842cc7..2249bc2c05 100644
--- a/diffcore.h
+++ b/diffcore.h
@@ -53,11 +53,12 @@ struct diff_filepair {
char status; /* M C R N D U (see Documentation/diff-format.txt) */
unsigned source_stays : 1; /* all of R/C are copies */
unsigned broken_pair : 1;
+ unsigned renamed_pair : 1;
};
#define DIFF_PAIR_UNMERGED(p) \
(!DIFF_FILE_VALID((p)->one) && !DIFF_FILE_VALID((p)->two))
-#define DIFF_PAIR_RENAME(p) (strcmp((p)->one->path, (p)->two->path))
+#define DIFF_PAIR_RENAME(p) ((p)->renamed_pair)
#define DIFF_PAIR_BROKEN(p) \
( (!DIFF_FILE_VALID((p)->one) != !DIFF_FILE_VALID((p)->two)) && \
diff --git a/git-annotate.perl b/git-annotate.perl
index 6db2f48241..505b5ccb28 100755
--- a/git-annotate.perl
+++ b/git-annotate.perl
@@ -317,7 +317,6 @@ sub _git_diff_parse {
$gotheader = 1;
- printf("Copying from %d to %d\n", $ri, $remstart);
foreach my $parent (@$parents) {
for (my $i = $ri; $i < $remstart; $i++) {
$plines{$parent}[$pi{$parent}++] = $slines->[$i];
diff --git a/git-clone.sh b/git-clone.sh
index a92b22a13d..acc7a51b97 100755
--- a/git-clone.sh
+++ b/git-clone.sh
@@ -205,7 +205,7 @@ dir="$2"
[ -e "$dir" ] && echo "$dir already exists." && usage
mkdir -p "$dir" &&
D=$(cd "$dir" && pwd) &&
-trap 'err=$?; cd ..; rm -r "$D"; exit $err' 0
+trap 'err=$?; cd ..; rm -rf "$D"; exit $err' 0
case "$bare" in
yes)
GIT_DIR="$D" ;;
@@ -324,7 +324,8 @@ test -d "$GIT_DIR/refs/reference-tmp" && rm -fr "$GIT_DIR/refs/reference-tmp"
if test -f "$GIT_DIR/CLONE_HEAD"
then
# Read git-fetch-pack -k output and store the remote branches.
- @@PERL@@ -e "$copy_refs" "$GIT_DIR" "$use_separate_remote" "$origin"
+ @@PERL@@ -e "$copy_refs" "$GIT_DIR" "$use_separate_remote" "$origin" ||
+ exit
fi
cd "$D" || exit
diff --git a/git-push.sh b/git-push.sh
deleted file mode 100755
index 21775fc21a..0000000000
--- a/git-push.sh
+++ /dev/null
@@ -1,87 +0,0 @@
-#!/bin/sh
-
-USAGE='[--all] [--tags] [--force] <repository> [<refspec>...]'
-. git-sh-setup
-
-# Parse out parameters and then stop at remote, so that we can
-# translate it using .git/branches information
-has_all=
-has_force=
-has_exec=
-has_thin=--thin
-remote=
-do_tags=
-
-while case "$#" in 0) break ;; esac
-do
- case "$1" in
- --all)
- has_all=--all ;;
- --tags)
- do_tags=yes ;;
- --force)
- has_force=--force ;;
- --exec=*)
- has_exec="$1" ;;
- --thin)
- ;; # noop
- --no-thin)
- has_thin= ;;
- -*)
- usage ;;
- *)
- set x "$@"
- shift
- break ;;
- esac
- shift
-done
-case "$#" in
-0)
- echo "Where would you want to push today?"
- usage ;;
-esac
-
-. git-parse-remote
-remote=$(get_remote_url "$@")
-
-case "$has_all" in
---all)
- set x ;;
-'')
- case "$do_tags,$#" in
- yes,1)
- set x $(cd "$GIT_DIR/refs" && find tags -type f -print) ;;
- yes,*)
- set x $(cd "$GIT_DIR/refs" && find tags -type f -print) \
- $(get_remote_refs_for_push "$@") ;;
- ,*)
- set x $(get_remote_refs_for_push "$@") ;;
- esac
-esac
-
-shift ;# away the initial 'x'
-
-# $# is now 0 if there was no explicit refspec on the command line
-# and there was no default refspec to push from remotes/ file.
-# we will let git-send-pack to do its "matching refs" thing.
-
-case "$remote" in
-git://*)
- die "Cannot use READ-ONLY transport to push to $remote" ;;
-rsync://*)
- die "Pushing with rsync transport is deprecated" ;;
-esac
-
-set x "$remote" "$@"; shift
-test "$has_all" && set x "$has_all" "$@" && shift
-test "$has_force" && set x "$has_force" "$@" && shift
-test "$has_exec" && set x "$has_exec" "$@" && shift
-test "$has_thin" && set x "$has_thin" "$@" && shift
-
-case "$remote" in
-http://* | https://*)
- exec git-http-push "$@";;
-*)
- exec git-send-pack "$@";;
-esac
diff --git a/git.c b/git.c
index d031eb9a18..6e72a893b7 100644
--- a/git.c
+++ b/git.c
@@ -15,6 +15,9 @@
#include "builtin.h"
+const char git_usage_string[] =
+ "git [--version] [--exec-path[=GIT_EXEC_PATH]] [--help] COMMAND [ ARGS ]";
+
static void prepend_to_path(const char *dir, int len)
{
const char *old_path = getenv("PATH");
@@ -78,7 +81,7 @@ static int handle_options(const char*** argv, int* argc)
setenv("GIT_DIR", getcwd(git_dir, 1024), 1);
} else {
fprintf(stderr, "Unknown option: %s\n", cmd);
- cmd_usage(0, NULL, NULL);
+ usage(git_usage_string);
}
(*argv)++;
@@ -260,6 +263,8 @@ static void handle_internal_command(int argc, const char **argv, char **envp)
{ "fmt-merge-msg", cmd_fmt_merge_msg, NEEDS_PREFIX },
{ "prune", cmd_prune, NEEDS_PREFIX },
{ "mv", cmd_mv, NEEDS_PREFIX },
+ { "prune-packed", cmd_prune_packed, NEEDS_PREFIX },
+ { "repo-config", cmd_repo_config },
};
int i;
@@ -375,7 +380,7 @@ int main(int argc, const char **argv, char **envp)
}
if (errno == ENOENT)
- cmd_usage(0, exec_path, "'%s' is not a git-command", cmd);
+ help_unknown_cmd(cmd);
fprintf(stderr, "Failed to run command '%s': %s\n",
cmd, strerror(errno));
diff --git a/gitk b/gitk
index ba4644f450..5acaadf495 100755
--- a/gitk
+++ b/gitk
@@ -4901,7 +4901,7 @@ proc domktag {} {
proc redrawtags {id} {
global canv linehtag commitrow idpos selectedline curview
- global mainfont
+ global mainfont canvxmax
if {![info exists commitrow($curview,$id)]} return
drawcmitrow $commitrow($curview,$id)
diff --git a/mktag.c b/mktag.c
index 27f4c4f041..09b6e437d4 100644
--- a/mktag.c
+++ b/mktag.c
@@ -2,10 +2,11 @@
#include "tag.h"
/*
- * A signature file has a very simple fixed format: three lines
- * of "object <sha1>" + "type <typename>" + "tag <tagname>",
- * followed by some free-form signature that git itself doesn't
- * care about, but that can be verified with gpg or similar.
+ * A signature file has a very simple fixed format: four lines
+ * of "object <sha1>" + "type <typename>" + "tag <tagname>" +
+ * "tagger <committer>", followed by a blank line, a free-form tag
+ * message and a signature block that git itself doesn't care about,
+ * but that can be verified with gpg or similar.
*
* The first three lines are guaranteed to be at least 63 bytes:
* "object <sha1>\n" is 48 bytes, "type tag\n" at 9 bytes is the
@@ -38,6 +39,12 @@ static int verify_object(unsigned char *sha1, const char *expected_type)
return ret;
}
+#ifdef NO_C99_FORMAT
+#define PD_FMT "%d"
+#else
+#define PD_FMT "%td"
+#endif
+
static int verify_tag(char *buffer, unsigned long size)
{
int typelen;
@@ -46,45 +53,42 @@ static int verify_tag(char *buffer, unsigned long size)
const char *object, *type_line, *tag_line, *tagger_line;
if (size < 64)
- return error("wanna fool me ? you obviously got the size wrong !\n");
+ return error("wanna fool me ? you obviously got the size wrong !");
buffer[size] = 0;
/* Verify object line */
object = buffer;
if (memcmp(object, "object ", 7))
- return error("char%d: does not start with \"object \"\n", 0);
+ return error("char%d: does not start with \"object \"", 0);
if (get_sha1_hex(object + 7, sha1))
- return error("char%d: could not get SHA1 hash\n", 7);
+ return error("char%d: could not get SHA1 hash", 7);
/* Verify type line */
type_line = object + 48;
if (memcmp(type_line - 1, "\ntype ", 6))
- return error("char%d: could not find \"\\ntype \"\n", 47);
+ return error("char%d: could not find \"\\ntype \"", 47);
/* Verify tag-line */
tag_line = strchr(type_line, '\n');
if (!tag_line)
- return error("char%td: could not find next \"\\n\"\n", type_line - buffer);
+ return error("char" PD_FMT ": could not find next \"\\n\"", type_line - buffer);
tag_line++;
if (memcmp(tag_line, "tag ", 4) || tag_line[4] == '\n')
- return error("char%td: no \"tag \" found\n", tag_line - buffer);
+ return error("char" PD_FMT ": no \"tag \" found", tag_line - buffer);
/* Get the actual type */
typelen = tag_line - type_line - strlen("type \n");
if (typelen >= sizeof(type))
- return error("char%td: type too long\n", type_line+5 - buffer);
+ return error("char" PD_FMT ": type too long", type_line+5 - buffer);
memcpy(type, type_line+5, typelen);
type[typelen] = 0;
/* Verify that the object matches */
- if (get_sha1_hex(object + 7, sha1))
- return error("char%d: could not get SHA1 hash but this is really odd since i got it before !\n", 7);
-
if (verify_object(sha1, type))
- return error("char%d: could not verify object %s\n", 7, sha1);
+ return error("char%d: could not verify object %s", 7, sha1_to_hex(sha1));
/* Verify the tag-name: we don't allow control characters or spaces in it */
tag_line += 4;
@@ -94,19 +98,24 @@ static int verify_tag(char *buffer, unsigned long size)
break;
if (c > ' ')
continue;
- return error("char%td: could not verify tag name\n", tag_line - buffer);
+ return error("char" PD_FMT ": could not verify tag name", tag_line - buffer);
}
/* Verify the tagger line */
tagger_line = tag_line;
if (memcmp(tagger_line, "tagger", 6) || (tagger_line[6] == '\n'))
- return error("char%td: could not find \"tagger\"\n", tagger_line - buffer);
+ return error("char" PD_FMT ": could not find \"tagger\"", tagger_line - buffer);
+
+ /* TODO: check for committer info + blank line? */
+ /* Also, the minimum length is probably + "tagger .", or 63+8=71 */
/* The actual stuff afterwards we don't care about.. */
return 0;
}
+#undef PD_FMT
+
int main(int argc, char **argv)
{
unsigned long size = 4096;
diff --git a/t/annotate-tests.sh b/t/annotate-tests.sh
index b6a2edd887..8baf2fef69 100644
--- a/t/annotate-tests.sh
+++ b/t/annotate-tests.sh
@@ -4,7 +4,8 @@
check_count () {
head=
case "$1" in -h) head="$2"; shift; shift ;; esac
- $PROG file $head | perl -e '
+ $PROG file $head >.result || return 1
+ cat .result | perl -e '
my %expect = (@ARGV);
my %count = ();
while (<STDIN>) {
diff --git a/t/t1003-read-tree-prefix.sh b/t/t1003-read-tree-prefix.sh
new file mode 100755
index 0000000000..48ab117d75
--- /dev/null
+++ b/t/t1003-read-tree-prefix.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+#
+# Copyright (c) 2006 Junio C Hamano
+#
+
+test_description='git-read-tree --prefix test.
+'
+
+. ./test-lib.sh
+
+test_expect_success setup '
+ echo hello >one &&
+ git-update-index --add one &&
+ tree=`git-write-tree` &&
+ echo tree is $tree
+'
+
+echo 'one
+two/one' >expect
+
+test_expect_success 'read-tree --prefix' '
+ git-read-tree --prefix=two/ $tree &&
+ git-ls-files >actual &&
+ cmp expect actual
+'
+
+test_done
diff --git a/t/t1020-subdirectory.sh b/t/t1020-subdirectory.sh
new file mode 100755
index 0000000000..4409b87f8d
--- /dev/null
+++ b/t/t1020-subdirectory.sh
@@ -0,0 +1,109 @@
+#!/bin/sh
+#
+# Copyright (c) 2006 Junio C Hamano
+#
+
+test_description='Try various core-level commands in subdirectory.
+'
+
+. ./test-lib.sh
+
+test_expect_success setup '
+ long="a b c d e f g h i j k l m n o p q r s t u v w x y z" &&
+ for c in $long; do echo $c; done >one &&
+ mkdir dir &&
+ for c in x y z $long a b c; do echo $c; done >dir/two &&
+ cp one original.one &&
+ cp dir/two original.two
+'
+HERE=`pwd`
+LF='
+'
+
+test_expect_success 'update-index and ls-files' '
+ cd $HERE &&
+ git-update-index --add one &&
+ case "`git-ls-files`" in
+ one) echo ok one ;;
+ *) echo bad one; exit 1 ;;
+ esac &&
+ cd dir &&
+ git-update-index --add two &&
+ case "`git-ls-files`" in
+ two) echo ok two ;;
+ *) echo bad two; exit 1 ;;
+ esac &&
+ cd .. &&
+ case "`git-ls-files`" in
+ dir/two"$LF"one) echo ok both ;;
+ *) echo bad; exit 1 ;;
+ esac
+'
+
+test_expect_success 'cat-file' '
+ cd $HERE &&
+ two=`git-ls-files -s dir/two` &&
+ two=`expr "$two" : "[0-7]* \\([0-9a-f]*\\)"` &&
+ echo "$two" &&
+ git-cat-file -p "$two" >actual &&
+ cmp dir/two actual &&
+ cd dir &&
+ git-cat-file -p "$two" >actual &&
+ cmp two actual
+'
+rm -f actual dir/actual
+
+test_expect_success 'diff-files' '
+ cd $HERE &&
+ echo a >>one &&
+ echo d >>dir/two &&
+ case "`git-diff-files --name-only`" in
+ dir/two"$LF"one) echo ok top ;;
+ *) echo bad top; exit 1 ;;
+ esac &&
+ # diff should not omit leading paths
+ cd dir &&
+ case "`git-diff-files --name-only`" in
+ dir/two"$LF"one) echo ok subdir ;;
+ *) echo bad subdir; exit 1 ;;
+ esac &&
+ case "`git-diff-files --name-only .`" in
+ dir/two) echo ok subdir limited ;;
+ *) echo bad subdir limited; exit 1 ;;
+ esac
+'
+
+test_expect_success 'write-tree' '
+ cd $HERE &&
+ top=`git-write-tree` &&
+ echo $top &&
+ cd dir &&
+ sub=`git-write-tree` &&
+ echo $sub &&
+ test "z$top" = "z$sub"
+'
+
+test_expect_success 'checkout-index' '
+ cd $HERE &&
+ git-checkout-index -f -u one &&
+ cmp one original.one &&
+ cd dir &&
+ git-checkout-index -f -u two &&
+ cmp two ../original.two
+'
+
+test_expect_success 'read-tree' '
+ cd $HERE &&
+ rm -f one dir/two &&
+ tree=`git-write-tree` &&
+ git-read-tree --reset -u "$tree" &&
+ cmp one original.one &&
+ cmp dir/two original.two &&
+ cd dir &&
+ rm -f two &&
+ git-read-tree --reset -u "$tree" &&
+ cmp two ../original.two &&
+ cmp ../one ../original.one
+'
+
+test_done
diff --git a/t/t3800-mktag.sh b/t/t3800-mktag.sh
new file mode 100755
index 0000000000..5b23b7769d
--- /dev/null
+++ b/t/t3800-mktag.sh
@@ -0,0 +1,227 @@
+#!/bin/sh
+#
+#
+
+test_description='git-mktag: tag object verify test'
+
+. ./test-lib.sh
+
+###########################################################
+# check the tag.sig file, expecting verify_tag() to fail,
+# and checking that the error message matches the pattern
+# given in the expect.pat file.
+
+check_verify_failure () {
+ test_expect_success \
+ "$1" \
+ 'git-mktag <tag.sig 2>message ||
+ egrep -q -f expect.pat message'
+}
+
+###########################################################
+# first create a commit, so we have a valid object/type
+# for the tag.
+echo Hello >A
+git-update-index --add A
+git-commit -m "Initial commit"
+head=$(git-rev-parse --verify HEAD)
+
+############################################################
+# 1. length check
+
+cat >tag.sig <<EOF
+too short for a tag
+EOF
+
+cat >expect.pat <<EOF
+^error: .*size wrong.*$
+EOF
+
+check_verify_failure 'Tag object length check'
+
+############################################################
+# 2. object line label check
+
+cat >tag.sig <<EOF
+xxxxxx 139e9b33986b1c2670fff52c5067603117b3e895
+type tag
+tag mytag
+EOF
+
+cat >expect.pat <<EOF
+^error: char0: .*"object "$
+EOF
+
+check_verify_failure '"object" line label check'
+
+############################################################
+# 3. object line SHA1 check
+
+cat >tag.sig <<EOF
+object zz9e9b33986b1c2670fff52c5067603117b3e895
+type tag
+tag mytag
+EOF
+
+cat >expect.pat <<EOF
+^error: char7: .*SHA1 hash$
+EOF
+
+check_verify_failure '"object" line SHA1 check'
+
+############################################################
+# 4. type line label check
+
+cat >tag.sig <<EOF
+object 779e9b33986b1c2670fff52c5067603117b3e895
+xxxx tag
+tag mytag
+EOF
+
+cat >expect.pat <<EOF
+^error: char47: .*"[\]ntype "$
+EOF
+
+check_verify_failure '"type" line label check'
+
+############################################################
+# 5. type line eol check
+
+echo "object 779e9b33986b1c2670fff52c5067603117b3e895" >tag.sig
+echo -n "type tagsssssssssssssssssssssssssssssss" >>tag.sig
+
+cat >expect.pat <<EOF
+^error: char48: .*"[\]n"$
+EOF
+
+check_verify_failure '"type" line eol check'
+
+############################################################
+# 6. tag line label check #1
+
+cat >tag.sig <<EOF
+object 779e9b33986b1c2670fff52c5067603117b3e895
+type tag
+xxx mytag
+EOF
+
+cat >expect.pat <<EOF
+^error: char57: no "tag " found$
+EOF
+
+check_verify_failure '"tag" line label check #1'
+
+############################################################
+# 7. tag line label check #2
+
+cat >tag.sig <<EOF
+object 779e9b33986b1c2670fff52c5067603117b3e895
+type taggggggggggggggggggggggggggggggg
+tag
+EOF
+
+cat >expect.pat <<EOF
+^error: char87: no "tag " found$
+EOF
+
+check_verify_failure '"tag" line label check #2'
+
+############################################################
+# 8. type line type-name length check
+
+cat >tag.sig <<EOF
+object 779e9b33986b1c2670fff52c5067603117b3e895
+type taggggggggggggggggggggggggggggggg
+tag mytag
+EOF
+
+cat >expect.pat <<EOF
+^error: char53: type too long$
+EOF
+
+check_verify_failure '"type" line type-name length check'
+
+############################################################
+# 9. verify object (SHA1/type) check
+
+cat >tag.sig <<EOF
+object 779e9b33986b1c2670fff52c5067603117b3e895
+type tagggg
+tag mytag
+EOF
+
+cat >expect.pat <<EOF
+^error: char7: could not verify object.*$
+EOF
+
+check_verify_failure 'verify object (SHA1/type) check'
+
+############################################################
+# 10. verify tag-name check
+
+cat >tag.sig <<EOF
+object $head
+type commit
+tag my tag
+EOF
+
+cat >expect.pat <<EOF
+^error: char67: could not verify tag name$
+EOF
+
+check_verify_failure 'verify tag-name check'
+
+############################################################
+# 11. tagger line lable check #1
+
+cat >tag.sig <<EOF
+object $head
+type commit
+tag mytag
+EOF
+
+cat >expect.pat <<EOF
+^error: char70: could not find "tagger"$
+EOF
+
+check_verify_failure '"tagger" line label check #1'
+
+############################################################
+# 12. tagger line lable check #2
+
+cat >tag.sig <<EOF
+object $head
+type commit
+tag mytag
+tagger
+EOF
+
+cat >expect.pat <<EOF
+^error: char70: could not find "tagger"$
+EOF
+
+check_verify_failure '"tagger" line label check #2'
+
+############################################################
+# 13. create valid tag
+
+cat >tag.sig <<EOF
+object $head
+type commit
+tag mytag
+tagger another@example.com
+EOF
+
+test_expect_success \
+ 'create valid tag' \
+ 'git-mktag <tag.sig >.git/refs/tags/mytag 2>message'
+
+############################################################
+# 14. check mytag
+
+test_expect_success \
+ 'check mytag' \
+ 'git-tag -l | grep mytag'
+
+
+test_done
diff --git a/t/t9100-git-svn-basic.sh b/t/t9100-git-svn-basic.sh
index bf1d6381d9..34a3ccd31c 100755
--- a/t/t9100-git-svn-basic.sh
+++ b/t/t9100-git-svn-basic.sh
@@ -170,7 +170,7 @@ then
test -L $SVN_TREE/exec-2.sh"
name='modify a symlink to become a file'
- git help > help || true
+ echo git help > help || true
rm exec-2.sh
cp help exec-2.sh
git update-index exec-2.sh
@@ -217,10 +217,10 @@ name='check imported tree checksums expected tree checksums'
rm -f expected
if test "$have_utf8" = t
then
- echo tree f735671b89a7eb30cab1d8597de35bd4271ab813 > expected
+ echo tree bf522353586b1b883488f2bc73dab0d9f774b9a9 > expected
fi
cat >> expected <<\EOF
-tree 4b9af72bb861eaed053854ec502cf7df72618f0f
+tree 83654bb36f019ae4fe77a0171f81075972087624
tree 031b8d557afc6fea52894eaebb45bec52f1ba6d1
tree 0b094cbff17168f24c302e297f55bfac65eb8bd3
tree d667270a1f7b109f5eb3aaea21ede14b56bfdd6e
@@ -231,4 +231,3 @@ EOF
test_expect_success "$name" "diff -u a expected"
test_done
-
diff --git a/templates/Makefile b/templates/Makefile
index 8f7f4fec34..9e1ae1a4e0 100644
--- a/templates/Makefile
+++ b/templates/Makefile
@@ -6,11 +6,9 @@ prefix ?= $(HOME)
template_dir ?= $(prefix)/share/git-core/templates/
# DESTDIR=
-# Shell quote;
-# Result of this needs to be placed inside ''
-shq = $(subst ','\'',$(1))
-# This has surrounding ''
-shellquote = '$(call shq,$(1))'
+# Shell quote (do not use $(call) to accomodate ancient setups);
+DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
+template_dir_SQ = $(subst ','\'',$(template_dir))
all: boilerplates.made custom
@@ -43,6 +41,6 @@ clean:
rm -rf blt boilerplates.made
install: all
- $(INSTALL) -d -m755 $(call shellquote,$(DESTDIR)$(template_dir))
+ $(INSTALL) -d -m755 '$(DESTDIR_SQ)$(template_dir_SQ)'
(cd blt && $(TAR) cf - .) | \
- (cd $(call shellquote,$(DESTDIR)$(template_dir)) && $(TAR) xf -)
+ (cd '$(DESTDIR_SQ)$(template_dir_SQ)' && $(TAR) xf -)