git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] dir.c: clean up handling of 'path' parameter in read_directory_recursive()
@ 2009-05-14 20:42 Linus Torvalds
  2009-05-14 20:46 ` [PATCH 2/3] Add 'fill_directory()' helper function for directory traversal Linus Torvalds
  0 siblings, 1 reply; 13+ messages in thread
From: Linus Torvalds @ 2009-05-14 20:42 UTC (permalink / raw)
  To: Git Mailing List, Junio C Hamano


From: Linus Torvalds <torvalds@linux-foundation.org>
Date: Thu, 14 May 2009 13:05:03 -0700

Right now we pass two different pathnames ('path' and 'base') down to
read_directory_recursive(), and the only real reason for that is that we
want to allow an empty 'base' parameter, but when we do so, we need the
pathname to "opendir()" to be "." rather than the empty string.

And rather than handle that confusion in the caller, we can just fix
read_directory_recursive() to handle the case of an empty path itself,
by just passing opendir() a "." ourselves if the path is empty.

This would allow us to then drop one of the pathnames entirely from the
calling convention, but rather than do that, we'll start separating them
out as a "filesystem pathname" (the one we use for filesystem accesses)
and a "git internal base name" (which is the name that we use for git
internally).

That will eventually allow us to do things like handle different
encodings (eg the filesystem pathnames might be Latin1, while git itself
would use UTF-8 for filename information).

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
---

This is a truly trivial diff, but it's independent from the other changes 
I have, and simplifies the next ones, so I've made it a patch of its own.

 dir.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/dir.c b/dir.c
index 6aae09a..0e6b752 100644
--- a/dir.c
+++ b/dir.c
@@ -576,7 +576,7 @@ static int get_dtype(struct dirent *de, const char *path)
  */
 static int read_directory_recursive(struct dir_struct *dir, const char *path, const char *base, int baselen, int check_only, const struct path_simplify *simplify)
 {
-	DIR *fdir = opendir(path);
+	DIR *fdir = opendir(*path ? path : ".");
 	int contents = 0;
 
 	if (fdir) {
-- 
1.6.3.1.11.g97114

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2009-05-19 13:39 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-14 20:42 [PATCH 1/3] dir.c: clean up handling of 'path' parameter in read_directory_recursive() Linus Torvalds
2009-05-14 20:46 ` [PATCH 2/3] Add 'fill_directory()' helper function for directory traversal Linus Torvalds
2009-05-14 20:54   ` [PATCH 3/3] read_directory(): infrastructure for pathname character set conversion Linus Torvalds
2009-05-14 21:23     ` Linus Torvalds
2009-05-14 22:19     ` Johannes Schindelin
2009-05-14 22:36       ` Aaron Cohen
2009-05-14 22:51         ` Linus Torvalds
2009-05-14 22:47       ` Linus Torvalds
2009-05-15 19:01     ` [PATCH 4/3] Introduce 'convert_path_to_git()' Linus Torvalds
2009-05-16  6:40       ` Junio C Hamano
2009-05-16 17:27         ` Linus Torvalds
2009-05-19 12:20         ` Jens Kilian
2009-05-19 13:31           ` John Koleszar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).