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
This commit is contained in:
commit
2db511fdbd
@ -138,7 +138,7 @@ aborts in the middle,. You can recover from this in one of two ways:
|
||||
|
||||
The command refuses to process new mailboxes while `.dotest`
|
||||
directory exists, so if you decide to start over from scratch,
|
||||
run `rm -f .dotest` before running the command with mailbox
|
||||
run `rm -f -r .dotest` before running the command with mailbox
|
||||
names.
|
||||
|
||||
|
||||
|
@ -56,7 +56,9 @@ notable exception of the commit filter, for technical reasons).
|
||||
Prior to that, the $GIT_COMMIT environment variable will be set to contain
|
||||
the id of the commit being rewritten. Also, GIT_AUTHOR_NAME,
|
||||
GIT_AUTHOR_EMAIL, GIT_AUTHOR_DATE, GIT_COMMITTER_NAME, GIT_COMMITTER_EMAIL,
|
||||
and GIT_COMMITTER_DATE are set according to the current commit.
|
||||
and GIT_COMMITTER_DATE are set according to the current commit. If any
|
||||
evaluation of <command> returns a non-zero exit status, the whole operation
|
||||
will be aborted.
|
||||
|
||||
A 'map' function is available that takes an "original sha1 id" argument
|
||||
and outputs a "rewritten sha1 id" if the commit has been already
|
||||
@ -197,7 +199,7 @@ happened). If this is not the case, use:
|
||||
|
||||
--------------------------------------------------------------------------
|
||||
git filter-branch --parent-filter \
|
||||
'cat; test $GIT_COMMIT = <commit-id> && echo "-p <graft-id>"' HEAD
|
||||
'test $GIT_COMMIT = <commit-id> && echo "-p <graft-id>" || cat' HEAD
|
||||
--------------------------------------------------------------------------
|
||||
|
||||
or even simpler:
|
||||
@ -240,6 +242,15 @@ committed a merge between P1 and P2, it will be propagated properly
|
||||
and all children of the merge will become merge commits with P1,P2
|
||||
as their parents instead of the merge commit.
|
||||
|
||||
You can rewrite the commit log messages using `--message-filter`. For
|
||||
example, `git-svn-id` strings in a repository created by `git-svn` can
|
||||
be removed this way:
|
||||
|
||||
-------------------------------------------------------
|
||||
git filter-branch --message-filter '
|
||||
sed -e "/^git-svn-id:/d"
|
||||
'
|
||||
-------------------------------------------------------
|
||||
|
||||
To restrict rewriting to only part of the history, specify a revision
|
||||
range in addition to the new branch name. The new branch name will
|
||||
|
@ -123,7 +123,7 @@ static void show_filemodify(struct diff_queue_struct *q,
|
||||
printf("D %s\n", spec->path);
|
||||
else {
|
||||
struct object *object = lookup_object(spec->sha1);
|
||||
printf("M 0%06o :%d %s\n", spec->mode,
|
||||
printf("M %06o :%d %s\n", spec->mode,
|
||||
get_object_mark(object), spec->path);
|
||||
}
|
||||
}
|
||||
|
@ -29,27 +29,6 @@ static void safe_create_dir(const char *dir, int share)
|
||||
die("Could not make %s writable by group\n", dir);
|
||||
}
|
||||
|
||||
static int copy_file(const char *dst, const char *src, int mode)
|
||||
{
|
||||
int fdi, fdo, status;
|
||||
|
||||
mode = (mode & 0111) ? 0777 : 0666;
|
||||
if ((fdi = open(src, O_RDONLY)) < 0)
|
||||
return fdi;
|
||||
if ((fdo = open(dst, O_WRONLY | O_CREAT | O_EXCL, mode)) < 0) {
|
||||
close(fdi);
|
||||
return fdo;
|
||||
}
|
||||
status = copy_fd(fdi, fdo);
|
||||
if (close(fdo) != 0)
|
||||
return error("%s: write error: %s", dst, strerror(errno));
|
||||
|
||||
if (!status && adjust_shared_perm(dst))
|
||||
return -1;
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static void copy_templates_1(char *path, int baselen,
|
||||
char *template, int template_baselen,
|
||||
DIR *dir)
|
||||
|
@ -267,23 +267,6 @@ static int diff_two(const char *file1, const char *label1,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int copy_file(const char *src, const char *dest)
|
||||
{
|
||||
FILE *in, *out;
|
||||
char buffer[32768];
|
||||
int count;
|
||||
|
||||
if (!(in = fopen(src, "r")))
|
||||
return error("Could not open %s", src);
|
||||
if (!(out = fopen(dest, "w")))
|
||||
return error("Could not open %s", dest);
|
||||
while ((count = fread(buffer, 1, sizeof(buffer), in)))
|
||||
fwrite(buffer, 1, count, out);
|
||||
fclose(in);
|
||||
fclose(out);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int do_plain_rerere(struct path_list *rr, int fd)
|
||||
{
|
||||
struct path_list conflict = { NULL, 0, 0, 1 };
|
||||
@ -343,7 +326,7 @@ static int do_plain_rerere(struct path_list *rr, int fd)
|
||||
continue;
|
||||
|
||||
fprintf(stderr, "Recorded resolution for '%s'.\n", path);
|
||||
copy_file(path, rr_path(name, "postimage"));
|
||||
copy_file(rr_path(name, "postimage"), path, 0666);
|
||||
tail_optimization:
|
||||
if (i < rr->nr - 1)
|
||||
memmove(rr->items + i,
|
||||
|
@ -315,7 +315,7 @@ static int cmd_parseopt(int argc, const char **argv, const char *prefix)
|
||||
s = strchr(sb.buf, ' ');
|
||||
if (!s || *sb.buf == ' ') {
|
||||
o->type = OPTION_GROUP;
|
||||
o->help = xstrdup(skipspaces(s));
|
||||
o->help = xstrdup(skipspaces(sb.buf));
|
||||
continue;
|
||||
}
|
||||
|
||||
|
1
cache.h
1
cache.h
@ -698,6 +698,7 @@ extern const char *git_log_output_encoding;
|
||||
/* IO helper functions */
|
||||
extern void maybe_flush_or_die(FILE *, const char *);
|
||||
extern int copy_fd(int ifd, int ofd);
|
||||
extern int copy_file(const char *dst, const char *src, int mode);
|
||||
extern int read_in_full(int fd, void *buf, size_t count);
|
||||
extern int write_in_full(int fd, const void *buf, size_t count);
|
||||
extern void write_or_die(int fd, const void *buf, size_t count);
|
||||
|
21
copy.c
21
copy.c
@ -34,3 +34,24 @@ int copy_fd(int ifd, int ofd)
|
||||
close(ifd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int copy_file(const char *dst, const char *src, int mode)
|
||||
{
|
||||
int fdi, fdo, status;
|
||||
|
||||
mode = (mode & 0111) ? 0777 : 0666;
|
||||
if ((fdi = open(src, O_RDONLY)) < 0)
|
||||
return fdi;
|
||||
if ((fdo = open(dst, O_WRONLY | O_CREAT | O_EXCL, mode)) < 0) {
|
||||
close(fdi);
|
||||
return fdo;
|
||||
}
|
||||
status = copy_fd(fdi, fdo);
|
||||
if (close(fdo) != 0)
|
||||
return error("%s: write error: %s", dst, strerror(errno));
|
||||
|
||||
if (!status && adjust_shared_perm(dst))
|
||||
return -1;
|
||||
|
||||
return status;
|
||||
}
|
||||
|
6
date.c
6
date.c
@ -213,9 +213,9 @@ static const struct {
|
||||
{ "EAST", +10, 0, }, /* Eastern Australian Standard */
|
||||
{ "EADT", +10, 1, }, /* Eastern Australian Daylight */
|
||||
{ "GST", +10, 0, }, /* Guam Standard, USSR Zone 9 */
|
||||
{ "NZT", +11, 0, }, /* New Zealand */
|
||||
{ "NZST", +11, 0, }, /* New Zealand Standard */
|
||||
{ "NZDT", +11, 1, }, /* New Zealand Daylight */
|
||||
{ "NZT", +12, 0, }, /* New Zealand */
|
||||
{ "NZST", +12, 0, }, /* New Zealand Standard */
|
||||
{ "NZDT", +12, 1, }, /* New Zealand Daylight */
|
||||
{ "IDLE", +12, 0, }, /* International Date Line East */
|
||||
};
|
||||
|
||||
|
6
diff.c
6
diff.c
@ -272,7 +272,7 @@ static void print_line_count(int count)
|
||||
}
|
||||
}
|
||||
|
||||
static void copy_file(int prefix, const char *data, int size,
|
||||
static void copy_file_with_prefix(int prefix, const char *data, int size,
|
||||
const char *set, const char *reset)
|
||||
{
|
||||
int ch, nl_just_seen = 1;
|
||||
@ -331,9 +331,9 @@ static void emit_rewrite_diff(const char *name_a,
|
||||
print_line_count(lc_b);
|
||||
printf(" @@%s\n", reset);
|
||||
if (lc_a)
|
||||
copy_file('-', one->data, one->size, old, reset);
|
||||
copy_file_with_prefix('-', one->data, one->size, old, reset);
|
||||
if (lc_b)
|
||||
copy_file('+', two->data, two->size, new, reset);
|
||||
copy_file_with_prefix('+', two->data, two->size, new, reset);
|
||||
}
|
||||
|
||||
static int fill_mmfile(mmfile_t *mf, struct diff_filespec *one)
|
||||
|
43
t/t1502-rev-parse-parseopt.sh
Executable file
43
t/t1502-rev-parse-parseopt.sh
Executable file
@ -0,0 +1,43 @@
|
||||
#!/bin/sh
|
||||
|
||||
test_description='test git rev-parse --parseopt'
|
||||
. ./test-lib.sh
|
||||
|
||||
cat > expect.err <<EOF
|
||||
usage: some-command [options] <args>...
|
||||
|
||||
some-command does foo and bar!
|
||||
|
||||
-h, --help show the help
|
||||
--foo some nifty option --foo
|
||||
--bar ... some cool option --bar with an argument
|
||||
|
||||
An option group Header
|
||||
-C [...] option C with an optional argument
|
||||
|
||||
Extras
|
||||
--extra1 line above used to cause a segfault but no longer does
|
||||
|
||||
EOF
|
||||
|
||||
test_expect_success 'test --parseopt help output' '
|
||||
git rev-parse --parseopt -- -h 2> output.err <<EOF
|
||||
some-command [options] <args>...
|
||||
|
||||
some-command does foo and bar!
|
||||
--
|
||||
h,help show the help
|
||||
|
||||
foo some nifty option --foo
|
||||
bar= some cool option --bar with an argument
|
||||
|
||||
An option group Header
|
||||
C? option C with an optional argument
|
||||
|
||||
Extras
|
||||
extra1 line above used to cause a segfault but no longer does
|
||||
EOF
|
||||
git diff expect.err output.err
|
||||
'
|
||||
|
||||
test_done
|
Loading…
Reference in New Issue
Block a user