git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Git Mailing List <git@vger.kernel.org>,
	Junio C Hamano <gitster@pobox.com>
Subject: [PATCH 1/3] dir.c: clean up handling of 'path' parameter in read_directory_recursive()
Date: Thu, 14 May 2009 13:42:47 -0700 (PDT)	[thread overview]
Message-ID: <alpine.LFD.2.01.0905141341470.3343@localhost.localdomain> (raw)


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

             reply	other threads:[~2009-05-14 20:43 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-14 20:42 Linus Torvalds [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LFD.2.01.0905141341470.3343@localhost.localdomain \
    --to=torvalds@linux-foundation.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).