Merge branch 'mw/sendemail'
authorShawn O. Pearce <spearce@spearce.org>
Thu, 9 Oct 2008 17:19:51 +0000 (10:19 -0700)
committerShawn O. Pearce <spearce@spearce.org>
Thu, 9 Oct 2008 17:19:51 +0000 (10:19 -0700)
* mw/sendemail:
bash completion: Add --[no-]validate to "git send-email"
send-email: signedoffcc -> signedoffbycc, but handle both
Docs: send-email: Create logical groupings for man text
Docs: send-email: Create logical groupings for --help text
Docs: send-email: Remove unnecessary config variable description
Docs: send-email: --chain_reply_to -> --[no-]chain-reply-to
send-email: change --no-validate to boolean --[no-]validate
Docs: send-email: Man page option ordering
Docs: send-email usage text much sexier
Docs: send-email's usage text and man page mention same options

71 files changed:
Documentation/RelNotes-1.6.0.3.txt
Documentation/git-grep.txt
Documentation/git-prune.txt
Documentation/git-push.txt
Documentation/githooks.txt
Documentation/technical/api-run-command.txt
Makefile
archive.c
arm/sha1.c
arm/sha1.h
arm/sha1_arm.S
builtin-apply.c
builtin-blame.c
builtin-checkout.c
builtin-fmt-merge-msg.c
builtin-grep.c
builtin-init-db.c
builtin-merge-base.c
builtin-merge-file.c
builtin-merge.c
builtin-pack-objects.c
builtin-prune.c
builtin-push.c
builtin-reset.c
builtin-rm.c
builtin-unpack-objects.c
cache.h
commit.c
commit.h
config.c
contrib/completion/git-completion.bash
csum-file.c
csum-file.h
diff.c
dir.c
dir.h
fast-import.c
git-rebase--interactive.sh
git-rebase.sh
git-stash.sh
gitweb/gitweb.perl
grep.c
grep.h
http-push.c
http-walker.c
index-pack.c
merge-tree.c
mozilla-sha1/sha1.c
mozilla-sha1/sha1.h
pack-check.c
pack-write.c
patch-id.c
ppc/sha1.c
ppc/sha1.h
ppc/sha1ppc.S
read-cache.c
remote.c
rerere.c
run-command.c
run-command.h
setup.c
sha1_file.c
t/t0001-init.sh
t/t3409-rebase-hook.sh [new file with mode: 0755]
t/t3600-rm.sh
t/t4012-diff-binary.sh
t/t7403-submodule-sync.sh [new file with mode: 0755]
t/t7600-merge.sh
t/t9500-gitweb-standalone-no-errors.sh
test-sha1.c
transport.c
index 46e13a450afae63226a89543369fc6396436a042..6cf8ae4ea1423d3dce3522890a666a424d163fb7 100644 (file)
@@ -13,33 +13,83 @@ Fixes since v1.6.0.2
 * Continuing "git rebase -i" was also very confused when the user left
   some staged changes in the index after "edit".
 
+* "git rebase -i" now honors the pre-rebase hook, just like the
+  other rebase implementations "git rebase" and "git rebase -m".
+
 * Behaviour of "git diff --quiet" was inconsistent with "diff --exit-code"
   with the output redirected to /dev/null.
 
+* "git diff --no-index" on binary files no longer outputs a bogus
+  "diff --git" header line.
+
+* Hunk headers in "git diff" default to using extended regular
+  expressions, fixing some of the internal patterns on non-GNU
+  platforms.
+
+* New config "diff.*.xfuncname" exposes extended regular expressions
+  for user specified hunk header patterns.
+
 * "git stash apply sash@{1}" was fixed to error out.  Prior versions
   would have applied stash@{0} incorrectly.
 
+* "git stash apply" now offers a better suggestion on how to continue
+  if the working tree is currently dirty.
+
 * "git for-each-ref --format=%(subject)" fixed for commits with no
   no newline in the message body.
 
 * "git remote" fixed to protect printf from user input.
 
+* "git remote show -v" now displays all URLs of a remote.
+
 * "git checkout -q" once again suppresses the locally modified file list.
 
+* "git clone -q", "git fetch -q" asks remote side to not send
+  progress messages, actually making their output quiet.
+
 * Cross-directory renames are no longer used when creating packs.  This
   allows more graceful behavior on filesystems like sshfs.
 
 * Stale temporary files under $GIT_DIR/objects/pack are now cleaned up
   automatically by "git prune".
 
+* "git merge" once again removes directories after the last file has
+  been removed from it during the merge.
+
+* "git blame -C -C" no longer segfaults while trying to pass blame if
+   it encounters a submodule reference.
+
+* "git svn" fixed to display an error message when 'set-tree' failed,
+   instead of a Perl compile error.
+
+* "git submodule" fixed to handle checking out a different commit
+  than HEAD after initializing the submodule.
+
+* The "git commit" error message when there are still unmerged
+  files present was clarified to match "git write-tree".
+
+* Some segfaults due to uncaught NULL pointers were fixed in multiple
+  tools such as apply, reset, update-index.
+
+* Solaris builds now default to OLD_ICONV=1 to avoid compile warnings.
+
 * "Git.pm" tests relied on unnecessarily more recent version of Perl.
 
 * "gitweb" triggered undef warning on commits without log messages.
 
+* "gitweb" triggered undef warnings on missing trees.
+
+* "gitweb" now removes PATH_INFO from its URLs so users don't have
+  to manually set the URL in the gitweb configuration.
+
+* Bash completion removed support for legacy "git-fetch", "git-push"
+  and "git-pull" as these are no longer installed.  Dashless form
+  ("git fetch") is still however supported.
+
 Many other documentation updates.
 
 --
 exec >/var/tmp/1
-O=v1.6.0.2-41-g7fe4a72
+O=v1.6.0.2-76-gd70b4a8
 echo O=$(git describe maint)
 git shortlog --no-merges $O..maint
index fa4d133c1bccc088d3c8da65bce4e15cafd394aa..553da6cbb1777a94cb3d6b48dc77c445e18ca2b0 100644 (file)
@@ -15,6 +15,7 @@ SYNOPSIS
           [-E | --extended-regexp] [-G | --basic-regexp]
           [-F | --fixed-strings] [-n]
           [-l | --files-with-matches] [-L | --files-without-match]
+          [-z | --null]
           [-c | --count] [--all-match]
           [-A <post-context>] [-B <pre-context>] [-C <context>]
           [-f <file>] [-e] <pattern>
@@ -94,6 +95,11 @@ OPTIONS
        For better compatibility with 'git-diff', --name-only is a
        synonym for --files-with-matches.
 
+-z::
+--null::
+       Output \0 instead of the character that normally follows a
+       file name.
+
 -c::
 --count::
        Instead of showing every matched line, show the number of
index 54f1dab38de9e01d8452753ac6028875b91d5f6b..da6055d4b8cf78aff16fa553e684b0b3ed57138e 100644 (file)
@@ -8,7 +8,7 @@ git-prune - Prune all unreachable objects from the object database
 
 SYNOPSIS
 --------
-'git-prune' [-n] [--expire <expire>] [--] [<head>...]
+'git-prune' [-n] [-v] [--expire <expire>] [--] [<head>...]
 
 DESCRIPTION
 -----------
@@ -34,6 +34,9 @@ OPTIONS
        Do not remove anything; just report what it would
        remove.
 
+-v::
+       Report all removed objects.
+
 \--::
        Do not interpret any more arguments as options.
 
index 45c96435fa66ab4b1b57b6a860a2fc264321cfe4..6150b1b959e17655a2875d39ec3b70449684a0eb 100644 (file)
@@ -9,8 +9,8 @@ git-push - Update remote refs along with associated objects
 SYNOPSIS
 --------
 [verse]
-'git push' [--all] [--dry-run] [--tags] [--receive-pack=<git-receive-pack>]
-          [--repo=all] [-f | --force] [-v | --verbose]
+'git push' [--all | --mirror] [--dry-run] [--tags] [--receive-pack=<git-receive-pack>]
+          [--repo=<repository>] [-f | --force] [-v | --verbose]
           [<repository> <refspec>...]
 
 DESCRIPTION
@@ -101,9 +101,23 @@ nor in any Push line of the corresponding remotes file---see below).
        This flag disables the check.  This can cause the
        remote repository to lose commits; use it with care.
 
---repo=<repo>::
-       When no repository is specified the command defaults to
-       "origin"; this overrides it.
+--repo=<repository>::
+       This option is only relevant if no <repository> argument is
+       passed in the invocation. In this case, 'git-push' derives the
+       remote name from the current branch: If it tracks a remote
+       branch, then that remote repository is pushed to. Otherwise,
+       the name "origin" is used. For this latter case, this option
+       can be used to override the name "origin". In other words,
+       the difference between these two commands
++
+--------------------------
+git push public         #1
+git push --repo=public  #2
+--------------------------
++
+is that #1 always pushes to "public" whereas #2 pushes to "public"
+only if the current branch does not track a remote branch. This is
+useful if you write an alias or script around 'git-push'.
 
 --thin::
 --no-thin::
index 7fefdb1f453720381b4038f773d8686dd41d7b0c..5faaaa5fedcd0d61234d3927a89d77144f2a15ad 100644 (file)
@@ -130,6 +130,13 @@ parameter, and is invoked after a commit is made.
 This hook is meant primarily for notification, and cannot affect
 the outcome of 'git-commit'.
 
+pre-rebase
+----------
+
+This hook is called by 'git-rebase' and can be used to prevent a branch
+from getting rebased.
+
+
 post-checkout
 -----------
 
index 75aa5d49234ec36857a7c8d2f3900001af5cbcde..82e9e831b6a97dfaa62c02d30447415ef65e4fa3 100644 (file)
@@ -30,7 +30,7 @@ Functions
        start_command() followed by finish_command(). Takes a pointer
        to a `struct child_process` that specifies the details.
 
-`run_command_v_opt`, `run_command_v_opt_cd`, `run_command_v_opt_cd_env`::
+`run_command_v_opt`, `run_command_v_opt_cd_env`::
 
        Convenience functions that encapsulate a sequence of
        start_command() followed by finish_command(). The argument argv
index e0c03c3eecc26d995f8829429092e887df17489f..dd31e339fb8d28baaaba78ea09518de0171d35a5 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -648,8 +648,8 @@ ifeq ($(uname_S),SunOS)
        NO_MEMMEM = YesPlease
        NO_HSTRERROR = YesPlease
        NO_MKDTEMP = YesPlease
+       OLD_ICONV = UnfortunatelyYes
        ifeq ($(uname_R),5.8)
-               NEEDS_LIBICONV = YesPlease
                NO_UNSETENV = YesPlease
                NO_SETENV = YesPlease
                NO_C99_FORMAT = YesPlease
index e2280df56723809c5af1d566f0721e2639fff10c..44ab008039854b7c585adf53bee195b81f4e18c7 100644 (file)
--- a/archive.c
+++ b/archive.c
@@ -15,7 +15,7 @@ static char const * const archive_usage[] = {
 
 #define USES_ZLIB_COMPRESSION 1
 
-const struct archiver {
+static const struct archiver {
        const char *name;
        write_archive_fn_t write_archive;
        unsigned int flags;
index 9e3ae038e818f4e21bc50f864fc5204f6fa44daa..c61ad4aff97eed5f2f332f881a99e06f47b11128 100644 (file)
@@ -8,9 +8,9 @@
 #include <string.h>
 #include "sha1.h"
 
-extern void sha_transform(uint32_t *hash, const unsigned char *data, uint32_t *W);
+extern void arm_sha_transform(uint32_t *hash, const unsigned char *data, uint32_t *W);
 
-void SHA1_Init(SHA_CTX *c)
+void arm_SHA1_Init(arm_SHA_CTX *c)
 {
        c->len = 0;
        c->hash[0] = 0x67452301;
@@ -20,7 +20,7 @@ void SHA1_Init(SHA_CTX *c)
        c->hash[4] = 0xc3d2e1f0;
 }
 
-void SHA1_Update(SHA_CTX *c, const void *p, unsigned long n)
+void arm_SHA1_Update(arm_SHA_CTX *c, const void *p, unsigned long n)
 {
        uint32_t workspace[80];
        unsigned int partial;
@@ -32,12 +32,12 @@ void SHA1_Update(SHA_CTX *c, const void *p, unsigned long n)
                if (partial) {
                        done = 64 - partial;
                        memcpy(c->buffer + partial, p, done);
-                       sha_transform(c->hash, c->buffer, workspace);
+                       arm_sha_transform(c->hash, c->buffer, workspace);
                        partial = 0;
                } else
                        done = 0;
                while (n >= done + 64) {
-                       sha_transform(c->hash, p + done, workspace);
+                       arm_sha_transform(c->hash, p + done, workspace);
                        done += 64;
                }
        } else
@@ -46,7 +46,7 @@ void SHA1_Update(SHA_CTX *c, const void *p, unsigned long n)
                memcpy(c->buffer + partial, p + done, n - done);
 }
 
-void SHA1_Final(unsigned char *hash, SHA_CTX *c)
+void arm_SHA1_Final(unsigned char *hash, arm_SHA_CTX *c)
 {
        uint64_t bitlen;
        uint32_t bitlen_hi, bitlen_lo;
@@ -57,7 +57,7 @@ void SHA1_Final(unsigned char *hash, SHA_CTX *c)
        bitlen = c->len << 3;
        offset = c->len & 0x3f;
        padlen = ((offset < 56) ? 56 : (64 + 56)) - offset;
-       SHA1_Update(c, padding, padlen);
+       arm_SHA1_Update(c, padding, padlen);
 
        bitlen_hi = bitlen >> 32;
        bitlen_lo = bitlen & 0xffffffff;
@@ -69,7 +69,7 @@ void SHA1_Final(unsigned char *hash, SHA_CTX *c)
        bits[5] = bitlen_lo >> 16;
        bits[6] = bitlen_lo >> 8;
        bits[7] = bitlen_lo;
-       SHA1_Update(c, bits, 8);
+       arm_SHA1_Update(c, bits, 8);
 
        for (i = 0; i < 5; i++) {
                uint32_t v = c->hash[i];
index 3952646349cf9d033177e69ba9433652a378c0e9..b61b618486f9776170efaa0f76dda728b19a164f 100644 (file)
@@ -7,12 +7,17 @@
 
 #include <stdint.h>
 
-typedef struct sha_context {
+typedef struct {
        uint64_t len;
        uint32_t hash[5];
        unsigned char buffer[64];
-} SHA_CTX;
+} arm_SHA_CTX;
 
-void SHA1_Init(SHA_CTX *c);
-void SHA1_Update(SHA_CTX *c, const void *p, unsigned long n);
-void SHA1_Final(unsigned char *hash, SHA_CTX *c);
+void arm_SHA1_Init(arm_SHA_CTX *c);
+void arm_SHA1_Update(arm_SHA_CTX *c, const void *p, unsigned long n);
+void arm_SHA1_Final(unsigned char *hash, arm_SHA_CTX *c);
+
+#define git_SHA_CTX    arm_SHA_CTX
+#define git_SHA1_Init  arm_SHA1_Init
+#define git_SHA1_Update        arm_SHA1_Update
+#define git_SHA1_Final arm_SHA1_Final
index 8c1cb99fb403875af85e4d1524d21f7eb818f59b..41e92636e0ff98ac620de75d66917999d55aca9e 100644 (file)
@@ -10,7 +10,7 @@
  */
 
        .text
-       .globl  sha_transform
+       .globl  arm_sha_transform
 
 /*
  * void sha_transform(uint32_t *hash, const unsigned char *data, uint32_t *W);
@@ -18,7 +18,7 @@
  * note: the "data" pointer may be unaligned.
  */
 
-sha_transform:
+arm_sha_transform:
 
        stmfd   sp!, {r4 - r8, lr}
 
index e2c611bf964d8cd589171f74e5ccce5aeb392643..bf806105062caa47ca168720e0e987ac8957c8af 100644 (file)
@@ -1697,7 +1697,7 @@ static int match_fragment(struct image *img,
                fixlen = ws_fix_copy(buf, orig, oldlen, ws_rule, NULL);
 
                /* Try fixing the line in the target */
-               if (sizeof(tgtfixbuf) < tgtlen)
+               if (sizeof(tgtfixbuf) > tgtlen)
                        tgtfix = tgtfixbuf;
                else
                        tgtfix = xmalloc(tgtlen);
@@ -2586,6 +2586,8 @@ static void build_fake_ancestor(struct patch *list, const char *filename)
                        sha1_ptr = sha1;
 
                ce = make_cache_entry(patch->old_mode, sha1_ptr, name, 0, 0);
+               if (!ce)
+                       die("make_cache_entry failed for path '%s'", name);
                if (add_index_entry(&result, ce, ADD_CACHE_OK_TO_ADD))
                        die ("Could not add %s to temporary index", name);
        }
index 6b7b9f4466989ca02d3a5e53caac9ff5c7e8a922..df537593d052f0b4d705eb1d0d19ed296f76a39d 100644 (file)
@@ -1132,6 +1132,8 @@ static int find_copy_in_parent(struct scoreboard *sb,
 
                        if (!DIFF_FILE_VALID(p->one))
                                continue; /* does not exist in parent */
+                       if (S_ISGITLINK(p->one->mode))
+                               continue; /* ignore git links */
                        if (porigin && !strcmp(p->one->path, porigin->path))
                                /* find_move already dealt with this path */
                                continue;
index b572b3bf69c791912717eae313942316cd77ac37..3762f71aaeae623b37d38c5c03b7a0d10973efc4 100644 (file)
@@ -206,6 +206,8 @@ static int checkout_merged(int pos, struct checkout *state)
        ce = make_cache_entry(create_ce_mode(active_cache[pos+1]->ce_mode),
                              sha1,
                              path, 2, 0);
+       if (!ce)
+               die("make_cache_entry failed for path '%s'", path);
        status = checkout_entry(ce, state, NULL);
        return status;
 }
index df02ba7afdd615492361a1897a9dedd6ab233c96..c6324dc795bfd778470fbbe7b0720ce9ff83a34e 100644 (file)
@@ -5,8 +5,10 @@
 #include "revision.h"
 #include "tag.h"
 
-static const char *fmt_merge_msg_usage =
-       "git fmt-merge-msg [--log] [--no-log] [--file <file>]";
+static const char * const fmt_merge_msg_usage[] = {
+       "git fmt-merge-msg [--log|--no-log] [--file <file>]",
+       NULL
+};
 
 static int merge_summary;
 
@@ -347,38 +349,29 @@ int fmt_merge_msg(int merge_summary, struct strbuf *in, struct strbuf *out) {
 
 int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix)
 {
+       const char *inpath = NULL;
+       struct option options[] = {
+               OPT_BOOLEAN(0, "log",     &merge_summary, "populate log with the shortlog"),
+               OPT_BOOLEAN(0, "summary", &merge_summary, "alias for --log"),
+               OPT_STRING('F', "file",   &inpath, "file", "file to read from"),
+               OPT_END()
+       };
+
        FILE *in = stdin;
        struct strbuf input, output;
        int ret;
 
        git_config(fmt_merge_msg_config, NULL);
-
-       while (argc > 1) {
-               if (!strcmp(argv[1], "--log") || !strcmp(argv[1], "--summary"))
-                       merge_summary = 1;
-               else if (!strcmp(argv[1], "--no-log")
-                               || !strcmp(argv[1], "--no-summary"))
-                       merge_summary = 0;
-               else if (!strcmp(argv[1], "-F") || !strcmp(argv[1], "--file")) {
-                       if (argc < 3)
-                               die ("Which file?");
-                       if (!strcmp(argv[2], "-"))
-                               in = stdin;
-                       else {
-                               fclose(in);
-                               in = fopen(argv[2], "r");
-                               if (!in)
-                                       die("cannot open %s", argv[2]);
-                       }
-                       argc--; argv++;
-               } else
-                       break;
-               argc--; argv++;
+       argc = parse_options(argc, argv, options, fmt_merge_msg_usage, 0);
+       if (argc > 0)
+               usage_with_options(fmt_merge_msg_usage, options);
+
+       if (inpath && strcmp(inpath, "-")) {
+               in = fopen(inpath, "r");
+               if (!in)
+                       die("cannot open %s", inpath);
        }
 
-       if (argc > 1)
-               usage(fmt_merge_msg_usage);
-
        strbuf_init(&input, 0);
        if (strbuf_read(&input, fileno(in), 0) < 0)
                die("could not read input file %s", strerror(errno));
@@ -387,6 +380,6 @@ int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix)
        ret = fmt_merge_msg(merge_summary, &input, &output);
        if (ret)
                return ret;
-       printf("%s", output.buf);
+       write_in_full(STDOUT_FILENO, output.buf, output.len);
        return 0;
 }
index 3a51662a35878ae6b5965c90abb747b5b27c5493..624f86e287cf6304d122850f8258444c5f916702 100644 (file)
@@ -295,6 +295,9 @@ static int external_grep(struct grep_opt *opt, const char **paths, int cached)
                push_arg("-l");
        if (opt->unmatch_name_only)
                push_arg("-L");
+       if (opt->null_following_name)
+               /* in GNU grep git's "-z" translates to "-Z" */
+               push_arg("-Z");
        if (opt->count)
                push_arg("-c");
        if (opt->post_context || opt->pre_context) {
@@ -599,6 +602,11 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
                        opt.unmatch_name_only = 1;
                        continue;
                }
+               if (!strcmp("-z", arg) ||
+                   !strcmp("--null", arg)) {
+                       opt.null_following_name = 1;
+                       continue;
+               }
                if (!strcmp("-c", arg) ||
                    !strcmp("--count", arg)) {
                        opt.count = 1;
index 8140c1299afe368266de1153f3bb891f000fe5f5..d30c3fe2ca542b061ab8b7a7696cdd5416e17147 100644 (file)
@@ -17,6 +17,9 @@
 #define TEST_FILEMODE 1
 #endif
 
+static int init_is_bare_repository = 0;
+static int init_shared_repository = -1;
+
 static void safe_create_dir(const char *dir, int share)
 {
        if (mkdir(dir, 0777) < 0) {
@@ -191,6 +194,9 @@ static int create_default_files(const char *template_path)
        copy_templates(template_path);
 
        git_config(git_default_config, NULL);
+       is_bare_repository_cfg = init_is_bare_repository;
+       if (init_shared_repository != -1)
+               shared_repository = init_shared_repository;
 
        /*
         * We would have created the above under user's umask -- under
@@ -277,6 +283,8 @@ int init_db(const char *template_dir, unsigned int flags)
 
        safe_create_dir(get_git_dir(), 0);
 
+       init_is_bare_repository = is_bare_repository();
+
        /* Check to see if the repository version is right.
         * Note that a newly created repository does not have
         * config file, so this will not fail.  What we are catching
@@ -381,9 +389,9 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
                        setenv(GIT_DIR_ENVIRONMENT, getcwd(git_dir,
                                                sizeof(git_dir)), 0);
                } else if (!strcmp(arg, "--shared"))
-                       shared_repository = PERM_GROUP;
+                       init_shared_repository = PERM_GROUP;
                else if (!prefixcmp(arg, "--shared="))
-                       shared_repository = git_config_perm("arg", arg+9);
+                       init_shared_repository = git_config_perm("arg", arg+9);
                else if (!strcmp(arg, "-q") || !strcmp(arg, "--quiet"))
                        flags |= INIT_DB_QUIET;
                else
index b08da516e491e7089b1bb178e9a4b05c2ab36539..03fc1c211453f1ed09ee2c6b71d438b0bfbf474f 100644 (file)
@@ -1,6 +1,7 @@
 #include "builtin.h"
 #include "cache.h"
 #include "commit.h"
+#include "parse-options.h"
 
 static int show_merge_base(struct commit **rev, int rev_nr, int show_all)
 {
@@ -21,8 +22,10 @@ static int show_merge_base(struct commit **rev, int rev_nr, int show_all)
        return 0;
 }
 
-static const char merge_base_usage[] =
-"git merge-base [--all] <commit-id> <commit-id>...";
+static const char * const merge_base_usage[] = {
+       "git merge-base [--all] <commit-id> <commit-id>...",
+       NULL
+};
 
 static struct commit *get_commit_reference(const char *arg)
 {
@@ -44,25 +47,17 @@ int cmd_merge_base(int argc, const char **argv, const char *prefix)
        int rev_nr = 0;
        int show_all = 0;
 
-       git_config(git_default_config, NULL);
-
-       while (1 < argc && argv[1][0] == '-') {
-               const char *arg = argv[1];
-               if (!strcmp(arg, "-a") || !strcmp(arg, "--all"))
-                       show_all = 1;
-               else
-                       usage(merge_base_usage);
-               argc--; argv++;
-       }
-       if (argc < 3)
-               usage(merge_base_usage);
-
-       rev = xmalloc((argc - 1) * sizeof(*rev));
-
-       do {
-               rev[rev_nr++] = get_commit_reference(argv[1]);
-               argc--; argv++;
-       } while (argc > 1);
+       struct option options[] = {
+               OPT_BOOLEAN('a', "all", &show_all, "outputs all common ancestors"),
+               OPT_END()
+       };
 
+       git_config(git_default_config, NULL);
+       argc = parse_options(argc, argv, options, merge_base_usage, 0);
+       if (argc < 2)
+               usage_with_options(merge_base_usage, options);
+       rev = xmalloc(argc * sizeof(*rev));
+       while (argc-- > 0)
+               rev[rev_nr++] = get_commit_reference(*argv++);
        return show_merge_base(rev, rev_nr, show_all);
 }
index 45c98538cdbf35352f7a3b5adf40fca9d7512ea5..9d4e874809f495ad685a7218584041fa001696e5 100644 (file)
@@ -2,21 +2,44 @@
 #include "cache.h"
 #include "xdiff/xdiff.h"
 #include "xdiff-interface.h"
+#include "parse-options.h"
 
-static const char merge_file_usage[] =
-"git merge-file [-p | --stdout] [--diff3] [-q | --quiet] [-L name1 [-L orig [-L name2]]] file1 orig_file file2";
+static const char *const merge_file_usage[] = {
+       "git merge-file [options] [-L name1 [-L orig [-L name2]]] file1 orig_file file2",
+       NULL
+};
+
+static int label_cb(const struct option *opt, const char *arg, int unset)
+{
+       static int label_count = 0;
+       const char **names = (const char **)opt->value;
+
+       if (label_count >= 3)
+               return error("too many labels on the command line");
+       names[label_count++] = arg;
+       return 0;
+}
 
 int cmd_merge_file(int argc, const char **argv, const char *prefix)
 {
-       const char *names[3];
+       const char *names[3] = { NULL, NULL, NULL };
        mmfile_t mmfs[3];
        mmbuffer_t result = {NULL, 0};
        xpparam_t xpp = {XDF_NEED_MINIMAL};
        int ret = 0, i = 0, to_stdout = 0;
        int merge_level = XDL_MERGE_ZEALOUS_ALNUM;
-       int merge_style = 0;
+       int merge_style = 0, quiet = 0;
        int nongit;
 
+       struct option options[] = {
+               OPT_BOOLEAN('p', "stdout", &to_stdout, "send results to standard output"),
+               OPT_SET_INT(0, "diff3", &merge_style, "use a diff3 based merge", XDL_MERGE_DIFF3),
+               OPT__QUIET(&quiet),
+               OPT_CALLBACK('L', NULL, names, "name",
+                            "set labels for file1/orig_file/file2", &label_cb),
+               OPT_END(),
+       };
+
        prefix = setup_git_directory_gently(&nongit);
        if (!nongit) {
                /* Read the configuration file */
@@ -25,37 +48,20 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)
                        merge_style = git_xmerge_style;
        }
 
-       while (argc > 4) {
-               if (!strcmp(argv[1], "-L") && i < 3) {
-                       names[i++] = argv[2];
-                       argc--;
-                       argv++;
-               } else if (!strcmp(argv[1], "-p") ||
-                               !strcmp(argv[1], "--stdout"))
-                       to_stdout = 1;
-               else if (!strcmp(argv[1], "-q") ||
-                               !strcmp(argv[1], "--quiet"))
-                       freopen("/dev/null", "w", stderr);
-               else if (!strcmp(argv[1], "--diff3"))
-                       merge_style = XDL_MERGE_DIFF3;
-               else
-                       usage(merge_file_usage);
-               argc--;
-               argv++;
-       }
-
-       if (argc != 4)
-               usage(merge_file_usage);
-
-       for (; i < 3; i++)
-               names[i] = argv[i + 1];
+       argc = parse_options(argc, argv, options, merge_file_usage, 0);
+       if (argc != 3)
+               usage_with_options(merge_file_usage, options);
+       if (quiet)
+               freopen("/dev/null", "w", stderr);
 
        for (i = 0; i < 3; i++) {
-               if (read_mmfile(mmfs + i, argv[i + 1]))
+               if (!names[i])
+                       names[i] = argv[i];
+               if (read_mmfile(mmfs + i, argv[i]))
                        return -1;
                if (buffer_is_binary(mmfs[i].ptr, mmfs[i].size))
                        return error("Cannot merge binary files: %s\n",
-                                       argv[i + 1]);
+                                       argv[i]);
        }
 
        ret = xdl_merge(mmfs + 1, mmfs + 0, names[0], mmfs + 2, names[2],
@@ -65,7 +71,7 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)
                free(mmfs[i].ptr);
 
        if (ret >= 0) {
-               const char *filename = argv[1];
+               const char *filename = argv[0];
                FILE *f = to_stdout ? stdout : fopen(filename, "wb");
 
                if (!f)
index 5c65a5869900ad1a1014fb3aad88c874a5410bf7..38266baf5fe9f54a0006baaae205b55f12ed15fc 100644 (file)
@@ -123,8 +123,7 @@ static struct strategy *get_strategy(const char *name)
                exit(1);
        }
 
-       ret = xmalloc(sizeof(struct strategy));
-       memset(ret, 0, sizeof(struct strategy));
+       ret = xcalloc(1, sizeof(struct strategy));
        ret->name = xstrdup(name);
        return ret;
 }
@@ -547,6 +546,16 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,
        int i = 0, ret;
        struct commit_list *j;
        struct strbuf buf;
+       int index_fd;
+       struct lock_file *lock = xcalloc(1, sizeof(struct lock_file));
+
+       index_fd = hold_locked_index(lock, 1);
+       refresh_cache(REFRESH_QUIET);
+       if (active_cache_changed &&
+                       (write_cache(index_fd, active_cache, active_nr) ||
+                        commit_locked_index(lock)))
+               return error("Unable to write index.");
+       rollback_lock_file(lock);
 
        if (!strcmp(strategy, "recursive") || !strcmp(strategy, "subtree")) {
                int clean;
@@ -723,12 +732,12 @@ static void add_strategies(const char *string, unsigned attr)
 static int merge_trivial(void)
 {
        unsigned char result_tree[20], result_commit[20];
-       struct commit_list *parent = xmalloc(sizeof(struct commit_list *));
+       struct commit_list *parent = xmalloc(sizeof(*parent));
 
        write_tree_trivial(result_tree);
        printf("Wonderful.\n");
        parent->item = lookup_commit(head);
-       parent->next = xmalloc(sizeof(struct commit_list *));
+       parent->next = xmalloc(sizeof(*parent->next));
        parent->next->item = remoteheads->item;
        parent->next->next = NULL;
        commit_tree(merge_msg.buf, result_tree, parent, result_commit, NULL);
index 1158e42cba81e2bdb8640cd6c5a3835453d17e7f..59c30d1caa37416041177ff4aaf01b67f4e8add4 100644 (file)
@@ -1369,12 +1369,10 @@ static void find_deltas(struct object_entry **list, unsigned *list_size,
                        int window, int depth, unsigned *processed)
 {
        uint32_t i, idx = 0, count = 0;
-       unsigned int array_size = window * sizeof(struct unpacked);
        struct unpacked *array;
        unsigned long mem_usage = 0;
 
-       array = xmalloc(array_size);
-       memset(array, 0, array_size);
+       array = xcalloc(window, sizeof(struct unpacked));
 
        for (;;) {
                struct object_entry *entry = *list++;
index 1663f8bdb1e27713bab6cf7a16ca15cfcfc1abef..7b4ec80e62997fe70f53c92380cd4d66e80d62a0 100644 (file)
@@ -7,10 +7,11 @@
 #include "parse-options.h"
 
 static const char * const prune_usage[] = {
-       "git prune [-n] [--expire <time>] [--] [<head>...]",
+       "git prune [-n] [-v] [--expire <time>] [--] [<head>...]",
        NULL
 };
 static int show_only;
+static int verbose;
 static unsigned long expire;
 
 static int prune_tmp_object(const char *path, const char *filename)
@@ -39,11 +40,12 @@ static int prune_object(char *path, const char *filename, const unsigned char *s
                if (st.st_mtime > expire)
                        return 0;
        }
-       if (show_only) {
+       if (show_only || verbose) {
                enum object_type type = sha1_object_info(sha1, NULL);
                printf("%s %s\n", sha1_to_hex(sha1),
                       (type > 0) ? typename(type) : "unknown");
-       } else
+       }
+       if (!show_only)
                unlink(fullpath);
        return 0;
 }
@@ -135,6 +137,8 @@ int cmd_prune(int argc, const char **argv, const char *prefix)
        const struct option options[] = {
                OPT_BOOLEAN('n', NULL, &show_only,
                            "do not remove, show only"),
+               OPT_BOOLEAN('v', NULL, &verbose,
+                       "report pruned objects"),
                OPT_DATE(0, "expire", &expire,
                         "expire objects older than <time>"),
                OPT_END()
index cc6666f75e7db8a546d4a1589335589190e414fe..122fdcfbdc13a11388a091e5ec33d077648fab0a 100644 (file)
@@ -10,7 +10,7 @@
 #include "parse-options.h"
 
 static const char * const push_usage[] = {
-       "git push [--all | --mirror] [--dry-run] [--tags] [--receive-pack=<git-receive-pack>] [--repo=all] [-f | --force] [-v] [<repository> <refspec>...]",
+       "git push [--all | --mirror] [--dry-run] [--tags] [--receive-pack=<git-receive-pack>] [--repo=<repository>] [-f | --force] [-v] [<repository> <refspec>...]",
        NULL,
 };
 
index c24c21909194014b467c86fd3598796e7db576b3..16e6bb20f1af6a7a684a747b3c0cc26ceabe8ce7 100644 (file)
@@ -121,6 +121,9 @@ static void update_index_from_diff(struct diff_queue_struct *q,
                        struct cache_entry *ce;
                        ce = make_cache_entry(one->mode, one->sha1, one->path,
                                0, 0);
+                       if (!ce)
+                               die("make_cache_entry failed for path '%s'",
+                                   one->path);
                        add_cache_entry(ce, ADD_CACHE_OK_TO_ADD |
                                ADD_CACHE_OK_TO_REPLACE);
                } else
index 50ae6d54011fad89387f0d56ce7a4591d07874f3..e06640cf8d3418cbbe177b8fdcdccd19e0f3379f 100644 (file)
@@ -137,6 +137,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix)
 
        if (read_cache() < 0)
                die("index file corrupt");
+       refresh_cache(REFRESH_QUIET);
 
        pathspec = get_pathspec(prefix, argv);
        seen = NULL;
index 40b20f26e86acca2ee37b34519e84a1ce79689c3..9f4bdd3296d19b75211ca0f2434d227eafac44b6 100644 (file)
@@ -19,7 +19,7 @@ static const char unpack_usage[] = "git unpack-objects [-n] [-q] [-r] [--strict]
 static unsigned char buffer[4096];
 static unsigned int offset, len;
 static off_t consumed_bytes;
-static SHA_CTX ctx;
+static git_SHA_CTX ctx;
 
 /*
  * When running under --strict mode, objects whose reachability are
@@ -59,7 +59,7 @@ static void *fill(int min)
        if (min > sizeof(buffer))
                die("cannot fill %d bytes", min);
        if (offset) {
-               SHA1_Update(&ctx, buffer, offset);
+               git_SHA1_Update(&ctx, buffer, offset);
                memmove(buffer, buffer + offset, len);
                offset = 0;
        }
@@ -477,8 +477,7 @@ static void unpack_all(void)
 
        if (!quiet)
                progress = start_progress("Unpacking objects", nr_objects);
-       obj_list = xmalloc(nr_objects * sizeof(*obj_list));
-       memset(obj_list, 0, nr_objects * sizeof(*obj_list));
+       obj_list = xcalloc(nr_objects, sizeof(*obj_list));
        for (i = 0; i < nr_objects; i++) {
                unpack_one(i);
                display_progress(progress, i + 1);
@@ -539,10 +538,10 @@ int cmd_unpack_objects(int argc, const char **argv, const char *prefix)
                /* We don't take any non-flag arguments now.. Maybe some day */
                usage(unpack_usage);
        }
-       SHA1_Init(&ctx);
+       git_SHA1_Init(&ctx);
        unpack_all();
-       SHA1_Update(&ctx, buffer, offset);
-       SHA1_Final(sha1, &ctx);
+       git_SHA1_Update(&ctx, buffer, offset);
+       git_SHA1_Final(sha1, &ctx);
        if (strict)
                write_rest();
        if (hashcmp(fill(20), sha1))
diff --git a/cache.h b/cache.h
index 99af83a0479ef472078afcd288b1f6ba6283a2f0..9f4e5c0d459dcf73c86ef977469ba4885cc8f4c2 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -6,8 +6,14 @@
 #include "hash.h"
 
 #include SHA1_HEADER
-#include <zlib.h>
+#ifndef git_SHA_CTX
+#define git_SHA_CTX    SHA_CTX
+#define git_SHA1_Init  SHA1_Init
+#define git_SHA1_Update        SHA1_Update
+#define git_SHA1_Final SHA1_Final
+#endif
 
+#include <zlib.h>
 #if defined(NO_DEFLATE_BOUND) || ZLIB_VERNUM < 0x1200
 #define deflateBound(c,s)  ((s) + (((s) + 7) >> 3) + (((s) + 63) >> 6) + 11)
 #endif
@@ -749,7 +755,6 @@ typedef int (*config_fn_t)(const char *, const char *, void *);
 extern int git_default_config(const char *, const char *, void *);
 extern int git_config_from_file(config_fn_t fn, const char *, void *);
 extern int git_config(config_fn_t fn, void *);
-extern int git_parse_long(const char *, long *);
 extern int git_parse_ulong(const char *, unsigned long *);
 extern int git_config_int(const char *, const char *);
 extern unsigned long git_config_ulong(const char *, const char *);
index dc0c5bfdab7296bf7febb6f1b1aad64550838c15..c99db162a48e0a47e73e6bfc2ae5fd4b7c9dfa1a 100644 (file)
--- a/commit.c
+++ b/commit.c
@@ -160,7 +160,7 @@ struct commit_graft *read_graft_line(char *buf, int len)
        return graft;
 }
 
-int read_graft_file(const char *graft_file)
+static int read_graft_file(const char *graft_file)
 {
        FILE *fp = fopen(graft_file, "r");
        char buf[1024];
index de15f4d715ded4d8fd4f882b44fd9a320e7cdb2e..4c05864fb426d61a652f7df12c13315665972846 100644 (file)
--- a/commit.h
+++ b/commit.h
@@ -118,7 +118,6 @@ struct commit_graft {
 
 struct commit_graft *read_graft_line(char *buf, int len);
 int register_commit_graft(struct commit_graft *, int);
-int read_graft_file(const char *graft_file);
 struct commit_graft *lookup_commit_graft(const unsigned char *sha1);
 
 extern struct commit_list *get_merge_bases(struct commit *rev1, struct commit *rev2, int cleanup);
index 53f04a076a7275965090edd4ca2a34652c4f5679..18d305c890d3f4ba00962cfa4033ff9ed68cf95b 100644 (file)
--- a/config.c
+++ b/config.c
@@ -205,8 +205,27 @@ static int git_parse_file(config_fn_t fn, void *data)
        int baselen = 0;
        static char var[MAXNAME];
 
+       /* U+FEFF Byte Order Mark in UTF8 */
+       static const unsigned char *utf8_bom = (unsigned char *) "\xef\xbb\xbf";
+       const unsigned char *bomptr = utf8_bom;
+
        for (;;) {
                int c = get_next_char();
+               if (bomptr && *bomptr) {
+                       /* We are at the file beginning; skip UTF8-encoded BOM
+                        * if present. Sane editors won't put this in on their
+                        * own, but e.g. Windows Notepad will do it happily. */
+                       if ((unsigned char) c == *bomptr) {
+                               bomptr++;
+                               continue;
+                       } else {
+                               /* Do not tolerate partial BOM. */
+                               if (bomptr != utf8_bom)
+                                       break;
+                               /* No BOM at file beginning. Cool. */
+                               bomptr = NULL;
+                       }
+               }
                if (c == '\n') {
                        if (config_file_eof)
                                return 0;
@@ -255,7 +274,7 @@ static int parse_unit_factor(const char *end, unsigned long *val)
        return 0;
 }
 
-int git_parse_long(const char *value, long *ret)
+static int git_parse_long(const char *value, long *ret)
 {
        if (value && *value) {
                char *end;
@@ -291,7 +310,7 @@ static void die_bad_config(const char *name)
 
 int git_config_int(const char *name, const char *value)
 {
-       long ret;
+       long ret = 0;
        if (!git_parse_long(value, &ret))
                die_bad_config(name);
        return ret;
index 7284c3b5a8d34f126632a3c87fda93d5bf7240a5..d192927c20a1b4bca97a6bea91cc10b0b67bdd29 100755 (executable)
@@ -785,14 +785,9 @@ _git_fetch ()
 {
        local cur="${COMP_WORDS[COMP_CWORD]}"
 
-       case "${COMP_WORDS[0]},$COMP_CWORD" in
-       git-fetch*,1)
+       if [ "$COMP_CWORD" = 2 ]; then
                __gitcomp "$(__git_remotes)"
-               ;;
-       git,2)
-               __gitcomp "$(__git_remotes)"
-               ;;
-       *)
+       else
                case "$cur" in
                *:*)
                        local pfx=""
@@ -811,8 +806,7 @@ _git_fetch ()
                        __gitcomp "$(__git_refs2 "$remote")"
                        ;;
                esac
-               ;;
-       esac
+       fi
 }
 
 _git_format_patch ()
@@ -1049,36 +1043,25 @@ _git_pull ()
 {
        local cur="${COMP_WORDS[COMP_CWORD]}"
 
-       case "${COMP_WORDS[0]},$COMP_CWORD" in
-       git-pull*,1)
-               __gitcomp "$(__git_remotes)"
-               ;;
-       git,2)
+       if [ "$COMP_CWORD" = 2 ]; then
                __gitcomp "$(__git_remotes)"
-               ;;
-       *)
+       else
                local remote
                case "${COMP_WORDS[0]}" in
                git-pull)  remote="${COMP_WORDS[1]}" ;;
                git)       remote="${COMP_WORDS[2]}" ;;
                esac
                __gitcomp "$(__git_refs "$remote")"
-               ;;
-       esac
+       fi
 }
 
 _git_push ()
 {
        local cur="${COMP_WORDS[COMP_CWORD]}"
 
-       case "${COMP_WORDS[0]},$COMP_CWORD" in
-       git-push*,1)
-               __gitcomp "$(__git_remotes)"
-               ;;
-       git,2)
+       if [ "$COMP_CWORD" = 2 ]; then
                __gitcomp "$(__git_remotes)"
-               ;;
-       *)
+       else
                case "$cur" in
                *:*)
                        local remote
@@ -1102,8 +1085,7 @@ _git_push ()
                        __gitcomp "$(__git_refs)"
                        ;;
                esac
-               ;;
-       esac
+       fi
 }
 
 _git_rebase ()
index bb70c75ee1ed54a11ce31d7092ef6e35cae37c04..717d29fc03ba0bf375efa58be8dc0f676d9ac5c4 100644 (file)
@@ -36,11 +36,11 @@ int sha1close(struct sha1file *f, unsigned char *result, unsigned int flags)
        unsigned offset = f->offset;
 
        if (offset) {
-               SHA1_Update(&f->ctx, f->buffer, offset);
+               git_SHA1_Update(&f->ctx, f->buffer, offset);
                sha1flush(f, f->buffer, offset);
                f->offset = 0;
        }
-       SHA1_Final(f->buffer, &f->ctx);
+       git_SHA1_Final(f->buffer, &f->ctx);
        if (result)
                hashcpy(result, f->buffer);
        if (flags & (CSUM_CLOSE | CSUM_FSYNC)) {
@@ -82,7 +82,7 @@ int sha1write(struct sha1file *f, void *buf, unsigned int count)
                buf = (char *) buf + nr;
                left -= nr;
                if (!left) {
-                       SHA1_Update(&f->ctx, data, offset);
+                       git_SHA1_Update(&f->ctx, data, offset);
                        sha1flush(f, data, offset);
                        offset = 0;
                }
@@ -105,7 +105,7 @@ struct sha1file *sha1fd_throughput(int fd, const char *name, struct progress *tp
        f->tp = tp;
        f->name = name;
        f->do_crc = 0;
-       SHA1_Init(&f->ctx);
+       git_SHA1_Init(&f->ctx);
        return f;
 }
 
index 72c9487f4fd9fcab5e02fc2dc6afd3cb7f9c036a..9e13342eb357d6427a208fc6777ea170eb55acb8 100644 (file)
@@ -7,7 +7,7 @@ struct progress;
 struct sha1file {
        int fd;
        unsigned int offset;
-       SHA_CTX ctx;
+       git_SHA_CTX ctx;
        off_t total;
        struct progress *tp;
        const char *name;
diff --git a/diff.c b/diff.c
index 7c982b49477bf791586246fc3a38a6a0dc92eb70..02e948c9dd6244a0003c2c6bc81f55e46cf0ad2b 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -1509,6 +1509,10 @@ static void builtin_diff(const char *name_a,
                b_prefix = o->b_prefix;
        }
 
+       /* Never use a non-valid filename anywhere if at all possible */
+       name_a = DIFF_FILE_VALID(one) ? name_a : name_b;
+       name_b = DIFF_FILE_VALID(two) ? name_b : name_a;
+
        a_one = quote_two(a_prefix, name_a + (*name_a == '/'));
        b_two = quote_two(b_prefix, name_b + (*name_b == '/'));
        lbl[0] = DIFF_FILE_VALID(one) ? a_one : "/dev/null";
@@ -3087,7 +3091,7 @@ static void diff_summary(FILE *file, struct diff_filepair *p)
 }
 
 struct patch_id_t {
-       SHA_CTX *ctx;
+       git_SHA_CTX *ctx;
        int patchlen;
 };
 
@@ -3115,7 +3119,7 @@ static void patch_id_consume(void *priv, char *line, unsigned long len)
 
        new_len = remove_space(line, len);
 
-       SHA1_Update(data->ctx, line, new_len);
+       git_SHA1_Update(data->ctx, line, new_len);
        data->patchlen += new_len;
 }
 
@@ -3124,11 +3128,11 @@ static int diff_get_patch_id(struct diff_options *options, unsigned char *sha1)
 {
        struct diff_queue_struct *q = &diff_queued_diff;
        int i;
-       SHA_CTX ctx;
+       git_SHA_CTX ctx;
        struct patch_id_t data;
        char buffer[PATH_MAX * 4 + 20];
 
-       SHA1_Init(&ctx);
+       git_SHA1_Init(&ctx);
        memset(&data, 0, sizeof(struct patch_id_t));
        data.ctx = &ctx;
 
@@ -3190,7 +3194,7 @@ static int diff_get_patch_id(struct diff_options *options, unsigned char *sha1)
                                        len2, p->two->path,
                                        len1, p->one->path,
                                        len2, p->two->path);
-               SHA1_Update(&ctx, buffer, len1);
+               git_SHA1_Update(&ctx, buffer, len1);
 
                xpp.flags = XDF_NEED_MINIMAL;
                xecfg.ctxlen = 3;
@@ -3199,7 +3203,7 @@ static int diff_get_patch_id(struct diff_options *options, unsigned char *sha1)
                              &xpp, &xecfg, &ecb);
        }
 
-       SHA1_Final(sha1, &ctx);
+       git_SHA1_Final(sha1, &ctx);
        return 0;
 }
 
diff --git a/dir.c b/dir.c
index 1c3c5015249e6ac0ed0461b49f6581aebc8701a3..0131983dfbc143ce5dae77e067663bb2e7d5f126 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -382,7 +382,7 @@ static struct dir_entry *dir_entry_new(const char *pathname, int len)
        return ent;
 }
 
-struct dir_entry *dir_add_name(struct dir_struct *dir, const char *pathname, int len)
+static struct dir_entry *dir_add_name(struct dir_struct *dir, const char *pathname, int len)
 {
        if (cache_name_exists(pathname, len, ignore_case))
                return NULL;
@@ -391,7 +391,7 @@ struct dir_entry *dir_add_name(struct dir_struct *dir, const char *pathname, int
        return dir->entries[dir->nr++] = dir_entry_new(pathname, len);
 }
 
-struct dir_entry *dir_add_ignored(struct dir_struct *dir, const char *pathname, int len)
+static struct dir_entry *dir_add_ignored(struct dir_struct *dir, const char *pathname, int len)
 {
        if (cache_name_pos(pathname, len) >= 0)
                return NULL;
diff --git a/dir.h b/dir.h
index 278ee42295ed3724801d56eb65c86b29002486aa..768425af0e7095a54edf161fe20400c4caf85b31 100644 (file)
--- a/dir.h
+++ b/dir.h
@@ -73,7 +73,6 @@ extern void add_excludes_from_file(struct dir_struct *, const char *fname);
 extern void add_exclude(const char *string, const char *base,
                        int baselen, struct exclude_list *which);
 extern int file_exists(const char *);
-extern struct dir_entry *dir_add_name(struct dir_struct *dir, const char *pathname, int len);
 
 extern char *get_relative_cwd(char *buffer, int size, const char *dir);
 extern int is_inside_dir(const char *dir);
index ab6689a64d69bdb741f662df2038ae1daae99837..3c035a57886329acf4d53a600af0a82ee55d514b 100644 (file)
@@ -845,7 +845,7 @@ static int oecmp (const void *a_, const void *b_)
 static char *create_index(void)
 {
        static char tmpfile[PATH_MAX];
-       SHA_CTX ctx;
+       git_SHA_CTX ctx;
        struct sha1file *f;
        struct object_entry **idx, **c, **last, *e;
        struct object_entry_pool *o;
@@ -882,17 +882,17 @@ static char *create_index(void)
        idx_fd = xmkstemp(tmpfile);
        f = sha1fd(idx_fd, tmpfile);
        sha1write(f, array, 256 * sizeof(int));
-       SHA1_Init(&ctx);
+       git_SHA1_Init(&ctx);
        for (c = idx; c != last; c++) {
                uint32_t offset = htonl((*c)->offset);
                sha1write(f, &offset, 4);
                sha1write(f, (*c)->sha1, sizeof((*c)->sha1));
-               SHA1_Update(&ctx, (*c)->sha1, 20);
+               git_SHA1_Update(&ctx, (*c)->sha1, 20);
        }
        sha1write(f, pack_data->sha1, sizeof(pack_data->sha1));
        sha1close(f, NULL, CSUM_FSYNC);
        free(idx);
-       SHA1_Final(pack_data->sha1, &ctx);
+       git_SHA1_Final(pack_data->sha1, &ctx);
        return tmpfile;
 }
 
@@ -1033,15 +1033,15 @@ static int store_object(
        unsigned char hdr[96];
        unsigned char sha1[20];
        unsigned long hdrlen, deltalen;
-       SHA_CTX c;
+       git_SHA_CTX c;
        z_stream s;
 
        hdrlen = sprintf((char*)hdr,"%s %lu", typename(type),
                (unsigned long)dat->len) + 1;
-       SHA1_Init(&c);
-       SHA1_Update(&c, hdr, hdrlen);
-       SHA1_Update(&c, dat->buf, dat->len);
-       SHA1_Final(sha1, &c);
+       git_SHA1_Init(&c);
+       git_SHA1_Update(&c, hdr, hdrlen);
+       git_SHA1_Update(&c, dat->buf, dat->len);
+       git_SHA1_Final(sha1, &c);
        if (sha1out)
                hashcpy(sha1out, sha1);
 
index edb6ec6ed00b74764764802d0ebae56d223a2ac6..bdec43c3f604b22d29b52bd6a026785a6ac0f21b 100755 (executable)
@@ -65,6 +65,16 @@ output () {
        esac
 }
 
+run_pre_rebase_hook () {
+       if test -x "$GIT_DIR/hooks/pre-rebase"
+       then
+               "$GIT_DIR/hooks/pre-rebase" ${1+"$@"} || {
+                       echo >&2 "The pre-rebase hook refused to rebase."
+                       exit 1
+               }
+       fi
+}
+
 require_clean_work_tree () {
        # test if working tree is dirty
        git rev-parse --verify HEAD > /dev/null &&
@@ -304,23 +314,28 @@ do_next () {
 
                mark_action_done
                make_squash_message $sha1 > "$MSG"
+               failed=f
+               author_script=$(get_author_ident_from_commit HEAD)
+               output git reset --soft HEAD^
+               pick_one -n $sha1 || failed=t
                case "$(peek_next_command)" in
                squash|s)
                        EDIT_COMMIT=
                        USE_OUTPUT=output
+                       MSG_OPT=-F
+                       MSG_FILE="$MSG"
                        cp "$MSG" "$SQUASH_MSG"
                        ;;
                *)
                        EDIT_COMMIT=-e
                        USE_OUTPUT=
+                       MSG_OPT=
+                       MSG_FILE=
                        rm -f "$SQUASH_MSG" || exit
+                       cp "$MSG" "$GIT_DIR"/SQUASH_MSG
+                       rm -f "$GIT_DIR"/MERGE_MSG || exit
                        ;;
                esac
-
-               failed=f
-               author_script=$(get_author_ident_from_commit HEAD)
-               output git reset --soft HEAD^
-               pick_one -n $sha1 || failed=t
                echo "$author_script" > "$DOTEST"/author-script
                if test $failed = f
                then
@@ -329,7 +344,7 @@ do_next () {
                        GIT_AUTHOR_NAME="$GIT_AUTHOR_NAME" \
                        GIT_AUTHOR_EMAIL="$GIT_AUTHOR_EMAIL" \
                        GIT_AUTHOR_DATE="$GIT_AUTHOR_DATE" \
-                       $USE_OUTPUT git commit --no-verify -F "$MSG" $EDIT_COMMIT || failed=t
+                       $USE_OUTPUT git commit --no-verify $MSG_OPT "$MSG_FILE" $EDIT_COMMIT || failed=t
                fi
                if test $failed = t
                then
@@ -507,6 +522,7 @@ first and then run 'git rebase --continue' again."
                ;;
        --)
                shift
+               run_pre_rebase_hook ${1+"$@"}
                test $# -eq 1 -o $# -eq 2 || usage
                test -d "$DOTEST" &&
                        die "Interactive rebase already started"
index 528b604cd57a774030c5f5830d3d78b5a04454cf..a30d40c0056dc32aa6123adc9856e649c469fcd0 100755 (executable)
@@ -144,6 +144,16 @@ is_interactive () {
        done && test -n "$1"
 }
 
+run_pre_rebase_hook () {
+       if test -x "$GIT_DIR/hooks/pre-rebase"
+       then
+               "$GIT_DIR/hooks/pre-rebase" ${1+"$@"} || {
+                       echo >&2 "The pre-rebase hook refused to rebase."
+                       exit 1
+               }
+       fi
+}
+
 test -f "$GIT_DIR"/rebase-apply/applying &&
        die 'It looks like git-am is in progress. Cannot rebase.'
 
@@ -320,13 +330,7 @@ onto_name=${newbase-"$upstream_name"}
 onto=$(git rev-parse --verify "${onto_name}^0") || exit
 
 # If a hook exists, give it a chance to interrupt
-if test -x "$GIT_DIR/hooks/pre-rebase"
-then
-       "$GIT_DIR/hooks/pre-rebase" ${1+"$@"} || {
-               echo >&2 "The pre-rebase hook refused to rebase."
-               exit 1
-       }
-fi
+run_pre_rebase_hook ${1+"$@"}
 
 # If the branch to rebase is given, that is the branch we will rebase
 # $branch_name -- branch being rebased, or HEAD (already detached)
index 42f626f9d555f26f3e50441c0ab27de5cac19bf4..b9ace9970492aaf48472904d978d809d90ca33db 100755 (executable)
@@ -145,16 +145,8 @@ show_stash () {
                flags=--stat
        fi
 
-       if test $# = 0
-       then
-               set x "$ref_stash@{0}"
-               shift
-       fi
-
-       s=$(git rev-parse --revs-only --no-flags "$@")
-
-       w_commit=$(git rev-parse --verify "$s") &&
-       b_commit=$(git rev-parse --verify "$s^") &&
+       w_commit=$(git rev-parse --verify --default $ref_stash "$@") &&
+       b_commit=$(git rev-parse --verify "$w_commit^") &&
        git diff $flags $b_commit $w_commit
 }
 
@@ -170,19 +162,13 @@ apply_stash () {
                shift
        esac
 
-       if test $# = 0
-       then
-               set x "$ref_stash@{0}"
-               shift
-       fi
-
        # current index state
        c_tree=$(git write-tree) ||
                die 'Cannot apply a stash in the middle of a merge'
 
        # stash records the work tree, and is a merge between the
        # base commit (first parent) and the index tree (second parent).
-       s=$(git rev-parse --revs-only --no-flags "$@") &&
+       s=$(git rev-parse --verify --default $ref_stash "$@") &&
        w_tree=$(git rev-parse --verify "$s:") &&
        b_tree=$(git rev-parse --verify "$s^1:") &&
        i_tree=$(git rev-parse --verify "$s^2:") ||
@@ -242,7 +228,7 @@ drop_stash () {
                shift
        fi
        # Verify supplied argument looks like a stash entry
-       s=$(git rev-parse --revs-only --no-flags "$@") &&
+       s=$(git rev-parse --verify "$@") &&
        git rev-parse --verify "$s:"   > /dev/null 2>&1 &&
        git rev-parse --verify "$s^1:" > /dev/null 2>&1 &&
        git rev-parse --verify "$s^2:" > /dev/null 2>&1 ||
index 18e70a366333fffbadd37a7fbe509b4c33f9421f..83f810ad46cd2dfcea37308791ba64870ebfbd3c 100755 (executable)
@@ -27,6 +27,13 @@ BEGIN
 our $my_url = $cgi->url();
 our $my_uri = $cgi->url(-absolute => 1);
 
+# if we're called with PATH_INFO, we have to strip that
+# from the URL to find our real URL
+if (my $path_info = $ENV{"PATH_INFO"}) {
+       $my_url =~ s,\Q$path_info\E$,,;
+       $my_uri =~ s,\Q$path_info\E$,,;
+}
+
 # core git executable to use
 # this can just be "git" if your webserver has a sensible PATH
 our $GIT = "++GIT_BINDIR++/git";
@@ -775,7 +782,7 @@ sub quot_cec {
        );
        my $chr = ( (exists $es{$cntrl})
                    ? $es{$cntrl}
-                   : sprintf('\%03o', ord($cntrl)) );
+                   : sprintf('\%2x', ord($cntrl)) );
        if ($opts{-nohtml}) {
                return $chr;
        } else {
@@ -4070,10 +4077,10 @@ sub git_summary {
 
        print "<div class=\"title\">&nbsp;</div>\n";
        print "<table class=\"projects_list\">\n" .
-             "<tr><td>description</td><td>" . esc_html($descr) . "</td></tr>\n" .
-             "<tr><td>owner</td><td>" . esc_html($owner) . "</td></tr>\n";
+             "<tr id=\"metadata_desc\"><td>description</td><td>" . esc_html($descr) . "</td></tr>\n" .
+             "<tr id=\"metadata_owner\"><td>owner</td><td>" . esc_html($owner) . "</td></tr>\n";
        if (defined $cd{'rfc2822'}) {
-               print "<tr><td>last change</td><td>$cd{'rfc2822'}</td></tr>\n";
+               print "<tr id=\"metadata_lchange\"><td>last change</td><td>$cd{'rfc2822'}</td></tr>\n";
        }
 
        # use per project git URL list in $projectroot/$project/cloneurl
@@ -4083,7 +4090,7 @@ sub git_summary {
        @url_list = map { "$_/$project" } @git_base_url_list unless @url_list;
        foreach my $git_url (@url_list) {
                next unless $git_url;
-               print "<tr><td>$url_tag</td><td>$git_url</td></tr>\n";
+               print "<tr class=\"metadata_url\"><td>$url_tag</td><td>$git_url</td></tr>\n";
                $url_tag = "";
        }
        print "</table>\n";
@@ -4445,6 +4452,7 @@ sub git_tree {
                        $hash = $hash_base;
                }
        }
+       die_error(404, "No such tree") unless defined($hash);
        $/ = "\0";
        open my $fd, "-|", git_cmd(), "ls-tree", '-z', $hash
                or die_error(500, "Open git-ls-tree failed");
@@ -4485,8 +4493,8 @@ sub git_tree {
                if ($basedir ne '' && substr($basedir, -1) ne '/') {
                        $basedir .= '/';
                }
+               git_print_page_path($file_name, 'tree', $hash_base);
        }
-       git_print_page_path($file_name, 'tree', $hash_base);
        print "<div class=\"page_body\">\n";
        print "<table class=\"tree\">\n";
        my $alternate = 1;
diff --git a/grep.c b/grep.c
index 706351197fc26efa10c4666d38433f8fbdf1d6b5..e2c190a7f66f9e9311f91d9a41b7dc3f295f00fb 100644 (file)
--- a/grep.c
+++ b/grep.c
@@ -239,6 +239,8 @@ static int word_char(char ch)
 static void show_line(struct grep_opt *opt, const char *bol, const char *eol,
                      const char *name, unsigned lno, char sign)
 {
+       if (opt->null_following_name)
+               sign = '\0';
        if (opt->pathname)
                printf("%s%c", name, sign);
        if (opt->linenum)
@@ -246,6 +248,11 @@ static void show_line(struct grep_opt *opt, const char *bol, const char *eol,
        printf("%.*s\n", (int)(eol-bol), bol);
 }
 
+static void show_name(struct grep_opt *opt, const char *name)
+{
+       printf("%s%c", name, opt->null_following_name ? '\0' : '\n');
+}
+
 static int fixmatch(const char *pattern, char *line, regmatch_t *match)
 {
        char *hit = strstr(line, pattern);
@@ -489,7 +496,7 @@ static int grep_buffer_1(struct grep_opt *opt, const char *name,
                                return 1;
                        }
                        if (opt->name_only) {
-                               printf("%s\n", name);
+                               show_name(opt, name);
                                return 1;
                        }
                        /* Hit at this line.  If we haven't shown the
@@ -555,7 +562,7 @@ static int grep_buffer_1(struct grep_opt *opt, const char *name,
                return 0;
        if (opt->unmatch_name_only) {
                /* We did not see any hit, so we want to show this */
-               printf("%s\n", name);
+               show_name(opt, name);
                return 1;
        }
 
@@ -565,7 +572,8 @@ static int grep_buffer_1(struct grep_opt *opt, const char *name,
         * make it another option?  For now suppress them.
         */
        if (opt->count && count)
-               printf("%s:%u\n", name, count);
+               printf("%s%c%u\n", name,
+                      opt->null_following_name ? '\0' : ':', count);
        return !!last_hit;
 }
 
diff --git a/grep.h b/grep.h
index 59b3f871ea63619f8d3caae74c41b4da1e9a2b9f..45a222d904b5898758c3c84f6ef1e0119c81f6b2 100644 (file)
--- a/grep.h
+++ b/grep.h
@@ -74,6 +74,7 @@ struct grep_opt {
        unsigned extended:1;
        unsigned relative:1;
        unsigned pathname:1;
+       unsigned null_following_name:1;
        int regflags;
        unsigned pre_context;
        unsigned post_context;
index c9dd9a1f6475cc8772b1e0f528a9f54751d6445a..42f4d78e54edbb73d14952f5fb3992f2cebb40ae 100644 (file)
@@ -126,7 +126,7 @@ struct transfer_request
        char errorstr[CURL_ERROR_SIZE];
        long http_code;
        unsigned char real_sha1[20];
-       SHA_CTX c;
+       git_SHA_CTX c;
        z_stream stream;
        int zret;
        int rename;
@@ -209,7 +209,7 @@ static size_t fwrite_sha1_file(void *ptr, size_t eltsize, size_t nmemb,
                request->stream.next_out = expn;
                request->stream.avail_out = sizeof(expn);
                request->zret = inflate(&request->stream, Z_SYNC_FLUSH);
-               SHA1_Update(&request->c, expn,
+               git_SHA1_Update(&request->c, expn,
                            sizeof(expn) - request->stream.avail_out);
        } while (request->stream.avail_in && request->zret == Z_OK);
        data_received++;
@@ -270,7 +270,7 @@ static void start_fetch_loose(struct transfer_request *request)
 
        inflateInit(&request->stream);
 
-       SHA1_Init(&request->c);
+       git_SHA1_Init(&request->c);
 
        url = xmalloc(strlen(remote->url) + 50);
        request->url = xmalloc(strlen(remote->url) + 50);
@@ -310,7 +310,7 @@ static void start_fetch_loose(struct transfer_request *request)
        if (prev_read == -1) {
                memset(&request->stream, 0, sizeof(request->stream));
                inflateInit(&request->stream);
-               SHA1_Init(&request->c);
+               git_SHA1_Init(&request->c);
                if (prev_posn>0) {
                        prev_posn = 0;
                        lseek(request->local_fileno, 0, SEEK_SET);
@@ -742,7 +742,7 @@ static void finish_request(struct transfer_request *request)
                                fprintf(stderr, "Warning: requested range invalid; we may already have all the data.\n");
 
                        inflateEnd(&request->stream);
-                       SHA1_Final(request->real_sha1, &request->c);
+                       git_SHA1_Final(request->real_sha1, &request->c);
                        if (request->zret != Z_STREAM_END) {
                                unlink(request->tmpfile);
                        } else if (hashcmp(request->obj->sha1, request->real_sha1)) {
index 9dc6b27b457a2979a95018679a0b885e6fb62d9a..7271c7d19d3b08ef76c9c868ae57f6872f6186d0 100644 (file)
@@ -36,7 +36,7 @@ struct object_request
        char errorstr[CURL_ERROR_SIZE];
        long http_code;
        unsigned char real_sha1[20];
-       SHA_CTX c;
+       git_SHA_CTX c;
        z_stream stream;
        int zret;
        int rename;
@@ -83,7 +83,7 @@ static size_t fwrite_sha1_file(void *ptr, size_t eltsize, size_t nmemb,
                obj_req->stream.next_out = expn;
                obj_req->stream.avail_out = sizeof(expn);
                obj_req->zret = inflate(&obj_req->stream, Z_SYNC_FLUSH);
-               SHA1_Update(&obj_req->c, expn,
+               git_SHA1_Update(&obj_req->c, expn,
                            sizeof(expn) - obj_req->stream.avail_out);
        } while (obj_req->stream.avail_in && obj_req->zret == Z_OK);
        data_received++;
@@ -144,7 +144,7 @@ static void start_object_request(struct walker *walker,
 
        inflateInit(&obj_req->stream);
 
-       SHA1_Init(&obj_req->c);
+       git_SHA1_Init(&obj_req->c);
 
        url = xmalloc(strlen(obj_req->repo->base) + 51);
        obj_req->url = xmalloc(strlen(obj_req->repo->base) + 51);
@@ -184,7 +184,7 @@ static void start_object_request(struct walker *walker,
        if (prev_read == -1) {
                memset(&obj_req->stream, 0, sizeof(obj_req->stream));
                inflateInit(&obj_req->stream);
-               SHA1_Init(&obj_req->c);
+               git_SHA1_Init(&obj_req->c);
                if (prev_posn>0) {
                        prev_posn = 0;
                        lseek(obj_req->local, 0, SEEK_SET);
@@ -244,7 +244,7 @@ static void finish_object_request(struct object_request *obj_req)
        }
 
        inflateEnd(&obj_req->stream);
-       SHA1_Final(obj_req->real_sha1, &obj_req->c);
+       git_SHA1_Final(obj_req->real_sha1, &obj_req->c);
        if (obj_req->zret != Z_STREAM_END) {
                unlink(obj_req->tmpfile);
                return;
index 530d820370fb2b02a443873b8b9ddd0bcffcb5ec..73860bf3da062d283c266f6b83fdf3f613af26e7 100644 (file)
@@ -67,7 +67,7 @@ static struct progress *progress;
 static unsigned char input_buffer[4096];
 static unsigned int input_offset, input_len;
 static off_t consumed_bytes;
-static SHA_CTX input_ctx;
+static git_SHA_CTX input_ctx;
 static uint32_t input_crc32;
 static int input_fd, output_fd, pack_fd;
 
@@ -119,7 +119,7 @@ static void flush(void)
        if (input_offset) {
                if (output_fd >= 0)
                        write_or_die(output_fd, input_buffer, input_offset);
-               SHA1_Update(&input_ctx, input_buffer, input_offset);
+               git_SHA1_Update(&input_ctx, input_buffer, input_offset);
                memmove(input_buffer, input_buffer + input_offset, input_len);
                input_offset = 0;
        }
@@ -188,7 +188,7 @@ static char *open_pack_file(char *pack_name)
                output_fd = -1;
                pack_fd = input_fd;
        }
-       SHA1_Init(&input_ctx);
+       git_SHA1_Init(&input_ctx);
        return pack_name;
 }
 
@@ -365,8 +365,11 @@ static void *get_data_from_pack(struct object_entry *obj)
        data = src;
        do {
                ssize_t n = pread(pack_fd, data + rdy, len - rdy, from + rdy);
-               if (n <= 0)
+               if (n < 0)
                        die("cannot pread pack file: %s", strerror(errno));
+               if (!n)
+                       die("premature end of pack file, %lu bytes missing",
+                           len - rdy);
                rdy += n;
        } while (rdy < len);
        data = xmalloc(obj->size);
@@ -588,7 +591,7 @@ static void parse_pack_objects(unsigned char *sha1)
 
        /* Check pack integrity */
        flush();
-       SHA1_Final(sha1, &input_ctx);
+       git_SHA1_Final(sha1, &input_ctx);
        if (hashcmp(fill(20), sha1))
                die("pack is corrupted (SHA1 mismatch)");
        use(20);
index 02fc10f7e622ba1c53065e7cf4563ff10af0c41f..2d1413efbbc33c51fd4820933dcb54164e12d706 100644 (file)
@@ -158,9 +158,8 @@ static int same_entry(struct name_entry *a, struct name_entry *b)
 
 static struct merge_list *create_entry(unsigned stage, unsigned mode, const unsigned char *sha1, const char *path)
 {
-       struct merge_list *res = xmalloc(sizeof(*res));
+       struct merge_list *res = xcalloc(1, sizeof(*res));
 
-       memset(res, 0, sizeof(*res));
        res->stage = stage;
        res->path = path;
        res->mode = mode;
index 3f06b835675206912777a774d91c3ba611fa5a06..95a4ebf49612e4f1bb74e8c5e395d564a797de1f 100644 (file)
@@ -35,9 +35,9 @@
 
 #include "sha1.h"
 
-static void shaHashBlock(SHA_CTX *ctx);
+static void shaHashBlock(moz_SHA_CTX *ctx);
 
-void SHA1_Init(SHA_CTX *ctx) {
+void moz_SHA1_Init(moz_SHA_CTX *ctx) {
   int i;
 
   ctx->lenW = 0;
@@ -56,7 +56,7 @@ void SHA1_Init(SHA_CTX *ctx) {
 }
 
 
-void SHA1_Update(SHA_CTX *ctx, const void *_dataIn, int len) {
+void moz_SHA1_Update(moz_SHA_CTX *ctx, const void *_dataIn, int len) {
   const unsigned char *dataIn = _dataIn;
   int i;
 
@@ -75,7 +75,7 @@ void SHA1_Update(SHA_CTX *ctx, const void *_dataIn, int len) {
 }
 
 
-void SHA1_Final(unsigned char hashout[20], SHA_CTX *ctx) {
+void moz_SHA1_Final(unsigned char hashout[20], moz_SHA_CTX *ctx) {
   unsigned char pad0x80 = 0x80;
   unsigned char pad0x00 = 0x00;
   unsigned char padlen[8];
@@ -91,10 +91,10 @@ void SHA1_Final(unsigned char hashout[20], SHA_CTX *ctx) {
   padlen[5] = (unsigned char)((ctx->sizeLo >> 16) & 255);
   padlen[6] = (unsigned char)((ctx->sizeLo >> 8) & 255);
   padlen[7] = (unsigned char)((ctx->sizeLo >> 0) & 255);
-  SHA1_Update(ctx, &pad0x80, 1);
+  moz_SHA1_Update(ctx, &pad0x80, 1);
   while (ctx->lenW != 56)
-    SHA1_Update(ctx, &pad0x00, 1);
-  SHA1_Update(ctx, padlen, 8);
+    moz_SHA1_Update(ctx, &pad0x00, 1);
+  moz_SHA1_Update(ctx, padlen, 8);
 
   /* Output hash
    */
@@ -106,13 +106,13 @@ void SHA1_Final(unsigned char hashout[20], SHA_CTX *ctx) {
   /*
    *  Re-initialize the context (also zeroizes contents)
    */
-  SHA1_Init(ctx);
+  moz_SHA1_Init(ctx);
 }
 
 
 #define SHA_ROT(X,n) (((X) << (n)) | ((X) >> (32-(n))))
 
-static void shaHashBlock(SHA_CTX *ctx) {
+static void shaHashBlock(moz_SHA_CTX *ctx) {
   int t;
   unsigned int A,B,C,D,E,TEMP;
 
index 16f2d3d43ca8bee1eeb306308277bef8c707a972..aa48a46cf708eaef61fc5856310063a2ce87b93b 100644 (file)
@@ -38,8 +38,13 @@ typedef struct {
   unsigned int W[80];
   int lenW;
   unsigned int sizeHi,sizeLo;
-} SHA_CTX;
+} moz_SHA_CTX;
 
-void SHA1_Init(SHA_CTX *ctx);
-void SHA1_Update(SHA_CTX *ctx, const void *dataIn, int len);
-void SHA1_Final(unsigned char hashout[20], SHA_CTX *ctx);
+void moz_SHA1_Init(moz_SHA_CTX *ctx);
+void moz_SHA1_Update(moz_SHA_CTX *ctx, const void *dataIn, int len);
+void moz_SHA1_Final(unsigned char hashout[20], moz_SHA_CTX *ctx);
+
+#define git_SHA_CTX    moz_SHA_CTX
+#define git_SHA1_Init  moz_SHA1_Init
+#define git_SHA1_Update        moz_SHA1_Update
+#define git_SHA1_Final moz_SHA1_Final
index f596bf2db5e0a0065e6856b8caa3ded8a134f74d..90c33b1b84ef793bf017927026863de41e31fa2c 100644 (file)
@@ -47,7 +47,7 @@ static int verify_packfile(struct packed_git *p,
 {
        off_t index_size = p->index_size;
        const unsigned char *index_base = p->index_data;
-       SHA_CTX ctx;
+       git_SHA_CTX ctx;
        unsigned char sha1[20], *pack_sig;
        off_t offset = 0, pack_sig_ofs = p->pack_size - 20;
        uint32_t nr_objects, i;
@@ -60,16 +60,16 @@ static int verify_packfile(struct packed_git *p,
         * immediately.
         */
 
-       SHA1_Init(&ctx);
+       git_SHA1_Init(&ctx);
        while (offset < pack_sig_ofs) {
                unsigned int remaining;
                unsigned char *in = use_pack(p, w_curs, offset, &remaining);
                offset += remaining;
                if (offset > pack_sig_ofs)
                        remaining -= (unsigned int)(offset - pack_sig_ofs);
-               SHA1_Update(&ctx, in, remaining);
+               git_SHA1_Update(&ctx, in, remaining);
        }
-       SHA1_Final(sha1, &ctx);
+       git_SHA1_Final(sha1, &ctx);
        pack_sig = use_pack(p, w_curs, pack_sig_ofs, NULL);
        if (hashcmp(sha1, pack_sig))
                err = error("%s SHA1 checksum mismatch",
@@ -135,7 +135,7 @@ int verify_pack(struct packed_git *p)
 {
        off_t index_size;
        const unsigned char *index_base;
-       SHA_CTX ctx;
+       git_SHA_CTX ctx;
        unsigned char sha1[20];
        int err = 0;
        struct pack_window *w_curs = NULL;
@@ -146,9 +146,9 @@ int verify_pack(struct packed_git *p)
        index_base = p->index_data;
 
        /* Verify SHA1 sum of the index file */
-       SHA1_Init(&ctx);
-       SHA1_Update(&ctx, index_base, (unsigned int)(index_size - 20));
-       SHA1_Final(sha1, &ctx);
+       git_SHA1_Init(&ctx);
+       git_SHA1_Update(&ctx, index_base, (unsigned int)(index_size - 20));
+       git_SHA1_Final(sha1, &ctx);
        if (hashcmp(sha1, index_base + index_size - 20))
                err = error("Packfile index for %s SHA1 mismatch",
                            p->pack_name);
index 3621f1dd3258d9dcd63bf5a6738e5d54940ffbbb..b426006c5851c98fce8894bd9f76cd51a7cde170 100644 (file)
@@ -25,7 +25,7 @@ char *write_idx_file(char *index_name, struct pack_idx_entry **objects,
        off_t last_obj_offset = 0;
        uint32_t array[256];
        int i, fd;
-       SHA_CTX ctx;
+       git_SHA_CTX ctx;
        uint32_t index_version;
 
        if (nr_objects) {
@@ -86,7 +86,7 @@ char *write_idx_file(char *index_name, struct pack_idx_entry **objects,
        sha1write(f, array, 256 * 4);
 
        /* compute the SHA1 hash of sorted object names. */
-       SHA1_Init(&ctx);
+       git_SHA1_Init(&ctx);
 
        /*
         * Write the actual SHA1 entries..
@@ -99,7 +99,7 @@ char *write_idx_file(char *index_name, struct pack_idx_entry **objects,
                        sha1write(f, &offset, 4);
                }
                sha1write(f, obj->sha1, 20);
-               SHA1_Update(&ctx, obj->sha1, 20);
+               git_SHA1_Update(&ctx, obj->sha1, 20);
        }
 
        if (index_version >= 2) {
@@ -140,7 +140,7 @@ char *write_idx_file(char *index_name, struct pack_idx_entry **objects,
 
        sha1write(f, sha1, 20);
        sha1close(f, NULL, CSUM_FSYNC);
-       SHA1_Final(sha1, &ctx);
+       git_SHA1_Final(sha1, &ctx);
        return index_name;
 }
 
@@ -168,12 +168,12 @@ void fixup_pack_header_footer(int pack_fd,
                         off_t partial_pack_offset)
 {
        int aligned_sz, buf_sz = 8 * 1024;
-       SHA_CTX old_sha1_ctx, new_sha1_ctx;
+       git_SHA_CTX old_sha1_ctx, new_sha1_ctx;
        struct pack_header hdr;
        char *buf;
 
-       SHA1_Init(&old_sha1_ctx);
-       SHA1_Init(&new_sha1_ctx);
+       git_SHA1_Init(&old_sha1_ctx);
+       git_SHA1_Init(&new_sha1_ctx);
 
        if (lseek(pack_fd, 0, SEEK_SET) != 0)
                die("Failed seeking to start of %s: %s", pack_name, strerror(errno));
@@ -181,9 +181,9 @@ void fixup_pack_header_footer(int pack_fd,
                die("Unable to reread header of %s: %s", pack_name, strerror(errno));
        if (lseek(pack_fd, 0, SEEK_SET) != 0)
                die("Failed seeking to start of %s: %s", pack_name, strerror(errno));
-       SHA1_Update(&old_sha1_ctx, &hdr, sizeof(hdr));
+       git_SHA1_Update(&old_sha1_ctx, &hdr, sizeof(hdr));
        hdr.hdr_entries = htonl(object_count);
-       SHA1_Update(&new_sha1_ctx, &hdr, sizeof(hdr));
+       git_SHA1_Update(&new_sha1_ctx, &hdr, sizeof(hdr));
        write_or_die(pack_fd, &hdr, sizeof(hdr));
        partial_pack_offset -= sizeof(hdr);
 
@@ -198,7 +198,7 @@ void fixup_pack_header_footer(int pack_fd,
                        break;
                if (n < 0)
                        die("Failed to checksum %s: %s", pack_name, strerror(errno));
-               SHA1_Update(&new_sha1_ctx, buf, n);
+               git_SHA1_Update(&new_sha1_ctx, buf, n);
 
                aligned_sz -= n;
                if (!aligned_sz)
@@ -207,11 +207,11 @@ void fixup_pack_header_footer(int pack_fd,
                if (!partial_pack_sha1)
                        continue;
 
-               SHA1_Update(&old_sha1_ctx, buf, n);
+               git_SHA1_Update(&old_sha1_ctx, buf, n);
                partial_pack_offset -= n;
                if (partial_pack_offset == 0) {
                        unsigned char sha1[20];
-                       SHA1_Final(sha1, &old_sha1_ctx);
+                       git_SHA1_Final(sha1, &old_sha1_ctx);
                        if (hashcmp(sha1, partial_pack_sha1) != 0)
                                die("Unexpected checksum for %s "
                                    "(disk corruption?)", pack_name);
@@ -220,7 +220,7 @@ void fixup_pack_header_footer(int pack_fd,
                         * pack, which also means making partial_pack_offset
                         * big enough not to matter anymore.
                         */
-                       SHA1_Init(&old_sha1_ctx);
+                       git_SHA1_Init(&old_sha1_ctx);
                        partial_pack_offset = ~partial_pack_offset;
                        partial_pack_offset -= MSB(partial_pack_offset, 1);
                }
@@ -228,8 +228,8 @@ void fixup_pack_header_footer(int pack_fd,
        free(buf);
 
        if (partial_pack_sha1)
-               SHA1_Final(partial_pack_sha1, &old_sha1_ctx);
-       SHA1_Final(new_pack_sha1, &new_sha1_ctx);
+               git_SHA1_Final(partial_pack_sha1, &old_sha1_ctx);
+       git_SHA1_Final(new_pack_sha1, &new_sha1_ctx);
        write_or_die(pack_fd, new_pack_sha1, 20);
        fsync_or_die(pack_fd, pack_name);
 }
index 9349bc5580456b378d41da7cc2518e4fa9a7e81a..871f1d20c0e364220d23035b34685ced8737cda8 100644 (file)
@@ -1,6 +1,6 @@
 #include "cache.h"
 
-static void flush_current_id(int patchlen, unsigned char *id, SHA_CTX *c)
+static void flush_current_id(int patchlen, unsigned char *id, git_SHA_CTX *c)
 {
        unsigned char result[20];
        char name[50];
@@ -8,10 +8,10 @@ static void flush_current_id(int patchlen, unsigned char *id, SHA_CTX *c)
        if (!patchlen)
                return;
 
-       SHA1_Final(result, c);
+       git_SHA1_Final(result, c);
        memcpy(name, sha1_to_hex(id), 41);
        printf("%s %s\n", sha1_to_hex(result), name);
-       SHA1_Init(c);
+       git_SHA1_Init(c);
 }
 
 static int remove_space(char *line)
@@ -31,10 +31,10 @@ static void generate_id_list(void)
 {
        static unsigned char sha1[20];
        static char line[1000];
-       SHA_CTX ctx;
+       git_SHA_CTX ctx;
        int patchlen = 0;
 
-       SHA1_Init(&ctx);
+       git_SHA1_Init(&ctx);
        while (fgets(line, sizeof(line), stdin) != NULL) {
                unsigned char n[20];
                char *p = line;
@@ -67,7 +67,7 @@ static void generate_id_list(void)
                /* Compute the sha without whitespace */
                len = remove_space(line);
                patchlen += len;
-               SHA1_Update(&ctx, line, len);
+               git_SHA1_Update(&ctx, line, len);
        }
        flush_current_id(patchlen, sha1, &ctx);
 }
index 738e36c1e81def4822ccc2a66bc2761402a07f26..ec6a1926d4465e61364a7a8450e8f4c86ed841f0 100644 (file)
 #include <string.h>
 #include "sha1.h"
 
-extern void sha1_core(uint32_t *hash, const unsigned char *p,
-                     unsigned int nblocks);
+extern void ppc_sha1_core(uint32_t *hash, const unsigned char *p,
+                         unsigned int nblocks);
 
-int SHA1_Init(SHA_CTX *c)
+int ppc_SHA1_Init(ppc_SHA_CTX *c)
 {
        c->hash[0] = 0x67452301;
        c->hash[1] = 0xEFCDAB89;
@@ -25,7 +25,7 @@ int SHA1_Init(SHA_CTX *c)
        return 0;
 }
 
-int SHA1_Update(SHA_CTX *c, const void *ptr, unsigned long n)
+int ppc_SHA1_Update(ppc_SHA_CTX *c, const void *ptr, unsigned long n)
 {
        unsigned long nb;
        const unsigned char *p = ptr;
@@ -38,12 +38,12 @@ int SHA1_Update(SHA_CTX *c, const void *ptr, unsigned long n)
                                nb = n;
                        memcpy(&c->buf.b[c->cnt], p, nb);
                        if ((c->cnt += nb) == 64) {
-                               sha1_core(c->hash, c->buf.b, 1);
+                               ppc_sha1_core(c->hash, c->buf.b, 1);
                                c->cnt = 0;
                        }
                } else {
                        nb = n >> 6;
-                       sha1_core(c->hash, p, nb);
+                       ppc_sha1_core(c->hash, p, nb);
                        nb <<= 6;
                }
                n -= nb;
@@ -52,7 +52,7 @@ int SHA1_Update(SHA_CTX *c, const void *ptr, unsigned long n)
        return 0;
 }
 
-int SHA1_Final(unsigned char *hash, SHA_CTX *c)
+int ppc_SHA1_Final(unsigned char *hash, ppc_SHA_CTX *c)
 {
        unsigned int cnt = c->cnt;
 
@@ -60,13 +60,13 @@ int SHA1_Final(unsigned char *hash, SHA_CTX *c)
        if (cnt > 56) {
                if (cnt < 64)
                        memset(&c->buf.b[cnt], 0, 64 - cnt);
-               sha1_core(c->hash, c->buf.b, 1);
+               ppc_sha1_core(c->hash, c->buf.b, 1);
                cnt = 0;
        }
        if (cnt < 56)
                memset(&c->buf.b[cnt], 0, 56 - cnt);
        c->buf.l[7] = c->len;
-       sha1_core(c->hash, c->buf.b, 1);
+       ppc_sha1_core(c->hash, c->buf.b, 1);
        memcpy(hash, c->hash, 20);
        return 0;
 }
index c3c51aa4d487f2e85c02b0257c1f0b57d6158d76..c405f734c2050e2e4ad3469d087368a29a98d27e 100644 (file)
@@ -5,7 +5,7 @@
  */
 #include <stdint.h>
 
-typedef struct sha_context {
+typedef struct {
        uint32_t hash[5];
        uint32_t cnt;
        uint64_t len;
@@ -13,8 +13,13 @@ typedef struct sha_context {
                unsigned char b[64];
                uint64_t l[8];
        } buf;
-} SHA_CTX;
+} ppc_SHA_CTX;
 
-int SHA1_Init(SHA_CTX *c);
-int SHA1_Update(SHA_CTX *c, const void *p, unsigned long n);
-int SHA1_Final(unsigned char *hash, SHA_CTX *c);
+int ppc_SHA1_Init(ppc_SHA_CTX *c);
+int ppc_SHA1_Update(ppc_SHA_CTX *c, const void *p, unsigned long n);
+int ppc_SHA1_Final(unsigned char *hash, ppc_SHA_CTX *c);
+
+#define git_SHA_CTX    ppc_SHA_CTX
+#define git_SHA1_Init  ppc_SHA1_Init
+#define git_SHA1_Update        ppc_SHA1_Update
+#define git_SHA1_Final ppc_SHA1_Final
index f132696ee72bf4a2e3d608a24322a6839f9a03a8..1711eef6e71be6d243016b5e138766b3777e08ef 100644 (file)
@@ -162,8 +162,8 @@ add RE(t),RE(t),%r0;  rotlwi RB(t),RB(t),30
        STEPUP4(fn, (t)+12, (s)+12,);   \
        STEPUP4(fn, (t)+16, (s)+16, loadk)
 
-       .globl  sha1_core
-sha1_core:
+       .globl  ppc_sha1_core
+ppc_sha1_core:
        stwu    %r1,-80(%r1)
        stmw    %r13,4(%r1)
 
index 5b1b3ad03b6d7294ca06b5b1053799958ad831c7..901064bf1ae72aacb583ff735058eec953475ae3 100644 (file)
@@ -1072,16 +1072,16 @@ struct cache_entry *refresh_cache_entry(struct cache_entry *ce, int really)
 
 static int verify_hdr(struct cache_header *hdr, unsigned long size)
 {
-       SHA_CTX c;
+       git_SHA_CTX c;
        unsigned char sha1[20];
 
        if (hdr->hdr_signature != htonl(CACHE_SIGNATURE))
                return error("bad signature");
        if (hdr->hdr_version != htonl(2))
                return error("bad index version");
-       SHA1_Init(&c);
-       SHA1_Update(&c, hdr, size - 20);
-       SHA1_Final(sha1, &c);
+       git_SHA1_Init(&c);
+       git_SHA1_Update(&c, hdr, size - 20);
+       git_SHA1_Final(sha1, &c);
        if (hashcmp(sha1, (unsigned char *)hdr + size - 20))
                return error("bad index file sha1 signature");
        return 0;
@@ -1278,11 +1278,11 @@ int unmerged_index(const struct index_state *istate)
 static unsigned char write_buffer[WRITE_BUFFER_SIZE];
 static unsigned long write_buffer_len;
 
-static int ce_write_flush(SHA_CTX *context, int fd)
+static int ce_write_flush(git_SHA_CTX *context, int fd)
 {
        unsigned int buffered = write_buffer_len;
        if (buffered) {
-               SHA1_Update(context, write_buffer, buffered);
+               git_SHA1_Update(context, write_buffer, buffered);
                if (write_in_full(fd, write_buffer, buffered) != buffered)
                        return -1;
                write_buffer_len = 0;
@@ -1290,7 +1290,7 @@ static int ce_write_flush(SHA_CTX *context, int fd)
        return 0;
 }
 
-static int ce_write(SHA_CTX *context, int fd, void *data, unsigned int len)
+static int ce_write(git_SHA_CTX *context, int fd, void *data, unsigned int len)
 {
        while (len) {
                unsigned int buffered = write_buffer_len;
@@ -1312,7 +1312,7 @@ static int ce_write(SHA_CTX *context, int fd, void *data, unsigned int len)
        return 0;
 }
 
-static int write_index_ext_header(SHA_CTX *context, int fd,
+static int write_index_ext_header(git_SHA_CTX *context, int fd,
                                  unsigned int ext, unsigned int sz)
 {
        ext = htonl(ext);
@@ -1321,13 +1321,13 @@ static int write_index_ext_header(SHA_CTX *context, int fd,
                (ce_write(context, fd, &sz, 4) < 0)) ? -1 : 0;
 }
 
-static int ce_flush(SHA_CTX *context, int fd)
+static int ce_flush(git_SHA_CTX *context, int fd)
 {
        unsigned int left = write_buffer_len;
 
        if (left) {
                write_buffer_len = 0;
-               SHA1_Update(context, write_buffer, left);
+               git_SHA1_Update(context, write_buffer, left);
        }
 
        /* Flush first if not enough space for SHA1 signature */
@@ -1338,7 +1338,7 @@ static int ce_flush(SHA_CTX *context, int fd)
        }
 
        /* Append the SHA1 signature at the end */
-       SHA1_Final(write_buffer + left, context);
+       git_SHA1_Final(write_buffer + left, context);
        left += 20;
        return (write_in_full(fd, write_buffer, left) != left) ? -1 : 0;
 }
@@ -1392,7 +1392,7 @@ static void ce_smudge_racily_clean_entry(struct cache_entry *ce)
        }
 }
 
-static int ce_write_entry(SHA_CTX *c, int fd, struct cache_entry *ce)
+static int ce_write_entry(git_SHA_CTX *c, int fd, struct cache_entry *ce)
 {
        int size = ondisk_ce_size(ce);
        struct ondisk_cache_entry *ondisk = xcalloc(1, size);
@@ -1416,7 +1416,7 @@ static int ce_write_entry(SHA_CTX *c, int fd, struct cache_entry *ce)
 
 int write_index(const struct index_state *istate, int newfd)
 {
-       SHA_CTX c;
+       git_SHA_CTX c;
        struct cache_header hdr;
        int i, err, removed;
        struct cache_entry **cache = istate->cache;
@@ -1430,7 +1430,7 @@ int write_index(const struct index_state *istate, int newfd)
        hdr.hdr_version = htonl(2);
        hdr.hdr_entries = htonl(entries - removed);
 
-       SHA1_Init(&c);
+       git_SHA1_Init(&c);
        if (ce_write(&c, newfd, &hdr, sizeof(hdr)) < 0)
                return -1;
 
index c45d96e98fffe3411284144b6d836cf499d42ba4..a2d7ab146ed6627cae5c845ef4801963635bf395 100644 (file)
--- a/remote.c
+++ b/remote.c
@@ -751,8 +751,7 @@ int remote_find_tracking(struct remote *remote, struct refspec *refspec)
 
 struct ref *alloc_ref(unsigned namelen)
 {
-       struct ref *ret = xmalloc(sizeof(struct ref) + namelen);
-       memset(ret, 0, sizeof(struct ref) + namelen);
+       struct ref *ret = xcalloc(1, sizeof(struct ref) + namelen);
        return ret;
 }
 
index 8447caeebc3c030398cd00d25f1fb61bc952e150..121f9114140708efd36bd4bd1b375f5ad0c558bc 100644 (file)
--- a/rerere.c
+++ b/rerere.c
@@ -73,7 +73,7 @@ static int write_rr(struct string_list *rr, int out_fd)
 static int handle_file(const char *path,
         unsigned char *sha1, const char *output)
 {
-       SHA_CTX ctx;
+       git_SHA_CTX ctx;
        char buf[1024];
        int hunk_no = 0;
        enum {
@@ -95,7 +95,7 @@ static int handle_file(const char *path,
        }
 
        if (sha1)
-               SHA1_Init(&ctx);
+               git_SHA1_Init(&ctx);
 
        strbuf_init(&one, 0);
        strbuf_init(&two,  0);
@@ -127,9 +127,9 @@ static int handle_file(const char *path,
                                fputs(">>>>>>>\n", out);
                        }
                        if (sha1) {
-                               SHA1_Update(&ctx, one.buf ? one.buf : "",
+                               git_SHA1_Update(&ctx, one.buf ? one.buf : "",
                                            one.len + 1);
-                               SHA1_Update(&ctx, two.buf ? two.buf : "",
+                               git_SHA1_Update(&ctx, two.buf ? two.buf : "",
                                            two.len + 1);
                        }
                        strbuf_reset(&one);
@@ -154,7 +154,7 @@ static int handle_file(const char *path,
        if (out)
                fclose(out);
        if (sha1)
-               SHA1_Final(sha1, &ctx);
+               git_SHA1_Final(sha1, &ctx);
        if (hunk != RR_CONTEXT) {
                if (output)
                        unlink(output);
index caab374577e02e9a33cd8095b8da9234acb065f8..c90cdc50e3165bcdb798c85b2dc7b929a9b0a144 100644 (file)
@@ -273,14 +273,6 @@ int run_command_v_opt(const char **argv, int opt)
        return run_command(&cmd);
 }
 
-int run_command_v_opt_cd(const char **argv, int opt, const char *dir)
-{
-       struct child_process cmd;
-       prepare_run_command_v_opt(&cmd, argv, opt);
-       cmd.dir = dir;
-       return run_command(&cmd);
-}
-
 int run_command_v_opt_cd_env(const char **argv, int opt, const char *dir, const char *const *env)
 {
        struct child_process cmd;
index 4f2b7d7d403ee6d87fea5ba2dc32da7596965e5e..a8b0c209e9b7487ce3c2b214cbebe7ad4f97fd11 100644 (file)
@@ -53,7 +53,6 @@ int run_command(struct child_process *);
 #define RUN_GIT_CMD         2  /*If this is to be git sub-command */
 #define RUN_COMMAND_STDOUT_TO_STDERR 4
 int run_command_v_opt(const char **argv, int opt);
-int run_command_v_opt_cd(const char **argv, int opt, const char *dir);
 
 /*
  * env (the environment) is to be formatted like environ: "VAR=VALUE".
diff --git a/setup.c b/setup.c
index 2e3248a0c4958f31001213470a88d1154b5947fc..78a8041ff0d17a5220133549880ccbc507b1890d 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -110,9 +110,7 @@ const char *prefix_path(const char *prefix, int len, const char *path)
                if (strncmp(sanitized, work_tree, len) ||
                    (sanitized[len] != '\0' && sanitized[len] != '/')) {
                error_out:
-                       error("'%s' is outside repository", orig);
-                       free(sanitized);
-                       return NULL;
+                       die("'%s' is outside repository", orig);
                }
                if (sanitized[len] == '/')
                        len++;
@@ -216,10 +214,7 @@ const char **get_pathspec(const char *prefix, const char **pathspec)
        prefixlen = prefix ? strlen(prefix) : 0;
        while (*src) {
                const char *p = prefix_path(prefix, prefixlen, *src);
-               if (p)
-                       *(dst++) = p;
-               else
-                       exit(128); /* error message already given */
+               *(dst++) = p;
                src++;
        }
        *dst = NULL;
index 70ff904717c2ffed12a70b988b1aa4dea3a896e2..ea6bd996b2953e876a02fcf972229c97cb7d590a 100644 (file)
@@ -1571,11 +1571,9 @@ static void *cache_or_unpack_entry(struct packed_git *p, off_t base_offset,
        struct delta_base_cache_entry *ent = delta_base_cache + hash;
 
        ret = ent->data;
-       if (ret && ent->p == p && ent->base_offset == base_offset)
-               goto found_cache_entry;
-       return unpack_entry(p, base_offset, type, base_size);
+       if (!ret || ent->p != p || ent->base_offset != base_offset)
+               return unpack_entry(p, base_offset, type, base_size);
 
-found_cache_entry:
        if (!keep_cache) {
                ent->data = NULL;
                ent->lru.next->prev = ent->lru.prev;
@@ -2132,16 +2130,16 @@ static void write_sha1_file_prepare(const void *buf, unsigned long len,
                                     const char *type, unsigned char *sha1,
                                     char *hdr, int *hdrlen)
 {
-       SHA_CTX c;
+       git_SHA_CTX c;
 
        /* Generate the header */
        *hdrlen = sprintf(hdr, "%s %lu", type, len)+1;
 
        /* Sha1.. */
-       SHA1_Init(&c);
-       SHA1_Update(&c, hdr, *hdrlen);
-       SHA1_Update(&c, buf, len);
-       SHA1_Final(sha1, &c);
+       git_SHA1_Init(&c);
+       git_SHA1_Update(&c, hdr, *hdrlen);
+       git_SHA1_Update(&c, buf, len);
+       git_SHA1_Final(sha1, &c);
 }
 
 /*
index 620da5b32041b1ad69bfdcb6d139f2705386a5ff..5ac0a273a94c033fbb7c48cb9a22e44c389e0f7d 100755 (executable)
@@ -167,4 +167,36 @@ test_expect_success 'init with --template (blank)' '
        ! test -f template-blank/.git/info/exclude
 '
 
+test_expect_success 'init --bare/--shared overrides system/global config' '
+       (
+               HOME="`pwd`" &&
+               export HOME &&
+               test_config="$HOME"/.gitconfig &&
+               unset GIT_CONFIG_NOGLOBAL &&
+               git config -f "$test_config" core.bare false &&
+               git config -f "$test_config" core.sharedRepository 0640 &&
+               mkdir init-bare-shared-override &&
+               cd init-bare-shared-override &&
+               git init --bare --shared=0666
+       ) &&
+       check_config init-bare-shared-override true unset &&
+       test x0666 = \
+       x`git config -f init-bare-shared-override/config core.sharedRepository`
+'
+
+test_expect_success 'init honors global core.sharedRepository' '
+       (
+               HOME="`pwd`" &&
+               export HOME &&
+               test_config="$HOME"/.gitconfig &&
+               unset GIT_CONFIG_NOGLOBAL &&
+               git config -f "$test_config" core.sharedRepository 0666 &&
+               mkdir shared-honor-global &&
+               cd shared-honor-global &&
+               git init
+       ) &&
+       test x0666 = \
+       x`git config -f shared-honor-global/.git/config core.sharedRepository`
+'
+
 test_done
diff --git a/t/t3409-rebase-hook.sh b/t/t3409-rebase-hook.sh
new file mode 100755 (executable)
index 0000000..bc93dda
--- /dev/null
@@ -0,0 +1,126 @@
+#!/bin/sh
+
+test_description='git rebase with its hook(s)'
+
+. ./test-lib.sh
+
+test_expect_success setup '
+       echo hello >file &&
+       git add file &&
+       test_tick &&
+       git commit -m initial &&
+       echo goodbye >file &&
+       git add file &&
+       test_tick &&
+       git commit -m second &&
+       git checkout -b side HEAD^ &&
+       echo world >git &&
+       git add git &&
+       test_tick &&
+       git commit -m side &&
+       git checkout master &&
+       git log --pretty=oneline --abbrev-commit --graph --all &&
+       git branch test side
+'
+
+test_expect_success 'rebase' '
+       git checkout test &&
+       git reset --hard side &&
+       git rebase master &&
+       test "z$(cat git)" = zworld
+'
+
+test_expect_success 'rebase -i' '
+       git checkout test &&
+       git reset --hard side &&
+       EDITOR=true git rebase -i master &&
+       test "z$(cat git)" = zworld
+'
+
+test_expect_success 'setup pre-rebase hook' '
+       mkdir -p .git/hooks &&
+       cat >.git/hooks/pre-rebase <<EOF &&
+#!$SHELL_PATH
+echo "\$1,\$2" >.git/PRE-REBASE-INPUT
+EOF
+       chmod +x .git/hooks/pre-rebase
+'
+
+test_expect_success 'pre-rebase hook gets correct input (1)' '
+       git checkout test &&
+       git reset --hard side &&
+       git rebase master &&
+       test "z$(cat git)" = zworld &&
+       test "z$(cat .git/PRE-REBASE-INPUT)" = zmaster,
+
+'
+
+test_expect_success 'pre-rebase hook gets correct input (2)' '
+       git checkout test &&
+       git reset --hard side &&
+       git rebase master test &&
+       test "z$(cat git)" = zworld &&
+       test "z$(cat .git/PRE-REBASE-INPUT)" = zmaster,test
+'
+
+test_expect_success 'pre-rebase hook gets correct input (3)' '
+       git checkout test &&
+       git reset --hard side &&
+       git checkout master &&
+       git rebase master test &&
+       test "z$(cat git)" = zworld &&
+       test "z$(cat .git/PRE-REBASE-INPUT)" = zmaster,test
+'
+
+test_expect_success 'pre-rebase hook gets correct input (4)' '
+       git checkout test &&
+       git reset --hard side &&
+       EDITOR=true git rebase -i master &&
+       test "z$(cat git)" = zworld &&
+       test "z$(cat .git/PRE-REBASE-INPUT)" = zmaster,
+
+'
+
+test_expect_success 'pre-rebase hook gets correct input (5)' '
+       git checkout test &&
+       git reset --hard side &&
+       EDITOR=true git rebase -i master test &&
+       test "z$(cat git)" = zworld &&
+       test "z$(cat .git/PRE-REBASE-INPUT)" = zmaster,test
+'
+
+test_expect_success 'pre-rebase hook gets correct input (6)' '
+       git checkout test &&
+       git reset --hard side &&
+       git checkout master &&
+       EDITOR=true git rebase -i master test &&
+       test "z$(cat git)" = zworld &&
+       test "z$(cat .git/PRE-REBASE-INPUT)" = zmaster,test
+'
+
+test_expect_success 'setup pre-rebase hook that fails' '
+       mkdir -p .git/hooks &&
+       cat >.git/hooks/pre-rebase <<EOF &&
+#!$SHELL_PATH
+false
+EOF
+       chmod +x .git/hooks/pre-rebase
+'
+
+test_expect_success 'pre-rebase hook stops rebase (1)' '
+       git checkout test &&
+       git reset --hard side &&
+       test_must_fail git rebase master &&
+       test "z$(git symbolic-ref HEAD)" = zrefs/heads/test &&
+       test 0 = $(git rev-list HEAD...side | wc -l)
+'
+
+test_expect_success 'pre-rebase hook stops rebase (2)' '
+       git checkout test &&
+       git reset --hard side &&
+       EDITOR=true test_must_fail git rebase -i master &&
+       test "z$(git symbolic-ref HEAD)" = zrefs/heads/test &&
+       test 0 = $(git rev-list HEAD...side | wc -l)
+'
+
+test_done
index 558c80edbfa5c0c90566a0be94723e2783d6df9b..66aca99fd32c6b98f5e6e34a3cf7b096b3e236cf 100755 (executable)
@@ -219,14 +219,23 @@ test_expect_success 'Remove nonexistent file returns nonzero exit status' '
 
 test_expect_success 'Call "rm" from outside the work tree' '
        mkdir repo &&
-       cd repo &&
-       git init &&
-       echo something > somefile &&
-       git add somefile &&
-       git commit -m "add a file" &&
-       (cd .. &&
-        git --git-dir=repo/.git --work-tree=repo rm somefile) &&
-       test_must_fail git ls-files --error-unmatch somefile
+       (cd repo &&
+        git init &&
+        echo something > somefile &&
+        git add somefile &&
+        git commit -m "add a file" &&
+        (cd .. &&
+         git --git-dir=repo/.git --work-tree=repo rm somefile) &&
+       test_must_fail git ls-files --error-unmatch somefile)
+'
+
+test_expect_success 'refresh index before checking if it is up-to-date' '
+
+       git reset --hard &&
+       test-chmtime -86400 frotz/nitfol &&
+       git rm frotz/nitfol &&
+       test ! -f frotz/nitfol
+
 '
 
 test_done
index b8ec6e90afb970b1b2540e30901b2f058522544e..421f4bba3fbc666cf2ab7ec4289f10d29d61eebb 100755 (executable)
@@ -77,4 +77,25 @@ test_expect_success 'apply binary patch' \
         tree1=`git write-tree` &&
         test "$tree1" = "$tree0"'
 
+q_to_nul() {
+       perl -pe 'y/Q/\000/'
+}
+
+nul_to_q() {
+       perl -pe 'y/\000/Q/'
+}
+
+test_expect_success 'diff --no-index with binary creation' '
+       echo Q | q_to_nul >binary &&
+       (:# hide error code from diff, which just indicates differences
+        git diff --binary --no-index /dev/null binary >current ||
+        true
+       ) &&
+       rm binary &&
+       git apply --binary <current &&
+       echo Q >expected &&
+       nul_to_q <binary >actual &&
+       test_cmp expected actual
+'
+
 test_done
diff --git a/t/t7403-submodule-sync.sh b/t/t7403-submodule-sync.sh
new file mode 100755 (executable)
index 0000000..7538756
--- /dev/null
@@ -0,0 +1,64 @@
+#!/bin/sh
+#
+# Copyright (c) 2008 David Aguilar
+#
+
+test_description='git submodule sync
+
+These tests exercise the "git submodule sync" subcommand.
+'
+
+. ./test-lib.sh
+
+test_expect_success setup '
+       echo file > file &&
+       git add file &&
+       test_tick &&
+       git commit -m upstream
+       git clone . super &&
+       git clone super submodule &&
+       (cd super &&
+        git submodule add ../submodule submodule &&
+        test_tick &&
+        git commit -m "submodule"
+       ) &&
+       git clone super super-clone &&
+       (cd super-clone && git submodule update --init)
+'
+
+test_expect_success 'change submodule' '
+       (cd submodule &&
+        echo second line >> file &&
+        test_tick &&
+        git commit -a -m "change submodule"
+       )
+'
+
+test_expect_success 'change submodule url' '
+       (cd super &&
+        cd submodule &&
+        git checkout master &&
+        git pull
+       ) &&
+       mv submodule moved-submodule &&
+       (cd super &&
+        git config -f .gitmodules submodule.submodule.url ../moved-submodule
+        test_tick &&
+        git commit -a -m moved-submodule
+       )
+'
+
+test_expect_success '"git submodule sync" should update submodule URLs' '
+       (cd super-clone &&
+        git pull &&
+        git submodule sync
+       ) &&
+       test -d "$(git config -f super-clone/submodule/.git/config \
+                               remote.origin.url)" &&
+       (cd super-clone/submodule &&
+        git checkout master &&
+        git pull
+       )
+'
+
+test_done
index 9516f541e9c47f83fed2fc8d3baa065a9bb206de..7313ac278cb7cb1d741e49f261e65d929ddeffb7 100755 (executable)
@@ -511,4 +511,13 @@ test_expect_success 'in-index merge' '
 
 test_debug 'gitk --all'
 
+test_expect_success 'refresh the index before merging' '
+       git reset --hard c1 &&
+       sleep 1 &&
+       touch file &&
+       git merge c3
+'
+
+test_debug 'gitk --all'
+
 test_done
index 07117a8b7d9cdd95ebf013e11b9474667ac0bfd3..64c4cce58b85e7948d5c3a769f437ebfda1daab7 100755 (executable)
@@ -502,6 +502,55 @@ test_expect_success \
         gitweb_run "p=.git;a=history;f=deleted_file"'
 test_debug 'cat gitweb.log'
 
+# ----------------------------------------------------------------------
+# path_info links
+test_expect_success \
+       'path_info: project' \
+       'gitweb_run "" "/.git"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       'path_info: project/branch' \
+       'gitweb_run "" "/.git/b"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       'path_info: project/branch:file' \
+       'gitweb_run "" "/.git/master:file"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       'path_info: project/branch:dir/' \
+       'gitweb_run "" "/.git/master:foo/"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       'path_info: project/branch:file (non-existent)' \
+       'gitweb_run "" "/.git/master:non-existent"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       'path_info: project/branch:dir/ (non-existent)' \
+       'gitweb_run "" "/.git/master:non-existent/"'
+test_debug 'cat gitweb.log'
+
+
+test_expect_success \
+       'path_info: project/branch:/file' \
+       'gitweb_run "" "/.git/master:/file"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       'path_info: project/:/file (implicit HEAD)' \
+       'gitweb_run "" "/.git/:/file"'
+test_debug 'cat gitweb.log'
+
+test_expect_success \
+       'path_info: project/:/ (implicit HEAD, top tree)' \
+       'gitweb_run "" "/.git/:/"'
+test_debug 'cat gitweb.log'
+
+
 # ----------------------------------------------------------------------
 # feed generation
 
index 78d7e983a7a05ba0652132425a66477ef5773304..9b98d07c786b36f005f4b3ffd51926f3c1a343dd 100644 (file)
@@ -2,7 +2,7 @@
 
 int main(int ac, char **av)
 {
-       SHA_CTX ctx;
+       git_SHA_CTX ctx;
        unsigned char sha1[20];
        unsigned bufsz = 8192;
        char *buffer;
@@ -20,7 +20,7 @@ int main(int ac, char **av)
                        die("OOPS");
        }
 
-       SHA1_Init(&ctx);
+       git_SHA1_Init(&ctx);
 
        while (1) {
                ssize_t sz, this_sz;
@@ -39,9 +39,9 @@ int main(int ac, char **av)
                }
                if (this_sz == 0)
                        break;
-               SHA1_Update(&ctx, buffer, this_sz);
+               git_SHA1_Update(&ctx, buffer, this_sz);
        }
-       SHA1_Final(sha1, &ctx);
+       git_SHA1_Final(sha1, &ctx);
        puts(sha1_to_hex(sha1));
        exit(0);
 }
index f7db5d91103c09a8cdc9bdbd27de4b0d4a15ea73..5110c56c4e80dc224ff3308e643fad6d5ed77ffb 100644 (file)
@@ -643,8 +643,8 @@ static int fetch_refs_via_pack(struct transport *transport,
        args.use_thin_pack = data->thin;
        args.include_tag = data->followtags;
        args.verbose = (transport->verbose > 0);
-       args.quiet = args.no_progress = (transport->verbose < 0);
-       args.no_progress = !isatty(1);
+       args.quiet = (transport->verbose < 0);
+       args.no_progress = args.quiet || !isatty(1);
        args.depth = data->depth;
 
        for (i = 0; i < nr_heads; i++)