Thread (2 messages) flat view 2 messages, 2 authors, 2016-06-15

Re: [PATCH] init: show "Reinit" message even in an (existing) empty repository

From: Johannes Schindelin <hidden>
Date: 2016-06-15 22:44:25

Possibly related (same subject, not in this thread)

Hi,

On Tue, 25 Mar 2008, Junio C Hamano wrote:
Johannes Schindelin [off-list ref] writes:
quoted
diff --git a/builtin-init-db.c b/builtin-init-db.c
index 1975910..ceb4727 100644
--- a/builtin-init-db.c
+++ b/builtin-init-db.c
@@ -168,10 +168,9 @@ static int create_default_files(const char *git_dir, const char *template_path)
 {
 	unsigned len = strlen(git_dir);
 	static char path[PATH_MAX];
-	unsigned char sha1[20];
 	struct stat st1;
 	char repo_version_string[10];
	int reinit;
Here I saw a hand-edit, but that is less of a problem...
Heh, yes.  I originally set reinit = 0, and thought I was clever by patch 
editing.  But I have less experience with that than necessary, and then, I 
am not as clever as I thought, either... ;-)
quoted
 	int filemode;
 
 	if (len > sizeof(path)-50)
@@ -220,7 +219,7 @@ static int create_default_files(const char *git_dir, const char *template_path)
 	 * branch, if it does not exist yet.
 	 */
 	strcpy(path + len, "HEAD");
-	reinit = !read_ref("HEAD", sha1);
+	reinit = !access(path, R_OK);
If this is a HEAD (or .git/HEAD) that is a dangling symlink (we do still
support them, don't we?) wouldn't this access fail?
Right.  I already saw your commit, and while I would have to think hard if 
it is implementing the correct logic (what does access() do with a 
dangling symlink? Is || correct?), I just trust you.

Although I have to admit that having the authorship of this commit is 
giving me more credit than I deserve.

Thanks,
Dscho
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help