Skip to content

Commit f873a27

Browse files
chriscoolgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Jonathan Nieder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 18c8ff4 commit f873a27

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

Documentation/git-cherry-pick.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,13 @@ git cherry-pick --ff ..next::
113113
are in next but not HEAD to the current branch, creating a new
114114
commit for each new change.
115115

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+
116123
Author
117124
------
118125
Written by Junio C Hamano <[email protected]>

builtin/revert.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ static void parse_args(int argc, const char **argv)
7878
die("program error");
7979
}
8080

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);
8283
if (commit_argc < 1)
8384
usage_with_options(usage_str, options);
8485

t/t3508-cherry-pick-many-commits.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,14 @@ test_expect_failure 'cherry-pick -3 fourth works' '
9292
test "$(git rev-parse --verify HEAD)" != "$(git rev-parse --verify fourth)"
9393
'
9494

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+
95105
test_done

0 commit comments

Comments
 (0)