git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Petr Baudis <pasky@ucw.cz>
To: Daniel Barkalow <barkalow@iabervon.org>
Cc: git@vger.kernel.org
Subject: Re: [4/5] Add option for hardlinkable cache of extracted blobs
Date: Sun, 17 Apr 2005 19:47:36 +0200	[thread overview]
Message-ID: <20050417174736.GA1461@pasky.ji.cz> (raw)
In-Reply-To: <Pine.LNX.4.21.0504171131230.30848-100000@iabervon.org>

Dear diary, on Sun, Apr 17, 2005 at 05:35:19PM CEST, I got a letter
where Daniel Barkalow <barkalow@iabervon.org> told me that...
> Index: checkout-cache.c
> ===================================================================
> --- 157b46ce1d82b3579e2e1258927b0d9bdbc033ab/checkout-cache.c  (mode:100644 sha1:5d3028df0a45329e45fff2006719c9267adeb946)
> +++ 08f7700831e056ad710af69f91e3a8a705b6b2b1/checkout-cache.c  (mode:100644 sha1:338588259e17dd235fdc7db759d770004a760e15)
> @@ -67,6 +71,80 @@
>  	return fd;
>  }
>  
> +#ifdef HARDLINK_CACHE
> +
> +/*
> + * NOTE! This returns a statically allocated buffer, so you have to be
> + * careful about using it. Do a "strdup()" if you need to save the
> + * filename.
> + */
> +char *sha1_blob_cache_file_name(const unsigned char *sha1)
> +{
..code basically identical with sha1_file_name()..
> +}

You can guess what would I like you to do. ;-)

> +
> +static int write_entry(struct cache_entry *ce)
> +{
> +	int fd;
> +	void *new;
> +	unsigned long size;
> +	long wrote;
> +	char type[20];
> +	char *cache_name;
> +	struct stat st;
> +
> +	cache_name = sha1_blob_cache_file_name(ce->sha1);
> +
> +	if (stat(cache_name, &st)) {
..basically cut'n'paste of non-hardlinking write_entry()..

BTW, I'd just use access(F_OK) instead of stat() it I don't care about
the file's stat at all anyway.

> +	}
> +	if (link(cache_name, ce->name)) {
> +		if (errno == ENOENT) {
> +			create_directories(ce->name);
> +			link(cache_name, ce->name);
> +		}
> +	}
> +	return 0;
> +}

I think it would be better to have this as hardlink_entry() and
write_entry() to take the file name to write the entry to. Then you
should explicitly multiplex in checkout_cache() between what you do.

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor

  reply	other threads:[~2005-04-17 17:44 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20050417144947.GG1487@pasky.ji.cz>
2005-04-17 15:20 ` [0/5] Patch set for various things Daniel Barkalow
2005-04-17 15:24   ` [1/5] Parsing code in revision.h Daniel Barkalow
2005-04-17 16:09     ` Petr Baudis
2005-04-17 16:44       ` Daniel Barkalow
2005-04-17 18:18     ` [1/5] " Linus Torvalds
2005-04-17 18:30       ` Petr Baudis
2005-04-17 19:25         ` Linus Torvalds
2005-04-17 19:45           ` Daniel Barkalow
2005-04-17 19:54             ` Linus Torvalds
2005-04-17 20:06               ` Linus Torvalds
2005-04-17 20:22                 ` Daniel Barkalow
2005-04-17 19:09       ` Daniel Barkalow
2005-04-17 15:27   ` [2/5] Add merge-base Daniel Barkalow
2005-04-17 16:01     ` Petr Baudis
2005-04-17 16:36       ` Daniel Barkalow
2005-04-17 16:51     ` [2.1/5] " Daniel Barkalow
2005-04-17 21:21       ` Petr Baudis
2005-04-17 21:25         ` Daniel Barkalow
2005-04-17 15:31   ` [3/5] Add http-pull Daniel Barkalow
2005-04-17 18:10     ` Petr Baudis
2005-04-17 18:49       ` Daniel Barkalow
2005-04-17 19:08         ` Petr Baudis
2005-04-17 19:24           ` Daniel Barkalow
2005-04-17 19:59             ` Petr Baudis
2005-04-21  3:27               ` Brad Roberts
2005-04-21  4:28                 ` Daniel Barkalow
2005-04-21 22:05                   ` tony.luck
2005-04-22 19:46                     ` Daniel Barkalow
2005-04-22 22:40                       ` Petr Baudis
2005-04-22 23:00                         ` Daniel Barkalow
2005-04-22 23:08                           ` Petr Baudis
2005-04-22 23:12                             ` Daniel Barkalow
2005-04-22 23:24                               ` Martin Schlemmer
2005-04-17 18:58     ` [3.1/5] " Daniel Barkalow
2005-04-17 15:35   ` [4/5] Add option for hardlinkable cache of extracted blobs Daniel Barkalow
2005-04-17 17:47     ` Petr Baudis [this message]
2005-04-17 18:54       ` Daniel Barkalow
2005-04-17 19:25       ` Paul Jackson
2005-04-17 19:59         ` Petr Baudis
2005-04-17 20:03           ` Daniel Barkalow
2005-04-17 20:18             ` Petr Baudis
2005-04-18  1:35               ` Paul Jackson
2005-04-18  1:48                 ` Petr Baudis
2005-04-18  4:49                   ` Paul Jackson
2005-04-17 20:58             ` Russell King
2005-04-17 22:10               ` First ever real kernel git merge! Linus Torvalds
2005-04-18  1:24             ` [4/5] Add option for hardlinkable cache of extracted blobs Paul Jackson
2005-04-18  1:20           ` Paul Jackson
2005-04-17 15:37   ` [5/5] Add commit-id to version Daniel Barkalow

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=20050417174736.GA1461@pasky.ji.cz \
    --to=pasky@ucw.cz \
    --cc=barkalow@iabervon.org \
    --cc=git@vger.kernel.org \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).