apply --reverse: tie it all together.
Add a few tests, usage string, and documentation. Signed-off-by: Junio C Hamano <junkio@cox.net>maint
parent
d4c452f03b
commit
2cda1a214e
|
@ -10,7 +10,8 @@ SYNOPSIS
|
||||||
--------
|
--------
|
||||||
[verse]
|
[verse]
|
||||||
'git-apply' [--stat] [--numstat] [--summary] [--check] [--index] [--apply]
|
'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>]
|
[-CNUM] [--whitespace=<nowarn|warn|error|error-all|strip>]
|
||||||
[<patch>...]
|
[<patch>...]
|
||||||
|
|
||||||
|
@ -62,6 +63,9 @@ OPTIONS
|
||||||
the original version of the blob is available locally,
|
the original version of the blob is available locally,
|
||||||
outputs information about them to the standard output.
|
outputs information about them to the standard output.
|
||||||
|
|
||||||
|
--reverse::
|
||||||
|
Apply the patch in reverse.
|
||||||
|
|
||||||
-z::
|
-z::
|
||||||
When showing the index information, do not munge paths,
|
When showing the index information, do not munge paths,
|
||||||
but use NUL terminated machine readable format. Without
|
but use NUL terminated machine readable format. Without
|
||||||
|
|
|
@ -43,7 +43,7 @@ static int show_index_info;
|
||||||
static int line_termination = '\n';
|
static int line_termination = '\n';
|
||||||
static unsigned long p_context = -1;
|
static unsigned long p_context = -1;
|
||||||
static const char apply_usage[] =
|
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 {
|
static enum whitespace_eol {
|
||||||
nowarn_whitespace,
|
nowarn_whitespace,
|
||||||
|
|
|
@ -22,25 +22,64 @@ test_expect_success setup '
|
||||||
tr "[mon]" '\''[\0\1\2]'\'' <file1 >file2 &&
|
tr "[mon]" '\''[\0\1\2]'\'' <file1 >file2 &&
|
||||||
|
|
||||||
git commit -a -m second &&
|
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' '
|
test_expect_success 'apply in forward' '
|
||||||
|
|
||||||
|
T0=`git rev-parse "second^{tree}"` &&
|
||||||
|
git reset --hard initial &&
|
||||||
git apply --index --binary patch &&
|
git apply --index --binary patch &&
|
||||||
git diff initial >diff &&
|
T1=`git write-tree` &&
|
||||||
diff -u /dev/null diff
|
test "$T0" = "$T1"
|
||||||
|
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'apply in reverse' '
|
test_expect_success 'apply in reverse' '
|
||||||
|
|
||||||
|
git reset --hard second &&
|
||||||
git apply --reverse --binary --index patch &&
|
git apply --reverse --binary --index patch &&
|
||||||
git diff >diff &&
|
git diff >diff &&
|
||||||
diff -u /dev/null 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
|
test_done
|
||||||
|
|
Loading…
Reference in New Issue