Skip to content

Commit 2db511f

Browse files
committed
Merge branch 'maint'
* maint: Documentation/git-am.txt: Pass -r in the example invocation of rm -f .dotest timezone_names[]: fixed the tz offset for New Zealand. filter-branch documentation: non-zero exit status in command abort the filter rev-parse: fix potential bus error with --parseopt option spec handling Use a single implementation and API for copy_file() Documentation/git-filter-branch: add a new msg-filter example Correct fast-export file mode strings to match fast-import standard
2 parents b8d97d0 + 81fa145 commit 2db511f

File tree

11 files changed

+89
-51
lines changed

11 files changed

+89
-51
lines changed

Documentation/git-am.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ aborts in the middle,. You can recover from this in one of two ways:
138138

139139
The command refuses to process new mailboxes while `.dotest`
140140
directory exists, so if you decide to start over from scratch,
141-
run `rm -f .dotest` before running the command with mailbox
141+
run `rm -f -r .dotest` before running the command with mailbox
142142
names.
143143

144144

Documentation/git-filter-branch.txt

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ notable exception of the commit filter, for technical reasons).
5656
Prior to that, the $GIT_COMMIT environment variable will be set to contain
5757
the id of the commit being rewritten. Also, GIT_AUTHOR_NAME,
5858
GIT_AUTHOR_EMAIL, GIT_AUTHOR_DATE, GIT_COMMITTER_NAME, GIT_COMMITTER_EMAIL,
59-
and GIT_COMMITTER_DATE are set according to the current commit.
59+
and GIT_COMMITTER_DATE are set according to the current commit. If any
60+
evaluation of <command> returns a non-zero exit status, the whole operation
61+
will be aborted.
6062

6163
A 'map' function is available that takes an "original sha1 id" argument
6264
and outputs a "rewritten sha1 id" if the commit has been already
@@ -197,7 +199,7 @@ happened). If this is not the case, use:
197199

198200
--------------------------------------------------------------------------
199201
git filter-branch --parent-filter \
200-
'cat; test $GIT_COMMIT = <commit-id> && echo "-p <graft-id>"' HEAD
202+
'test $GIT_COMMIT = <commit-id> && echo "-p <graft-id>" || cat' HEAD
201203
--------------------------------------------------------------------------
202204

203205
or even simpler:
@@ -240,6 +242,15 @@ committed a merge between P1 and P2, it will be propagated properly
240242
and all children of the merge will become merge commits with P1,P2
241243
as their parents instead of the merge commit.
242244

245+
You can rewrite the commit log messages using `--message-filter`. For
246+
example, `git-svn-id` strings in a repository created by `git-svn` can
247+
be removed this way:
248+
249+
-------------------------------------------------------
250+
git filter-branch --message-filter '
251+
sed -e "/^git-svn-id:/d"
252+
'
253+
-------------------------------------------------------
243254

244255
To restrict rewriting to only part of the history, specify a revision
245256
range in addition to the new branch name. The new branch name will

builtin-fast-export.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ static void show_filemodify(struct diff_queue_struct *q,
123123
printf("D %s\n", spec->path);
124124
else {
125125
struct object *object = lookup_object(spec->sha1);
126-
printf("M 0%06o :%d %s\n", spec->mode,
126+
printf("M %06o :%d %s\n", spec->mode,
127127
get_object_mark(object), spec->path);
128128
}
129129
}

builtin-init-db.c

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -29,27 +29,6 @@ static void safe_create_dir(const char *dir, int share)
2929
die("Could not make %s writable by group\n", dir);
3030
}
3131

32-
static int copy_file(const char *dst, const char *src, int mode)
33-
{
34-
int fdi, fdo, status;
35-
36-
mode = (mode & 0111) ? 0777 : 0666;
37-
if ((fdi = open(src, O_RDONLY)) < 0)
38-
return fdi;
39-
if ((fdo = open(dst, O_WRONLY | O_CREAT | O_EXCL, mode)) < 0) {
40-
close(fdi);
41-
return fdo;
42-
}
43-
status = copy_fd(fdi, fdo);
44-
if (close(fdo) != 0)
45-
return error("%s: write error: %s", dst, strerror(errno));
46-
47-
if (!status && adjust_shared_perm(dst))
48-
return -1;
49-
50-
return status;
51-
}
52-
5332
static void copy_templates_1(char *path, int baselen,
5433
char *template, int template_baselen,
5534
DIR *dir)

builtin-rerere.c

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -267,23 +267,6 @@ static int diff_two(const char *file1, const char *label1,
267267
return 0;
268268
}
269269

270-
static int copy_file(const char *src, const char *dest)
271-
{
272-
FILE *in, *out;
273-
char buffer[32768];
274-
int count;
275-
276-
if (!(in = fopen(src, "r")))
277-
return error("Could not open %s", src);
278-
if (!(out = fopen(dest, "w")))
279-
return error("Could not open %s", dest);
280-
while ((count = fread(buffer, 1, sizeof(buffer), in)))
281-
fwrite(buffer, 1, count, out);
282-
fclose(in);
283-
fclose(out);
284-
return 0;
285-
}
286-
287270
static int do_plain_rerere(struct path_list *rr, int fd)
288271
{
289272
struct path_list conflict = { NULL, 0, 0, 1 };
@@ -343,7 +326,7 @@ static int do_plain_rerere(struct path_list *rr, int fd)
343326
continue;
344327

345328
fprintf(stderr, "Recorded resolution for '%s'.\n", path);
346-
copy_file(path, rr_path(name, "postimage"));
329+
copy_file(rr_path(name, "postimage"), path, 0666);
347330
tail_optimization:
348331
if (i < rr->nr - 1)
349332
memmove(rr->items + i,

builtin-rev-parse.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ static int cmd_parseopt(int argc, const char **argv, const char *prefix)
315315
s = strchr(sb.buf, ' ');
316316
if (!s || *sb.buf == ' ') {
317317
o->type = OPTION_GROUP;
318-
o->help = xstrdup(skipspaces(s));
318+
o->help = xstrdup(skipspaces(sb.buf));
319319
continue;
320320
}
321321

cache.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,7 @@ extern const char *git_log_output_encoding;
698698
/* IO helper functions */
699699
extern void maybe_flush_or_die(FILE *, const char *);
700700
extern int copy_fd(int ifd, int ofd);
701+
extern int copy_file(const char *dst, const char *src, int mode);
701702
extern int read_in_full(int fd, void *buf, size_t count);
702703
extern int write_in_full(int fd, const void *buf, size_t count);
703704
extern void write_or_die(int fd, const void *buf, size_t count);

copy.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,24 @@ int copy_fd(int ifd, int ofd)
3434
close(ifd);
3535
return 0;
3636
}
37+
38+
int copy_file(const char *dst, const char *src, int mode)
39+
{
40+
int fdi, fdo, status;
41+
42+
mode = (mode & 0111) ? 0777 : 0666;
43+
if ((fdi = open(src, O_RDONLY)) < 0)
44+
return fdi;
45+
if ((fdo = open(dst, O_WRONLY | O_CREAT | O_EXCL, mode)) < 0) {
46+
close(fdi);
47+
return fdo;
48+
}
49+
status = copy_fd(fdi, fdo);
50+
if (close(fdo) != 0)
51+
return error("%s: write error: %s", dst, strerror(errno));
52+
53+
if (!status && adjust_shared_perm(dst))
54+
return -1;
55+
56+
return status;
57+
}

date.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,9 @@ static const struct {
213213
{ "EAST", +10, 0, }, /* Eastern Australian Standard */
214214
{ "EADT", +10, 1, }, /* Eastern Australian Daylight */
215215
{ "GST", +10, 0, }, /* Guam Standard, USSR Zone 9 */
216-
{ "NZT", +11, 0, }, /* New Zealand */
217-
{ "NZST", +11, 0, }, /* New Zealand Standard */
218-
{ "NZDT", +11, 1, }, /* New Zealand Daylight */
216+
{ "NZT", +12, 0, }, /* New Zealand */
217+
{ "NZST", +12, 0, }, /* New Zealand Standard */
218+
{ "NZDT", +12, 1, }, /* New Zealand Daylight */
219219
{ "IDLE", +12, 0, }, /* International Date Line East */
220220
};
221221

diff.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,8 @@ static void print_line_count(int count)
272272
}
273273
}
274274

275-
static void copy_file(int prefix, const char *data, int size,
276-
const char *set, const char *reset)
275+
static void copy_file_with_prefix(int prefix, const char *data, int size,
276+
const char *set, const char *reset)
277277
{
278278
int ch, nl_just_seen = 1;
279279
while (0 < size--) {
@@ -331,9 +331,9 @@ static void emit_rewrite_diff(const char *name_a,
331331
print_line_count(lc_b);
332332
printf(" @@%s\n", reset);
333333
if (lc_a)
334-
copy_file('-', one->data, one->size, old, reset);
334+
copy_file_with_prefix('-', one->data, one->size, old, reset);
335335
if (lc_b)
336-
copy_file('+', two->data, two->size, new, reset);
336+
copy_file_with_prefix('+', two->data, two->size, new, reset);
337337
}
338338

339339
static int fill_mmfile(mmfile_t *mf, struct diff_filespec *one)

0 commit comments

Comments
 (0)