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.
ls-files.c: add --deduplicate option
In order to provide users a better experience when viewing information about files in the index and the working tree, the `--deduplicate` option will suppress some duplicate name under some conditions. In a merge conflict, one file name of "git ls-files" output may appear multiple times. For example,now there is an unmerged path `a.c`,`a.c` will appear three times in the output of "git ls-files".We can use "git ls-files --deduplicate" to output `a.c` only one time.(unless `--stage` or `--unmerged` is used to view all the detailed information in the index) In addition, if you use both `--delete` and `--modify` at the same time, The `--deduplicate` option can also suppress file name output. Additional instructions: In order to display entries information,`deduplicate` suppresses the output of duplicate file names, not the output of duplicate entries information, so under the option of `-t`, `--stage`, `--unmerge`, `--deduplicate` will have no effect. Signed-off-by: ZheNing Hu <adlternative@gmail.com>
- Loading branch information
1 parent
802ff80
commit e9c5318
Showing
3 changed files
with
98 additions
and
5 deletions.
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,66 @@ | ||
#!/bin/sh | ||
|
||
test_description='git ls-files --deduplicate test' | ||
|
||
. ./test-lib.sh | ||
|
||
test_expect_success 'setup' ' | ||
>a.txt && | ||
>b.txt && | ||
>delete.txt && | ||
git add a.txt b.txt delete.txt && | ||
git commit -m base && | ||
echo a >a.txt && | ||
echo b >b.txt && | ||
echo delete >delete.txt && | ||
git add a.txt b.txt delete.txt && | ||
git commit -m tip && | ||
git tag tip && | ||
git reset --hard HEAD^ && | ||
echo change >a.txt && | ||
git commit -a -m side && | ||
git tag side | ||
' | ||
|
||
test_expect_success 'git ls-files --deduplicate to show unique unmerged path' ' | ||
test_must_fail git merge tip && | ||
git ls-files --deduplicate >actual && | ||
cat >expect <<-\EOF && | ||
a.txt | ||
b.txt | ||
delete.txt | ||
EOF | ||
test_cmp expect actual && | ||
git merge --abort | ||
' | ||
|
||
test_expect_success 'git ls-files -d -m --deduplicate with different display options' ' | ||
git reset --hard side && | ||
test_must_fail git merge tip && | ||
rm delete.txt && | ||
git ls-files -d -m --deduplicate >actual && | ||
cat >expect <<-\EOF && | ||
a.txt | ||
delete.txt | ||
EOF | ||
test_cmp expect actual && | ||
git ls-files -d -m -t --deduplicate >actual && | ||
cat >expect <<-\EOF && | ||
C a.txt | ||
C a.txt | ||
C a.txt | ||
R delete.txt | ||
C delete.txt | ||
EOF | ||
test_cmp expect actual && | ||
git ls-files -d -m -c --deduplicate >actual && | ||
cat >expect <<-\EOF && | ||
a.txt | ||
b.txt | ||
delete.txt | ||
EOF | ||
test_cmp expect actual && | ||
git merge --abort | ||
' | ||
|
||
test_done |