]> rtime.felk.cvut.cz Git - git.git/commitdiff
Merge branch 'rb/maint-python-path' into maint
authorJunio C Hamano <gitster@pobox.com>
Sat, 10 Apr 2010 05:22:19 +0000 (22:22 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sat, 10 Apr 2010 05:22:19 +0000 (22:22 -0700)
* rb/maint-python-path:
  Correct references to /usr/bin/python which does not exist on FreeBSD

43 files changed:
.mailmap
Documentation/RelNotes-1.7.0.4.txt [new file with mode: 0644]
Documentation/git-branch.txt
Documentation/git-describe.txt
Documentation/git-fetch.txt
Documentation/git-http-backend.txt
Documentation/git-push.txt
Documentation/git-show-ref.txt
Documentation/git.txt
Documentation/technical/pack-protocol.txt
GIT-VERSION-GEN
Makefile
RelNotes
builtin-add.c
builtin-apply.c
builtin-fast-export.c
builtin-fetch.c
builtin-log.c
builtin-push.c
builtin-reset.c
color.c
color.h
compat/bswap.h
compat/mingw.c
daemon.c
diff.c
dir.c
git-difftool.perl
git-stash.sh
gitweb/gitweb.perl
refs.c
t/t0050-filesystem.sh
t/t2200-add-update.sh
t/t2204-add-ignored.sh [new file with mode: 0755]
t/t3417-rebase-whitespace-fix.sh [new file with mode: 0755]
t/t3700-add.sh
t/t4014-format-patch.sh
t/t4026-color.sh
t/t4104-apply-boundary.sh
t/t4124-apply-ws-rule.sh
t/t5505-remote.sh
t/t7800-difftool.sh
t/t9350-fast-export.sh

index 88bd01e16d91f002cf3ac405e2a923884058d724..a8091eb5dfa430bf1b0537da47a31e7cf88d8622 100644 (file)
--- a/.mailmap
+++ b/.mailmap
@@ -5,6 +5,7 @@
 # same person appearing not to be so.
 #
 
+Alex Bennée <kernel-hacker@bennee.com>
 Alexander Gavrilov <angavrilov@gmail.com>
 Aneesh Kumar K.V <aneesh.kumar@gmail.com>
 Brian M. Carlson <sandals@crustytoothpaste.ath.cx>
@@ -15,6 +16,7 @@ Daniel Barkalow <barkalow@iabervon.org>
 David D. Kilzer <ddkilzer@kilzer.net>
 David Kågedal <davidk@lysator.liu.se>
 David S. Miller <davem@davemloft.net>
+Deskin Miller <deskinm@umich.edu>
 Dirk Süsserott <newsletter@dirk.my1.cc>
 Fredrik Kuivinen <freku045@student.liu.se>
 H. Peter Anvin <hpa@bonde.sc.orionmulti.com>
@@ -60,6 +62,7 @@ Uwe Kleine-König <ukleinek@informatik.uni-freiburg.de>
 Uwe Kleine-König <uzeisberger@io.fsforth.de>
 Uwe Kleine-König <zeisberg@informatik.uni-freiburg.de>
 Ville Skyttä <scop@xemacs.org>
+Vitaly "_Vi" Shukela <public_vi@tut.by>
 William Pursell <bill.pursell@gmail.com>
 YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
 anonymous <linux@horizon.com>
diff --git a/Documentation/RelNotes-1.7.0.4.txt b/Documentation/RelNotes-1.7.0.4.txt
new file mode 100644 (file)
index 0000000..cf7f60e
--- /dev/null
@@ -0,0 +1,27 @@
+Git v1.7.0.4 Release Notes
+==========================
+
+Fixes since v1.7.0.3
+--------------------
+
+ * Optimized ntohl/htonl on big-endian machines were broken.
+
+ * Color values given to "color.<cmd>.<slot>" configuration can now have
+   more than one attributes (e.g. "bold ul").
+
+ * "git add -u nonexistent-path" did not complain.
+
+ * "git apply --whitespace=fix" didn't work well when an early patch in
+   a patch series adds trailing blank lines and a later one depended on
+   such a block of blank lines at the end.
+
+ * "git fast-export" didn't check error status and stop when marks file
+   cannot be opened.
+
+ * "git format-patch --ignore-if-in-upstream" gave unwarranted errors
+   when the range was empty, instead of silently finishing.
+
+ * "git remote prune" did not detect remote tracking refs that became
+   dangling correctly.
+
+And other minor fixes and documentation updates.
index 6b6c3da2d95ad2d5d94949034d5dd723f48d977a..b3605c0ec560025e2b53286e4f69bc75c894140b 100644 (file)
@@ -72,6 +72,8 @@ OPTIONS
        Create the branch's reflog.  This activates recording of
        all changes made to the branch ref, enabling use of date
        based sha1 expressions such as "<branchname>@\{yesterday}".
+       Note that in non-bare repositories, reflogs are usually
+       enabled by default by the `core.logallrefupdates` config option.
 
 -f::
 --force::
index 6fc5323ee6a9d3cd22f8c68ebaf514f26c82f684..7ef9d51577594ae6a27f71bae251d6ee2f52befa 100644 (file)
@@ -105,6 +105,9 @@ The number of additional commits is the number
 of commits which would be displayed by "git log v1.0.4..parent".
 The hash suffix is "-g" + 7-char abbreviation for the tip commit
 of parent (which was `2414721b194453f058079d897d13c4e377f92dc6`).
+The "g" prefix stands for "git" and is used to allow describing the version of
+a software depending on the SCM the software is managed with. This is useful
+in an environment where people may use different SCMs.
 
 Doing a 'git describe' on a tag-name will just show the tag name:
 
index 948ea26c5a2b3825e61d0c6495d03829669a7351..400fe7f956961ba0ddf09d2dcc6e539adec7ff74 100644 (file)
@@ -8,13 +8,13 @@ git-fetch - Download objects and refs from another repository
 
 SYNOPSIS
 --------
-'git fetch' <options> <repository> <refspec>...
+'git fetch' [<options>] [<repository> [<refspec>...]]
 
-'git fetch' <options> <group>
+'git fetch' [<options>] <group>
 
-'git fetch' --multiple <options> [<repository> | <group>]...
+'git fetch' --multiple [<options>] [<repository> | <group>]...
 
-'git fetch' --all <options>
+'git fetch' --all [<options>]
 
 
 DESCRIPTION
index 52388206570238636d50ed360120d3464f630a94..277d9e141bf81bddb4ba661e43763b7774a1417d 100644 (file)
@@ -35,7 +35,7 @@ These services can be enabled/disabled using the per-repository
 configuration file:
 
 http.getanyfile::
-       This serves older Git clients which are unable to use the
+       This serves Git clients older than version 1.6.6 that are unable to use the
        upload pack service.  When enabled, clients are able to read
        any file within the repository, including objects that are
        no longer reachable from a branch but are still present.
index 49b6bd9d925f9150a4aaf2f2c4d7439503863d05..7a4e507c4b6c436a72ec5e8519427d64f8b31c1d 100644 (file)
@@ -11,7 +11,7 @@ SYNOPSIS
 [verse]
 'git push' [--all | --mirror | --tags] [-n | --dry-run] [--receive-pack=<git-receive-pack>]
           [--repo=<repository>] [-f | --force] [-v | --verbose] [-u | --set-upstream]
-          [<repository> <refspec>...]
+          [<repository> [<refspec>...]]
 
 DESCRIPTION
 -----------
index df17d49b87c260c6f5b3fd75d4aad41b77fcf8c3..3f9d9c6db39e030c82e1159043c45c834a47012c 100644 (file)
@@ -10,7 +10,7 @@ SYNOPSIS
 [verse]
 'git show-ref' [-q|--quiet] [--verify] [--head] [-d|--dereference]
             [-s|--hash[=<n>]] [--abbrev[=<n>]] [--tags]
-            [--heads] [--] <pattern>...
+            [--heads] [--] [<pattern>...]
 'git show-ref' --exclude-existing[=<pattern>] < ref-list
 
 DESCRIPTION
index 4e00b315ff7450efb4a48ba184c6d65991d53c58..657eac831cf0650ce3c4ac6a1f6a690b282cea59 100644 (file)
@@ -43,9 +43,10 @@ unreleased) version of git, that is available from 'master'
 branch of the `git.git` repository.
 Documentation for older releases are available here:
 
-* link:v1.7.0.3/git.html[documentation for release 1.7.0.3]
+* link:v1.7.0.4/git.html[documentation for release 1.7.0.4]
 
 * release notes for
+  link:RelNotes-1.7.0.4.txt[1.7.0.4],
   link:RelNotes-1.7.0.3.txt[1.7.0.3],
   link:RelNotes-1.7.0.2.txt[1.7.0.2],
   link:RelNotes-1.7.0.1.txt[1.7.0.1],
index 9a5cdafa9cb8c5af8a3903ae18297a23adab0fbf..369f91d3b949b23682c4deda8234f13513f15732 100644 (file)
@@ -36,7 +36,7 @@ Git Transport
 
 The Git transport starts off by sending the command and repository
 on the wire using the pkt-line format, followed by a NUL byte and a
-hostname paramater, terminated by a NUL byte.
+hostname parameter, terminated by a NUL byte.
 
    0032git-upload-pack /project.git\0host=myserver.com\0
 
@@ -331,7 +331,7 @@ An incremental update (fetch) response might look like this:
 
    C: 0009done\n
 
-   S: 003aACK 74730d410fcb6603ace96f1dc55ea6196122532d\n
+   S: 0031ACK 74730d410fcb6603ace96f1dc55ea6196122532d\n
    S: [PACKFILE]
 ----
 
@@ -488,7 +488,7 @@ An example client/server communication might look like this:
    C: 0000
    C: [PACKDATA]
 
-   S: 000aunpack ok\n
-   S: 0014ok refs/heads/debug\n
-   S: 0026ng refs/heads/master non-fast-forward\n
+   S: 000eunpack ok\n
+   S: 0018ok refs/heads/debug\n
+   S: 002ang refs/heads/master non-fast-forward\n
 ----
index 076c18ecc3fc9dc77d1be5dc6e960da72c519576..3eb6d8517eeda1e51d042363f0265fc87f4e5ba0 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 GVF=GIT-VERSION-FILE
-DEF_VER=v1.7.0.3
+DEF_VER=v1.7.0.4
 
 LF='
 '
index 5bb07699191c29516e247f13161479cefd1807b5..e57d9754e28f280cb3074094c800c97dbdb91d12 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -887,6 +887,7 @@ ifeq ($(uname_S),IRIX)
        SNPRINTF_RETURNS_BOGUS = YesPlease
        SHELL_PATH = /usr/gnu/bin/bash
        NEEDS_LIBGEN = YesPlease
+       NEEDS_LIBICONV = YesPlease
 endif
 ifeq ($(uname_S),IRIX64)
        NO_SETENV=YesPlease
@@ -905,6 +906,7 @@ ifeq ($(uname_S),IRIX64)
        SNPRINTF_RETURNS_BOGUS = YesPlease
        SHELL_PATH=/usr/gnu/bin/bash
        NEEDS_LIBGEN = YesPlease
+       NEEDS_LIBICONV = YesPlease
 endif
 ifeq ($(uname_S),HP-UX)
        NO_IPV6=YesPlease
index 02e74966cd59f2377ef8868708d4f5fbe3872c37..9148d7c5c2d201bf9ad28a3487be0aeb7075721e 120000 (symlink)
--- a/RelNotes
+++ b/RelNotes
@@ -1 +1 @@
-Documentation/RelNotes-1.7.0.3.txt
\ No newline at end of file
+Documentation/RelNotes-1.7.0.4.txt
\ No newline at end of file
index 2705f8d057a93f7b4a9351713b89fd9f4e041815..87d2980313e71afc08df3eacde4a99a8468ff874 100644 (file)
@@ -117,7 +117,19 @@ static void fill_pathspec_matches(const char **pathspec, char *seen, int specs)
        }
 }
 
-static void prune_directory(struct dir_struct *dir, const char **pathspec, int prefix)
+static char *find_used_pathspec(const char **pathspec)
+{
+       char *seen;
+       int i;
+
+       for (i = 0; pathspec[i];  i++)
+               ; /* just counting */
+       seen = xcalloc(i, 1);
+       fill_pathspec_matches(pathspec, seen, i);
+       return seen;
+}
+
+static char *prune_directory(struct dir_struct *dir, const char **pathspec, int prefix)
 {
        char *seen;
        int i, specs;
@@ -137,13 +149,7 @@ static void prune_directory(struct dir_struct *dir, const char **pathspec, int p
        }
        dir->nr = dst - dir->entries;
        fill_pathspec_matches(pathspec, seen, specs);
-
-       for (i = 0; i < specs; i++) {
-               if (!seen[i] && pathspec[i][0] && !file_exists(pathspec[i]))
-                       die("pathspec '%s' did not match any files",
-                                       pathspec[i]);
-       }
-        free(seen);
+       return seen;
 }
 
 static void treat_gitlinks(const char **pathspec)
@@ -359,6 +365,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
        int flags;
        int add_new_files;
        int require_pathspec;
+       char *seen = NULL;
 
        git_config(add_config, NULL);
 
@@ -418,7 +425,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
                /* This picks up the paths that are not tracked */
                baselen = fill_directory(&dir, pathspec);
                if (pathspec)
-                       prune_directory(&dir, pathspec, baselen);
+                       seen = prune_directory(&dir, pathspec, baselen);
        }
 
        if (refresh_only) {
@@ -426,6 +433,19 @@ int cmd_add(int argc, const char **argv, const char *prefix)
                goto finish;
        }
 
+       if (pathspec) {
+               int i;
+               if (!seen)
+                       seen = find_used_pathspec(pathspec);
+               for (i = 0; pathspec[i]; i++) {
+                       if (!seen[i] && pathspec[i][0]
+                           && !file_exists(pathspec[i]))
+                               die("pathspec '%s' did not match any files",
+                                   pathspec[i]);
+               }
+               free(seen);
+       }
+
        exit_status |= add_files_to_cache(prefix, pathspec, flags);
 
        if (add_new_files)
index 3af4ae0c269bc8a2cb1bb4240af1f191d2ba0442..7ca90472c10eed8535e76b1e0ec25c92af7cff05 100644 (file)
@@ -1854,33 +1854,76 @@ static int match_fragment(struct image *img,
 {
        int i;
        char *fixed_buf, *buf, *orig, *target;
+       int preimage_limit;
 
-       if (preimage->nr + try_lno > img->nr)
+       if (preimage->nr + try_lno <= img->nr) {
+               /*
+                * The hunk falls within the boundaries of img.
+                */
+               preimage_limit = preimage->nr;
+               if (match_end && (preimage->nr + try_lno != img->nr))
+                       return 0;
+       } else if (ws_error_action == correct_ws_error &&
+                  (ws_rule & WS_BLANK_AT_EOF) && match_end) {
+               /*
+                * This hunk that matches at the end extends beyond
+                * the end of img, and we are removing blank lines
+                * at the end of the file.  This many lines from the
+                * beginning of the preimage must match with img, and
+                * the remainder of the preimage must be blank.
+                */
+               preimage_limit = img->nr - try_lno;
+       } else {
+               /*
+                * The hunk extends beyond the end of the img and
+                * we are not removing blanks at the end, so we
+                * should reject the hunk at this position.
+                */
                return 0;
+       }
 
        if (match_beginning && try_lno)
                return 0;
 
-       if (match_end && preimage->nr + try_lno != img->nr)
-               return 0;
-
        /* Quick hash check */
-       for (i = 0; i < preimage->nr; i++)
+       for (i = 0; i < preimage_limit; i++)
                if (preimage->line[i].hash != img->line[try_lno + i].hash)
                        return 0;
 
-       /*
-        * Do we have an exact match?  If we were told to match
-        * at the end, size must be exactly at try+fragsize,
-        * otherwise try+fragsize must be still within the preimage,
-        * and either case, the old piece should match the preimage
-        * exactly.
-        */
-       if ((match_end
-            ? (try + preimage->len == img->len)
-            : (try + preimage->len <= img->len)) &&
-           !memcmp(img->buf + try, preimage->buf, preimage->len))
-               return 1;
+       if (preimage_limit == preimage->nr) {
+               /*
+                * Do we have an exact match?  If we were told to match
+                * at the end, size must be exactly at try+fragsize,
+                * otherwise try+fragsize must be still within the preimage,
+                * and either case, the old piece should match the preimage
+                * exactly.
+                */
+               if ((match_end
+                    ? (try + preimage->len == img->len)
+                    : (try + preimage->len <= img->len)) &&
+                   !memcmp(img->buf + try, preimage->buf, preimage->len))
+                       return 1;
+       } else {
+               /*
+                * The preimage extends beyond the end of img, so
+                * there cannot be an exact match.
+                *
+                * There must be one non-blank context line that match
+                * a line before the end of img.
+                */
+               char *buf_end;
+
+               buf = preimage->buf;
+               buf_end = buf;
+               for (i = 0; i < preimage_limit; i++)
+                       buf_end += preimage->line[i].len;
+
+               for ( ; buf < buf_end; buf++)
+                       if (!isspace(*buf))
+                               break;
+               if (buf == buf_end)
+                       return 0;
+       }
 
        /*
         * No exact match. If we are ignoring whitespace, run a line-by-line
@@ -1891,7 +1934,10 @@ static int match_fragment(struct image *img,
                size_t imgoff = 0;
                size_t preoff = 0;
                size_t postlen = postimage->len;
-               for (i = 0; i < preimage->nr; i++) {
+               size_t extra_chars;
+               char *preimage_eof;
+               char *preimage_end;
+               for (i = 0; i < preimage_limit; i++) {
                        size_t prelen = preimage->line[i].len;
                        size_t imglen = img->line[try_lno+i].len;
 
@@ -1905,20 +1951,36 @@ static int match_fragment(struct image *img,
                }
 
                /*
-                * Ok, the preimage matches with whitespace fuzz. Update it and
-                * the common postimage lines to use the same whitespace as the
-                * target. imgoff now holds the true length of the target that
-                * matches the preimage, and we need to update the line lengths
-                * of the preimage to match the target ones.
+                * Ok, the preimage matches with whitespace fuzz.
+                *
+                * imgoff now holds the true length of the target that
+                * matches the preimage before the end of the file.
+                *
+                * Count the number of characters in the preimage that fall
+                * beyond the end of the file and make sure that all of them
+                * are whitespace characters. (This can only happen if
+                * we are removing blank lines at the end of the file.)
                 */
-               fixed_buf = xmalloc(imgoff);
-               memcpy(fixed_buf, img->buf + try, imgoff);
-               for (i = 0; i < preimage->nr; i++)
-                       preimage->line[i].len = img->line[try_lno+i].len;
+               buf = preimage_eof = preimage->buf + preoff;
+               for ( ; i < preimage->nr; i++)
+                       preoff += preimage->line[i].len;
+               preimage_end = preimage->buf + preoff;
+               for ( ; buf < preimage_end; buf++)
+                       if (!isspace(*buf))
+                               return 0;
 
                /*
-                * Update the preimage buffer and the postimage context lines.
+                * Update the preimage and the common postimage context
+                * lines to use the same whitespace as the target.
+                * If whitespace is missing in the target (i.e.
+                * if the preimage extends beyond the end of the file),
+                * use the whitespace from the preimage.
                 */
+               extra_chars = preimage_end - preimage_eof;
+               fixed_buf = xmalloc(imgoff + extra_chars);
+               memcpy(fixed_buf, img->buf + try, imgoff);
+               memcpy(fixed_buf + imgoff, preimage_eof, extra_chars);
+               imgoff += extra_chars;
                update_pre_post_images(preimage, postimage,
                                fixed_buf, imgoff, postlen);
                return 1;
@@ -1932,12 +1994,16 @@ static int match_fragment(struct image *img,
         * it might with whitespace fuzz. We haven't been asked to
         * ignore whitespace, we were asked to correct whitespace
         * errors, so let's try matching after whitespace correction.
+        *
+        * The preimage may extend beyond the end of the file,
+        * but in this loop we will only handle the part of the
+        * preimage that falls within the file.
         */
        fixed_buf = xmalloc(preimage->len + 1);
        buf = fixed_buf;
        orig = preimage->buf;
        target = img->buf + try;
-       for (i = 0; i < preimage->nr; i++) {
+       for (i = 0; i < preimage_limit; i++) {
                size_t fixlen; /* length after fixing the preimage */
                size_t oldlen = preimage->line[i].len;
                size_t tgtlen = img->line[try_lno + i].len;
@@ -1977,6 +2043,29 @@ static int match_fragment(struct image *img,
                target += tgtlen;
        }
 
+
+       /*
+        * Now handle the lines in the preimage that falls beyond the
+        * end of the file (if any). They will only match if they are
+        * empty or only contain whitespace (if WS_BLANK_AT_EOL is
+        * false).
+        */
+       for ( ; i < preimage->nr; i++) {
+               size_t fixlen; /* length after fixing the preimage */
+               size_t oldlen = preimage->line[i].len;
+               int j;
+
+               /* Try fixing the line in the preimage */
+               fixlen = ws_fix_copy(buf, orig, oldlen, ws_rule, NULL);
+
+               for (j = 0; j < fixlen; j++)
+                       if (!isspace(buf[j]))
+                               goto unmatch_exit;
+
+               orig += oldlen;
+               buf += fixlen;
+       }
+
        /*
         * Yes, the preimage is based on an older version that still
         * has whitespace breakages unfixed, and fixing them makes the
@@ -2002,9 +2091,6 @@ static int find_pos(struct image *img,
        unsigned long backwards, forwards, try;
        int backwards_lno, forwards_lno, try_lno;
 
-       if (preimage->nr > img->nr)
-               return -1;
-
        /*
         * If match_beginning or match_end is specified, there is no
         * point starting from a wrong line that will never match and
@@ -2015,7 +2101,12 @@ static int find_pos(struct image *img,
        else if (match_end)
                line = img->nr - preimage->nr;
 
-       if (line > img->nr)
+       /*
+        * Because the comparison is unsigned, the following test
+        * will also take care of a negative line number that can
+        * result when match_end and preimage is larger than the target.
+        */
+       if ((size_t) line > img->nr)
                line = img->nr;
 
        try = 0;
@@ -2091,12 +2182,26 @@ static void update_image(struct image *img,
        int i, nr;
        size_t remove_count, insert_count, applied_at = 0;
        char *result;
+       int preimage_limit;
+
+       /*
+        * If we are removing blank lines at the end of img,
+        * the preimage may extend beyond the end.
+        * If that is the case, we must be careful only to
+        * remove the part of the preimage that falls within
+        * the boundaries of img. Initialize preimage_limit
+        * to the number of lines in the preimage that falls
+        * within the boundaries.
+        */
+       preimage_limit = preimage->nr;
+       if (preimage_limit > img->nr - applied_pos)
+               preimage_limit = img->nr - applied_pos;
 
        for (i = 0; i < applied_pos; i++)
                applied_at += img->line[i].len;
 
        remove_count = 0;
-       for (i = 0; i < preimage->nr; i++)
+       for (i = 0; i < preimage_limit; i++)
                remove_count += img->line[applied_pos + i].len;
        insert_count = postimage->len;
 
@@ -2113,8 +2218,8 @@ static void update_image(struct image *img,
        result[img->len] = '\0';
 
        /* Adjust the line table */
-       nr = img->nr + postimage->nr - preimage->nr;
-       if (preimage->nr < postimage->nr) {
+       nr = img->nr + postimage->nr - preimage_limit;
+       if (preimage_limit < postimage->nr) {
                /*
                 * NOTE: this knows that we never call remove_first_line()
                 * on anything other than pre/post image.
@@ -2122,10 +2227,10 @@ static void update_image(struct image *img,
                img->line = xrealloc(img->line, nr * sizeof(*img->line));
                img->line_allocated = img->line;
        }
-       if (preimage->nr != postimage->nr)
+       if (preimage_limit != postimage->nr)
                memmove(img->line + applied_pos + postimage->nr,
-                       img->line + applied_pos + preimage->nr,
-                       (img->nr - (applied_pos + preimage->nr)) *
+                       img->line + applied_pos + preimage_limit,
+                       (img->nr - (applied_pos + preimage_limit)) *
                        sizeof(*img->line));
        memcpy(img->line + applied_pos,
               postimage->line,
@@ -2321,7 +2426,7 @@ static int apply_one_fragment(struct image *img, struct fragment *frag,
 
        if (applied_pos >= 0) {
                if (new_blank_lines_at_end &&
-                   preimage.nr + applied_pos == img->nr &&
+                   preimage.nr + applied_pos >= img->nr &&
                    (ws_rule & WS_BLANK_AT_EOF) &&
                    ws_error_action != nowarn_ws_error) {
                        record_ws_error(WS_BLANK_AT_EOF, "+", 1, frag->linenr);
index b0a4029c94d1bdb1c673fe604cdbfec93df875aa..c6dd71a7bcd0dfcb4691c9ca66a0c3a7bd4dcaae 100644 (file)
@@ -503,7 +503,7 @@ static void export_marks(char *file)
 
        f = fopen(file, "w");
        if (!f)
-               error("Unable to open marks file %s for writing.", file);
+               die_errno("Unable to open marks file %s for writing.", file);
 
        for (i = 0; i < idnums.size; i++) {
                if (deco->base && deco->base->type == 1) {
index bbc425b655e456d57e37118690a088351162ff3c..007dabf62f2574fc9214d6fb2a961619ad305a6b 100644 (file)
 #include "sigchain.h"
 
 static const char * const builtin_fetch_usage[] = {
-       "git fetch [options] [<repository> <refspec>...]",
-       "git fetch [options] <group>",
-       "git fetch --multiple [options] [<repository> | <group>]...",
-       "git fetch --all [options]",
+       "git fetch [<options>] [<repository> [<refspec>...]]",
+       "git fetch [<options>] <group>",
+       "git fetch --multiple [<options>] [<repository> | <group>]...",
+       "git fetch --all [<options>]",
        NULL
 };
 
index e0d5caa61bac72cb40272ab26aa9b2202d5bb3e8..76962e1b08ec6a7e52320c97cc3b54887cc67ef9 100644 (file)
@@ -1106,8 +1106,15 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
                        return 0;
        }
 
-       if (ignore_if_in_upstream)
+       if (ignore_if_in_upstream) {
+               /* Don't say anything if head and upstream are the same. */
+               if (rev.pending.nr == 2) {
+                       struct object_array_entry *o = rev.pending.objects;
+                       if (hashcmp(o[0].item->sha1, o[1].item->sha1) == 0)
+                               return 0;
+               }
                get_patch_ids(&rev, &ids, prefix);
+       }
 
        if (!use_stdout)
                realstdout = xfdopen(xdup(1), "w");
index f7bc2b292fb85725d9cc26ce09f2302aaa7167fe..9fc69312472828a5d6c467799823fc96d94334cd 100644 (file)
@@ -10,7 +10,7 @@
 #include "parse-options.h"
 
 static const char * const push_usage[] = {
-       "git push [<options>] [<repository> <refspec>...]",
+       "git push [<options>] [<repository> [<refspec>...]]",
        NULL,
 };
 
index 0f5022eed24f980f6fedee49f8602fefa6fe85e4..a174a316102c6ed40b4cef24d7812220f6ac5d89 100644 (file)
@@ -23,7 +23,8 @@
 
 static const char * const git_reset_usage[] = {
        "git reset [--mixed | --soft | --hard | --merge] [-q] [<commit>]",
-       "git reset [--mixed] <commit> [--] <paths>...",
+       "git reset [-q] <commit> [--] <paths>...",
+       "git reset --patch [<commit>] [--] [<paths>...]",
        NULL
 };
 
diff --git a/color.c b/color.c
index 62977f4808ae339fdfe797e16b4eb28dc6abb85d..e8bcac0a79a27ee093f3d5a92013780cf52eb9da 100644 (file)
--- a/color.c
+++ b/color.c
@@ -47,7 +47,7 @@ void color_parse_mem(const char *value, int value_len, const char *var,
 {
        const char *ptr = value;
        int len = value_len;
-       int attr = -1;
+       unsigned int attr = 0;
        int fg = -2;
        int bg = -2;
 
@@ -56,7 +56,7 @@ void color_parse_mem(const char *value, int value_len, const char *var,
                return;
        }
 
-       /* [fg [bg]] [attr] */
+       /* [fg [bg]] [attr]... */
        while (len > 0) {
                const char *word = ptr;
                int val, wordlen = 0;
@@ -85,19 +85,27 @@ void color_parse_mem(const char *value, int value_len, const char *var,
                        goto bad;
                }
                val = parse_attr(word, wordlen);
-               if (val < 0 || attr != -1)
+               if (0 <= val)
+                       attr |= (1 << val);
+               else
                        goto bad;
-               attr = val;
        }
 
-       if (attr >= 0 || fg >= 0 || bg >= 0) {
+       if (attr || fg >= 0 || bg >= 0) {
                int sep = 0;
+               int i;
 
                *dst++ = '\033';
                *dst++ = '[';
-               if (attr >= 0) {
-                       *dst++ = '0' + attr;
-                       sep++;
+
+               for (i = 0; attr; i++) {
+                       unsigned bit = (1 << i);
+                       if (!(attr & bit))
+                               continue;
+                       attr &= ~bit;
+                       if (sep++)
+                               *dst++ = ';';
+                       *dst++ = '0' + i;
                }
                if (fg >= 0) {
                        if (sep++)
diff --git a/color.h b/color.h
index 3cb4b7fc890880b0fcf19a11c6bc7de6b10d6e8d..bcb28cf10f2cbef11d9dba0e5a7f3f0515cbbd70 100644 (file)
--- a/color.h
+++ b/color.h
@@ -1,8 +1,20 @@
 #ifndef COLOR_H
 #define COLOR_H
 
-/* "\033[1;38;5;2xx;48;5;2xxm\0" is 23 bytes */
-#define COLOR_MAXLEN 24
+/*  2 + (2 * num_attrs) + 8 + 1 + 8 + 'm' + NUL */
+/* "\033[1;2;4;5;7;38;5;2xx;48;5;2xxm\0" */
+/*
+ * The maximum length of ANSI color sequence we would generate:
+ * - leading ESC '['            2
+ * - attr + ';'                 2 * 8 (e.g. "1;")
+ * - fg color + ';'             9 (e.g. "38;5;2xx;")
+ * - fg color + ';'             9 (e.g. "48;5;2xx;")
+ * - terminating 'm' NUL        2
+ *
+ * The above overcounts attr (we only use 5 not 8) and one semicolon
+ * but it is close enough.
+ */
+#define COLOR_MAXLEN 40
 
 /*
  * IMPORTANT: Due to the way these color codes are emulated on Windows,
index f3b8c44181776a99c3eb79e15542104d67001c9d..54756dbb05ba99ab1679f17a50f04c3f1cede8e6 100644 (file)
@@ -17,6 +17,8 @@ static inline uint32_t default_swab32(uint32_t val)
                ((val & 0x000000ff) << 24));
 }
 
+#undef bswap32
+
 #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
 
 #define bswap32(x) ({ \
index ab65f77ab99500d99d24a9b7266669f37bb02cb2..59b18dc7ca51180426a0dbf11e651a93c5eedc81 100644 (file)
@@ -259,8 +259,17 @@ int mingw_utime (const char *file_name, const struct utimbuf *times)
        int fh, rc;
 
        /* must have write permission */
-       if ((fh = open(file_name, O_RDWR | O_BINARY)) < 0)
-               return -1;
+       DWORD attrs = GetFileAttributes(file_name);
+       if (attrs != INVALID_FILE_ATTRIBUTES &&
+           (attrs & FILE_ATTRIBUTE_READONLY)) {
+               /* ignore errors here; open() will report them */
+               SetFileAttributes(file_name, attrs & ~FILE_ATTRIBUTE_READONLY);
+       }
+
+       if ((fh = open(file_name, O_RDWR | O_BINARY)) < 0) {
+               rc = -1;
+               goto revert_attrs;
+       }
 
        time_t_to_filetime(times->modtime, &mft);
        time_t_to_filetime(times->actime, &aft);
@@ -270,6 +279,13 @@ int mingw_utime (const char *file_name, const struct utimbuf *times)
        } else
                rc = 0;
        close(fh);
+
+revert_attrs:
+       if (attrs != INVALID_FILE_ATTRIBUTES &&
+           (attrs & FILE_ATTRIBUTE_READONLY)) {
+               /* ignore errors again */
+               SetFileAttributes(file_name, attrs);
+       }
        return rc;
 }
 
index 7d9e1c03e88d7785f4ff0d534563ba5778fbc244..a90ab10505a3694de83a0ffd8fc472518f12cf2b 100644 (file)
--- a/daemon.c
+++ b/daemon.c
@@ -590,14 +590,17 @@ static int execute(struct sockaddr *addr)
 static int addrcmp(const struct sockaddr_storage *s1,
     const struct sockaddr_storage *s2)
 {
-       if (s1->ss_family != s2->ss_family)
-               return s1->ss_family - s2->ss_family;
-       if (s1->ss_family == AF_INET)
+       const struct sockaddr *sa1 = (const struct sockaddr*) s1;
+       const struct sockaddr *sa2 = (const struct sockaddr*) s2;
+
+       if (sa1->sa_family != sa2->sa_family)
+               return sa1->sa_family - sa2->sa_family;
+       if (sa1->sa_family == AF_INET)
                return memcmp(&((struct sockaddr_in *)s1)->sin_addr,
                    &((struct sockaddr_in *)s2)->sin_addr,
                    sizeof(struct in_addr));
 #ifndef NO_IPV6
-       if (s1->ss_family == AF_INET6)
+       if (sa1->sa_family == AF_INET6)
                return memcmp(&((struct sockaddr_in6 *)s1)->sin6_addr,
                    &((struct sockaddr_in6 *)s2)->sin6_addr,
                    sizeof(struct in6_addr));
diff --git a/diff.c b/diff.c
index 0d465faa1e546382267dc0779116a013647ecf41..99059231b4e9d7eac9eb2d63ce6baa4d43190b95 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -3865,6 +3865,7 @@ static char *run_textconv(const char *pgm, struct diff_filespec *spec,
        const char **arg = argv;
        struct child_process child;
        struct strbuf buf = STRBUF_INIT;
+       int err = 0;
 
        temp = prepare_temp_file(spec->path, spec);
        *arg++ = pgm;
@@ -3875,16 +3876,20 @@ static char *run_textconv(const char *pgm, struct diff_filespec *spec,
        child.use_shell = 1;
        child.argv = argv;
        child.out = -1;
-       if (start_command(&child) != 0 ||
-           strbuf_read(&buf, child.out, 0) < 0 ||
-           finish_command(&child) != 0) {
-               close(child.out);
-               strbuf_release(&buf);
+       if (start_command(&child)) {
                remove_tempfile();
-               error("error running textconv command '%s'", pgm);
                return NULL;
        }
+
+       if (strbuf_read(&buf, child.out, 0) < 0)
+               err = error("error reading from textconv command '%s'", pgm);
        close(child.out);
+
+       if (finish_command(&child) || err) {
+               strbuf_release(&buf);
+               remove_tempfile();
+               return NULL;
+       }
        remove_tempfile();
 
        return strbuf_detach(&buf, outsize);
diff --git a/dir.c b/dir.c
index 133c333df61be37e7908f77367f63c85cfc9c548..cb83332a261f97026f9c6273afb162245944dec7 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -594,13 +594,29 @@ static int simplify_away(const char *path, int pathlen, const struct path_simpli
        return 0;
 }
 
-static int in_pathspec(const char *path, int len, const struct path_simplify *simplify)
+/*
+ * This function tells us whether an excluded path matches a
+ * list of "interesting" pathspecs. That is, whether a path matched
+ * by any of the pathspecs could possibly be ignored by excluding
+ * the specified path. This can happen if:
+ *
+ *   1. the path is mentioned explicitly in the pathspec
+ *
+ *   2. the path is a directory prefix of some element in the
+ *      pathspec
+ */
+static int exclude_matches_pathspec(const char *path, int len,
+               const struct path_simplify *simplify)
 {
        if (simplify) {
                for (; simplify->path; simplify++) {
                        if (len == simplify->len
                            && !memcmp(path, simplify->path, len))
                                return 1;
+                       if (len < simplify->len
+                           && simplify->path[len] == '/'
+                           && !memcmp(path, simplify->path, len))
+                               return 1;
                }
        }
        return 0;
@@ -678,7 +694,7 @@ static enum path_treatment treat_one_path(struct dir_struct *dir,
 {
        int exclude = excluded(dir, path, &dtype);
        if (exclude && (dir->flags & DIR_COLLECT_IGNORED)
-           && in_pathspec(path, *len, simplify))
+           && exclude_matches_pathspec(path, *len, simplify))
                dir_add_ignored(dir, path, *len);
 
        /*
index d975d072dbf0fab36266c3f3a71a69875206e4d8..adc42de8752fd395707f1e395c61991b3146cebb 100755 (executable)
@@ -78,11 +78,13 @@ sub generate_command
                        next;
                }
                if ($arg eq '-g' || $arg eq '--gui') {
-                       my $tool = Git::command_oneline('config',
-                                                       'diff.guitool');
-                       if (length($tool)) {
-                               $ENV{GIT_DIFF_TOOL} = $tool;
-                       }
+                       eval {
+                               my $tool = Git::command_oneline('config',
+                                                               'diff.guitool');
+                               if (length($tool)) {
+                                       $ENV{GIT_DIFF_TOOL} = $tool;
+                               }
+                       };
                        next;
                }
                if ($arg eq '-y' || $arg eq '--no-prompt') {
index aa47e541ee4fe55254edc3fb59ef534ba4d5be66..59db3dc38e72fda88d521171a174c08b919677a9 100755 (executable)
@@ -210,14 +210,18 @@ list_stash () {
 }
 
 show_stash () {
+       have_stash || die 'No stash found'
+
        flags=$(git rev-parse --no-revs --flags "$@")
        if test -z "$flags"
        then
                flags=--stat
        fi
 
-       w_commit=$(git rev-parse --verify --default $ref_stash "$@") &&
-       b_commit=$(git rev-parse --verify "$w_commit^") &&
+       w_commit=$(git rev-parse --quiet --verify --default $ref_stash "$@") &&
+       b_commit=$(git rev-parse --quiet --verify "$w_commit^") ||
+               die "'$*' is not a stash"
+
        git diff $flags $b_commit $w_commit
 }
 
index 3d80deba01696f7d039955da68daac9e61507420..9d4c58238ea87963221d948020e928d232c0d90d 100755 (executable)
@@ -2209,8 +2209,7 @@ sub config_to_multi {
 sub git_get_project_config {
        my ($key, $type) = @_;
 
-       # do we have project
-       return unless (defined $project && defined $git_dir);
+       return unless defined $git_dir;
 
        # key sanity check
        return unless ($key);
diff --git a/refs.c b/refs.c
index 63e30d74a7eacee53682b20068e8e24a37840ccc..a7518b6f0ddb505aa0133d5920a76a19f8e00a75 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -6,6 +6,7 @@
 
 /* ISSYMREF=01 and ISPACKED=02 are public interfaces */
 #define REF_KNOWS_PEELED 04
+#define REF_BROKEN 010
 
 struct ref_list {
        struct ref_list *next;
@@ -275,8 +276,10 @@ static struct ref_list *get_ref_dir(const char *base, struct ref_list *list)
                                list = get_ref_dir(ref, list);
                                continue;
                        }
-                       if (!resolve_ref(ref, sha1, 1, &flag))
+                       if (!resolve_ref(ref, sha1, 1, &flag)) {
                                hashclr(sha1);
+                               flag |= REF_BROKEN;
+                       }
                        list = add_ref(ref, sha1, flag, list, NULL);
                }
                free(ref);
@@ -539,10 +542,10 @@ static int do_one_ref(const char *base, each_ref_fn fn, int trim,
 {
        if (strncmp(base, entry->name, trim))
                return 0;
-       /* Is this a "negative ref" that represents a deleted ref? */
-       if (is_null_sha1(entry->sha1))
-               return 0;
+
        if (!(flags & DO_FOR_EACH_INCLUDE_BROKEN)) {
+               if (entry->flag & REF_BROKEN)
+                       return 0; /* ignore dangling symref */
                if (!has_sha1_file(entry->sha1)) {
                        error("%s does not point to a valid object!", entry->name);
                        return 0;
index 89282ccf7a1a73d4b5ee085c4236b1204dc502c8..41df6bcf279a1abc4462e63866076094cfbdedd8 100755 (executable)
@@ -108,13 +108,17 @@ $test_case 'merge (case change)' '
 
 '
 
-$test_case 'add (with different case)' '
+
+
+test_expect_failure 'add (with different case)' '
 
        git reset --hard initial &&
        rm camelcase &&
        echo 1 >CamelCase &&
        git add CamelCase &&
-       test $(git ls-files | grep -i camelcase | wc -l) = 1
+       camel=$(git ls-files | grep -i camelcase) &&
+       test $(echo "$camel" | wc -l) = 1 &&
+       test "z$(git cat-file blob :$camel)" = z1
 
 '
 
index 912075063b9946d38a9ff72621cb80bcf2c05399..2ad2819a345af53ff6ab0b7c28fa313f1a0a5956 100755 (executable)
@@ -176,4 +176,9 @@ test_expect_success 'add -u resolves unmerged paths' '
 
 '
 
+test_expect_success '"add -u non-existent" should fail' '
+       test_must_fail git add -u non-existent &&
+       ! (git ls-files | grep "non-existent")
+'
+
 test_done
diff --git a/t/t2204-add-ignored.sh b/t/t2204-add-ignored.sh
new file mode 100755 (executable)
index 0000000..24afdab
--- /dev/null
@@ -0,0 +1,79 @@
+#!/bin/sh
+
+test_description='giving ignored paths to git add'
+
+. ./test-lib.sh
+
+test_expect_success setup '
+       mkdir sub dir dir/sub &&
+       echo sub >.gitignore &&
+       echo ign >>.gitignore &&
+       for p in . sub dir dir/sub
+       do
+               >"$p/ign" &&
+               >"$p/file" || exit 1
+       done
+'
+
+for i in file dir/file dir 'd*'
+do
+       test_expect_success "no complaints for unignored $i" '
+               rm -f .git/index &&
+               git add "$i" &&
+               git ls-files "$i" >out &&
+               test -s out
+       '
+done
+
+for i in ign dir/ign dir/sub dir/sub/*ign sub/file sub sub/*
+do
+       test_expect_success "complaints for ignored $i" '
+               rm -f .git/index &&
+               test_must_fail git add "$i" 2>err &&
+               git ls-files "$i" >out &&
+               ! test -s out &&
+               grep -e "Use -f if" err &&
+               cat err
+       '
+
+       test_expect_success "complaints for ignored $i with unignored file" '
+               rm -f .git/index &&
+               test_must_fail git add "$i" file 2>err &&
+               git ls-files "$i" >out &&
+               ! test -s out &&
+               grep -e "Use -f if" err &&
+               cat err
+       '
+done
+
+for i in sub sub/*
+do
+       test_expect_success "complaints for ignored $i in dir" '
+               rm -f .git/index &&
+               (
+                       cd dir &&
+                       test_must_fail git add "$i" 2>err &&
+                       git ls-files "$i" >out &&
+                       ! test -s out &&
+                       grep -e "Use -f if" err &&
+                       cat err
+               )
+       '
+done
+
+for i in ign file
+do
+       test_expect_success "complaints for ignored $i in sub" '
+               rm -f .git/index &&
+               (
+                       cd sub &&
+                       test_must_fail git add "$i" 2>err &&
+                       git ls-files "$i" >out &&
+                       ! test -s out &&
+                       grep -e "Use -f if" err &&
+                       cat err
+               )
+       '
+done
+
+test_done
diff --git a/t/t3417-rebase-whitespace-fix.sh b/t/t3417-rebase-whitespace-fix.sh
new file mode 100755 (executable)
index 0000000..220a740
--- /dev/null
@@ -0,0 +1,126 @@
+#!/bin/sh
+
+test_description='git rebase --whitespace=fix
+
+This test runs git rebase --whitespace=fix and make sure that it works.
+'
+
+. ./test-lib.sh
+
+# prepare initial revision of "file" with a blank line at the end
+cat >file <<EOF
+a
+b
+c
+
+EOF
+
+# expected contents in "file" after rebase
+cat >expect-first <<EOF
+a
+b
+c
+EOF
+
+# prepare second revision of "file"
+cat >second <<EOF
+a
+b
+c
+
+d
+e
+f
+
+
+
+
+EOF
+
+# expected contents in second revision after rebase
+cat >expect-second <<EOF
+a
+b
+c
+
+d
+e
+f
+EOF
+
+test_expect_success 'blank line at end of file; extend at end of file' '
+       git commit --allow-empty -m "Initial empty commit" &&
+       git add file && git commit -m first &&
+       mv second file &&
+       git add file && git commit -m second &&
+       git rebase --whitespace=fix HEAD^^ &&
+       git diff --exit-code HEAD^:file expect-first &&
+       test_cmp file expect-second
+'
+
+# prepare third revision of "file"
+sed -e's/Z//' >third <<EOF
+a
+b
+c
+
+d
+e
+f
+    Z
+ Z
+h
+i
+j
+k
+l
+EOF
+
+sed -e's/ //g' <third >expect-third
+
+test_expect_success 'two blanks line at end of file; extend at end of file' '
+       cp third file && git add file && git commit -m third &&
+       git rebase --whitespace=fix HEAD^^ &&
+       git diff --exit-code HEAD^:file expect-second &&
+       test_cmp file expect-third
+'
+
+test_expect_success 'same, but do not remove trailing spaces' '
+       git config core.whitespace "-blank-at-eol" &&
+       git reset --hard HEAD^ &&
+       cp third file && git add file && git commit -m third &&
+       git rebase --whitespace=fix HEAD^^
+       git diff --exit-code HEAD^:file expect-second &&
+       test_cmp file third
+'
+
+sed -e's/Z//' >beginning <<EOF
+a
+                   Z
+       Z
+EOF
+
+cat >expect-beginning <<EOF
+a
+
+
+1
+2
+3
+4
+5
+EOF
+
+test_expect_success 'at beginning of file' '
+       git config core.whitespace "blank-at-eol" &&
+       cp beginning file &&
+       git commit -m beginning file &&
+       for i in 1 2 3 4 5; do
+               echo $i
+       done >> file &&
+       git commit -m more file &&
+       git rebase --whitespace=fix HEAD^^ &&
+       test_cmp file expect-beginning
+'
+
+test_done
index 85eb0fbf96a65ad958422da02ca4975fe687da95..525c9a8fdfb4953612e6946994c8e555f676bfd2 100755 (executable)
@@ -255,4 +255,9 @@ test_expect_success 'git add to resolve conflicts on otherwise ignored path' '
        git add track-this
 '
 
+test_expect_success '"add non-existent" should fail' '
+       test_must_fail git add non-existent &&
+       ! (git ls-files | grep "non-existent")
+'
+
 test_done
index f2a2aaa2b9c7fd84634bb74febb3f0f5ac1793e1..843ef7f88c3025ebe0660a645024fcf0942386bd 100755 (executable)
@@ -557,4 +557,8 @@ test_expect_success 'format-patch -- <path>' '
        ! grep "Use .--" error
 '
 
+test_expect_success 'format-patch --ignore-if-in-upstream HEAD' '
+       git format-patch --ignore-if-in-upstream HEAD
+'
+
 test_done
index 5ade44c043ca6577b2e331b152515359128dbd32..d5ccdd0cf8061e797e88185bfddb0864f73291dd 100755 (executable)
@@ -8,14 +8,13 @@ test_description='Test diff/status color escape codes'
 
 color()
 {
-       git config diff.color.new "$1" &&
-       test "`git config --get-color diff.color.new`" = "\e$2"
+       actual=$(git config --get-color no.such.slot "$1") &&
+       test "$actual" = "\e$2"
 }
 
 invalid_color()
 {
-       git config diff.color.new "$1" &&
-       test -z "`git config --get-color diff.color.new 2>/dev/null`"
+       test_must_fail git config --get-color no.such.slot "$1"
 }
 
 test_expect_success 'reset' '
@@ -42,6 +41,14 @@ test_expect_success 'fg bg attr' '
        color "blue red ul" "[4;34;41m"
 '
 
+test_expect_success 'fg bg attr...' '
+       color "blue bold dim ul blink reverse" "[1;2;4;5;7;34m"
+'
+
+test_expect_success 'long color specification' '
+       color "254 255 bold dim ul blink reverse" "[1;2;4;5;7;38;5;254;48;5;255m"
+'
+
 test_expect_success '256 colors' '
        color "254 bold 255" "[1;38;5;254;48;5;255m"
 '
index 0e3ce3611d9e83ab290ce034f2439961864ce30a..c617c2a33d8e8ac1dc7e049f9056ca6025fbf852 100755 (executable)
@@ -134,4 +134,13 @@ test_expect_success 'two lines' '
 
 '
 
+test_expect_success 'apply patch with 3 context lines matching at end' '
+       { echo a; echo b; echo c; echo d; } >file &&
+       git add file &&
+       echo e >>file &&
+       git diff >patch &&
+       >file &&
+       test_must_fail git apply patch
+'
+
 test_done
index ca26397590f3d79455c41894203fbff7bb6a9c3c..fb9ad247bf76c07a8b6dbbb0d6bf1ab830041770 100755 (executable)
@@ -261,4 +261,174 @@ test_expect_success 'blank but not empty at EOF' '
        grep "new blank line at EOF" error
 '
 
+test_expect_success 'applying beyond EOF requires one non-blank context line' '
+       { echo; echo; echo; echo; } >one &&
+       git add one &&
+       { echo b; } >>one &&
+       git diff -- one >patch &&
+
+       git checkout one &&
+       { echo a; echo; } >one &&
+       cp one expect &&
+       test_must_fail git apply --whitespace=fix patch &&
+       test_cmp one expect &&
+       test_must_fail git apply --ignore-space-change --whitespace=fix patch &&
+       test_cmp one expect
+'
+
+test_expect_success 'tons of blanks at EOF should not apply' '
+       for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16; do
+               echo; echo; echo; echo;
+       done >one &&
+       git add one &&
+       echo a >>one &&
+       git diff -- one >patch &&
+
+       >one &&
+       test_must_fail git apply --whitespace=fix patch &&
+       test_must_fail git apply --ignore-space-change --whitespace=fix patch
+'
+
+test_expect_success 'missing blank line at end with --whitespace=fix' '
+       echo a >one &&
+       echo >>one &&
+       git add one &&
+       echo b >>one &&
+       cp one expect &&
+       git diff -- one >patch &&
+       echo a >one &&
+       cp one saved-one &&
+       test_must_fail git apply patch &&
+       git apply --whitespace=fix patch &&
+       test_cmp one expect &&
+       mv saved-one one &&
+       git apply --ignore-space-change --whitespace=fix patch &&
+       test_cmp one expect
+'
+
+test_expect_success 'two missing blank lines at end with --whitespace=fix' '
+       { echo a; echo; echo b; echo c; } >one &&
+       cp one no-blank-lines &&
+       { echo; echo; } >>one &&
+       git add one &&
+       echo d >>one &&
+       cp one expect &&
+       echo >>one &&
+       git diff -- one >patch &&
+       cp no-blank-lines one &&
+       test_must_fail git apply patch &&
+       git apply --whitespace=fix patch &&
+       test_cmp one expect &&
+       mv no-blank-lines one &&
+       test_must_fail git apply patch &&
+       git apply --ignore-space-change --whitespace=fix patch &&
+       test_cmp one expect
+'
+
+test_expect_success 'shrink file with tons of missing blanks at end of file' '
+       { echo a; echo b; echo c; } >one &&
+       cp one no-blank-lines &&
+       for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16; do
+               echo; echo; echo; echo;
+       done >>one &&
+       git add one &&
+       echo a >one &&
+       cp one expect &&
+       git diff -- one >patch &&
+       cp no-blank-lines one &&
+       test_must_fail git apply patch &&
+       git apply --whitespace=fix patch &&
+       test_cmp one expect &&
+       mv no-blank-lines one &&
+       git apply --ignore-space-change --whitespace=fix patch &&
+       test_cmp one expect
+'
+
+test_expect_success 'missing blanks at EOF must only match blank lines' '
+       { echo a; echo b; } >one &&
+       git add one &&
+       { echo c; echo d; } >>one &&
+       git diff -- one >patch &&
+
+       echo a >one &&
+       test_must_fail git apply patch
+       test_must_fail git apply --whitespace=fix patch &&
+       test_must_fail git apply --ignore-space-change --whitespace=fix patch
+'
+
+sed -e's/Z//' >one <<EOF
+a
+b
+c
+                     Z
+EOF
+
+test_expect_success 'missing blank line should match context line with spaces' '
+       git add one &&
+       echo d >>one &&
+       git diff -- one >patch &&
+       { echo a; echo b; echo c; } >one &&
+       cp one expect &&
+       { echo; echo d; } >>expect &&
+       git add one &&
+
+       git apply --whitespace=fix patch &&
+       test_cmp one expect
+'
+
+sed -e's/Z//' >one <<EOF
+a
+b
+c
+                     Z
+EOF
+
+test_expect_success 'same, but with the --ignore-space-option' '
+       git add one &&
+       echo d >>one &&
+       cp one expect &&
+       git diff -- one >patch &&
+       { echo a; echo b; echo c; } >one &&
+       git add one &&
+
+       git checkout-index -f one &&
+       git apply --ignore-space-change --whitespace=fix patch &&
+       test_cmp one expect
+'
+
+test_expect_success 'same, but with CR-LF line endings && cr-at-eol set' '
+       git config core.whitespace cr-at-eol &&
+       printf "a\r\n" >one &&
+       printf "b\r\n" >>one &&
+       printf "c\r\n" >>one &&
+       cp one save-one &&
+       printf "                 \r\n" >>one
+       git add one &&
+       printf "d\r\n" >>one &&
+       cp one expect &&
+       git diff -- one >patch &&
+       mv save-one one &&
+
+       git apply --ignore-space-change --whitespace=fix patch &&
+       test_cmp one expect
+'
+
+test_expect_success 'same, but with CR-LF line endings && cr-at-eol unset' '
+       git config --unset core.whitespace &&
+       printf "a\r\n" >one &&
+       printf "b\r\n" >>one &&
+       printf "c\r\n" >>one &&
+       cp one save-one &&
+       printf "                 \r\n" >>one
+       git add one &&
+       cp one expect &&
+       printf "d\r\n" >>one &&
+       git diff -- one >patch &&
+       mv save-one one &&
+       echo d >>expect &&
+
+       git apply --ignore-space-change --whitespace=fix patch &&
+       test_cmp one expect
+'
+
 test_done
index a82c5ffa1c608f45786fe37531ffe93008a3570b..26920502093a98d4b5721f783e006de9d999792a 100755 (executable)
@@ -507,15 +507,15 @@ test_expect_success 'remote prune to cause a dangling symref' '
        (
                cd seven &&
                git remote prune origin
-       ) 2>err &&
+       ) >err 2>&1 &&
        grep "has become dangling" err &&
 
-       : And the dangling symref will not cause other annoying errors
+       : And the dangling symref will not cause other annoying errors &&
        (
                cd seven &&
                git branch -a
        ) 2>err &&
-       ! grep "points nowhere" err
+       ! grep "points nowhere" err &&
        (
                cd seven &&
                test_must_fail git branch nomore origin
index 19c72f55bf60c746f72e640e24043b2d83e00fe3..1de83ef98fdcbfd63469e66ba4886c2477b983ff 100755 (executable)
@@ -92,6 +92,15 @@ test_expect_success 'difftool honors --gui' '
        restore_test_defaults
 '
 
+test_expect_success 'difftool --gui works without configured diff.guitool' '
+       git config diff.tool test-tool &&
+
+       diff=$(git difftool --no-prompt --gui branch) &&
+       test "$diff" = "branch" &&
+
+       restore_test_defaults
+'
+
 # Specify the diff tool using $GIT_DIFF_TOOL
 test_expect_success 'GIT_DIFF_TOOL variable' '
        git config --unset diff.tool
index 356964e53a1acba1558881865fd99acdee48a17f..d43f37ccafb4ecf6f649a5504d2626f652d48d02 100755 (executable)
@@ -150,20 +150,22 @@ test_expect_success 'setup submodule' '
 
        git checkout -f master &&
        mkdir sub &&
-       cd sub &&
-       git init  &&
-       echo test file > file &&
-       git add file &&
-       git commit -m sub_initial &&
-       cd .. &&
+       (
+               cd sub &&
+               git init  &&
+               echo test file > file &&
+               git add file &&
+               git commit -m sub_initial
+       ) &&
        git submodule add "`pwd`/sub" sub &&
        git commit -m initial &&
        test_tick &&
-       cd sub &&
-       echo more data >> file &&
-       git add file &&
-       git commit -m sub_second &&
-       cd .. &&
+       (
+               cd sub &&
+               echo more data >> file &&
+               git add file &&
+               git commit -m sub_second
+       ) &&
        git add sub &&
        git commit -m second
 
@@ -264,19 +266,20 @@ test_expect_success 'cope with tagger-less tags' '
 
 test_expect_success 'setup for limiting exports by PATH' '
        mkdir limit-by-paths &&
-       cd limit-by-paths &&
-       git init &&
-       echo hi > there &&
-       git add there &&
-       git commit -m "First file" &&
-       echo foo > bar &&
-       git add bar &&
-       git commit -m "Second file" &&
-       git tag -a -m msg mytag &&
-       echo morefoo >> bar &&
-       git add bar &&
-       git commit -m "Change to second file" &&
-       cd ..
+       (
+               cd limit-by-paths &&
+               git init &&
+               echo hi > there &&
+               git add there &&
+               git commit -m "First file" &&
+               echo foo > bar &&
+               git add bar &&
+               git commit -m "Second file" &&
+               git tag -a -m msg mytag &&
+               echo morefoo >> bar &&
+               git add bar &&
+               git commit -m "Change to second file"
+       )
 '
 
 cat > limit-by-paths/expected << EOF
@@ -297,10 +300,11 @@ M 100644 :1 there
 EOF
 
 test_expect_success 'dropping tag of filtered out object' '
+(
        cd limit-by-paths &&
        git fast-export --tag-of-filtered-object=drop mytag -- there > output &&
-       test_cmp output expected &&
-       cd ..
+       test_cmp output expected
+)
 '
 
 cat >> limit-by-paths/expected << EOF
@@ -313,10 +317,11 @@ msg
 EOF
 
 test_expect_success 'rewriting tag of filtered out object' '
+(
        cd limit-by-paths &&
        git fast-export --tag-of-filtered-object=rewrite mytag -- there > output &&
-       test_cmp output expected &&
-       cd ..
+       test_cmp output expected
+)
 '
 
 cat > limit-by-paths/expected << EOF
@@ -343,13 +348,13 @@ M 100644 :2 there
 EOF
 
 test_expect_failure 'no exact-ref revisions included' '
-       cd limit-by-paths &&
-       git fast-export master~2..master~1 > output &&
-       test_cmp output expected &&
-       cd ..
+       (
+               cd limit-by-paths &&
+               git fast-export master~2..master~1 > output &&
+               test_cmp output expected
+       )
 '
 
-
 test_expect_success 'set-up a few more tags for tag export tests' '
        git checkout -f master &&
        HEAD_TREE=`git show -s --pretty=raw HEAD | grep tree | sed "s/tree //"` &&