* [PATCH v1] builtin/checkout.c: replace bit-shift values for macros in call to check_stages
@ 2020-06-07 5:48 Edmundo Carmona Antoranz
2020-06-07 5:54 ` Edmundo Carmona Antoranz
2020-06-09 20:22 ` Junio C Hamano
0 siblings, 2 replies; 4+ messages in thread
From: Edmundo Carmona Antoranz @ 2020-06-07 5:48 UTC (permalink / raw)
To: git; +Cc: Edmundo Carmona Antoranz
Currently a call to check_stages is using bit-shift values to define what will be used
as the first argument. If the reader doesn't know what the values are from heart, they
have to go dig in cache.h what each value is.
This patch is replacing those values for the macros from cache.h so that it's
clear at first sight what they are (CE_ENTRY_REMOVED, CE_ENTRY_ADDED)
Signed-off-by: Edmundo Carmona Antoranz <eantoranz@gmail.com>
---
builtin/checkout.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/builtin/checkout.c b/builtin/checkout.c
index ffa776c6e1..3a644b31f6 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -397,7 +397,7 @@ static int checkout_paths(const struct checkout_opts *opts,
} else if (opts->writeout_stage) {
errs |= check_stage(opts->writeout_stage, ce, pos, opts->overlay_mode);
} else if (opts->merge) {
- errs |= check_stages((1<<2) | (1<<3), ce, pos);
+ errs |= check_stages(CE_ENTRY_REMOVED | CE_ENTRY_ADDED, ce, pos);
} else {
errs = 1;
error(_("path '%s' is unmerged"), ce->name);
--
2.26.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v1] builtin/checkout.c: replace bit-shift values for macros in call to check_stages
2020-06-07 5:48 [PATCH v1] builtin/checkout.c: replace bit-shift values for macros in call to check_stages Edmundo Carmona Antoranz
@ 2020-06-07 5:54 ` Edmundo Carmona Antoranz
2020-06-09 20:22 ` Junio C Hamano
1 sibling, 0 replies; 4+ messages in thread
From: Edmundo Carmona Antoranz @ 2020-06-07 5:54 UTC (permalink / raw)
To: Git List
On Sat, Jun 6, 2020 at 11:49 PM Edmundo Carmona Antoranz
<eantoranz@gmail.com> wrote:
>
> Currently a call to check_stages is using bit-shift values to define what will be used
> as the first argument. If the reader doesn't know what the values are from heart, they
> have to go dig in cache.h what each value is.
>
> This patch is replacing those values for the macros from cache.h so that it's
> clear at first sight what they are (CE_ENTRY_REMOVED, CE_ENTRY_ADDED)
The macros are defined since at least v2.1.0 and I am able to apply
the patch on top of it. Should
I send the patch from that version? I am sending on top of v2.22.4
cause it's the oldest version I
was able to compile successfully.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v1] builtin/checkout.c: replace bit-shift values for macros in call to check_stages
2020-06-07 5:48 [PATCH v1] builtin/checkout.c: replace bit-shift values for macros in call to check_stages Edmundo Carmona Antoranz
2020-06-07 5:54 ` Edmundo Carmona Antoranz
@ 2020-06-09 20:22 ` Junio C Hamano
2020-06-10 5:15 ` Edmundo Carmona Antoranz
1 sibling, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2020-06-09 20:22 UTC (permalink / raw)
To: Edmundo Carmona Antoranz; +Cc: git
Edmundo Carmona Antoranz <eantoranz@gmail.com> writes:
> Currently a call to check_stages is using bit-shift values to
> define what will be used as the first argument. If the reader
> doesn't know what the values are from heart, they have to go dig
> in cache.h what each value is.
>
> This patch is replacing those values for the macros from cache.h so that it's
> clear at first sight what they are (CE_ENTRY_REMOVED, CE_ENTRY_ADDED)
The patch does not make sense. The hardcoded numbers you touched
have nothing to do with these macros.
The first argument to check_stages() is a bitmask for the stage
numbers in the index (which can span from 1 to 3), where 1 means
"common ancestor", 2 means "ours" and 3 means "theirs". The caller
gives a position 'pos' in the in-core index and asks the function
this question: "starting at position 'pos', there must be cache
entries with the same path as 'ce'---are these enries cover all the
stages specified by this mask?" This particular caller wants to
make sure that there are both "ours" and "theirs" entries for the
path.
The thing is, CE_ENTRY_REMOVED may also happen to have the value of
4, but that has nothing to do with (1<<2) used in the argument of
this. It was not chosen to be the value of 1 shifted by the stage
number for "ours". Same thing for CE_ENTRY_ADDED and (1<<3). Even
when these macros are renumbered, the argument to check_stages()
must stay the values they are written in the original code
(i.e. (1<<2)|(1<<3) == 12).
> Signed-off-by: Edmundo Carmona Antoranz <eantoranz@gmail.com>
> ---
> builtin/checkout.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/builtin/checkout.c b/builtin/checkout.c
> index ffa776c6e1..3a644b31f6 100644
> --- a/builtin/checkout.c
> +++ b/builtin/checkout.c
> @@ -397,7 +397,7 @@ static int checkout_paths(const struct checkout_opts *opts,
> } else if (opts->writeout_stage) {
> errs |= check_stage(opts->writeout_stage, ce, pos, opts->overlay_mode);
> } else if (opts->merge) {
> - errs |= check_stages((1<<2) | (1<<3), ce, pos);
> + errs |= check_stages(CE_ENTRY_REMOVED | CE_ENTRY_ADDED, ce, pos);
> } else {
> errs = 1;
> error(_("path '%s' is unmerged"), ce->name);
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v1] builtin/checkout.c: replace bit-shift values for macros in call to check_stages
2020-06-09 20:22 ` Junio C Hamano
@ 2020-06-10 5:15 ` Edmundo Carmona Antoranz
0 siblings, 0 replies; 4+ messages in thread
From: Edmundo Carmona Antoranz @ 2020-06-10 5:15 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Git List
On Tue, Jun 9, 2020 at 2:22 PM Junio C Hamano <gitster@pobox.com> wrote:
> The patch does not make sense. The hardcoded numbers you touched
> have nothing to do with these macros.
>
Totally misguided myself. Sorry for the confusion.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-06-10 5:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-07 5:48 [PATCH v1] builtin/checkout.c: replace bit-shift values for macros in call to check_stages Edmundo Carmona Antoranz
2020-06-07 5:54 ` Edmundo Carmona Antoranz
2020-06-09 20:22 ` Junio C Hamano
2020-06-10 5:15 ` Edmundo Carmona Antoranz
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).