git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Petr Baudis <pasky@suse.cz>
To: "H. Peter Anvin" <hpa@zytor.com>
Cc: Junio C Hamano <junkio@cox.net>,
	Dmitry Torokhov <dtor_core@ameritech.net>,
	git@vger.kernel.org
Subject: [PATCH] Fix git-init-db creating crap directories (zeroth try)
Date: Tue, 20 Sep 2005 02:19:50 +0200	[thread overview]
Message-ID: <20050920001949.GL18320@pasky.or.cz> (raw)
In-Reply-To: <432F5345.3020303@zytor.com>

Dear diary, on Tue, Sep 20, 2005 at 02:09:41AM CEST, I got a letter
where "H. Peter Anvin" <hpa@zytor.com> told me that...
> Petr Baudis wrote:
> >diff --git a/init-db.c b/init-db.c
> >--- a/init-db.c
> >+++ b/init-db.c
> >@@ -153,7 +153,8 @@ static void copy_templates(const char *g
> > 		return;
> > 	}
> > 
> >-	memcpy(path, git_dir, len);
> >+	memcpy(path, git_dir, len-1);
> >+	path[len] = 0;
> > 	copy_templates_1(path, len,
> 
> Wrong!  You're not initializing path[len-1]!

Oops, sorry. That's what you get when you want to make things marginally
better. ;-) We indeed want to pass copy_templates_1() the trailing slash
as well.

Let's just settle with the original patch then.

--

The base target directory for the templates copying was initialized
to git_dir, but git_dir[len] is not zero but / at the time we do the
initialization. This is not what we want for our target directory string
since we pass it to mkdir(), so make it zero-terminated manually.

Signed-off-by: Petr Baudis <pasky@suse.cz>

---
diff --git a/init-db.c b/init-db.c
--- a/init-db.c
+++ b/init-db.c
@@ -154,6 +154,7 @@ static void copy_templates(const char *g
 	}
 
 	memcpy(path, git_dir, len);
+	path[len] = 0;
 	copy_templates_1(path, len,
 			 template_path, template_len,
 			 dir);


-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
VI has two modes: the one in which it beeps and the one in which
it doesn't.

  reply	other threads:[~2005-09-20  0:19 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-18  2:41 Garbage in .git directories??? Dmitry Torokhov
2005-09-18 17:10 ` Linus Torvalds
2005-09-18 17:54   ` Dmitry Torokhov
2005-09-19  4:33     ` Dmitry Torokhov
2005-09-19  5:21       ` Junio C Hamano
2005-09-19 14:51       ` Linus Torvalds
2005-09-19 15:00         ` Dmitry Torokhov
2005-09-20  0:09         ` Dmitry Torokhov
2005-09-20  0:45           ` Linus Torvalds
2005-09-20  3:37             ` Dmitry Torokhov
2005-09-19 19:10 ` H. Peter Anvin
2005-09-19 19:44   ` Petr Baudis
2005-09-19 23:16     ` H. Peter Anvin
2005-09-19 23:40       ` Petr Baudis
2005-09-19 23:58         ` H. Peter Anvin
2005-09-20  0:07           ` [PATCH] Fix git-init-db creating crap directories Petr Baudis
2005-09-20  0:09             ` H. Peter Anvin
2005-09-20  0:19               ` Petr Baudis [this message]
2005-09-20  0:42                 ` [PATCH] Fix git-init-db creating crap directories (zeroth try) H. Peter Anvin
2005-09-20  1:51                   ` Petr Baudis
2005-09-20  2:04                     ` Junio C Hamano
2005-09-20  3:27                     ` H. Peter Anvin
2005-09-19 21:58   ` Garbage in .git directories??? Horst von Brand

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=20050920001949.GL18320@pasky.or.cz \
    --to=pasky@suse.cz \
    --cc=dtor_core@ameritech.net \
    --cc=git@vger.kernel.org \
    --cc=hpa@zytor.com \
    --cc=junkio@cox.net \
    /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).