summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f485167)
raw | patch | inline | side by side (parent: f485167)
author | Linus Torvalds <torvalds@ppc970.osdl.org> | |
Thu, 23 Jun 2005 16:40:23 +0000 (09:40 -0700) | ||
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | |
Thu, 23 Jun 2005 16:40:23 +0000 (09:40 -0700) |
..and git-apply does a lot better job at it anyway.
Also, we break the comment/diff on a line that starts with "diff -", not
just on the "---" line. Especially for git diffs, we actually want that
line in the diff.
(We should probably also break on "Index: ..." followed by "=====")
Also, we break the comment/diff on a line that starts with "diff -", not
just on the "---" line. Especially for git diffs, we actually want that
line in the diff.
(We should probably also break on "Index: ..." followed by "=====")
applypatch | patch | blob | history | |
dotest | patch | blob | history | |
mailinfo.c | patch | blob | history |
diff --git a/applypatch b/applypatch
index 789917f3c51325e80418cfdeccfa6fb4dcb7d290..5a3a44b0e6a4b725bd4771d57aa9a76f100e94ed 100755 (executable)
--- a/applypatch
+++ b/applypatch
## The arguments are:
## $1 - file with commit message
## $2 - file with the actual patch
-## $3 - file with list of filenames the patch touches
-## $4 - "info" file with Author, email and subject
-## $5 - optional file containing signoff to add
+## $3 - "info" file with Author, email and subject
+## $4 - optional file containing signoff to add
##
-signoff="$5"
+signoff="$4"
final=.dotest/final-commit
##
## If this file exists, we ask before applying
query_apply=.dotest/.query_apply
MSGFILE=$1
PATCHFILE=$2
-FILES=$3
-INFO=$4
+INFO=$3
EDIT=${VISUAL:-$EDITOR}
EDIT=${EDIT:-vi}
index ccc1f0304f10b58975705de256d8e23df82ec535..c6f44e1c413cacc0d2e233ace73214ceb402d7e5 100755 (executable)
--- a/dotest
+++ b/dotest
mailsplit $1 .dotest || exit 1
for i in .dotest/*
do
- mailinfo .dotest/msg .dotest/patch .dotest/file < $i > .dotest/info || exit 1
+ mailinfo .dotest/msg .dotest/patch < $i > .dotest/info || exit 1
stripspace < .dotest/msg > .dotest/msg-clean
- applypatch .dotest/msg-clean .dotest/patch .dotest/file .dotest/info "$2"
+ applypatch .dotest/msg-clean .dotest/patch .dotest/info "$2"
ret=$?
if [ $ret -ne 0 ]; then
# 2 is a special exit code from applypatch to indicate that
diff --git a/mailinfo.c b/mailinfo.c
index 13c1e951ac2d24cb9ecaeb743406a5318ccd5d9c..6c4d5898238704954a0b67b99079193f588795b6 100644 (file)
--- a/mailinfo.c
+++ b/mailinfo.c
#include <string.h>
#include <ctype.h>
-static FILE *cmitmsg, *patchfile, *filelist;
+static FILE *cmitmsg, *patchfile;
static char line[1000];
static char date[1000];
}
}
-/*
- * Hacky hacky. This depends not only on -p1, but on
- * filenames not having some special characters in them,
- * like tilde.
- */
-static void show_filename(char *line)
-{
- int len;
- char *name = strchr(line, '/');
-
- if (!name || !isspace(*line))
- return;
- name++;
- len = 0;
- for (;;) {
- unsigned char c = name[len];
- switch (c) {
- default:
- len++;
- continue;
-
- case 0: case ' ':
- case '\t': case '\n':
- break;
-
- /* patch tends to special-case these things.. */
- case '~':
- break;
- }
- break;
- }
- /* remove ".orig" from the end - common patch behaviour */
- if (len > 5 && !memcmp(name+len-5, ".orig", 5))
- len -=5;
- if (!len)
- return;
- fprintf(filelist, "%.*s\n", len, name);
-}
-
static void handle_rest(void)
{
char *sub = cleanup_subject(subject);
FILE *out = cmitmsg;
do {
- /* Track filename information from the patch.. */
- if (!memcmp("---", line, 3)) {
+ if (!memcmp("diff -", line, 6) ||
+ !memcmp("---", line, 3))
out = patchfile;
- show_filename(line+3);
- }
-
- if (!memcmp("+++", line, 3))
- show_filename(line+3);
fputs(line, out);
} while (fgets(line, sizeof(line), stdin) != NULL);
static void usage(void)
{
- fprintf(stderr, "mailinfo msg-file path-file filelist-file < email\n");
+ fprintf(stderr, "mailinfo msg-file path-file < email\n");
exit(1);
}
int main(int argc, char ** argv)
{
- if (argc != 4)
+ if (argc != 3)
usage();
cmitmsg = fopen(argv[1], "w");
if (!cmitmsg) {
perror(argv[2]);
exit(1);
}
- filelist = fopen(argv[3], "w");
- if (!filelist) {
- perror(argv[3]);
- exit(1);
- }
while (fgets(line, sizeof(line), stdin) != NULL) {
int len = eatspace(line);
if (!len) {