Imported Upstream version 2.3.8 upstream/2.3.8
authorDongHun Kwak <dh0128.kwak@samsung.com>
Wed, 3 Mar 2021 06:15:00 +0000 (15:15 +0900)
committerDongHun Kwak <dh0128.kwak@samsung.com>
Wed, 3 Mar 2021 06:15:00 +0000 (15:15 +0900)
14 files changed:
Documentation/RelNotes/2.3.8.txt [new file with mode: 0644]
Documentation/blame-options.txt
Documentation/git-log.txt
Documentation/git.txt
Documentation/gitk.txt
Documentation/line-range-format.txt
GIT-VERSION-GEN
RelNotes
builtin/config.c
date.c
diff-no-index.c
line-log.c
t/t4053-diff-no-index.sh
t/t4211-line-log.sh

diff --git a/Documentation/RelNotes/2.3.8.txt b/Documentation/RelNotes/2.3.8.txt
new file mode 100644 (file)
index 0000000..0b67268
--- /dev/null
@@ -0,0 +1,22 @@
+Git v2.3.8 Release Notes
+========================
+
+Fixes since v2.3.7
+------------------
+
+ * The usual "git diff" when seeing a file turning into a directory
+   showed a patchset to remove the file and create all files in the
+   directory, but "git diff --no-index" simply refused to work.  Also,
+   when asked to compare a file and a directory, imitate POSIX "diff"
+   and compare the file with the file with the same name in the
+   directory, instead of refusing to run.
+
+ * The default $HOME/.gitconfig file created upon "git config --global"
+   that edits it had incorrectly spelled user.name and user.email
+   entries in it.
+
+ * "git commit --date=now" or anything that relies on approxidate lost
+   the daylight-saving-time offset.
+
+Also contains typofixes, documentation updates and trivial code
+clean-ups.
index 0cebc4f..23b8ff8 100644 (file)
@@ -10,7 +10,7 @@
        Include additional statistics at the end of blame output.
 
 -L <start>,<end>::
--L :<regex>::
+-L :<funcname>::
        Annotate only the given line range. May be specified multiple times.
        Overlapping ranges are allowed.
 +
index 1f7bc67..6e65c5a 100644 (file)
@@ -62,9 +62,9 @@ produced by `--stat`, etc.
        output by allowing them to allocate space in advance.
 
 -L <start>,<end>:<file>::
--L :<regex>:<file>::
+-L :<funcname>:<file>::
        Trace the evolution of the line range given by "<start>,<end>"
-       (or the funcname regex <regex>) within the <file>.  You may
+       (or the function name regex <funcname>) within the <file>.  You may
        not give any pathspec limiters.  This is currently limited to
        a walk starting from a single revision, i.e., you may only
        give zero or one positive revision arguments.
index 8704ffd..adff610 100644 (file)
@@ -43,9 +43,10 @@ unreleased) version of Git, that is available from the 'master'
 branch of the `git.git` repository.
 Documentation for older releases are available here:
 
-* link:v2.3.7/git.html[documentation for release 2.3.7]
+* link:v2.3.8/git.html[documentation for release 2.3.8]
 
 * release notes for
+  link:RelNotes/2.3.8.txt[2.3.8],
   link:RelNotes/2.3.7.txt[2.3.7],
   link:RelNotes/2.3.6.txt[2.3.6],
   link:RelNotes/2.3.5.txt[2.3.5],
index 7ae50aa..6ade002 100644 (file)
@@ -99,10 +99,10 @@ linkgit:git-rev-list[1] for a complete list.
        detailed explanation.)
 
 -L<start>,<end>:<file>::
--L:<regex>:<file>::
+-L:<funcname>:<file>::
 
        Trace the evolution of the line range given by "<start>,<end>"
-       (or the funcname regex <regex>) within the <file>.  You may
+       (or the function name regex <funcname>) within the <file>.  You may
        not give any pathspec limiters.  This is currently limited to
        a walk starting from a single revision, i.e., you may only
        give zero or one positive revision arguments.
index d7f2603..829676f 100644 (file)
@@ -22,8 +22,9 @@ This is only valid for <end> and will specify a number
 of lines before or after the line given by <start>.
 
 +
-If ``:<regex>'' is given in place of <start> and <end>, it denotes the range
-from the first funcname line that matches <regex>, up to the next
-funcname line. ``:<regex>'' searches from the end of the previous `-L` range,
-if any, otherwise from the start of file.
-``^:<regex>'' searches from the start of file.
+If ``:<funcname>'' is given in place of <start> and <end>, it is a
+regular expression that denotes the range from the first funcname line
+that matches <funcname>, up to the next funcname line. ``:<funcname>''
+searches from the end of the previous `-L` range, if any, otherwise
+from the start of file. ``^:<funcname>'' searches from the start of
+file.
index 0c1ee67..a2fe57a 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 GVF=GIT-VERSION-FILE
-DEF_VER=v2.3.7
+DEF_VER=v2.3.8
 
 LF='
 '
index 8f376a9..159d09e 120000 (symlink)
--- a/RelNotes
+++ b/RelNotes
@@ -1 +1 @@
-Documentation/RelNotes/2.3.7.txt
\ No newline at end of file
+Documentation/RelNotes/2.3.8.txt
\ No newline at end of file
index 15a7bea..73dc2f1 100644 (file)
@@ -455,9 +455,9 @@ static char *default_user_config(void)
        struct strbuf buf = STRBUF_INIT;
        strbuf_addf(&buf,
                    _("# This is Git's per-user configuration file.\n"
-                     "[core]\n"
+                     "[user]\n"
                      "# Please adapt and uncomment the following lines:\n"
-                     "#        user = %s\n"
+                     "#        name = %s\n"
                      "#        email = %s\n"),
                    ident_default_name(),
                    ident_default_email());
diff --git a/date.c b/date.c
index 3eba2df..733d1b2 100644 (file)
--- a/date.c
+++ b/date.c
@@ -704,10 +704,17 @@ int parse_date_basic(const char *date, unsigned long *timestamp, int *offset)
                date += match;
        }
 
-       /* mktime uses local timezone */
+       /* do not use mktime(), which uses local timezone, here */
        *timestamp = tm_to_time_t(&tm);
+       if (*timestamp == -1)
+               return -1;
+
        if (*offset == -1) {
-               time_t temp_time = mktime(&tm);
+               time_t temp_time;
+
+               /* gmtime_r() in match_digit() may have clobbered it */
+               tm.tm_isdst = -1;
+               temp_time = mktime(&tm);
                if ((time_t)*timestamp > temp_time) {
                        *offset = ((time_t)*timestamp - temp_time) / 60;
                } else {
@@ -715,9 +722,6 @@ int parse_date_basic(const char *date, unsigned long *timestamp, int *offset)
                }
        }
 
-       if (*timestamp == -1)
-               return -1;
-
        if (!tm_gmt)
                *timestamp -= *offset * 60;
        return 0; /* success */
index 265709b..0320605 100644 (file)
@@ -97,8 +97,27 @@ static int queue_diff(struct diff_options *o,
        if (get_mode(name1, &mode1) || get_mode(name2, &mode2))
                return -1;
 
-       if (mode1 && mode2 && S_ISDIR(mode1) != S_ISDIR(mode2))
-               return error("file/directory conflict: %s, %s", name1, name2);
+       if (mode1 && mode2 && S_ISDIR(mode1) != S_ISDIR(mode2)) {
+               struct diff_filespec *d1, *d2;
+
+               if (S_ISDIR(mode1)) {
+                       /* 2 is file that is created */
+                       d1 = noindex_filespec(NULL, 0);
+                       d2 = noindex_filespec(name2, mode2);
+                       name2 = NULL;
+                       mode2 = 0;
+               } else {
+                       /* 1 is file that is deleted */
+                       d1 = noindex_filespec(name1, mode1);
+                       d2 = noindex_filespec(NULL, 0);
+                       name1 = NULL;
+                       mode1 = 0;
+               }
+               /* emit that file */
+               diff_queue(&diff_queued_diff, d1, d2);
+
+               /* and then let the entire directory be created or deleted */
+       }
 
        if (S_ISDIR(mode1) || S_ISDIR(mode2)) {
                struct strbuf buffer1 = STRBUF_INIT;
@@ -182,12 +201,50 @@ static int queue_diff(struct diff_options *o,
        }
 }
 
+/* append basename of F to D */
+static void append_basename(struct strbuf *path, const char *dir, const char *file)
+{
+       const char *tail = strrchr(file, '/');
+
+       strbuf_addstr(path, dir);
+       while (path->len && path->buf[path->len - 1] == '/')
+               path->len--;
+       strbuf_addch(path, '/');
+       strbuf_addstr(path, tail ? tail + 1 : file);
+}
+
+/*
+ * DWIM "diff D F" into "diff D/F F" and "diff F D" into "diff F D/F"
+ * Note that we append the basename of F to D/, so "diff a/b/file D"
+ * becomes "diff a/b/file D/file", not "diff a/b/file D/a/b/file".
+ */
+static void fixup_paths(const char **path, struct strbuf *replacement)
+{
+       unsigned int isdir0, isdir1;
+
+       if (path[0] == file_from_standard_input ||
+           path[1] == file_from_standard_input)
+               return;
+       isdir0 = is_directory(path[0]);
+       isdir1 = is_directory(path[1]);
+       if (isdir0 == isdir1)
+               return;
+       if (isdir0) {
+               append_basename(replacement, path[0], path[1]);
+               path[0] = replacement->buf;
+       } else {
+               append_basename(replacement, path[1], path[0]);
+               path[1] = replacement->buf;
+       }
+}
+
 void diff_no_index(struct rev_info *revs,
                   int argc, const char **argv,
                   const char *prefix)
 {
        int i, prefixlen;
        const char *paths[2];
+       struct strbuf replacement = STRBUF_INIT;
 
        diff_setup(&revs->diffopt);
        for (i = 1; i < argc - 2; ) {
@@ -217,6 +274,9 @@ void diff_no_index(struct rev_info *revs,
                        p = xstrdup(prefix_filename(prefix, prefixlen, p));
                paths[i] = p;
        }
+
+       fixup_paths(paths, &replacement);
+
        revs->diffopt.skip_stat_unmatch = 1;
        if (!revs->diffopt.output_format)
                revs->diffopt.output_format = DIFF_FORMAT_PATCH;
@@ -235,6 +295,8 @@ void diff_no_index(struct rev_info *revs,
        diffcore_std(&revs->diffopt);
        diff_flush(&revs->diffopt);
 
+       strbuf_release(&replacement);
+
        /*
         * The return code for --no-index imitates diff(1):
         * 0 = no changes, 1 = changes, else error
index b7864ad..1a6bc59 100644 (file)
@@ -575,7 +575,7 @@ parse_lines(struct commit *commit, const char *prefix, struct string_list *args)
 
                name_part = skip_range_arg(item->string);
                if (!name_part || *name_part != ':' || !name_part[1])
-                       die("-L argument '%s' not of the form start,end:file",
+                       die("-L argument not 'start,end:file' or ':funcname:file': %s",
                            item->string);
                range_part = xstrndup(item->string, name_part - item->string);
                name_part++;
index 2ab3c48..596dfe7 100755 (executable)
@@ -55,4 +55,38 @@ test_expect_success 'git diff --no-index executed outside repo gives correct err
        )
 '
 
+test_expect_success 'diff D F and diff F D' '
+       (
+               cd repo &&
+               echo in-repo >a &&
+               echo non-repo >../non/git/a &&
+               mkdir sub &&
+               echo sub-repo >sub/a &&
+
+               test_must_fail git diff --no-index sub/a ../non/git/a >expect &&
+               test_must_fail git diff --no-index sub/a ../non/git/ >actual &&
+               test_cmp expect actual &&
+
+               test_must_fail git diff --no-index a ../non/git/a >expect &&
+               test_must_fail git diff --no-index a ../non/git/ >actual &&
+               test_cmp expect actual &&
+
+               test_must_fail git diff --no-index ../non/git/a a >expect &&
+               test_must_fail git diff --no-index ../non/git a >actual &&
+               test_cmp expect actual
+       )
+'
+
+test_expect_success 'turning a file into a directory' '
+       (
+               cd non/git &&
+               mkdir d e e/sub &&
+               echo 1 >d/sub &&
+               echo 2 >e/sub/file &&
+               printf "D\td/sub\nA\te/sub/file\n" >expect &&
+               test_must_fail git diff --no-index --name-status d e >actual &&
+               test_cmp expect actual
+       )
+'
+
 test_done
index 0901b30..4451127 100755 (executable)
@@ -54,14 +54,14 @@ canned_test "-L 4:a.c -L 8,12:a.c simple" multiple-superset
 canned_test "-L 8,12:a.c -L 4:a.c simple" multiple-superset
 
 test_bad_opts "-L" "switch.*requires a value"
-test_bad_opts "-L b.c" "argument.*not of the form"
-test_bad_opts "-L 1:" "argument.*not of the form"
+test_bad_opts "-L b.c" "argument not .start,end:file"
+test_bad_opts "-L 1:" "argument not .start,end:file"
 test_bad_opts "-L 1:nonexistent" "There is no path"
 test_bad_opts "-L 1:simple" "There is no path"
-test_bad_opts "-L '/foo:b.c'" "argument.*not of the form"
+test_bad_opts "-L '/foo:b.c'" "argument not .start,end:file"
 test_bad_opts "-L 1000:b.c" "has only.*lines"
 test_bad_opts "-L 1,1000:b.c" "has only.*lines"
-test_bad_opts "-L :b.c" "argument.*not of the form"
+test_bad_opts "-L :b.c" "argument not .start,end:file"
 test_bad_opts "-L :foo:b.c" "no match"
 
 test_expect_success '-L X (X == nlines)' '