Add a %(skipworktree) atom git ls-files --format to indicate whether the file in the index match the sparse specification. v1: add %(skipworktree) atom to git ls-files format option. v2: 1. no longer mentioned git ls-files -t. 2. change %(skipworktree) output from "true"/"false" to "1"/"". 3. fix the sparse-checkout docs link. ZheNing Hu (2): docs: fix sparse-checkout docs link ls-files: add %(skipworktree) atom to format option Documentation/Makefile | 1 + Documentation/git-ls-files.txt | 5 +++ Documentation/technical/sparse-checkout.txt | 43 ++++++++++++++------- builtin/ls-files.c | 3 ++ t/t3013-ls-files-format.sh | 23 +++++++++++ 5 files changed, 61 insertions(+), 14 deletions(-) base-commit: a7caae2729742fc80147bca1c02ae848cb55921a Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1458%2Fadlternative%2Fzh%2Fls-file-format-skipworktree-v2 Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1458/adlternative/zh/ls-file-format-skipworktree-v2 Pull-Request: https://github.com/gitgitgadget/git/pull/1458 Range-diff vs v1: -: ----------- > 1: cde4827da13 docs: fix sparse-checkout docs link 1: c4cd5b3a32f ! 2: 9ebd6b77a69 ls-files: add %(skipworktree) atom to format option @@ Commit message ls-files: add %(skipworktree) atom to format option Because sometimes we want to check if the files in the - index match the sparse specification by using - `git ls-files -t`, but `-t` option have semi-deprecated, - - So introduce "%(skipworktree)" atom to git ls-files - `--format` option. When we use this option, if the file - match the sparse specification and removed from working - tree, it will output "yes", othewise, output "no". + index match the sparse specification, so introduce + "%(skipworktree)" atom to git ls-files `--format` option. + When we use this option, if the file match the sparse + specification, it will output "1", otherwise, output + empty string "". Signed-off-by: ZheNing Hu <adlternative@xxxxxxxxx> @@ Documentation/git-ls-files.txt: eolattr:: The pathname of the file which is recorded in the index. +skipworktree:: + If the file in the index marked with SKIP_WORKTREE bit. -+ It means the file do not match the sparse specification -+ and removed from working tree. ++ It means the file do not match the sparse specification. + See link:technical/sparse-checkout.txt[sparse-checkout] + for more information. @@ builtin/ls-files.c: static size_t expand_show_index(struct strbuf *sb, const cha write_name_to_buf(sb, data->pathname); + else if (skip_prefix(start, "(skipworktree)", &p)) + strbuf_addstr(sb, ce_skip_worktree(data->ce) ? -+ "true" : "false"); ++ "1" : ""); else die(_("bad ls-files format: %%%.*s"), (int)len, start); @@ t/t3013-ls-files-format.sh: test_expect_success 'git ls-files --format with --de ' +test_expect_success 'git ls-files --format with skipworktree' ' ++ test_when_finished "git sparse-checkout disable" && + mkdir dir1 dir2 && + echo "file1" >dir1/file1.txt && + echo "file2" >dir2/file2.txt && + git add dir1 dir2 && + git commit -m skipworktree && + git sparse-checkout set dir1 && -+ git ls-files --format="%(path) %(skipworktree)" >actual && ++ git ls-files --format="%(path)%(skipworktree)" >actual && + cat >expect <<-\EOF && -+ dir1/file1.txt false -+ dir2/file2.txt true -+ o1.txt false -+ o2.txt false -+ o3.txt false -+ o4.txt false -+ o5.txt false -+ o6.txt false -+ o7.txt false ++ dir1/file1.txt ++ dir2/file2.txt1 ++ o1.txt ++ o2.txt ++ o3.txt ++ o4.txt ++ o5.txt ++ o6.txt ++ o7.txt + EOF + test_cmp expect actual +' -- gitgitgadget