Re: [PATCH v3 24/25] prune: strategies for linked checkouts
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Feb 19, 2014, 22:08 UTC
- Message-ID
- <CAPig+cQgphSBA6iAYqLJ7RnEwSzBA1dApcLWAydZEXarQRcTKQ@mail.gmail.com>
- In-Reply-To
- <1392730814-19656-25-git-send-email-pclouds@gmail.com>
On Tue, Feb 18, 2014 at 8:40 AM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:
Show 5 quoted lines
> The pruning rules are: > > - if $REPO/locked exists, repos/<id> is not supposed to be pruned. > > - if $REPO/locked exists and $REPO/gitdir's mtimer is older than a
s/mtimer/mtime/
Show 20 quoted lines
> really long limit, warn about old unused repo.
>
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
> diff --git a/builtin/checkout.c b/builtin/checkout.c
> index 7b86f2b..c501e9c 100644
> --- a/builtin/checkout.c
> +++ b/builtin/checkout.c
> @@ -854,6 +854,17 @@ static void remove_junk_on_signal(int signo)
> raise(signo);
> }
>
> +static dev_t get_device_or_die(const char *path)
> +{
> + struct stat buf;
> + if (stat(path, &buf))
> + die_errno("failed to stat '%s'", path);
> + /* Ah Windows! Make different drives different "partitions" */
> + if (buf.st_dev == 0 && has_dos_drive_prefix("c:\\"))
> + buf.st_dev = toupper(real_path(path)[0]);This invocation of has_dos_drive_prefix() with hardcoded "c:\\" at first looks like an error until the reader realizes that it's an #ifdef-less check if the platforms is Windows. Would it make more sense to encapsulate this anomaly and abstract it away by fixing compat/mingw.c:do_lstat() to instead set 'st_dev' automatically like you do here? In particular, this line in mingw.c:
buf->st_dev = buf->st_rdev = 0; /* not used by Git */
> + return buf.st_dev; > +}