revert: accept arbitrary rev-list options
This can be useful to do something like: git rev-list --reverse master -- README | git cherry-pick -n --stdin without using xargs. Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Christian Couder committed
Jun 14, 2010 at 00:29 UTC
f873a273d1381574fd9b2f3f613c0c7e40fe3a1c
3 files changed
+19
-1
Documentation/git-cherry-pick.txt
+7
@@ -113,6 +113,13 @@ git cherry-pick --ff ..next::
113
are in next but not HEAD to the current branch, creating a new
114
commit for each new change.
115
116
+git rev-list --reverse master \-- README | git cherry-pick -n --stdin::
117
+
118
+ Apply the changes introduced by all commits on the master
119
+ branch that touched README to the working tree and index,
120
+ so the result can be inspected and made into a single new
121
+ commit if suitable.
122
+
123
Author
124
------
125
Written by Junio C Hamano <gitster@pobox.com>
builtin/revert.c
+2
-1
@@ -78,7 +78,8 @@ static void parse_args(int argc, const char **argv)
78
die("program error");
79
}
80
81
- commit_argc = parse_options(argc, argv, NULL, options, usage_str, 0);
81
+ commit_argc = parse_options(argc, argv, NULL, options, usage_str,
82
+ PARSE_OPT_KEEP_UNKNOWN);
83
if (commit_argc < 1)
84
usage_with_options(usage_str, options);
85
t/t3508-cherry-pick-many-commits.sh
+10
@@ -92,4 +92,14 @@ test_expect_failure 'cherry-pick -3 fourth works' '
92
test "$(git rev-parse --verify HEAD)" != "$(git rev-parse --verify fourth)"
93
'
94
95
+test_expect_success 'cherry-pick --stdin works' '
96
+ git checkout -f master &&
97
+ git reset --hard first &&
98
+ test_tick &&
99
+ git rev-list --reverse first..fourth | git cherry-pick --stdin &&
100
+ git diff --quiet other &&
101
+ git diff --quiet HEAD other &&
102
+ test "$(git rev-parse --verify HEAD)" != "$(git rev-parse --verify fourth)"
103
+'
104
+
105
test_done