git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Martin Ågren" <martin.agren@gmail.com>
To: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH 02/10] repository.c: replace hold_locked_index() with repo_hold_locked_index()
Date: Sat, 5 Jan 2019 15:33:49 +0100	[thread overview]
Message-ID: <CAN0heSoRSgZVZ=NE6eof4dusEhfdz-eSiht06rGKb=GELvm86Q@mail.gmail.com> (raw)
In-Reply-To: <20190105055153.3256-3-pclouds@gmail.com>

On Sat, 5 Jan 2019 at 07:07, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:
>
> hold_locked_index() assumes the index path at $GIT_DIR/index. This is
> not good for places that take an arbitrary index_state instead of
> the_index, which is basically everywhere except builtin/.
>
> Replace it with repo_hold_locked_index(). hold_locked_index() remains
> as a wrapper around repo_hold_locked_index() to reduce changes in builtin/

> diff --git a/builtin/clone.c b/builtin/clone.c
> index 7c7f98c72c..ddb3230d21 100644
> --- a/builtin/clone.c
> +++ b/builtin/clone.c
> @@ -8,6 +8,7 @@
>   * Clone a repository into a different directory that does not yet exist.
>   */
>
> +#define USE_THE_INDEX_COMPATIBILITY_MACROS

I think this should be in patch 10/10.

> diff --git a/cache.h b/cache.h
> index ca36b44ee0..634c9ce325 100644
> --- a/cache.h
> +++ b/cache.h
> @@ -433,6 +433,7 @@ void validate_cache_entries(const struct index_state *istate);
>  #define unmerge_cache_entry_at(at) unmerge_index_entry_at(&the_index, at)
>  #define unmerge_cache(pathspec) unmerge_index(&the_index, pathspec)
>  #define read_blob_data_from_cache(path, sz) read_blob_data_from_index(&the_index, (path), (sz))
> +#define hold_locked_index(lock_file, flags) repo_hold_locked_index(the_repository, (lock_file), (flags))
>  #endif
>
>  #define TYPE_BITS 3
> @@ -833,7 +834,6 @@ extern struct cache_entry *refresh_cache_entry(struct index_state *, struct cach
>   */
>  extern void update_index_if_able(struct index_state *, struct lock_file *);
>
> -extern int hold_locked_index(struct lock_file *, int);

The reason this moves is it gets protected with "#ifndef
NO_THE_INDEX_COMPATIBILITY_MACROS". Ok.

> -int hold_locked_index(struct lock_file *lk, int lock_flags)
> -{
> -       return hold_lock_file_for_update(lk, get_index_file(), lock_flags);
> -}

> +int repo_hold_locked_index(struct repository *repo,
> +                          struct lock_file *lf,
> +                          int flags)
> +{
> +       return hold_lock_file_for_update(lf, repo->index_file, flags);
> +}

`get_index_file()` BUGs if `the_repository->index_file` is NULL, but
other than that, this looks like a faithful conversion. Do we want to
keep that check here?


Martin

  reply	other threads:[~2019-01-05 14:34 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-05  5:51 [PATCH 00/10] Remove the_index, the final part Nguyễn Thái Ngọc Duy
2019-01-05  5:51 ` [PATCH 01/10] notes-utils.c: remove the_repository references Nguyễn Thái Ngọc Duy
2019-01-05  5:51 ` [PATCH 02/10] repository.c: replace hold_locked_index() with repo_hold_locked_index() Nguyễn Thái Ngọc Duy
2019-01-05 14:33   ` Martin Ågren [this message]
2019-01-07 12:55     ` Duy Nguyen
2019-01-05  5:51 ` [PATCH 03/10] checkout: avoid the_index when possible Nguyễn Thái Ngọc Duy
2019-01-05  5:51 ` [PATCH 04/10] read-cache.c: kill read_index() Nguyễn Thái Ngọc Duy
2019-01-05  5:51 ` [PATCH 05/10] read-cache.c: replace update_index_if_able with repo_& Nguyễn Thái Ngọc Duy
2019-01-05  5:51 ` [PATCH 06/10] sha1-name.c: remove implicit dependency on the_index Nguyễn Thái Ngọc Duy
2019-01-05  5:51 ` [PATCH 07/10] merge-recursive.c: " Nguyễn Thái Ngọc Duy
2019-01-05  5:51 ` [PATCH 08/10] merge-recursive.c: remove implicit dependency on the_repository Nguyễn Thái Ngọc Duy
2019-01-05  5:51 ` [PATCH 09/10] read-cache.c: remove the_* from index_has_changes() Nguyễn Thái Ngọc Duy
2019-01-05  5:51 ` [PATCH 10/10] cache.h: flip NO_THE_INDEX_COMPATIBILITY_MACROS switch Nguyễn Thái Ngọc Duy
2019-01-12  2:13 ` [PATCH v2 00/11] Remove the_index, the final part Nguyễn Thái Ngọc Duy
2019-01-12  2:13   ` [PATCH v2 01/11] grep: use grep_opt->repo instead of explict repo argument Nguyễn Thái Ngọc Duy
2019-01-12  2:13   ` [PATCH v2 02/11] notes-utils.c: remove the_repository references Nguyễn Thái Ngọc Duy
2019-01-12  2:13   ` [PATCH v2 03/11] repository.c: replace hold_locked_index() with repo_hold_locked_index() Nguyễn Thái Ngọc Duy
2019-01-12  2:13   ` [PATCH v2 04/11] checkout: avoid the_index when possible Nguyễn Thái Ngọc Duy
2019-01-12  2:13   ` [PATCH v2 05/11] read-cache.c: kill read_index() Nguyễn Thái Ngọc Duy
2019-01-12  2:13   ` [PATCH v2 06/11] read-cache.c: replace update_index_if_able with repo_& Nguyễn Thái Ngọc Duy
2019-01-12  2:13   ` [PATCH v2 07/11] sha1-name.c: remove implicit dependency on the_index Nguyễn Thái Ngọc Duy
2019-01-12  2:13   ` [PATCH v2 08/11] merge-recursive.c: " Nguyễn Thái Ngọc Duy
2019-01-12  2:13   ` [PATCH v2 09/11] merge-recursive.c: remove implicit dependency on the_repository Nguyễn Thái Ngọc Duy
2019-01-12  2:13   ` [PATCH v2 10/11] read-cache.c: remove the_* from index_has_changes() Nguyễn Thái Ngọc Duy
2019-01-12  2:13   ` [PATCH v2 11/11] cache.h: flip NO_THE_INDEX_COMPATIBILITY_MACROS switch Nguyễn Thái Ngọc Duy

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='CAN0heSoRSgZVZ=NE6eof4dusEhfdz-eSiht06rGKb=GELvm86Q@mail.gmail.com' \
    --to=martin.agren@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=pclouds@gmail.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.
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).