From: Junio C Hamano <gitster@pobox•com>
To: Brad King <brad.king@kitware•com>
Cc: git@vger•kernel.org, newren@gmail•com, jrnieder@gmail•com
Subject: Re: [PATCH v3 2/4] read-cache.c: Refactor --ignore-missing implementation
Date: Mon, 27 Jan 2014 09:39:46 -0800 [thread overview]
Message-ID: <xmqqy521nx25.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <e8a33f2e20e9f2041bf5f0fa952536755dbdf34c.1390833624.git.brad.king@kitware.com> (Brad King's message of "Mon, 27 Jan 2014 09:45:07 -0500")
Brad King <brad.king@kitware•com> writes:
> Move lstat ENOENT handling from refresh_index to refresh_cache_ent and
> activate it with a new CE_MATCH_IGNORE_MISSING option. This will allow
> other call paths into refresh_cache_ent to use the feature.
>
> Signed-off-by: Brad King <brad.king@kitware•com>
> ---
Good!
I forgot that we had "update-index --ignore-missing --refresh", and
that is conceptually the thing you want to use in your "perform
merge-recursive in an empty tree while pretending that the working
tree is fully populated and up-to-date" scenario.
> cache.h | 2 ++
> read-cache.c | 8 +++++---
> 2 files changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/cache.h b/cache.h
> index c9efe88..c96ada7 100644
> --- a/cache.h
> +++ b/cache.h
> @@ -498,6 +498,8 @@ extern void *read_blob_data_from_index(struct index_state *, const char *, unsig
> #define CE_MATCH_RACY_IS_DIRTY 02
> /* do stat comparison even if CE_SKIP_WORKTREE is true */
> #define CE_MATCH_IGNORE_SKIP_WORKTREE 04
> +/* ignore non-existent files during stat update */
> +#define CE_MATCH_IGNORE_MISSING 0x08
> extern int ie_match_stat(const struct index_state *, const struct cache_entry *, struct stat *, unsigned int);
> extern int ie_modified(const struct index_state *, const struct cache_entry *, struct stat *, unsigned int);
>
> diff --git a/read-cache.c b/read-cache.c
> index 33dd676..d61846c 100644
> --- a/read-cache.c
> +++ b/read-cache.c
> @@ -1031,6 +1031,7 @@ static struct cache_entry *refresh_cache_ent(struct index_state *istate,
> int changed, size;
> int ignore_valid = options & CE_MATCH_IGNORE_VALID;
> int ignore_skip_worktree = options & CE_MATCH_IGNORE_SKIP_WORKTREE;
> + int ignore_missing = options & CE_MATCH_IGNORE_MISSING;
>
> if (ce_uptodate(ce))
> return ce;
> @@ -1050,6 +1051,8 @@ static struct cache_entry *refresh_cache_ent(struct index_state *istate,
> }
>
> if (lstat(ce->name, &st) < 0) {
> + if (ignore_missing && errno == ENOENT)
> + return ce;
> if (err)
> *err = errno;
> return NULL;
> @@ -1127,7 +1130,8 @@ int refresh_index(struct index_state *istate, unsigned int flags,
> int ignore_submodules = (flags & REFRESH_IGNORE_SUBMODULES) != 0;
> int first = 1;
> int in_porcelain = (flags & REFRESH_IN_PORCELAIN);
> - unsigned int options = really ? CE_MATCH_IGNORE_VALID : 0;
> + unsigned int options = ((really ? CE_MATCH_IGNORE_VALID : 0) |
> + (not_new ? CE_MATCH_IGNORE_MISSING : 0));
> const char *modified_fmt;
> const char *deleted_fmt;
> const char *typechange_fmt;
> @@ -1176,8 +1180,6 @@ int refresh_index(struct index_state *istate, unsigned int flags,
> if (!new) {
> const char *fmt;
>
> - if (not_new && cache_errno == ENOENT)
> - continue;
> if (really && cache_errno == EINVAL) {
> /* If we are doing --really-refresh that
> * means the index is not valid anymore.
next prev parent reply other threads:[~2014-01-27 17:40 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CABPp-BGAsrrjcZxVirzKU_VEyUM1U=4TFj18CieKKE7==c7v2A@mail.gmail.com>
2014-01-24 15:01 ` [PATCH/RFC 0/3] merge-recursive: Avoid diagnostic on empty work tree Brad King
2014-01-24 15:01 ` [PATCH/RFC 1/3] t3030-merge-recursive: Test known breakage with " Brad King
2014-01-24 16:51 ` Jonathan Nieder
2014-01-24 17:50 ` Brad King
2014-01-24 15:01 ` [PATCH/RFC 2/3] read-cache.c: Thread lstat error through make_cache_entry signature Brad King
2014-01-24 15:01 ` [PATCH/RFC 3/3] merge-recursive: Tolerate missing file when HEAD is up to date Brad King
[not found] ` <CABPp-BEK9+_ebRiodCp59DHJZExYn3N1jjtBsikSmwt-s_v_0A@mail.gmail.com>
2014-01-24 19:37 ` Fwd: " newren
2014-01-24 19:45 ` Brad King
2014-01-24 19:50 ` Junio C Hamano
2014-01-24 20:02 ` Brad King
2014-01-24 20:10 ` [PATCH v2 0/3] merge-recursive: Avoid diagnostic on empty work tree Brad King
2014-01-24 20:10 ` [PATCH v2 1/3] t3030-merge-recursive: Test known breakage with " Brad King
2014-01-24 20:10 ` [PATCH v2 2/3] read-cache.c: Optionally tolerate missing files in make_cache_entry Brad King
2014-01-24 20:39 ` Junio C Hamano
2014-01-24 20:10 ` [PATCH v2 3/3] merge-recursive.c: Tolerate missing files while refreshing index Brad King
2014-01-27 14:45 ` [PATCH v3 0/3] merge-recursive: Avoid diagnostic on empty work tree Brad King
2014-01-27 14:45 ` [PATCH v3 1/4] t3030-merge-recursive: Test known breakage with " Brad King
2014-01-27 14:45 ` [PATCH v3 2/4] read-cache.c: Refactor --ignore-missing implementation Brad King
2014-01-27 17:39 ` Junio C Hamano [this message]
2014-01-27 14:45 ` [PATCH v3 3/4] read-cache.c: Extend make_cache_entry refresh flag with options Brad King
2014-01-27 14:45 ` [PATCH v3 4/4] merge-recursive.c: Tolerate missing files while refreshing index Brad King
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=xmqqy521nx25.fsf@gitster.dls.corp.google.com \
--to=gitster@pobox$(echo .)com \
--cc=brad.king@kitware$(echo .)com \
--cc=git@vger$(echo .)kernel.org \
--cc=jrnieder@gmail$(echo .)com \
--cc=newren@gmail$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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