]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'jc/maint-reset-remove-unmerged-new' into maint
authorJunio C Hamano <gitster@pobox.com>
Sun, 2 Nov 2008 21:36:20 +0000 (13:36 -0800)
committerJunio C Hamano <gitster@pobox.com>
Sun, 2 Nov 2008 21:36:20 +0000 (13:36 -0800)
* jc/maint-reset-remove-unmerged-new:
  reset --hard/read-tree --reset -u: remove unmerged new paths

45 files changed:
Documentation/RelNotes-1.6.0.3.txt
Documentation/RelNotes-1.6.0.4.txt [new file with mode: 0644]
Documentation/SubmittingPatches
Documentation/asciidoc.conf
Documentation/diff-options.txt
Documentation/git-check-attr.txt
Documentation/git-commit.txt
Documentation/gitattributes.txt
Makefile
RelNotes
archive.c
branch.c
builtin-archive.c
builtin-checkout.c
builtin-commit.c
builtin-fetch-pack.c
builtin-pack-objects.c
builtin-revert.c
builtin-send-pack.c
bundle.c
cache.h
contrib/completion/git-completion.bash
contrib/examples/git-remote.perl
contrib/stats/packinfo.pl
diffcore-rename.c
git-add--interactive.perl
git-gui/lib/spellcheck.tcl
git-send-email.perl
git-svn.perl
index-pack.c
lockfile.c
pack-refs.c
path.c
refs.c
rerere.c
sha1_file.c
t/t1301-shared-repo.sh
t/t4018-diff-funcname.sh
t/t4128-apply-root.sh
t/t5000-tar-tree.sh
t/t5302-pack-index.sh
t/t7201-co.sh
test-chmtime.c
unpack-trees.c
xdiff-interface.c

index 214a400aa2e90cc104e90bd1e388a33b2be79c9b..ae0577836ae8b3ea73f8565acc42964d4144dd26 100644 (file)
@@ -24,6 +24,9 @@ Fixes since v1.6.0.2
 * "git diff --no-index" on binary files no longer outputs a bogus
   "diff --git" header line.
 
+* "git diff" hunk header patterns with multiple elements separated by LF
+  were not used correctly.
+
 * Hunk headers in "git diff" default to using extended regular
   expressions, fixing some of the internal patterns on non-GNU
   platforms.
@@ -31,9 +34,15 @@ Fixes since v1.6.0.2
 * New config "diff.*.xfuncname" exposes extended regular expressions
   for user specified hunk header patterns.
 
+* "git gc" when ejecting otherwise unreachable objects from packfiles into
+  loose form leaked memory.
+
 * "git index-pack" was recently broken and mishandled objects added by
   thin-pack completion processing under memory pressure.
 
+* "git index-pack" was recently broken and misbehaved when run from inside
+  .git/objects/pack/ directory.
+
 * "git stash apply sash@{1}" was fixed to error out.  Prior versions
   would have applied stash@{0} incorrectly.
 
@@ -47,6 +56,8 @@ Fixes since v1.6.0.2
 
 * "git remote show -v" now displays all URLs of a remote.
 
+* "git checkout -b branch" was confused when branch already existed.
+
 * "git checkout -q" once again suppresses the locally modified file list.
 
 * "git clone -q", "git fetch -q" asks remote side to not send
@@ -104,9 +115,3 @@ Fixes since v1.6.0.2
   ("git fetch") is still however supported.
 
 Many other documentation updates.
-
---
-exec >/var/tmp/1
-O=v1.6.0.2-95-g72d404d
-echo O=$(git describe maint)
-git shortlog --no-merges $O..maint
diff --git a/Documentation/RelNotes-1.6.0.4.txt b/Documentation/RelNotes-1.6.0.4.txt
new file mode 100644 (file)
index 0000000..4a4530b
--- /dev/null
@@ -0,0 +1,29 @@
+GIT v1.6.0.4 Release Notes
+==========================
+
+Fixes since v1.6.0.3
+--------------------
+
+* 'git-add -p' said "No changes" when only binary files were changed.
+
+* git-archive did not work correctly in bare repositories.
+
+* when we refuse to detect renames because there are too many new or
+  deleted files, we did not say how many there are.
+
+* 'git-push --mirror' tried and failed to push the stash; there is no
+  point in sending it to begin with.
+
+* 'git-send-email' had a small fd leak while scanning directory.
+
+* git-svn used deprecated 'git-foo' form of subcommand invocaition.
+
+* Plugged small memleaks here and there.
+
+* Also contains many documentation updates.
+
+--
+exec >/var/tmp/1
+O=v1.6.0.3-22-gc2163c6
+echo O=$(git describe maint)
+git shortlog --no-merges $O..maint
index 841bead9db18a025638570c10cac72bcf4791f68..c59edfa6a9d89aec712b61cb72f9f1605aacae86 100644 (file)
@@ -456,3 +456,30 @@ This should help you to submit patches inline using KMail.
 
 5) Back in the compose window: add whatever other text you wish to the
 message, complete the addressing and subject fields, and press send.
+
+
+Gmail
+-----
+
+Submitting properly formatted patches via Gmail is simple now that
+IMAP support is available. First, edit your ~/.gitconfig to specify your
+account settings:
+
+[imap]
+       folder = "[Gmail]/Drafts"
+       host = imaps://imap.gmail.com
+       user = user@gmail.com
+       pass = p4ssw0rd
+       port = 993
+       sslverify = false
+
+Next, ensure that your Gmail settings are correct. In "Settings" the
+"Use Unicode (UTF-8) encoding for outgoing messages" should be checked.
+
+Once your commits are ready to send to the mailing list, run the following
+command to send the patch emails to your Gmail Drafts folder.
+
+       $ git format-patch -M --stdout origin/master | git imap-send
+
+Go to your Gmail account, open the Drafts folder, find the patch email, fill
+in the To: and CC: fields and send away!
index 40d43b78ee9d6c3827bcf631c1f41f54d0e3dfbc..2da867d2f8dd1e5272d33571062bda5f169cd278 100644 (file)
@@ -40,6 +40,26 @@ endif::doctype-manpage[]
 </literallayout>
 {title#}</example>
 endif::docbook-xsl-172[]
+
+ifdef::docbook-xsl-172[]
+ifdef::doctype-manpage[]
+# The following two small workarounds insert a simple paragraph after screen
+[listingblock]
+<example><title>{title}</title>
+<screen>
+|
+</screen><simpara></simpara>
+{title#}</example>
+
+[verseblock]
+<formalpara{id? id="{id}"}><title>{title}</title><para>
+{title%}<literallayout{id? id="{id}"}>
+{title#}<literallayout>
+|
+</literallayout><simpara></simpara>
+{title#}</para></formalpara>
+endif::doctype-manpage[]
+endif::docbook-xsl-172[]
 endif::backend-docbook[]
 
 ifdef::doctype-manpage[]
index 746646bb3d09a16a5880fa6bff286389aae98870..45885bbbb2c39444a9640c79ab0ae5bc6d587939 100644 (file)
@@ -134,7 +134,8 @@ endif::git-format-patch[]
 --diff-filter=[ACDMRTUXB*]::
        Select only files that are Added (`A`), Copied (`C`),
        Deleted (`D`), Modified (`M`), Renamed (`R`), have their
-       type (mode) changed (`T`), are Unmerged (`U`), are
+       type (i.e. regular file, symlink, submodule, ...) changed (`T`),
+       are Unmerged (`U`), are
        Unknown (`X`), or have had their pairing Broken (`B`).
        Any combination of the filter characters may be used.
        When `*` (All-or-none) is added to the combination, all
index 2b821f2a1d70fa108ce279135fd5028453a04fd9..4b3c2b0b06e9821124759d0cc6240d0a1953d2fa 100644 (file)
@@ -22,6 +22,56 @@ OPTIONS
        arguments as path names. If not supplied, only the first argument will
        be treated as an attribute.
 
+OUTPUT
+------
+
+The output is of the form:
+<path> COLON SP <attribute> COLON SP <info> LF
+
+Where <path> is the path of a file being queried, <attribute> is an attribute
+being queried and <info> can be either:
+
+'unspecified';; when the attribute is not defined for the path.
+'unset';;      when the attribute is defined to false.
+'set';;                when the attribute is defined to true.
+<value>;;      when a value has been assigned to the attribute.
+
+EXAMPLES
+--------
+
+In the examples, the following '.gitattributes' file is used:
+---------------
+*.java diff=java -crlf myAttr
+NoMyAttr.java !myAttr
+README caveat=unspecified
+---------------
+
+* Listing a single attribute:
+---------------
+$ git check-attr diff org/example/MyClass.java
+org/example/MyClass.java: diff: java
+---------------
+
+* Listing multiple attributes for a file:
+---------------
+$ git check-attr crlf diff myAttr -- org/example/MyClass.java
+org/example/MyClass.java: crlf: unset
+org/example/MyClass.java: diff: java
+org/example/MyClass.java: myAttr: set
+---------------
+
+* Listing attribute for multiple files:
+---------------
+$ git check-attr myAttr -- org/example/MyClass.java org/example/NoMyAttr.java
+org/example/MyClass.java: myAttr: set
+org/example/NoMyAttr.java: myAttr: unspecified
+---------------
+
+* Not all values are equally unambiguous:
+---------------
+$ git check-attr caveat README
+README: caveat: unspecified
+---------------
 
 SEE ALSO
 --------
index 0e25bb862704eee4a22fe5349c04823d14ea9cba..79be4f1c0086fd1193734412019feeef8b07d669 100644 (file)
@@ -92,7 +92,8 @@ OPTIONS
 
 -s::
 --signoff::
-       Add Signed-off-by line at the end of the commit message.
+       Add Signed-off-by line by the commiter at the end of the commit
+       log message.
 
 -n::
 --no-verify::
index 53da9b4f6ba34b03768d77158c19d53e44681809..37fff208ffb6ce75911ef439ef140550a48b1a18 100644 (file)
@@ -163,8 +163,8 @@ few exceptions.  Even though...
 `ident`
 ^^^^^^^
 
-When the attribute `ident` is set to a path, git replaces
-`$Id$` in the blob object with `$Id:`, followed by
+When the attribute `ident` is set for a path, git replaces
+`$Id$` in the blob object with `$Id:`, followed by the
 40-character hexadecimal blob object name, followed by a dollar
 sign `$` upon checkout.  Any byte sequence that begins with
 `$Id:` and ends with `$` in the worktree file is replaced
@@ -213,6 +213,9 @@ with `crlf`, and then `ident` and fed to `filter`.
 Generating diff text
 ~~~~~~~~~~~~~~~~~~~~
 
+`diff`
+^^^^^^
+
 The attribute `diff` affects if 'git-diff' generates textual
 patch for the path or just says `Binary files differ`.  It also
 can affect what line is shown on the hunk header `@@ -k,l +n,m @@`
@@ -323,6 +326,9 @@ patterns are available:
 Performing a three-way merge
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
+`merge`
+^^^^^^^
+
 The attribute `merge` affects how three versions of a file is
 merged when a file-level merge is necessary during `git merge`,
 and other programs such as `git revert` and `git cherry-pick`.
index 0d40f0ecca30a6c86f2f7016be02d8e936bc1dab..becd008e04c265f7a822eeb74cfe218491710c7e 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1355,7 +1355,7 @@ install: all
        $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)'
        $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
        $(INSTALL) $(ALL_PROGRAMS) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
-       $(INSTALL) git$X git-upload-pack$X git-receive-pack$X git-upload-archive$X '$(DESTDIR_SQ)$(bindir_SQ)'
+       $(INSTALL) git$X git-upload-pack$X git-receive-pack$X git-upload-archive$X git-shell$X git-cvsserver '$(DESTDIR_SQ)$(bindir_SQ)'
        $(MAKE) -C templates DESTDIR='$(DESTDIR_SQ)' install
        $(MAKE) -C perl prefix='$(prefix_SQ)' DESTDIR='$(DESTDIR_SQ)' install
 ifndef NO_TCLTK
index a677737b90d7f1cc550d632a8e983e6e7df109fb..f9eb5528732ad3d45b5f685728b5f8943d435522 120000 (symlink)
--- a/RelNotes
+++ b/RelNotes
@@ -1 +1 @@
-Documentation/RelNotes-1.6.0.3.txt
\ No newline at end of file
+Documentation/RelNotes-1.6.0.4.txt
\ No newline at end of file
index e2280df56723809c5af1d566f0721e2639fff10c..45d242b884c2796b67329aaabfea62cd1e7bbecb 100644 (file)
--- a/archive.c
+++ b/archive.c
@@ -338,5 +338,7 @@ int write_archive(int argc, const char **argv, const char *prefix,
        parse_treeish_arg(argv, &args, prefix);
        parse_pathspec_arg(argv + 1, &args);
 
+       git_config(git_default_config, NULL);
+
        return ar->write_archive(&args);
 }
index b1e59f2196b933ab7169a30efc5d1d340f8f9c5c..6a750574fd376e4d54e4ef2576674d42521f1529 100644 (file)
--- a/branch.c
+++ b/branch.c
@@ -129,7 +129,9 @@ void create_branch(const char *head,
                        die("Cannot setup tracking information; starting point is not a branch.");
                break;
        case 1:
-               /* Unique completion -- good */
+               /* Unique completion -- good, only if it is a real ref */
+               if (track == BRANCH_TRACK_EXPLICIT && !strcmp(real_ref, "HEAD"))
+                       die("Cannot setup tracking information; starting point is not a branch.");
                break;
        default:
                die("Ambiguous object name: '%s'.", start_name);
index 432ce2acc6bb687b35f3e9663f3058ebef2354e7..5ceec433fd590e8bf6a51700ea69c37f9af30fa7 100644 (file)
@@ -111,8 +111,6 @@ int cmd_archive(int argc, const char **argv, const char *prefix)
 {
        const char *remote = NULL;
 
-       git_config(git_default_config, NULL);
-
        remote = extract_remote_arg(&argc, argv);
        if (remote)
                return run_remote_archiver(remote, argc, argv);
index c4fc2b2c562725018789dead3b86ccfbc4e2925f..1deda927cdfcbcdcb751aca3338ac77ef0aad836 100644 (file)
@@ -565,6 +565,18 @@ no_reference:
                return checkout_paths(source_tree, pathspec);
        }
 
+       if (opts.new_branch) {
+               struct strbuf buf;
+               strbuf_init(&buf, 0);
+               strbuf_addstr(&buf, "refs/heads/");
+               strbuf_addstr(&buf, opts.new_branch);
+               if (!get_sha1(buf.buf, rev))
+                       die("git checkout: branch %s already exists", opts.new_branch);
+               if (check_ref_format(buf.buf))
+                       die("git checkout: we do not like '%s' as a branch name.", opts.new_branch);
+               strbuf_release(&buf);
+       }
+
        if (new.name && !new.commit) {
                die("Cannot switch branch to a non-commit.");
        }
index e2a7e48b1ce97a74ef73a1feb53a9b9248cf8668..b563a0d67cedc66825692863d9e57001fba35348 100644 (file)
@@ -320,7 +320,8 @@ static char *prepare_index(int argc, const char **argv, const char *prefix)
                die("unable to write new_index file");
 
        fd = hold_lock_file_for_update(&false_lock,
-                                      git_path("next-index-%d", getpid()), 1);
+                                      git_path("next-index-%d", getpid()),
+                                      LOCK_DIE_ON_ERROR);
 
        create_base_index();
        add_remove_files(&partial);
index 85509f5ee5884589980c9a1c5f96b66a3d49d5dd..21ce3e016314e0c8500c9010b2ff214b1e05e022 100644 (file)
@@ -813,7 +813,8 @@ struct ref *fetch_pack(struct fetch_pack_args *my_args,
                          )
                        die("shallow file was changed during fetch");
 
-               fd = hold_lock_file_for_update(&lock, shallow, 1);
+               fd = hold_lock_file_for_update(&lock, shallow,
+                                              LOCK_DIE_ON_ERROR);
                if (!write_shallow_commits(fd, 0)) {
                        unlink(shallow);
                        rollback_lock_file(&lock);
index 4004e73e40db210334fa3ef69b49d07b929f2c99..b0dddbee4f93de462090218554e1b1b6d1038c34 100644 (file)
@@ -1377,7 +1377,7 @@ static void find_deltas(struct object_entry **list, unsigned *list_size,
        memset(array, 0, array_size);
 
        for (;;) {
-               struct object_entry *entry = *list++;
+               struct object_entry *entry;
                struct unpacked *n = array + idx;
                int j, max_depth, best_base = -1;
 
@@ -1386,6 +1386,7 @@ static void find_deltas(struct object_entry **list, unsigned *list_size,
                        progress_unlock();
                        break;
                }
+               entry = *list++;
                (*list_size)--;
                if (!entry->preferred_base) {
                        (*processed)++;
index 27881e94937dd79b9a0524eb2d9770427ec4f4fb..786a956f26486856c97e15ce8ab464dfb25dcbc5 100644 (file)
@@ -269,7 +269,7 @@ static int revert_or_cherry_pick(int argc, const char **argv)
        int i;
        char *oneline, *reencoded_message = NULL;
        const char *message, *encoding;
-       const char *defmsg = xstrdup(git_path("MERGE_MSG"));
+       char *defmsg = xstrdup(git_path("MERGE_MSG"));
 
        git_config(git_default_config, NULL);
        me = action == REVERT ? "revert" : "cherry-pick";
@@ -338,7 +338,8 @@ static int revert_or_cherry_pick(int argc, const char **argv)
         * reverse of it if we are revert.
         */
 
-       msg_fd = hold_lock_file_for_update(&msg_file, defmsg, 1);
+       msg_fd = hold_lock_file_for_update(&msg_file, defmsg,
+                                          LOCK_DIE_ON_ERROR);
 
        encoding = get_encoding(message);
        if (!encoding)
@@ -426,6 +427,7 @@ static int revert_or_cherry_pick(int argc, const char **argv)
                return execv_git_cmd(args);
        }
        free(reencoded_message);
+       free(defmsg);
 
        return 0;
 }
index 2af9f2934142f55858f4b5c76deb6397ac74b9f8..301f23043262059dcb28994527334ba1909671f0 100644 (file)
@@ -132,7 +132,13 @@ static struct ref *remote_refs, **remote_tail;
 static int one_local_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data)
 {
        struct ref *ref;
-       int len = strlen(refname) + 1;
+       int len;
+
+       /* we already know it starts with refs/ to get here */
+       if (check_ref_format(refname + 5))
+               return 0;
+
+       len = strlen(refname) + 1;
        ref = xcalloc(1, sizeof(*ref) + len);
        hashcpy(ref->new_sha1, sha1);
        memcpy(ref->name, refname, len);
index 00b2aabefca49b634f49143523ee31556baa7777..7d17a1fde16204859849aaf28945739aaa685f91 100644 (file)
--- a/bundle.c
+++ b/bundle.c
@@ -186,7 +186,8 @@ int create_bundle(struct bundle_header *header, const char *path,
        if (bundle_to_stdout)
                bundle_fd = 1;
        else
-               bundle_fd = hold_lock_file_for_update(&lock, path, 1);
+               bundle_fd = hold_lock_file_for_update(&lock, path,
+                                                     LOCK_DIE_ON_ERROR);
 
        /* write signature */
        write_or_die(bundle_fd, bundle_signature, strlen(bundle_signature));
diff --git a/cache.h b/cache.h
index 884fae826cb8c296520aecbc8c23d9848dacb606..8ab2fd8fd082bc0c263fc055cab8e248b56985e0 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -411,6 +411,8 @@ struct lock_file {
        char on_list;
        char filename[PATH_MAX];
 };
+#define LOCK_DIE_ON_ERROR 1
+#define LOCK_NODEREF 2
 extern int hold_lock_file_for_update(struct lock_file *, const char *path, int);
 extern int hold_lock_file_for_append(struct lock_file *, const char *path, int);
 extern int commit_lock_file(struct lock_file *);
index 751e273e1aeecd382bc584fcb80b2ed6f52ed862..39a1ce5a3979e6160b8450a0d9dd08ec6b6cd7a2 100755 (executable)
@@ -1410,6 +1410,8 @@ _git_shortlog ()
 
 _git_show ()
 {
+       __git_has_doubledash && return
+
        local cur="${COMP_WORDS[COMP_CWORD]}"
        case "$cur" in
        --pretty=*)
index 36bd54c985080f8dd5558a3e7a4e19ede9fbab93..b17952a785d9e45dea8a71c211f76f0271e659da 100755 (executable)
@@ -309,7 +309,7 @@ sub update_remote {
                        }
                }
        } else {
-               print STDERR "Remote group $name does not exists.\n";
+               print STDERR "Remote group $name does not exist.\n";
                exit(1);
        }
        for (@remotes) {
index f4a7b62cd9f1a397118b95792c04c2f70f910f9e..be188c0f11dbea8320737b4fdf426a2f5acd1a00 100755 (executable)
@@ -1,9 +1,9 @@
 #!/usr/bin/perl
 #
 # This tool will print vaguely pretty information about a pack.  It
-# expects the output of "git-verify-pack -v" as input on stdin.
+# expects the output of "git verify-pack -v" as input on stdin.
 #
-# $ git-verify-pack -v | packinfo.pl
+# $ git verify-pack -v | packinfo.pl
 #
 # This prints some full-pack statistics; currently "all sizes", "all
 # path sizes", "tree sizes", "tree path sizes", and "depths".
@@ -20,7 +20,7 @@
 #
 # When run as:
 #
-# $ git-verify-pack -v | packinfo.pl -tree
+# $ git verify-pack -v | packinfo.pl -tree
 #
 # the trees of objects are output along with the stats.  This looks
 # like:
@@ -43,7 +43,7 @@
 #
 # When run as:
 #
-# $ git-verify-pack -v | packinfo.pl -tree -filenames
+# $ git verify-pack -v | packinfo.pl -tree -filenames
 #
 # it adds filenames to the tree.  Getting this information is slow:
 #
@@ -58,7 +58,7 @@
 #
 # When run as:
 #
-# $ git-verify-pack -v | packinfo.pl -dump
+# $ git verify-pack -v | packinfo.pl -dump
 #
 # it prints out "sha1 size pathsize depth" for each sha1 in lexical
 # order.
@@ -106,7 +106,7 @@ while (<STDIN>) {
 }
 
 if ($filenames && ($tree || $dump)) {
-    open(NAMES, "git-name-rev --all|");
+    open(NAMES, "git name-rev --all|");
     while (<NAMES>) {
         if (/^(\S+)\s+(.*)$/) {
             my ($sha1, $name) = ($1, $2);
@@ -117,7 +117,7 @@ if ($filenames && ($tree || $dump)) {
 
     for my $commit (@commits) {
         my $name = $names{$commit};
-        open(TREE, "git-ls-tree -t -r $commit|");
+        open(TREE, "git ls-tree -t -r $commit|");
         print STDERR "Plumbing tree $name\n";
         while (<TREE>) {
             if (/^(\S+)\s+(\S+)\s+(\S+)\s+(.*)$/) {
index 1b2ebb40014d820fe4fb679509ab694d453be7b4..168a95b541c2d6a4679115ebc9f30b1016645b19 100644 (file)
@@ -493,7 +493,7 @@ void diffcore_rename(struct diff_options *options)
        if ((num_create > rename_limit && num_src > rename_limit) ||
            (num_create * num_src > rename_limit * rename_limit)) {
                if (options->warn_on_too_large_rename)
-                       warning("too many files, skipping inexact rename detection");
+                       warning("too many files (created: %d deleted: %d), skipping inexact rename detection", num_create, num_src);
                goto cleanup;
        }
 
index da768ee7acc22e6480f0a067e109239561d43927..b0223c3419301132032fb67519a275e57707df22 100755 (executable)
@@ -811,11 +811,16 @@ EOF
 }
 
 sub patch_update_cmd {
-       my @mods = grep { !($_->{BINARY}) } list_modified('file-only');
+       my @all_mods = list_modified('file-only');
+       my @mods = grep { !($_->{BINARY}) } @all_mods;
        my @them;
 
        if (!@mods) {
-               print STDERR "No changes.\n";
+               if (@all_mods) {
+                       print STDERR "Only binary files changed.\n";
+               } else {
+                       print STDERR "No changes.\n";
+               }
                return 0;
        }
        if ($patch_mode) {
index 78f344f08f34842c134b6b0e22b6eb8c49b1dbbd..a479b2f2857751d4d573c7bfe00f9e671d437aed 100644 (file)
@@ -80,7 +80,7 @@ method _connect {pipe_fd} {
                error_popup [strcat [mc "Unrecognized spell checker"] ":\n\n$s_version"]
                return
        }
-       set s_version [string range $s_version 5 end]
+       set s_version [string range [string trim $s_version] 5 end]
        regexp \
                {International Ispell Version .* \(but really (Aspell .*?)\)$} \
                $s_version _junk s_version
index d2fd89907688a044ffe0d2520744e00a9b33c942..18529c76e665e613d9c116e32da6acf31b3eac6a 100755 (executable)
@@ -407,10 +407,9 @@ for my $f (@ARGV) {
 
                push @files, grep { -f $_ } map { +$f . "/" . $_ }
                                sort readdir(DH);
-
+               closedir(DH);
        } elsif (-f $f or -p $f) {
                push @files, $f;
-
        } else {
                print STDERR "Skipping $f - not found.\n";
        }
index 33e1b503c4d58f5f0a0c109a37968419710fbd11..56238dad088d6da98f7285f74645814e6bb0fe9b 100755 (executable)
@@ -1126,7 +1126,7 @@ sub read_repo_config {
                my $v = $opts->{$o};
                my ($key) = ($o =~ /^([a-zA-Z\-]+)/);
                $key =~ s/-//g;
-               my $arg = 'git-config';
+               my $arg = 'git config';
                $arg .= ' --int' if ($o =~ /[:=]i$/);
                $arg .= ' --bool' if ($o !~ /[:=][sfi]$/);
                if (ref $v eq 'ARRAY') {
@@ -2202,7 +2202,7 @@ sub do_git_commit {
        }
        die "Tree is not a valid sha1: $tree\n" if $tree !~ /^$::sha1$/o;
 
-       my @exec = ('git-commit-tree', $tree);
+       my @exec = ('git', 'commit-tree', $tree);
        foreach ($self->get_commit_parents($log_entry)) {
                push @exec, '-p', $_;
        }
index 2a366206a4e830d0bb66d6ac708cd512a94d6d37..c99a1a152c7ddbb63073461b86179f2be5bf9640 100644 (file)
@@ -879,10 +879,26 @@ int main(int argc, char **argv)
        char *index_name_buf = NULL, *keep_name_buf = NULL;
        struct pack_idx_entry **idx_objects;
        unsigned char pack_sha1[20];
-       int nongit = 0;
 
-       setup_git_directory_gently(&nongit);
-       git_config(git_index_pack_config, NULL);
+       /*
+        * We wish to read the repository's config file if any, and
+        * for that it is necessary to call setup_git_directory_gently().
+        * However if the cwd was inside .git/objects/pack/ then we need
+        * to go back there or all the pack name arguments will be wrong.
+        * And in that case we cannot rely on any prefix returned by
+        * setup_git_directory_gently() either.
+        */
+       {
+               char cwd[PATH_MAX+1];
+               int nongit;
+
+               if (!getcwd(cwd, sizeof(cwd)-1))
+                       die("Unable to get current working directory");
+               setup_git_directory_gently(&nongit);
+               git_config(git_index_pack_config, NULL);
+               if (chdir(cwd))
+                       die("Cannot come back to cwd");
+       }
 
        for (i = 1; i < argc; i++) {
                char *arg = argv[i];
index 4023797b00fe21ecbabe3407ef8a12fca0690607..6d756086939b631ab13bf4fcdb8deed2787eed6b 100644 (file)
@@ -121,15 +121,17 @@ static char *resolve_symlink(char *p, size_t s)
 }
 
 
-static int lock_file(struct lock_file *lk, const char *path)
+static int lock_file(struct lock_file *lk, const char *path, int flags)
 {
-       if (strlen(path) >= sizeof(lk->filename)) return -1;
+       if (strlen(path) >= sizeof(lk->filename))
+               return -1;
        strcpy(lk->filename, path);
        /*
         * subtract 5 from size to make sure there's room for adding
         * ".lock" for the lock file name
         */
-       resolve_symlink(lk->filename, sizeof(lk->filename)-5);
+       if (!(flags & LOCK_NODEREF))
+               resolve_symlink(lk->filename, sizeof(lk->filename)-5);
        strcat(lk->filename, ".lock");
        lk->fd = open(lk->filename, O_RDWR | O_CREAT | O_EXCL, 0666);
        if (0 <= lk->fd) {
@@ -155,21 +157,21 @@ static int lock_file(struct lock_file *lk, const char *path)
        return lk->fd;
 }
 
-int hold_lock_file_for_update(struct lock_file *lk, const char *path, int die_on_error)
+int hold_lock_file_for_update(struct lock_file *lk, const char *path, int flags)
 {
-       int fd = lock_file(lk, path);
-       if (fd < 0 && die_on_error)
+       int fd = lock_file(lk, path, flags);
+       if (fd < 0 && (flags & LOCK_DIE_ON_ERROR))
                die("unable to create '%s.lock': %s", path, strerror(errno));
        return fd;
 }
 
-int hold_lock_file_for_append(struct lock_file *lk, const char *path, int die_on_error)
+int hold_lock_file_for_append(struct lock_file *lk, const char *path, int flags)
 {
        int fd, orig_fd;
 
-       fd = lock_file(lk, path);
+       fd = lock_file(lk, path, flags);
        if (fd < 0) {
-               if (die_on_error)
+               if (flags & LOCK_DIE_ON_ERROR)
                        die("unable to create '%s.lock': %s", path, strerror(errno));
                return fd;
        }
@@ -177,13 +179,13 @@ int hold_lock_file_for_append(struct lock_file *lk, const char *path, int die_on
        orig_fd = open(path, O_RDONLY);
        if (orig_fd < 0) {
                if (errno != ENOENT) {
-                       if (die_on_error)
+                       if (flags & LOCK_DIE_ON_ERROR)
                                die("cannot open '%s' for copying", path);
                        close(fd);
                        return error("cannot open '%s' for copying", path);
                }
        } else if (copy_fd(orig_fd, fd)) {
-               if (die_on_error)
+               if (flags & LOCK_DIE_ON_ERROR)
                        exit(128);
                close(fd);
                return -1;
@@ -215,7 +217,10 @@ int commit_lock_file(struct lock_file *lk)
 
 int hold_locked_index(struct lock_file *lk, int die_on_error)
 {
-       return hold_lock_file_for_update(lk, get_index_file(), die_on_error);
+       return hold_lock_file_for_update(lk, get_index_file(),
+                                        die_on_error
+                                        ? LOCK_DIE_ON_ERROR
+                                        : 0);
 }
 
 void set_alternate_index_output(const char *name)
index 848d311c2b2c651dbb14893c260584f00c639357..2c76fb181f64e10c65517224b0c09cb648db81ac 100644 (file)
@@ -89,7 +89,8 @@ int pack_refs(unsigned int flags)
        memset(&cbdata, 0, sizeof(cbdata));
        cbdata.flags = flags;
 
-       fd = hold_lock_file_for_update(&packed, git_path("packed-refs"), 1);
+       fd = hold_lock_file_for_update(&packed, git_path("packed-refs"),
+                                      LOCK_DIE_ON_ERROR);
        cbdata.refs_file = fdopen(fd, "w");
        if (!cbdata.refs_file)
                die("unable to create ref-pack file structure (%s)",
diff --git a/path.c b/path.c
index 76e8872622e435b050f77198ef6eef6e6ff6869e..c1cb54b7b8b478c717861a0205e537ded3fbbfc9 100644 (file)
--- a/path.c
+++ b/path.c
@@ -348,7 +348,7 @@ int normalize_absolute_path(char *buf, const char *path)
                        goto next;
                }
 
-               memcpy(dst, comp_start, comp_len);
+               memmove(dst, comp_start, comp_len);
                dst += comp_len;
        next:
                comp_start = comp_end;
diff --git a/refs.c b/refs.c
index 39a3b23804d2da715c564459bf320be23d41c1bf..9e422dcccbb3d499b55df5f39612b12c3c3f52e0 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -790,7 +790,7 @@ static struct ref_lock *lock_ref_sha1_basic(const char *ref, const unsigned char
        struct ref_lock *lock;
        struct stat st;
        int last_errno = 0;
-       int type;
+       int type, lflags;
        int mustexist = (old_sha1 && !is_null_sha1(old_sha1));
 
        lock = xcalloc(1, sizeof(struct ref_lock));
@@ -830,8 +830,11 @@ static struct ref_lock *lock_ref_sha1_basic(const char *ref, const unsigned char
 
        lock->lk = xcalloc(1, sizeof(struct lock_file));
 
-       if (flags & REF_NODEREF)
+       lflags = LOCK_DIE_ON_ERROR;
+       if (flags & REF_NODEREF) {
                ref = orig_ref;
+               lflags |= LOCK_NODEREF;
+       }
        lock->ref_name = xstrdup(ref);
        lock->orig_ref_name = xstrdup(orig_ref);
        ref_file = git_path("%s", ref);
@@ -845,8 +848,8 @@ static struct ref_lock *lock_ref_sha1_basic(const char *ref, const unsigned char
                error("unable to create directory for %s", ref_file);
                goto error_return;
        }
-       lock->lock_fd = hold_lock_file_for_update(lock->lk, ref_file, 1);
 
+       lock->lock_fd = hold_lock_file_for_update(lock->lk, ref_file, lflags);
        return old_sha1 ? verify_lock(lock, old_sha1, mustexist) : lock;
 
  error_return:
index 323e493dafee46c0d3f95e3c4cd9c4c9b463bbef..2b7a99d729e13b09239f1d9175d3d6c0048821b0 100644 (file)
--- a/rerere.c
+++ b/rerere.c
@@ -346,7 +346,8 @@ int setup_rerere(struct string_list *merge_rr)
                return -1;
 
        merge_rr_path = xstrdup(git_path("MERGE_RR"));
-       fd = hold_lock_file_for_update(&write_lock, merge_rr_path, 1);
+       fd = hold_lock_file_for_update(&write_lock, merge_rr_path,
+                                      LOCK_DIE_ON_ERROR);
        read_rr(merge_rr);
        return fd;
 }
index e2cb342a32f31be2b9ffc1867fbfd671fe63cef1..12fc767ee57103739e568a959981ca559417ecf4 100644 (file)
@@ -385,7 +385,7 @@ static void read_info_alternates(const char * relative_base, int depth)
 void add_to_alternates_file(const char *reference)
 {
        struct lock_file *lock = xcalloc(1, sizeof(struct lock_file));
-       int fd = hold_lock_file_for_append(lock, git_path("objects/info/alternates"), 1);
+       int fd = hold_lock_file_for_append(lock, git_path("objects/info/alternates"), LOCK_DIE_ON_ERROR);
        char *alt = mkpath("%s/objects\n", reference);
        write_or_die(fd, alt, strlen(alt));
        if (commit_lock_file(lock))
@@ -2322,6 +2322,7 @@ int force_object_loose(const unsigned char *sha1, time_t mtime)
        enum object_type type;
        char hdr[32];
        int hdrlen;
+       int ret;
 
        if (has_loose_object(sha1))
                return 0;
@@ -2329,7 +2330,10 @@ int force_object_loose(const unsigned char *sha1, time_t mtime)
        if (!buf)
                return error("cannot read sha1_file for %s", sha1_to_hex(sha1));
        hdrlen = sprintf(hdr, "%s %lu", typename(type), len) + 1;
-       return write_loose_object(sha1, hdr, hdrlen, buf, len, mtime);
+       ret = write_loose_object(sha1, hdr, hdrlen, buf, len, mtime);
+       free(buf);
+
+       return ret;
 }
 
 int has_pack_index(const unsigned char *sha1)
index dc85e8b60a5c10e57047d1692e383f177e2c478d..653362ba221ee017512264c83a216b1ad1723bcd 100755 (executable)
@@ -7,6 +7,9 @@ test_description='Test shared repository initialization'
 
 . ./test-lib.sh
 
+# Remove a default ACL from the test dir if possible.
+setfacl -k . 2>/dev/null
+
 # User must have read permissions to the repo -> failure on --shared=0400
 test_expect_success 'shared = 0400 (faulty permission u-w)' '
        mkdir sub && (
@@ -17,6 +20,10 @@ test_expect_success 'shared = 0400 (faulty permission u-w)' '
        test $ret != "0"
 '
 
+modebits () {
+       ls -l "$1" | sed -e 's|^\(..........\).*|\1|'
+}
+
 for u in 002 022
 do
        test_expect_success "shared=1 does not clear bits preset by umask $u" '
@@ -82,8 +89,7 @@ do
 
                rm -f .git/info/refs &&
                git update-server-info &&
-               actual="$(ls -l .git/info/refs)" &&
-               actual=${actual%% *} &&
+               actual="$(modebits .git/info/refs)" &&
                test "x$actual" = "x-$y" || {
                        ls -lt .git/info
                        false
@@ -95,8 +101,7 @@ do
 
                rm -f .git/info/refs &&
                git update-server-info &&
-               actual="$(ls -l .git/info/refs)" &&
-               actual=${actual%% *} &&
+               actual="$(modebits .git/info/refs)" &&
                test "x$actual" = "x-$x" || {
                        ls -lt .git/info
                        false
index 99fff973eb2479d7ec599b8fd298d4a970176244..398bf4b5d8e3d85562563059eaeb7bc8b8e4ce59 100755 (executable)
@@ -65,7 +65,14 @@ test_expect_success 'custom pattern' '
 
 test_expect_success 'last regexp must not be negated' '
        git config diff.java.funcname "!static" &&
-       test_must_fail git diff --no-index Beer.java Beer-correct.java
+       git diff --no-index Beer.java Beer-correct.java 2>&1 |
+       grep "fatal: Last expression must not be negated:"
+'
+
+test_expect_success 'pattern which matches to end of line' '
+       git config diff.java.funcname "Beer$" &&
+       git diff --no-index Beer.java Beer-correct.java |
+       grep "^@@.*@@ Beer"
 '
 
 test_expect_success 'alternation in pattern' '
index bc7a8a8689c8ca2b9902c577c9d9bdd1fa97815c..8f6aea48d84621ae3b7304636452c724a4bbe5b6 100755 (executable)
@@ -72,7 +72,7 @@ test_expect_success 'apply --directory (delete file)' '
        echo content >some/sub/dir/delfile &&
        git add some/sub/dir/delfile &&
        git apply --directory=some/sub/dir/ --index patch &&
-       ! git ls-files | grep delfile
+       ! (git ls-files | grep delfile)
 '
 
 cat > patch << 'EOF'
index e395ff4e341bacea21cc5cd909304b7bb4fcb044..c942c8be85339157e22f755d8fc94e64efaee4dd 100755 (executable)
@@ -57,6 +57,11 @@ test_expect_success \
      git update-ref HEAD $(TZ=GMT GIT_COMMITTER_DATE="2005-05-27 22:00:00" \
      git commit-tree $treeid </dev/null)'
 
+test_expect_success \
+    'create bare clone' \
+    'git clone --bare . bare.git &&
+     cp .gitattributes bare.git/info/attributes'
+
 test_expect_success \
     'remove ignored file' \
     'rm a/ignored'
@@ -73,11 +78,19 @@ test_expect_success \
     'git archive vs. git tar-tree' \
     'diff b.tar b2.tar'
 
+test_expect_success \
+    'git archive in a bare repo' \
+    '(cd bare.git && git archive HEAD) >b3.tar'
+
+test_expect_success \
+    'git archive vs. the same in a bare repo' \
+    'test_cmp b.tar b3.tar'
+
 test_expect_success \
     'validate file modification time' \
     'mkdir extract &&
      "$TAR" xf b.tar -C extract a/a &&
-     perl -e '\''print((stat("extract/a/a"))[9], "\n")'\'' >b.mtime &&
+     test-chmtime -v +0 extract/a/a |cut -f 1 >b.mtime &&
      echo "1117231200" >expected.mtime &&
      diff expected.mtime b.mtime'
 
@@ -151,6 +164,14 @@ test_expect_success \
     'git archive --format=zip' \
     'git archive --format=zip HEAD >d.zip'
 
+test_expect_success \
+    'git archive --format=zip in a bare repo' \
+    '(cd bare.git && git archive --format=zip HEAD) >d1.zip'
+
+test_expect_success \
+    'git archive --format=zip vs. the same in a bare repo' \
+    'test_cmp d.zip d1.zip'
+
 $UNZIP -v >/dev/null 2>&1
 if [ $? -eq 127 ]; then
        echo "Skipping ZIP tests, because unzip was not found"
index 6424db1f28e11c3ac6eb629ba4db7380812eab72..344ab25b8b6ddcd8b687a72e43b9e26aec18263e 100755 (executable)
@@ -177,4 +177,14 @@ test_expect_success \
        ".git/objects/pack/pack-${pack1}.pack" 2>&1) &&
      echo "$err" | grep "CRC mismatch"'
 
+test_expect_success 'running index-pack in the object store' '
+    rm -f .git/objects/pack/* &&
+    cp test-1-${pack1}.pack .git/objects/pack/pack-${pack1}.pack &&
+    (
+       cd .git/objects/pack
+       git index-pack pack-${pack1}.pack
+    ) &&
+    test -f .git/objects/pack/pack-${pack1}.idx
+'
+
 test_done
index fbec70d3c6abff4a97aa205aa10fbf6fe336fa5f..c9abed6a2b18404306e281c7b5d161686f1c3b20 100755 (executable)
@@ -330,12 +330,26 @@ test_expect_success \
     test "$(git config branch.track2.merge)"
     git config branch.autosetupmerge false'
 
-test_expect_success \
-    'checkout w/--track from non-branch HEAD fails' '
-    git checkout -b delete-me master &&
-    rm .git/refs/heads/delete-me &&
-    test refs/heads/delete-me = "$(git symbolic-ref HEAD)" &&
-    test_must_fail git checkout --track -b track'
+test_expect_success 'checkout w/--track from non-branch HEAD fails' '
+    git checkout master^0 &&
+    test_must_fail git symbolic-ref HEAD &&
+    test_must_fail git checkout --track -b track &&
+    test_must_fail git rev-parse --verify track &&
+    test_must_fail git symbolic-ref HEAD &&
+    test "z$(git rev-parse master^0)" = "z$(git rev-parse HEAD)"
+'
+
+test_expect_success 'detach a symbolic link HEAD' '
+    git checkout master &&
+    git config --bool core.prefersymlinkrefs yes &&
+    git checkout side &&
+    git checkout master &&
+    it=$(git symbolic-ref HEAD) &&
+    test "z$it" = zrefs/heads/master &&
+    here=$(git rev-parse --verify refs/heads/master) &&
+    git checkout side^ &&
+    test "z$(git rev-parse --verify refs/heads/master)" = "z$here"
+'
 
 test_expect_success 'checkout an unmerged path should fail' '
        rm -f .git/index &&
@@ -359,4 +373,14 @@ test_expect_success 'checkout an unmerged path should fail' '
        test_cmp sample file
 '
 
+test_expect_success 'failing checkout -b should not break working tree' '
+       git reset --hard master &&
+       git symbolic-ref HEAD refs/heads/master &&
+       test_must_fail git checkout -b renamer side^ &&
+       test $(git symbolic-ref HEAD) = refs/heads/master &&
+       git diff --exit-code &&
+       git diff --cached --exit-code
+
+'
+
 test_done
index 90da448ebec3e5375b7725ba7f297c1c74199b87..d5358cbaac2022483b74366555fc9707a7d8ad97 100644 (file)
@@ -1,39 +1,83 @@
+/*
+ * This program can either change modification time of the given
+ * file(s) or just print it. The program does not change atime nor
+ * ctime (their values are explicitely preserved).
+ *
+ * The mtime can be changed to an absolute value:
+ *
+ *     test-chmtime =<seconds> file...
+ *
+ * Relative to the current time as returned by time(3):
+ *
+ *     test-chmtime =+<seconds> (or =-<seconds>) file...
+ *
+ * Or relative to the current mtime of the file:
+ *
+ *     test-chmtime <seconds> file...
+ *     test-chmtime +<seconds> (or -<seconds>) file...
+ *
+ * Examples:
+ *
+ * To just print the mtime use --verbose and set the file mtime offset to 0:
+ *
+ *     test-chmtime -v +0 file
+ *
+ * To set the mtime to current time:
+ *
+ *     test-chmtime =+0 file
+ *
+ */
 #include "git-compat-util.h"
 #include <utime.h>
 
-static const char usage_str[] = "(+|=|=+|=-|-)<seconds> <file>...";
+static const char usage_str[] = "-v|--verbose (+|=|=+|=-|-)<seconds> <file>...";
 
-int main(int argc, const char *argv[])
+static int timespec_arg(const char *arg, long int *set_time, int *set_eq)
 {
-       int i;
-       int set_eq;
-       long int set_time;
        char *test;
-       const char *timespec;
-
-       if (argc < 3)
-               goto usage;
-
-       timespec = argv[1];
-       set_eq = (*timespec == '=') ? 1 : 0;
-       if (set_eq) {
+       const char *timespec = arg;
+       *set_eq = (*timespec == '=') ? 1 : 0;
+       if (*set_eq) {
                timespec++;
                if (*timespec == '+') {
-                       set_eq = 2; /* relative "in the future" */
+                       *set_eq = 2; /* relative "in the future" */
                        timespec++;
                }
        }
-       set_time = strtol(timespec, &test, 10);
+       *set_time = strtol(timespec, &test, 10);
        if (*test) {
-               fprintf(stderr, "Not a base-10 integer: %s\n", argv[1] + 1);
-               goto usage;
+               fprintf(stderr, "Not a base-10 integer: %s\n", arg + 1);
+               return 0;
        }
-       if ((set_eq && set_time < 0) || set_eq == 2) {
+       if ((*set_eq && *set_time < 0) || *set_eq == 2) {
                time_t now = time(NULL);
-               set_time += now;
+               *set_time += now;
        }
+       return 1;
+}
+
+int main(int argc, const char *argv[])
+{
+       static int verbose;
 
-       for (i = 2; i < argc; i++) {
+       int i = 1;
+       /* no mtime change by default */
+       int set_eq = 0;
+       long int set_time = 0;
+
+       if (argc < 3)
+               goto usage;
+
+       if (strcmp(argv[i], "--verbose") == 0 || strcmp(argv[i], "-v") == 0) {
+               verbose = 1;
+               ++i;
+       }
+       if (timespec_arg(argv[i], &set_time, &set_eq))
+               ++i;
+       else
+               goto usage;
+
+       for (; i < argc; i++) {
                struct stat sb;
                struct utimbuf utb;
 
@@ -46,7 +90,12 @@ int main(int argc, const char *argv[])
                utb.actime = sb.st_atime;
                utb.modtime = set_eq ? set_time : sb.st_mtime + set_time;
 
-               if (utime(argv[i], &utb) < 0) {
+               if (verbose) {
+                       uintmax_t mtime = utb.modtime < 0 ? 0: utb.modtime;
+                       printf("%"PRIuMAX"\t%s\n", mtime, argv[i]);
+               }
+
+               if (utb.modtime != sb.st_mtime && utime(argv[i], &utb) < 0) {
                        fprintf(stderr, "Failed to modify time on %s: %s\n",
                                argv[i], strerror(errno));
                        return -1;
index e59d144d28164f2451784513105f6269f0e9167c..e5749ef638b4a9a490894d9d4fc5876d904ab9ac 100644 (file)
@@ -382,7 +382,7 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
        o->merge_size = len;
 
        if (!dfc)
-               dfc = xcalloc(1, sizeof(struct cache_entry) + 1);
+               dfc = xcalloc(1, cache_entry_size(0));
        o->df_conflict_entry = dfc;
 
        if (len) {
index 2c81f40cb657f6e49bc6a7431f830a037713ab38..3bf83f81e38d4a4cc114f3c577241cf7b9eddc7e 100644 (file)
@@ -179,11 +179,21 @@ struct ff_regs {
 static long ff_regexp(const char *line, long len,
                char *buffer, long buffer_size, void *priv)
 {
-       char *line_buffer = xstrndup(line, len); /* make NUL terminated */
+       char *line_buffer;
        struct ff_regs *regs = priv;
        regmatch_t pmatch[2];
        int result = 0, i;
 
+       /* Exclude terminating newline (and cr) from matching */
+       if (len > 0 && line[len-1] == '\n') {
+               if (len > 1 && line[len-2] == '\r')
+                       len -= 2;
+               else
+                       len--;
+       }
+
+       line_buffer = xstrndup(line, len); /* make NUL terminated */
+
        for (i = 0; i < regs->nr; i++) {
                struct ff_reg *reg = regs->array + i;
                if (reg->negate ^ !!regexec(&reg->re,