aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2008-02-26 00:14:22 -0800
committerJunio C Hamano <gitster@pobox.com>2008-02-26 00:14:22 -0800
commit2db511fdbdbe1c8aab80f4bc13f0df037bce8a33 (patch)
tree23350997a56089356ccaeaa923a783378c198bf6
parentb8d97d07fd5025232cae74cfc9a555abd9ac390e (diff)
parent81fa145917c40b68a5e2cca6afc6a10cdfdbd25b (diff)
downloadgit-2db511fdbdbe1c8aab80f4bc13f0df037bce8a33.tar.gz
git-2db511fdbdbe1c8aab80f4bc13f0df037bce8a33.tar.xz
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
-rw-r--r--Documentation/git-am.txt2
-rw-r--r--Documentation/git-filter-branch.txt15
-rwxr-xr-xbuiltin-fast-export.c2
-rw-r--r--builtin-init-db.c21
-rw-r--r--builtin-rerere.c19
-rw-r--r--builtin-rev-parse.c2
-rw-r--r--cache.h1
-rw-r--r--copy.c21
-rw-r--r--date.c6
-rw-r--r--diff.c8
-rwxr-xr-xt/t1502-rev-parse-parseopt.sh43
11 files changed, 89 insertions, 51 deletions
diff --git a/Documentation/git-am.txt b/Documentation/git-am.txt
index 2ffba2102..e640fc75c 100644
--- a/Documentation/git-am.txt
+++ b/Documentation/git-am.txt
@@ -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.
diff --git a/Documentation/git-filter-branch.txt b/Documentation/git-filter-branch.txt
index e22dfa580..543a1cf10 100644
--- a/Documentation/git-filter-branch.txt
+++ b/Documentation/git-filter-branch.txt
@@ -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
diff --git a/builtin-fast-export.c b/builtin-fast-export.c
index f741df522..4bd1356d5 100755
--- a/builtin-fast-export.c
+++ b/builtin-fast-export.c
@@ -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);
}
}
diff --git a/builtin-init-db.c b/builtin-init-db.c
index 5d7cdda93..79eaf8d6e 100644
--- a/builtin-init-db.c
+++ b/builtin-init-db.c
@@ -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)
diff --git a/builtin-rerere.c b/builtin-rerere.c
index b0c17bde8..c607aade6 100644
--- a/builtin-rerere.c
+++ b/builtin-rerere.c
@@ -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,
diff --git a/builtin-rev-parse.c b/builtin-rev-parse.c
index b9af1a5a5..90dbb9d7c 100644
--- a/builtin-rev-parse.c
+++ b/builtin-rev-parse.c
@@ -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;
}
diff --git a/cache.h b/cache.h
index 4fa69f0ee..922bed921 100644
--- a/cache.h
+++ b/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);
diff --git a/copy.c b/copy.c
index c225d1b0f..afc4fbf41 100644
--- a/copy.c
+++ b/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;
+}
diff --git a/date.c b/date.c
index 8f7050027..a74ed8642 100644
--- a/date.c
+++ b/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 */
};
diff --git a/diff.c b/diff.c
index 99daca610..dff826b63 100644
--- a/diff.c
+++ b/diff.c
@@ -272,8 +272,8 @@ static void print_line_count(int count)
}
}
-static void copy_file(int prefix, const char *data, int size,
- const char *set, const char *reset)
+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;
while (0 < size--) {
@@ -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)
diff --git a/t/t1502-rev-parse-parseopt.sh b/t/t1502-rev-parse-parseopt.sh
new file mode 100755
index 000000000..762af5faf
--- /dev/null
+++ b/t/t1502-rev-parse-parseopt.sh
@@ -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