Skip to content

Commit c99fec6

Browse files
committed
Sync with 2.3.8
Signed-off-by: Junio C Hamano <[email protected]>
2 parents 3d4a3ff + 9a3d637 commit c99fec6

File tree

12 files changed

+149
-25
lines changed

12 files changed

+149
-25
lines changed

Documentation/RelNotes/2.3.8.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Git v2.3.8 Release Notes
2+
========================
3+
4+
Fixes since v2.3.7
5+
------------------
6+
7+
* The usual "git diff" when seeing a file turning into a directory
8+
showed a patchset to remove the file and create all files in the
9+
directory, but "git diff --no-index" simply refused to work. Also,
10+
when asked to compare a file and a directory, imitate POSIX "diff"
11+
and compare the file with the file with the same name in the
12+
directory, instead of refusing to run.
13+
14+
* The default $HOME/.gitconfig file created upon "git config --global"
15+
that edits it had incorrectly spelled user.name and user.email
16+
entries in it.
17+
18+
* "git commit --date=now" or anything that relies on approxidate lost
19+
the daylight-saving-time offset.
20+
21+
Also contains typofixes, documentation updates and trivial code
22+
clean-ups.

Documentation/blame-options.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
Include additional statistics at the end of blame output.
1111

1212
-L <start>,<end>::
13-
-L :<regex>::
13+
-L :<funcname>::
1414
Annotate only the given line range. May be specified multiple times.
1515
Overlapping ranges are allowed.
1616
+

Documentation/git-log.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ produced by `--stat`, etc.
6262
output by allowing them to allocate space in advance.
6363

6464
-L <start>,<end>:<file>::
65-
-L :<regex>:<file>::
65+
-L :<funcname>:<file>::
6666
Trace the evolution of the line range given by "<start>,<end>"
67-
(or the funcname regex <regex>) within the <file>. You may
67+
(or the function name regex <funcname>) within the <file>. You may
6868
not give any pathspec limiters. This is currently limited to
6969
a walk starting from a single revision, i.e., you may only
7070
give zero or one positive revision arguments.

Documentation/git.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,10 @@ Documentation for older releases are available here:
4848
* release notes for
4949
link:RelNotes/2.4.0.txt[2.4].
5050

51-
* link:v2.3.7/git.html[documentation for release 2.3.7]
51+
* link:v2.3.8/git.html[documentation for release 2.3.8]
5252

5353
* release notes for
54+
link:RelNotes/2.3.8.txt[2.3.8],
5455
link:RelNotes/2.3.7.txt[2.3.7],
5556
link:RelNotes/2.3.6.txt[2.3.6],
5657
link:RelNotes/2.3.5.txt[2.3.5],

Documentation/gitk.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,10 @@ linkgit:git-rev-list[1] for a complete list.
9999
detailed explanation.)
100100

101101
-L<start>,<end>:<file>::
102-
-L:<regex>:<file>::
102+
-L:<funcname>:<file>::
103103

104104
Trace the evolution of the line range given by "<start>,<end>"
105-
(or the funcname regex <regex>) within the <file>. You may
105+
(or the function name regex <funcname>) within the <file>. You may
106106
not give any pathspec limiters. This is currently limited to
107107
a walk starting from a single revision, i.e., you may only
108108
give zero or one positive revision arguments.

Documentation/line-range-format.txt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ This is only valid for <end> and will specify a number
2222
of lines before or after the line given by <start>.
2323

2424
+
25-
If ``:<regex>'' is given in place of <start> and <end>, it denotes the range
26-
from the first funcname line that matches <regex>, up to the next
27-
funcname line. ``:<regex>'' searches from the end of the previous `-L` range,
28-
if any, otherwise from the start of file.
29-
``^:<regex>'' searches from the start of file.
25+
If ``:<funcname>'' is given in place of <start> and <end>, it is a
26+
regular expression that denotes the range from the first funcname line
27+
that matches <funcname>, up to the next funcname line. ``:<funcname>''
28+
searches from the end of the previous `-L` range, if any, otherwise
29+
from the start of file. ``^:<funcname>'' searches from the start of
30+
file.

builtin/config.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,9 +455,9 @@ static char *default_user_config(void)
455455
struct strbuf buf = STRBUF_INIT;
456456
strbuf_addf(&buf,
457457
_("# This is Git's per-user configuration file.\n"
458-
"[core]\n"
458+
"[user]\n"
459459
"# Please adapt and uncomment the following lines:\n"
460-
"# user = %s\n"
460+
"# name = %s\n"
461461
"# email = %s\n"),
462462
ident_default_name(),
463463
ident_default_email());

date.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -704,20 +704,24 @@ int parse_date_basic(const char *date, unsigned long *timestamp, int *offset)
704704
date += match;
705705
}
706706

707-
/* mktime uses local timezone */
707+
/* do not use mktime(), which uses local timezone, here */
708708
*timestamp = tm_to_time_t(&tm);
709+
if (*timestamp == -1)
710+
return -1;
711+
709712
if (*offset == -1) {
710-
time_t temp_time = mktime(&tm);
713+
time_t temp_time;
714+
715+
/* gmtime_r() in match_digit() may have clobbered it */
716+
tm.tm_isdst = -1;
717+
temp_time = mktime(&tm);
711718
if ((time_t)*timestamp > temp_time) {
712719
*offset = ((time_t)*timestamp - temp_time) / 60;
713720
} else {
714721
*offset = -(int)((temp_time - (time_t)*timestamp) / 60);
715722
}
716723
}
717724

718-
if (*timestamp == -1)
719-
return -1;
720-
721725
if (!tm_gmt)
722726
*timestamp -= *offset * 60;
723727
return 0; /* success */

diff-no-index.c

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,27 @@ static int queue_diff(struct diff_options *o,
9797
if (get_mode(name1, &mode1) || get_mode(name2, &mode2))
9898
return -1;
9999

100-
if (mode1 && mode2 && S_ISDIR(mode1) != S_ISDIR(mode2))
101-
return error("file/directory conflict: %s, %s", name1, name2);
100+
if (mode1 && mode2 && S_ISDIR(mode1) != S_ISDIR(mode2)) {
101+
struct diff_filespec *d1, *d2;
102+
103+
if (S_ISDIR(mode1)) {
104+
/* 2 is file that is created */
105+
d1 = noindex_filespec(NULL, 0);
106+
d2 = noindex_filespec(name2, mode2);
107+
name2 = NULL;
108+
mode2 = 0;
109+
} else {
110+
/* 1 is file that is deleted */
111+
d1 = noindex_filespec(name1, mode1);
112+
d2 = noindex_filespec(NULL, 0);
113+
name1 = NULL;
114+
mode1 = 0;
115+
}
116+
/* emit that file */
117+
diff_queue(&diff_queued_diff, d1, d2);
118+
119+
/* and then let the entire directory be created or deleted */
120+
}
102121

103122
if (S_ISDIR(mode1) || S_ISDIR(mode2)) {
104123
struct strbuf buffer1 = STRBUF_INIT;
@@ -182,12 +201,50 @@ static int queue_diff(struct diff_options *o,
182201
}
183202
}
184203

204+
/* append basename of F to D */
205+
static void append_basename(struct strbuf *path, const char *dir, const char *file)
206+
{
207+
const char *tail = strrchr(file, '/');
208+
209+
strbuf_addstr(path, dir);
210+
while (path->len && path->buf[path->len - 1] == '/')
211+
path->len--;
212+
strbuf_addch(path, '/');
213+
strbuf_addstr(path, tail ? tail + 1 : file);
214+
}
215+
216+
/*
217+
* DWIM "diff D F" into "diff D/F F" and "diff F D" into "diff F D/F"
218+
* Note that we append the basename of F to D/, so "diff a/b/file D"
219+
* becomes "diff a/b/file D/file", not "diff a/b/file D/a/b/file".
220+
*/
221+
static void fixup_paths(const char **path, struct strbuf *replacement)
222+
{
223+
unsigned int isdir0, isdir1;
224+
225+
if (path[0] == file_from_standard_input ||
226+
path[1] == file_from_standard_input)
227+
return;
228+
isdir0 = is_directory(path[0]);
229+
isdir1 = is_directory(path[1]);
230+
if (isdir0 == isdir1)
231+
return;
232+
if (isdir0) {
233+
append_basename(replacement, path[0], path[1]);
234+
path[0] = replacement->buf;
235+
} else {
236+
append_basename(replacement, path[1], path[0]);
237+
path[1] = replacement->buf;
238+
}
239+
}
240+
185241
void diff_no_index(struct rev_info *revs,
186242
int argc, const char **argv,
187243
const char *prefix)
188244
{
189245
int i, prefixlen;
190246
const char *paths[2];
247+
struct strbuf replacement = STRBUF_INIT;
191248

192249
diff_setup(&revs->diffopt);
193250
for (i = 1; i < argc - 2; ) {
@@ -217,6 +274,9 @@ void diff_no_index(struct rev_info *revs,
217274
p = xstrdup(prefix_filename(prefix, prefixlen, p));
218275
paths[i] = p;
219276
}
277+
278+
fixup_paths(paths, &replacement);
279+
220280
revs->diffopt.skip_stat_unmatch = 1;
221281
if (!revs->diffopt.output_format)
222282
revs->diffopt.output_format = DIFF_FORMAT_PATCH;
@@ -235,6 +295,8 @@ void diff_no_index(struct rev_info *revs,
235295
diffcore_std(&revs->diffopt);
236296
diff_flush(&revs->diffopt);
237297

298+
strbuf_release(&replacement);
299+
238300
/*
239301
* The return code for --no-index imitates diff(1):
240302
* 0 = no changes, 1 = changes, else error

line-log.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ parse_lines(struct commit *commit, const char *prefix, struct string_list *args)
575575

576576
name_part = skip_range_arg(item->string);
577577
if (!name_part || *name_part != ':' || !name_part[1])
578-
die("-L argument '%s' not of the form start,end:file",
578+
die("-L argument not 'start,end:file' or ':funcname:file': %s",
579579
item->string);
580580
range_part = xstrndup(item->string, name_part - item->string);
581581
name_part++;

0 commit comments

Comments
 (0)