git-ls-files -o reports _all_ the unknown files it finds in a work area.
Subversion and probably other systems "simply ignore all the files
and directories inside an unknown directory and just note the directory
as unknown." (A quote from my porcelain's mailing list.)
I'd like to make this friendly behavior the default in my porcelain.
Unfortunately, getting the same result from a porcelain requires
implementing a non-trivial algorithm to discover common prefixes, worry
about performance on large projects, etc.
Would it be hard to make git-ls-files optionally do this?
--
Darrin
@@ -622,6 +640,10 @@ int main(int argc, const char **argv)show_killed=1;continue;}+if(!strcmp(arg,"--directory")){+show_ignored_directories=1;+continue;+}if(!strcmp(arg,"-u")||!strcmp(arg,"--unmerged")){/* There's no point in showing unmerged unless*youalsoshowthestageinformation.
From: Junio C Hamano <hidden> Date: 2016-06-15 22:42:16
Linus Torvalds [off-list ref] writes:
On Wed, 4 Jan 2006, Darrin Thompson wrote:
quoted
Would it be hard to make git-ls-files optionally do this?
Something like the appended may or may not be what you're looking for..
Linus
Not to mention test scripts, I suspect that making this the
default would break existing callers including the famous
"git-init-db && git-add ." pattern. The other commonplace use
is git-status, which might benefit from this option. If we are
going to use it in git-status, we may want to give them trailing
slashes to make them stand out, though.
This adds a test a test for the --directory option to git-ls-files.
Is '--directory' really what we want?
t/t3003-ls-files-others-directory.sh | 38
++++++++++++++++++++++++++++++++++
1 files changed, 38 insertions(+), 0 deletions(-)
create mode 100644 t/t3003-ls-files-others-directory.sh
applies-to: 5001806332081159b00c35291d6aea232ed7e909
d484a8477d430a5fb2cefd2cf7008a5973d1fea5
diff --git a/t/t3003-ls-files-others-directory.sh
b/t/t3003-ls-files-others-directory.sh
new file mode 100644
index 0000000..d1d3d86
@@ -0,0 +1,38 @@+#!/bin/sh+#+# Copyright (c) 2005 Darrin Thompson+# Based on an earlier test by Junio C Hamano+#++test_description='git-ls-filestest(--others--directory)++Thistestrunsgit-ls-files--others--directorywiththefollowingon+thefilesystem.++path0-afile+path1-asymlink+path2/file2-afileinadirectory++The--directoryoptionshouldcausepath2tobeinthelisting,but+notpath2/file2.+'+../test-lib.sh++date>path0+ln-sxyzzypath1+mkdirpath2+date>path2/file2+test_expect_success\+'git-ls-files --directory --others to show output.'\+'git-ls-files --directory --others >output'+cat>expected<<EOF+output+path0+path1+path2+EOF++test_expect_success\+'git-ls-files--directory--othersshouldnotpickupdir
Here's a rejiggered version of the original Linus patch. The names have
been changed a little.
Enjoy.
It prevents git from recursing into "other" directories when used with
the -o option.
---
ls-files.c | 22 ++++++++++++++++++++++
1 files changed, 22 insertions(+), 0 deletions(-)
applies-to: 4e7e791ecc24975530de1f2855cf5f17f112140b
741ec8ad5b7f3717bb462c2becfd00974da7ec16
@@ -622,6 +640,10 @@ int main(int argc, const char **argv)show_killed=1;continue;}+if(!strcmp(arg,"--directory")){+show_other_directories=1;+continue;+}if(!strcmp(arg,"-u")||!strcmp(arg,"--unmerged")){/* There's no point in showing unmerged unless*youalsoshowthestageinformation.
From: Junio C Hamano <hidden> Date: 2016-06-15 22:42:16
Darrin Thompson [off-list ref] writes:
Here's a rejiggered version of the original Linus patch. The names have
been changed a little.
Enjoy.
It prevents git from recursing into "other" directories when used with
the -o option.
Looks same to what I have in the proposed updates branch, so we
are on the same page. Thanks.
I have been unsure about the name "--directory", like you said.
The most accurate one I thought of so far is:
--dont-recurse-into-directories-without-tracked-files
but it is way too long. We cannot even say "untracked
directories" (we do not track directories) to shorten it a bit.
I have been unsure about the name "--directory", like you said.
Well, I didn't like "--directory" either, but couldn't come up with
anything better. How about just "--no-recurse", which is not technically
accurate (we always recurse into directories we know about), but might be
more understandable.
The reason I called it "--directory" was that it would talk about
directories that it doesn't know about (as opposed to individual files it
doesn't know about). So "--other --directory" kind of makes sense if you
read it that way ("show files and directories we don't know about").
But yeah, it's not a great name.
Linus