forked from git/git
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Just like with other Git commands, this option makes it read the paths from the standard input. It comes in handy when resetting many, many paths at once and wildcards are not an option (e.g. when the paths are generated by a tool). Note: we first parse the entire list and perform the actual reset action only in a second phase. This make the implementation simpler than adding the pathspecs immediately after the corresponding lines are read. Note also that we specifically handle CR/LF line endings in `stdin` to support Windows better. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
- Loading branch information
Showing
3 changed files
with
96 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/bin/sh | ||
|
||
test_description='reset --stdin' | ||
|
||
. ./test-lib.sh | ||
|
||
test_expect_success 'reset --stdin' ' | ||
test_commit hello && | ||
git rm hello.t && | ||
test -z "$(git ls-files hello.t)" && | ||
echo hello.t | git reset --stdin && | ||
test hello.t = "$(git ls-files hello.t)" | ||
' | ||
|
||
test_expect_success 'reset --stdin -z' ' | ||
test_commit world && | ||
git rm hello.t world.t && | ||
test -z "$(git ls-files hello.t world.t)" && | ||
printf world.tQworld.tQhello.tQ | q_to_nul | git reset --stdin -z && | ||
printf "hello.t\nworld.t\n" >expect && | ||
git ls-files >actual && | ||
test_cmp expect actual | ||
' | ||
|
||
test_expect_success '--stdin requires --mixed' ' | ||
echo hello.t >list && | ||
test_must_fail git reset --soft --stdin <list && | ||
test_must_fail git reset --hard --stdin <list && | ||
git reset --mixed --stdin <list | ||
' | ||
|
||
|
||
test_expect_success '--stdin trims carriage returns' ' | ||
test_commit endline && | ||
git rm endline.t && | ||
printf "endline.t\r\n" >list && | ||
git reset --stdin <list && | ||
test endline.t = "$(git ls-files endline.t)" | ||
' | ||
|
||
test_done |