summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d4c452f)
raw | patch | inline | side by side (parent: d4c452f)
author | Junio C Hamano <junkio@cox.net> | |
Wed, 16 Aug 2006 23:09:25 +0000 (16:09 -0700) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Thu, 17 Aug 2006 04:08:45 +0000 (21:08 -0700) |
Add a few tests, usage string, and documentation.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Documentation/git-apply.txt | patch | blob | history | |
builtin-apply.c | patch | blob | history | |
t/t4116-apply-reverse.sh | patch | blob | history |
index 2ff74949a73aa8670750105a7d292206877477c7..f1ab1f9da5d70cae95bfeee6ba4413edc993fbf3 100644 (file)
--------
[verse]
'git-apply' [--stat] [--numstat] [--summary] [--check] [--index] [--apply]
- [--no-add] [--index-info] [--allow-binary-replacement] [-z] [-pNUM]
+ [--no-add] [--index-info] [--allow-binary-replacement]
+ [--reverse] [-z] [-pNUM]
[-CNUM] [--whitespace=<nowarn|warn|error|error-all|strip>]
[<patch>...]
the original version of the blob is available locally,
outputs information about them to the standard output.
+--reverse::
+ Apply the patch in reverse.
+
-z::
When showing the index information, do not munge paths,
but use NUL terminated machine readable format. Without
diff --git a/builtin-apply.c b/builtin-apply.c
index be6e94d3674208de86edb0561bfcddb3d9177224..4737b64c323b6bea1f84932ba80d344ab9997f13 100644 (file)
--- a/builtin-apply.c
+++ b/builtin-apply.c
static int line_termination = '\n';
static unsigned long p_context = -1;
static const char apply_usage[] =
-"git-apply [--stat] [--numstat] [--summary] [--check] [--index] [--cached] [--apply] [--no-add] [--index-info] [--allow-binary-replacement] [-z] [-pNUM] [-CNUM] [--whitespace=<nowarn|warn|error|error-all|strip>] <patch>...";
+"git-apply [--stat] [--numstat] [--summary] [--check] [--index] [--cached] [--apply] [--no-add] [--index-info] [--allow-binary-replacement] [--reverse] [-z] [-pNUM] [-CNUM] [--whitespace=<nowarn|warn|error|error-all|strip>] <patch>...";
static enum whitespace_eol {
nowarn_whitespace,
index 69aebe600573fa0e014e97001f40836d3a18b82b..74f5c2a5755c8d29045498031c0bc3721a00b9c7 100755 (executable)
--- a/t/t4116-apply-reverse.sh
+++ b/t/t4116-apply-reverse.sh
tr "[mon]" '\''[\0\1\2]'\'' <file1 >file2 &&
git commit -a -m second &&
+ git tag second &&
- git diff --binary -R initial >patch
+ git diff --binary initial second >patch
'
test_expect_success 'apply in forward' '
+ T0=`git rev-parse "second^{tree}"` &&
+ git reset --hard initial &&
git apply --index --binary patch &&
- git diff initial >diff &&
- diff -u /dev/null diff
-
+ T1=`git write-tree` &&
+ test "$T0" = "$T1"
'
test_expect_success 'apply in reverse' '
+ git reset --hard second &&
git apply --reverse --binary --index patch &&
git diff >diff &&
diff -u /dev/null diff
'
+test_expect_success 'setup separate repository lacking postimage' '
+
+ git tar-tree initial initial | tar xf - &&
+ (
+ cd initial && git init-db && git add .
+ ) &&
+
+ git tar-tree second second | tar xf - &&
+ (
+ cd second && git init-db && git add .
+ )
+
+'
+
+test_expect_success 'apply in forward without postimage' '
+
+ T0=`git rev-parse "second^{tree}"` &&
+ (
+ cd initial &&
+ git apply --index --binary ../patch &&
+ T1=`git write-tree` &&
+ test "$T0" = "$T1"
+ )
+'
+
+test_expect_success 'apply in reverse without postimage' '
+
+ T0=`git rev-parse "initial^{tree}"` &&
+ (
+ cd second &&
+ git apply --index --binary --reverse ../patch &&
+ T1=`git write-tree` &&
+ test "$T0" = "$T1"
+ )
+'
+
test_done