Code

Merge branch 'dz/apply-again'
authorJunio C Hamano <gitster@pobox.com>
Tue, 1 Jul 2008 23:22:10 +0000 (16:22 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 1 Jul 2008 23:22:10 +0000 (16:22 -0700)
* dz/apply-again:
  git-apply: handle a patch that touches the same path more than once better

31 files changed:
Documentation/RelNotes-1.6.0.txt
Documentation/asciidoc.conf
Documentation/config.txt
Documentation/git-parse-remote.txt
Documentation/git-rev-parse.txt
Documentation/git-sh-setup.txt
Documentation/git-svn.txt
Documentation/gitcli.txt
GIT-VERSION-GEN
Makefile
abspath.c [new file with mode: 0644]
builtin-cat-file.c
builtin-commit-tree.c
builtin-upload-archive.c
check_bindir [new file with mode: 0755]
config.mak.in
contrib/completion/git-completion.bash
diff.c
environment.c
exec_cmd.c
git-repack.sh
git-svn.perl
git.c
git.spec.in
help.c
pack-write.c
path.c
quote.c
shell.c
t/.gitignore
t/t9700-perl-git.sh

index 5292bd730c30f2480221910b1a4c2de6c93cdb26..03e3a59ff5ba7660e2f660d4e5194c5cc81d5c18 100644 (file)
@@ -7,20 +7,16 @@ User visible changes
 [[Note that none of these are not merged to 'master' as of this writing
 but they will be before 1.6.0 happens]]
 
-With default Makefile settings, most of the programs are now installed
-outside your $PATH, except for "git", "gitk", "git-gui" and some server
-side programs that needs to be accessible when connecting over ssh.
-
-When talking to remote repository over ssh, necessary server side programs
-are now invoked with "git $program" notation, not with "git-$program"
-notation.  This should work with both servers running older git where you
-had all of these programs installed on $PATH, or newer git where you have
-only "git" on $PATH.  However, if the remote side is running a custom
-software that restricts programs you can run over ssh, it might cause
-problems.  Use --upload-pack="git-upload-pack" (when using ls-remote,
-fetch and pull on the client side), --receive-pack="git-receive-pack"
-(when using push on the client side), or --exec="git-upload-archive" (when
-using git-archive) as appropriate when talking to such a remote.
+With the default Makefile settings, most of the programs are now
+installed outside your $PATH, except for "git", "gitk", "git-gui" and
+some server side programs that need to be accessible for technical
+reasons.  Invoking a git subcommand as "git-xyzzy" from the command
+line has been deprecated since early 2006 (and officially announced in
+1.5.4 release notes); use of them from your scripts after adding
+output from "git --exec-path" to the $PATH is still supported in this
+release, but users are again strongly encouraged to adjust their
+scripts to use "git xyzzy" form, as we will stop installing
+"git-xyzzy" hardlinks for built-in commands in later releases.
 
 Source changes needed for porting to MinGW environment are now all in the
 main git.git codebase.
@@ -31,6 +27,9 @@ Updates since v1.5.6
 
 (subsystems)
 
+* git-p4 in contrib learned "allowSubmit" configuration to control on
+  which branch to allow "submit" subcommand.
+
 (portability)
 
 * Sample hook scripts shipped in templates/ are now suffixed with
@@ -47,7 +46,13 @@ Updates since v1.5.6
 
 * Updated howto/update-hook-example
 
-(performance, robustness etc.)
+* Got rid of usage of "git-foo" from the tutorial.
+
+* Disambiguating "--" between revs and paths is finally documented.
+
+(performance, robustness, sanity etc.)
+
+* even more documentation pages are now accessible via "man" and "git help".
 
 * reduced excessive inlining to shrink size of the "git" binary.
 
@@ -67,6 +72,9 @@ Updates since v1.5.6
   objects created will be fsync'ed (this is only useful on filesystems
   that does not order data writes properly).
 
+* "git commit-tree" plumbing can make Octopus with more than 16 parents.
+  "git commit" has been capable of this for quite some time.
+
 (usability, bells and whistles)
 
 * git-archive can be told to omit certain paths from its output using
@@ -100,6 +108,6 @@ this release, unless otherwise noted.
 
 ---
 exec >/var/tmp/1
-O=v1.5.6.1-77-gf9a08f6
+O=v1.5.6.1-104-ga08b868
 echo O=$(git describe refs/heads/master)
 git shortlog --no-merges $O..refs/heads/master ^refs/heads/maint
index 10c1a151a4c38fa594bd83f124f4b654dcfd11e3..40d43b78ee9d6c3827bcf631c1f41f54d0e3dfbc 100644 (file)
@@ -8,6 +8,7 @@
 # the command.
 
 [attributes]
+asterisk=&#42;
 plus=&#43;
 caret=&#94;
 startsb=&#91;
index 90c8a45a2f8dc70e61b32d5e3e10d7054c67e3ad..561ff645f96af3a53a6d43c4d9320090aef623e8 100644 (file)
@@ -945,9 +945,17 @@ pack.indexVersion::
        legacy pack index used by Git versions prior to 1.5.2, and 2 for
        the new pack index with capabilities for packs larger than 4 GB
        as well as proper protection against the repacking of corrupted
-       packs.  Version 2 is selected and this config option ignored
-       whenever the corresponding pack is larger than 2 GB.  Otherwise
-       the default is 1.
+       packs.  Version 2 is the default.  Note that version 2 is enforced
+       and this config option ignored whenever the corresponding pack is
+       larger than 2 GB.
++
+If you have an old git that does not understand the version 2 `{asterisk}.idx` file,
+cloning or fetching over a non native protocol (e.g. "http" and "rsync")
+that will copy both `{asterisk}.pack` file and corresponding `{asterisk}.idx` file from the
+other side may give you a repository that cannot be accessed with your
+older version of git. If the `{asterisk}.pack` file is smaller than 2 GB, however,
+you can use linkgit:git-index-pack[1] on the *.pack file to regenerate
+the `{asterisk}.idx` file.
 
 pack.packSizeLimit::
        The default maximum size of a pack.  This setting only affects
@@ -1004,12 +1012,12 @@ remotes.<group>::
        <group>".  See linkgit:git-remote[1].
 
 repack.usedeltabaseoffset::
-       Allow linkgit:git-repack[1] to create packs that uses
-       delta-base offset.  Defaults to false.
-
-show.difftree::
-       The default linkgit:git-diff-tree[1] arguments to be used
-       for linkgit:git-show[1].
+       By default, linkgit:git-repack[1] creates packs that use
+       delta-base offset. If you need to share your repository with
+       git older than version 1.4.4, either directly or via a dumb
+       protocol such as http, then you need to set this option to
+       "false" and repack. Access from old git versions over the
+       native protocol are unaffected by this option.
 
 showbranch.default::
        The default set of branches for linkgit:git-show-branch[1].
@@ -1075,10 +1083,6 @@ user.signingkey::
        unchanged to gpg's --local-user parameter, so you may specify a key
        using any method that gpg supports.
 
-whatchanged.difftree::
-       The default linkgit:git-diff-tree[1] arguments to be used
-       for linkgit:git-whatchanged[1].
-
 imap::
        The configuration variables in the 'imap' section are described
        in linkgit:git-imap-send[1].
index 951dbd6c830a15cafaa7281cb1c6de357d97b4cc..421312eca91d68711a08e6747e7730d77ba006aa 100644 (file)
@@ -8,7 +8,7 @@ git-parse-remote - Routines to help parsing remote repository access parameters
 
 SYNOPSIS
 --------
-'. git-parse-remote'
+'. "$(git --exec-path)/git-parse-remote"'
 
 DESCRIPTION
 -----------
index 9e273bc5a6ee091ad7b81254228d33fd4df5541e..59e95adf42d1d481d636929a0b3ad79eebc53426 100644 (file)
@@ -184,7 +184,10 @@ blobs contained in a commit.
   second ago\}' or '\{1979-02-26 18:30:00\}') to specify the value
   of the ref at a prior point in time.  This suffix may only be
   used immediately following a ref name and the ref must have an
-  existing log ($GIT_DIR/logs/<ref>).
+  existing log ($GIT_DIR/logs/<ref>). Note that this looks up the state
+  of your *local* ref at a given time; e.g., what was in your local
+  `master` branch last week. If you want to look at commits made during
+  certain times, see `--since` and `--until`.
 
 * A ref followed by the suffix '@' with an ordinal specification
   enclosed in a brace pair (e.g. '\{1\}', '\{15\}') to specify
index c543170342030e318e87e75c29f23334655ee7ce..6731f9ac4cc15a757600375307e4a10e32f4424a 100644 (file)
@@ -7,7 +7,7 @@ git-sh-setup - Common git shell script setup code
 
 SYNOPSIS
 --------
-'git-sh-setup'
+'. "$(git --exec-path)/git-sh-setup"'
 
 DESCRIPTION
 -----------
index 97bed54fbde18a1e7c5516382a54b341fc81668e..c350ad0f83b413fa4c7810195f64cdfbbfdd1717 100644 (file)
@@ -513,7 +513,7 @@ have each person clone that repository with 'git clone':
        cd project
        git-init
        git remote add origin server:/pub/project
-       git config --add remote.origin.fetch=+refs/remotes/*:refs/remotes/*
+       git config --add remote.origin.fetch '+refs/remotes/*:refs/remotes/*'
        git fetch
 # Initialize git-svn locally (be sure to use the same URL and -T/-b/-t options as were used on server)
        git-svn init http://svn.foo.org/project
index 8fb5d889e5757ad5c25717c4d9ed0a3ef378f794..23160498659a1e315ecd2976dfc348f28d26469c 100644 (file)
@@ -13,8 +13,37 @@ gitcli
 DESCRIPTION
 -----------
 
-This manual describes best practice in how to use git CLI.  Here are
-the rules that you should follow when you are scripting git:
+This manual describes the convention used throughout git CLI.
+
+Many commands take revisions (most often "commits", but sometimes
+"tree-ish", depending on the context and command) and paths as their
+arguments.  Here are the rules:
+
+ * Revisions come first and then paths.
+   E.g. in `git diff v1.0 v2.0 arch/x86 include/asm-x86`,
+   `v1.0` and `v2.0` are revisions and `arch/x86` and `include/asm-x86`
+   are paths.
+
+ * When an argument can be misunderstood as either a revision or a path,
+   they can be disambiguated by placing `\--` between them.
+   E.g. `git diff \-- HEAD` is, "I have a file called HEAD in my work
+   tree.  Please show changes between the version I staged in the index
+   and what I have in the work tree for that file". not "show difference
+   between the HEAD commit and the work tree as a whole".  You can say
+   `git diff HEAD \--` to ask for the latter.
+
+ * Without disambiguating `\--`, git makes a reasonable guess, but errors
+   out and asking you to disambiguate when ambiguous.  E.g. if you have a
+   file called HEAD in your work tree, `git diff HEAD` is ambiguous, and
+   you have to say either `git diff HEAD \--` or `git diff \-- HEAD` to
+   disambiguate.
+
+When writing a script that is expected to handle random user-input, it is
+a good practice to make it explicit which arguments are which by placing
+disambiguating `\--` at appropriate places.
+
+Here are the rules regarding the "flags" that you should follow when you are
+scripting git:
 
  * it's preferred to use the non dashed form of git commands, which means that
    you should prefer `"git foo"` to `"git-foo"`.
@@ -34,8 +63,8 @@ the rules that you should follow when you are scripting git:
    if you happen to have a file called `HEAD` in the work tree.
 
 
-ENHANCED CLI
-------------
+ENHANCED OPTION PARSER
+----------------------
 From the git 1.5.4 series and further, many git commands (not all of them at the
 time of the writing though) come with an enhanced option parser.
 
index f221447478aea8628c0ab6d098338f7e8630201e..cb7cd4b53827fa6820e84b1318572d0115b3b17f 100755 (executable)
@@ -16,7 +16,7 @@ elif test -d .git -o -f .git &&
        case "$VN" in
        *$LF*) (exit 1) ;;
        v[0-9]*)
-               test -z "$(git diff-index --name-only HEAD)" ||
+               test -z "$(git diff-index --name-only HEAD --)" ||
                VN="$VN-dirty" ;;
        esac
 then
index 3584b8ccdf030c62012f650a2d02127dc01d4a92..ba16f267932ef4bd270b17e789851c12ef70785e 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -174,7 +174,7 @@ prefix = $(HOME)
 bindir = $(prefix)/bin
 mandir = $(prefix)/share/man
 infodir = $(prefix)/share/info
-gitexecdir = $(bindir)
+gitexecdir = $(prefix)/libexec/git-core
 sharedir = $(prefix)/share
 template_dir = $(sharedir)/git-core/templates
 htmldir=$(sharedir)/doc/git-doc
@@ -378,6 +378,7 @@ LIB_H += unpack-trees.h
 LIB_H += utf8.h
 LIB_H += wt-status.h
 
+LIB_OBJS += abspath.o
 LIB_OBJS += alias.o
 LIB_OBJS += alloc.o
 LIB_OBJS += archive.o
@@ -1271,7 +1272,7 @@ install: all
        $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'
        $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitexecdir_SQ)'
        $(INSTALL) $(ALL_PROGRAMS) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
-       $(INSTALL) git$X '$(DESTDIR_SQ)$(bindir_SQ)'
+       $(INSTALL) git$X git-upload-pack$X git-receive-pack$X git-upload-archive$X '$(DESTDIR_SQ)$(bindir_SQ)'
        $(MAKE) -C templates DESTDIR='$(DESTDIR_SQ)' install
        $(MAKE) -C perl prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' install
 ifndef NO_TCLTK
@@ -1289,6 +1290,7 @@ endif
 ifneq (,$X)
        $(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) git$X)), $(RM) '$(DESTDIR_SQ)$(gitexecdir_SQ)/$p';)
 endif
+       ./check_bindir 'z$(bindir_SQ)' 'z$(gitexecdir_SQ)' '$(DESTDIR_SQ)$(bindir_SQ)/git-shell$X'
 
 install-doc:
        $(MAKE) -C Documentation install
diff --git a/abspath.c b/abspath.c
new file mode 100644 (file)
index 0000000..4f95a95
--- /dev/null
+++ b/abspath.c
@@ -0,0 +1,68 @@
+#include "cache.h"
+
+/* We allow "recursive" symbolic links. Only within reason, though. */
+#define MAXDEPTH 5
+
+const char *make_absolute_path(const char *path)
+{
+       static char bufs[2][PATH_MAX + 1], *buf = bufs[0], *next_buf = bufs[1];
+       char cwd[1024] = "";
+       int buf_index = 1, len;
+
+       int depth = MAXDEPTH;
+       char *last_elem = NULL;
+       struct stat st;
+
+       if (strlcpy(buf, path, PATH_MAX) >= PATH_MAX)
+               die ("Too long path: %.*s", 60, path);
+
+       while (depth--) {
+               if (stat(buf, &st) || !S_ISDIR(st.st_mode)) {
+                       char *last_slash = strrchr(buf, '/');
+                       if (last_slash) {
+                               *last_slash = '\0';
+                               last_elem = xstrdup(last_slash + 1);
+                       } else {
+                               last_elem = xstrdup(buf);
+                               *buf = '\0';
+                       }
+               }
+
+               if (*buf) {
+                       if (!*cwd && !getcwd(cwd, sizeof(cwd)))
+                               die ("Could not get current working directory");
+
+                       if (chdir(buf))
+                               die ("Could not switch to '%s'", buf);
+               }
+               if (!getcwd(buf, PATH_MAX))
+                       die ("Could not get current working directory");
+
+               if (last_elem) {
+                       int len = strlen(buf);
+                       if (len + strlen(last_elem) + 2 > PATH_MAX)
+                               die ("Too long path name: '%s/%s'",
+                                               buf, last_elem);
+                       buf[len] = '/';
+                       strcpy(buf + len + 1, last_elem);
+                       free(last_elem);
+                       last_elem = NULL;
+               }
+
+               if (!lstat(buf, &st) && S_ISLNK(st.st_mode)) {
+                       len = readlink(buf, next_buf, PATH_MAX);
+                       if (len < 0)
+                               die ("Invalid symlink: %s", buf);
+                       next_buf[len] = '\0';
+                       buf = next_buf;
+                       buf_index = 1 - buf_index;
+                       next_buf = bufs[buf_index];
+               } else
+                       break;
+       }
+
+       if (*cwd && chdir(cwd))
+               die ("Could not change back to '%s'", cwd);
+
+       return buf;
+}
index bd343efae7d6cc6fddef4df5c3433b97bd640d3c..880e75af5e1951689a417aa47e64f99a20d46ae6 100644 (file)
@@ -181,6 +181,7 @@ static int batch_one_object(const char *obj_name, int print_contents)
                write_or_die(1, contents, size);
                printf("\n");
                fflush(stdout);
+               free(contents);
        }
 
        return 0;
index e5e4bdbe862b23aafe932da411f597b0f3b5c997..3881f6c2f56f317726a688e44b98806987036999 100644 (file)
@@ -24,26 +24,20 @@ static void check_valid(unsigned char *sha1, enum object_type expect)
                    typename(expect));
 }
 
-/*
- * Having more than two parents is not strange at all, and this is
- * how multi-way merges are represented.
- */
-#define MAXPARENT (16)
-static unsigned char parent_sha1[MAXPARENT][20];
-
 static const char commit_tree_usage[] = "git-commit-tree <sha1> [-p <sha1>]* < changelog";
 
-static int new_parent(int idx)
+static void new_parent(struct commit *parent, struct commit_list **parents_p)
 {
-       int i;
-       unsigned char *sha1 = parent_sha1[idx];
-       for (i = 0; i < idx; i++) {
-               if (!hashcmp(parent_sha1[i], sha1)) {
+       unsigned char *sha1 = parent->object.sha1;
+       struct commit_list *parents;
+       for (parents = *parents_p; parents; parents = parents->next) {
+               if (parents->item == parent) {
                        error("duplicate parent %s ignored", sha1_to_hex(sha1));
-                       return 0;
+                       return;
                }
+               parents_p = &parents->next;
        }
-       return 1;
+       commit_list_insert(parent, parents_p);
 }
 
 static const char commit_utf8_warn[] =
@@ -54,7 +48,7 @@ static const char commit_utf8_warn[] =
 int cmd_commit_tree(int argc, const char **argv, const char *prefix)
 {
        int i;
-       int parents = 0;
+       struct commit_list *parents = NULL;
        unsigned char tree_sha1[20];
        unsigned char commit_sha1[20];
        struct strbuf buffer;
@@ -69,18 +63,16 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)
 
        check_valid(tree_sha1, OBJ_TREE);
        for (i = 2; i < argc; i += 2) {
+               unsigned char sha1[20];
                const char *a, *b;
                a = argv[i]; b = argv[i+1];
                if (!b || strcmp(a, "-p"))
                        usage(commit_tree_usage);
 
-               if (parents >= MAXPARENT)
-                       die("Too many parents (%d max)", MAXPARENT);
-               if (get_sha1(b, parent_sha1[parents]))
+               if (get_sha1(b, sha1))
                        die("Not a valid object name %s", b);
-               check_valid(parent_sha1[parents], OBJ_COMMIT);
-               if (new_parent(parents))
-                       parents++;
+               check_valid(sha1, OBJ_COMMIT);
+               new_parent(lookup_commit(sha1), &parents);
        }
 
        /* Not having i18n.commitencoding is the same as having utf-8 */
@@ -94,8 +86,13 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)
         * different order of parents will be a _different_ changeset even
         * if everything else stays the same.
         */
-       for (i = 0; i < parents; i++)
-               strbuf_addf(&buffer, "parent %s\n", sha1_to_hex(parent_sha1[i]));
+       while (parents) {
+               struct commit_list *next = parents->next;
+               strbuf_addf(&buffer, "parent %s\n",
+                       sha1_to_hex(parents->item->object.sha1));
+               free(parents);
+               parents = next;
+       }
 
        /* Person/date information */
        strbuf_addf(&buffer, "author %s\n", git_author_info(IDENT_ERROR_ON_NO_NAME));
index 48ae09e9b5268ce1f11cfba433680a147ca39f7e..371400d49a5ff9f6ce297d7af07eb3fd6426c9ee 100644 (file)
@@ -30,7 +30,7 @@ static int run_upload_archive(int argc, const char **argv, const char *prefix)
        if (argc != 2)
                usage(upload_archive_usage);
 
-       if (strlen(argv[1]) > sizeof(buf))
+       if (strlen(argv[1]) + 1 > sizeof(buf))
                die("insanely long repository name");
 
        strcpy(buf, argv[1]); /* enter-repo smudges its argument */
diff --git a/check_bindir b/check_bindir
new file mode 100755 (executable)
index 0000000..a1c4c3e
--- /dev/null
@@ -0,0 +1,13 @@
+#!/bin/sh
+bindir="$1"
+gitexecdir="$2"
+gitcmd="$3"
+if test "$bindir" != "$gitexecdir" -a -x "$gitcmd"
+then
+       echo
+       echo "!! You have installed git-* commands to new gitexecdir."
+       echo "!! Old version git-* commands still remain in bindir."
+       echo "!! Mixing two versions of Git will lead to problems."
+       echo "!! Please remove old version commands in bindir now."
+       echo
+fi
index 7868dfd93a8dab01927c3f5907733baf556e9b59..b776149531025c85f5665d971e6e072f0cc64893 100644 (file)
@@ -11,7 +11,7 @@ TCLTK_PATH = @TCLTK_PATH@
 prefix = @prefix@
 exec_prefix = @exec_prefix@
 bindir = @bindir@
-#gitexecdir = @libexecdir@/git-core/
+gitexecdir = @libexecdir@/git-core/
 datarootdir = @datarootdir@
 template_dir = @datadir@/git-core/templates/
 
index ebf7cde5c023c86ee7ed0751730e09d1245930da..3f46149853237fcded15d498f94b4ae3b174b79c 100755 (executable)
@@ -1041,7 +1041,6 @@ _git_config ()
                pull.octopus
                pull.twohead
                repack.useDeltaBaseOffset
-               show.difftree
                showbranch.default
                tar.umask
                transfer.unpackLimit
@@ -1050,7 +1049,6 @@ _git_config ()
                user.name
                user.email
                user.signingkey
-               whatchanged.difftree
                branch. remote.
        "
 }
diff --git a/diff.c b/diff.c
index 893942359bee551e4460449f66279f1a91ec6ab7..66851b5647c2a1a1b4853bb869d3eb707c117943 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -830,12 +830,12 @@ static void show_stats(struct diffstat_t* data, struct diff_options *options)
        /* Sanity: give at least 5 columns to the graph,
         * but leave at least 10 columns for the name.
         */
-       if (width < name_width + 15) {
-               if (name_width <= 25)
-                       width = name_width + 15;
-               else
-                       name_width = width - 15;
-       }
+       if (width < 25)
+               width = 25;
+       if (name_width < 10)
+               name_width = 10;
+       else if (width < name_width + 15)
+               name_width = width - 15;
 
        /* Find the longest filename and max number of changes */
        reset = diff_get_color_opt(options, DIFF_RESET);
index 084ac8a4361d5486456813149a1e673c07a7a0b2..4a88a17d54df19af51a4fe0596815badf32fce1f 100644 (file)
@@ -13,7 +13,6 @@ char git_default_email[MAX_GITNAME];
 char git_default_name[MAX_GITNAME];
 int user_ident_explicitly_given;
 int trust_executable_bit = 1;
-int quote_path_fully = 1;
 int has_symlinks = 1;
 int ignore_case;
 int assume_unchanged;
index e189caca629262334541ea8313d2931b06e67adf..0f8f4b5b7d9dea4458b9944dd81cf98c2e9a1322 100644 (file)
@@ -65,32 +65,25 @@ void setup_path(const char *cmd_path)
 
 int execv_git_cmd(const char **argv)
 {
-       struct strbuf cmd;
-       const char *tmp;
-
-       strbuf_init(&cmd, 0);
-       strbuf_addf(&cmd, "git-%s", argv[0]);
+       int argc;
+       const char **nargv;
 
-       /*
-        * argv[0] must be the git command, but the argv array
-        * belongs to the caller, and may be reused in
-        * subsequent loop iterations. Save argv[0] and
-        * restore it on error.
-        */
-       tmp = argv[0];
-       argv[0] = cmd.buf;
+       for (argc = 0; argv[argc]; argc++)
+               ; /* just counting */
+       nargv = xmalloc(sizeof(*nargv) * (argc + 2));
 
-       trace_argv_printf(argv, "trace: exec:");
+       nargv[0] = "git";
+       for (argc = 0; argv[argc]; argc++)
+               nargv[argc + 1] = argv[argc];
+       nargv[argc + 1] = NULL;
+       trace_argv_printf(nargv, "trace: exec:");
 
        /* execvp() can only ever return if it fails */
-       execvp(cmd.buf, (char **)argv);
+       execvp("git", (char **)nargv);
 
        trace_printf("trace: exec failed: %s\n", strerror(errno));
 
-       argv[0] = tmp;
-
-       strbuf_release(&cmd);
-
+       free(nargv);
        return -1;
 }
 
index 072d1b40f7d71aa731c90e9af158a0fe5cf89fde..8c3bc134add87f38a764f24c63b9e09f562ad6b1 100755 (executable)
@@ -44,11 +44,7 @@ do
        shift
 done
 
-# Later we will default repack.UseDeltaBaseOffset to true
-default_dbo=false
-
-case "`git config --bool repack.usedeltabaseoffset ||
-       echo $default_dbo`" in
+case "`git config --bool repack.usedeltabaseoffset || echo true`" in
 true)
        extra="$extra --delta-base-offset" ;;
 esac
index 4c9c59bc3ffb9ed2f8e808cf6849562669adfd18..f789a6eeca12ed34e6ef3746c3062e56f791d7e9 100755 (executable)
@@ -1462,13 +1462,6 @@ sub verify_remotes_sanity {
        }
 }
 
-# we allow more chars than remotes2config.sh...
-sub sanitize_remote_name {
-       my ($name) = @_;
-       $name =~ tr{A-Za-z0-9:,/+-}{.}c;
-       $name;
-}
-
 sub find_existing_remote {
        my ($url, $remotes) = @_;
        return undef if $no_reuse_existing;
@@ -2853,7 +2846,7 @@ sub _new {
        unless (defined $ref_id && length $ref_id) {
                $_[2] = $ref_id = $Git::SVN::default_ref_id;
        }
-       $_[1] = $repo_id = sanitize_remote_name($repo_id);
+       $_[1] = $repo_id;
        my $dir = "$ENV{GIT_DIR}/svn/$ref_id";
        $_[3] = $path = '' unless (defined $path);
        mkpath(["$ENV{GIT_DIR}/svn"]);
@@ -3243,7 +3236,9 @@ sub close_file {
                my ($tmp_fh, $tmp_filename) = File::Temp::tempfile(UNLINK => 1);
                my $result;
                while ($result = sysread($fh, my $string, 1024)) {
-                       syswrite($tmp_fh, $string, $result);
+                       my $wrote = syswrite($tmp_fh, $string, $result);
+                       defined($wrote) && $wrote == $result
+                               or croak("write $tmp_filename: $!\n");
                }
                defined $result or croak $!;
                close $tmp_fh or croak $!;
@@ -3251,6 +3246,7 @@ sub close_file {
                close $fh or croak $!;
 
                $hash = $::_repository->hash_and_insert_object($tmp_filename);
+               unlink($tmp_filename);
                $hash =~ /^[a-f\d]{40}$/ or die "not a sha1: $hash\n";
                close $fb->{base} or croak $!;
        } else {
@@ -4704,8 +4700,7 @@ sub minimize_connections {
 
                # skip existing cases where we already connect to the root
                if (($ra->{url} eq $ra->{repos_root}) ||
-                   (Git::SVN::sanitize_remote_name($ra->{repos_root}) eq
-                    $repo_id)) {
+                   ($ra->{repos_root} eq $repo_id)) {
                        $root_repos->{$ra->{url}} = $repo_id;
                        next;
                }
@@ -4744,8 +4739,7 @@ sub minimize_connections {
        foreach my $url (keys %$new_urls) {
                # see if we can re-use an existing [svn-remote "repo_id"]
                # instead of creating a(n ugly) new section:
-               my $repo_id = $root_repos->{$url} ||
-                             Git::SVN::sanitize_remote_name($url);
+               my $repo_id = $root_repos->{$url} || $url;
 
                my $fetch = $new_urls->{$url};
                foreach my $path (keys %$fetch) {
diff --git a/git.c b/git.c
index 59f0fcc1f2278d3234a7e4a306db56c7cfcde9a2..22ac5226def5c2dd4e699533255b84e18f630bfa 100644 (file)
--- a/git.c
+++ b/git.c
@@ -384,6 +384,36 @@ static void handle_internal_command(int argc, const char **argv)
        }
 }
 
+static void execv_dashed_external(const char **argv)
+{
+       struct strbuf cmd;
+       const char *tmp;
+
+       strbuf_init(&cmd, 0);
+       strbuf_addf(&cmd, "git-%s", argv[0]);
+
+       /*
+        * argv[0] must be the git command, but the argv array
+        * belongs to the caller, and may be reused in
+        * subsequent loop iterations. Save argv[0] and
+        * restore it on error.
+        */
+       tmp = argv[0];
+       argv[0] = cmd.buf;
+
+       trace_argv_printf(argv, "trace: exec:");
+
+       /* execvp() can only ever return if it fails */
+       execvp(cmd.buf, (char **)argv);
+
+       trace_printf("trace: exec failed: %s\n", strerror(errno));
+
+       argv[0] = tmp;
+
+       strbuf_release(&cmd);
+}
+
+
 int main(int argc, const char **argv)
 {
        const char *cmd = argv[0] ? argv[0] : "git-help";
@@ -448,7 +478,7 @@ int main(int argc, const char **argv)
                handle_internal_command(argc, argv);
 
                /* .. then try the external ones */
-               execv_git_cmd(argv);
+               execv_dashed_external(argv);
 
                /* It could be an alias -- this works around the insanity
                 * of overriding "git log" with "git show" by having
index 3d7f3ef4afeccefd56330342715cb89e73b94775..c6492e5be2763eab81358424ff625a34a5ff2fba 100644 (file)
@@ -117,6 +117,7 @@ find $RPM_BUILD_ROOT -type f -name '*.bs' -empty -exec rm -f {} ';'
 find $RPM_BUILD_ROOT -type f -name perllocal.pod -exec rm -f {} ';'
 
 (find $RPM_BUILD_ROOT%{_bindir} -type f | grep -vE "archimport|svn|cvs|email|gitk|git-gui|git-citool" | sed -e s@^$RPM_BUILD_ROOT@@)               > bin-man-doc-files
+(find $RPM_BUILD_ROOT%{_libexecdir}/git-core -type f | grep -vE "archimport|svn|cvs|email|gitk|git-gui|git-citool" | sed -e s@^$RPM_BUILD_ROOT@@)               >> bin-man-doc-files
 (find $RPM_BUILD_ROOT%{perl_vendorlib} -type f | sed -e s@^$RPM_BUILD_ROOT@@) >> perl-files
 %if %{!?_without_docs:1}0
 (find $RPM_BUILD_ROOT%{_mandir} $RPM_BUILD_ROOT/Documentation -type f | grep -vE "archimport|svn|git-cvs|email|gitk|git-gui|git-citool" | sed -e s@^$RPM_BUILD_ROOT@@ -e 's/$/*/' ) >> bin-man-doc-files
@@ -136,7 +137,7 @@ rm -rf $RPM_BUILD_ROOT
 
 %files svn
 %defattr(-,root,root)
-%{_bindir}/*svn*
+%{_libexecdir}/git-core/*svn*
 %doc Documentation/*svn*.txt
 %{!?_without_docs: %{_mandir}/man1/*svn*.1*}
 %{!?_without_docs: %doc Documentation/*svn*.html }
@@ -144,28 +145,28 @@ rm -rf $RPM_BUILD_ROOT
 %files cvs
 %defattr(-,root,root)
 %doc Documentation/*git-cvs*.txt
-%{_bindir}/*cvs*
+%{_libexecdir}/git-core/*cvs*
 %{!?_without_docs: %{_mandir}/man1/*cvs*.1*}
 %{!?_without_docs: %doc Documentation/*git-cvs*.html }
 
 %files arch
 %defattr(-,root,root)
 %doc Documentation/git-archimport.txt
-%{_bindir}/git-archimport
+%{_libexecdir}/git-core/git-archimport
 %{!?_without_docs: %{_mandir}/man1/git-archimport.1*}
 %{!?_without_docs: %doc Documentation/git-archimport.html }
 
 %files email
 %defattr(-,root,root)
 %doc Documentation/*email*.txt
-%{_bindir}/*email*
+%{_libexecdir}/git-core/*email*
 %{!?_without_docs: %{_mandir}/man1/*email*.1*}
 %{!?_without_docs: %doc Documentation/*email*.html }
 
 %files gui
 %defattr(-,root,root)
-%{_bindir}/git-gui
-%{_bindir}/git-citool
+%{_libexecdir}/git-core/git-gui
+%{_libexecdir}/git-core/git-citool
 %{_datadir}/git-gui/
 %{!?_without_docs: %{_mandir}/man1/git-gui.1*}
 %{!?_without_docs: %doc Documentation/git-gui.html}
diff --git a/help.c b/help.c
index 8aff94c64a1204f8a359e522a554f29c8f0fdc20..5d1a773ad7f3ed811c35a6b9fa8afe1697615cc8 100644 (file)
--- a/help.c
+++ b/help.c
@@ -527,20 +527,26 @@ static int is_git_command(const char *s)
                is_in_cmdlist(&other_cmds, s);
 }
 
+static const char *prepend(const char *prefix, const char *cmd)
+{
+       size_t pre_len = strlen(prefix);
+       size_t cmd_len = strlen(cmd);
+       char *p = xmalloc(pre_len + cmd_len + 1);
+       memcpy(p, prefix, pre_len);
+       strcpy(p + pre_len, cmd);
+       return p;
+}
+
 static const char *cmd_to_page(const char *git_cmd)
 {
        if (!git_cmd)
                return "git";
        else if (!prefixcmp(git_cmd, "git"))
                return git_cmd;
-       else {
-               int page_len = strlen(git_cmd) + 4;
-               char *p = xmalloc(page_len + 1);
-               strcpy(p, "git-");
-               strcpy(p + 4, git_cmd);
-               p[page_len] = 0;
-               return p;
-       }
+       else if (is_git_command(git_cmd))
+               return prepend("git-", git_cmd);
+       else
+               return prepend("git", git_cmd);
 }
 
 static void setup_man_path(void)
index f52cabe83829289dee7e44673b59a02db38918a5..a8f02699366c87de960d7637e9f69c26c2241693 100644 (file)
@@ -2,7 +2,7 @@
 #include "pack.h"
 #include "csum-file.h"
 
-uint32_t pack_idx_default_version = 1;
+uint32_t pack_idx_default_version = 2;
 uint32_t pack_idx_off32_limit = 0x7fffffff;
 
 static int sha1_compare(const void *_a, const void *_b)
diff --git a/path.c b/path.c
index 6e3df1849965be6a88fac89c007f9b5fe960f825..496123ca552a3aad32b009c668962045ec78d218 100644 (file)
--- a/path.c
+++ b/path.c
@@ -327,9 +327,6 @@ const char *make_nonrelative_path(const char *path)
        return buf;
 }
 
-/* We allow "recursive" symbolic links. Only within reason, though. */
-#define MAXDEPTH 5
-
 const char *make_relative_path(const char *abs, const char *base)
 {
        static char buf[PATH_MAX + 1];
@@ -346,67 +343,3 @@ const char *make_relative_path(const char *abs, const char *base)
        strcpy(buf, abs + baselen);
        return buf;
 }
-
-const char *make_absolute_path(const char *path)
-{
-       static char bufs[2][PATH_MAX + 1], *buf = bufs[0], *next_buf = bufs[1];
-       char cwd[1024] = "";
-       int buf_index = 1, len;
-
-       int depth = MAXDEPTH;
-       char *last_elem = NULL;
-       struct stat st;
-
-       if (strlcpy(buf, path, PATH_MAX) >= PATH_MAX)
-               die ("Too long path: %.*s", 60, path);
-
-       while (depth--) {
-               if (stat(buf, &st) || !S_ISDIR(st.st_mode)) {
-                       char *last_slash = strrchr(buf, '/');
-                       if (last_slash) {
-                               *last_slash = '\0';
-                               last_elem = xstrdup(last_slash + 1);
-                       } else {
-                               last_elem = xstrdup(buf);
-                               *buf = '\0';
-                       }
-               }
-
-               if (*buf) {
-                       if (!*cwd && !getcwd(cwd, sizeof(cwd)))
-                               die ("Could not get current working directory");
-
-                       if (chdir(buf))
-                               die ("Could not switch to '%s'", buf);
-               }
-               if (!getcwd(buf, PATH_MAX))
-                       die ("Could not get current working directory");
-
-               if (last_elem) {
-                       int len = strlen(buf);
-                       if (len + strlen(last_elem) + 2 > PATH_MAX)
-                               die ("Too long path name: '%s/%s'",
-                                               buf, last_elem);
-                       buf[len] = '/';
-                       strcpy(buf + len + 1, last_elem);
-                       free(last_elem);
-                       last_elem = NULL;
-               }
-
-               if (!lstat(buf, &st) && S_ISLNK(st.st_mode)) {
-                       len = readlink(buf, next_buf, PATH_MAX);
-                       if (len < 0)
-                               die ("Invalid symlink: %s", buf);
-                       next_buf[len] = '\0';
-                       buf = next_buf;
-                       buf_index = 1 - buf_index;
-                       next_buf = bufs[buf_index];
-               } else
-                       break;
-       }
-
-       if (*cwd && chdir(cwd))
-               die ("Could not change back to '%s'", cwd);
-
-       return buf;
-}
diff --git a/quote.c b/quote.c
index d5cf9d8f94f37fe8ff9f964998c7f0525617e5bc..6a520855d6c418ecb1384ef9571b122b134af1af 100644 (file)
--- a/quote.c
+++ b/quote.c
@@ -1,6 +1,8 @@
 #include "cache.h"
 #include "quote.h"
 
+int quote_path_fully = 1;
+
 /* Help to copy the thing properly quoted for the shell safety.
  * any single quote is replaced with '\'', any exclamation point
  * is replaced with '\!', and the whole thing is enclosed in a
diff --git a/shell.c b/shell.c
index b27d01c9e4ca51dc3259994da47f4d9a6e8344c3..91ca7de0827642fd949f861fca6991415853b1ce 100644 (file)
--- a/shell.c
+++ b/shell.c
@@ -3,6 +3,14 @@
 #include "exec_cmd.h"
 #include "strbuf.h"
 
+/* Stubs for functions that make no sense for git-shell. These stubs
+ * are provided here to avoid linking in external redundant modules.
+ */
+void release_pack_memory(size_t need, int fd){}
+void trace_argv_printf(const char **argv, const char *fmt, ...){}
+void trace_printf(const char *fmt, ...){}
+
+
 static int do_generic_cmd(const char *me, char *arg)
 {
        const char *my_argv[4];
index 11ffd910c1b5022e0bd3aa217147269c8e9ac29e..b27e280083867ac03c4abc188f0f37291eb123a0 100644 (file)
@@ -1 +1,2 @@
 /trash directory
+/test-results
index b2fb9ece9c9745fc7ce3240c88ca206b2dac7359..9706ee5773692bd8fcfbc9015ef062947c0a2da5 100755 (executable)
@@ -6,6 +6,11 @@
 test_description='perl interface (Git.pm)'
 . ./test-lib.sh
 
+perl -MTest::More -e 0 2>/dev/null || {
+       say_color skip "Perl Test::More unavailable, skipping test"
+       test_done
+}
+
 # set up test repository
 
 test_expect_success \