diff mbox series

[v2,21/29] tree-walk.h API users: use "tmp" for mode in shift_tree_by()

Message ID 20210316021312.13927-22-avarab@gmail.com (mailing list archive)
State New, archived
Headers show
Series tree-walk: mostly "mode" to "enum object_type" | expand

Commit Message

Ævar Arnfjörð Bjarmason March 16, 2021, 2:13 a.m. UTC
Refactor code added in 85e51b783c3 (Make "subtree" part more
orthogonal to the rest of merge-recursive., 2008-06-30) to make it
obvious that we don't care about the "mode" here outside of the if
statement it appears in.

That's opposed to the sub1 & sub2 variables, where we use the two
object ids later in this function.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 match-trees.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Elijah Newren March 16, 2021, 6:34 a.m. UTC | #1
On Mon, Mar 15, 2021 at 7:13 PM Ævar Arnfjörð Bjarmason
<avarab@gmail.com> wrote:

As with the previous round, why do you have the subject as "tree-walk:
..." instead of "match-trees: ..." ?

>
> Refactor code added in 85e51b783c3 (Make "subtree" part more
> orthogonal to the rest of merge-recursive., 2008-06-30) to make it
> obvious that we don't care about the "mode" here outside of the if
> statement it appears in.
>
> That's opposed to the sub1 & sub2 variables, where we use the two
> object ids later in this function.
>
> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
> ---
>  match-trees.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/match-trees.c b/match-trees.c
> index 0faacd8f4ae..e84f993a460 100644
> --- a/match-trees.c
> +++ b/match-trees.c
> @@ -317,17 +317,17 @@ void shift_tree_by(struct repository *r,
>                    const char *shift_prefix)
>  {
>         struct object_id sub1, sub2;
> -       unsigned short mode1, mode2;
> +       unsigned short tmp;
>         unsigned candidate = 0;
>
>         /* Can hash2 be a tree at shift_prefix in tree hash1? */
> -       if (!get_tree_entry_mode(r, hash1, shift_prefix, &sub1, &mode1) &&
> -           S_ISDIR(mode1))
> +       if (!get_tree_entry_mode(r, hash1, shift_prefix, &sub1, &tmp) &&
> +           S_ISDIR(tmp))
>                 candidate |= 1;
>
>         /* Can hash1 be a tree at shift_prefix in tree hash2? */
> -       if (!get_tree_entry_mode(r, hash2, shift_prefix, &sub2, &mode2) &&
> -           S_ISDIR(mode2))
> +       if (!get_tree_entry_mode(r, hash2, shift_prefix, &sub2, &tmp) &&
> +           S_ISDIR(tmp))
>                 candidate |= 2;
>
>         if (candidate == 3) {
> --
> 2.31.0.rc2.211.g1d0b8788b3
>
diff mbox series

Patch

diff --git a/match-trees.c b/match-trees.c
index 0faacd8f4ae..e84f993a460 100644
--- a/match-trees.c
+++ b/match-trees.c
@@ -317,17 +317,17 @@  void shift_tree_by(struct repository *r,
 		   const char *shift_prefix)
 {
 	struct object_id sub1, sub2;
-	unsigned short mode1, mode2;
+	unsigned short tmp;
 	unsigned candidate = 0;
 
 	/* Can hash2 be a tree at shift_prefix in tree hash1? */
-	if (!get_tree_entry_mode(r, hash1, shift_prefix, &sub1, &mode1) &&
-	    S_ISDIR(mode1))
+	if (!get_tree_entry_mode(r, hash1, shift_prefix, &sub1, &tmp) &&
+	    S_ISDIR(tmp))
 		candidate |= 1;
 
 	/* Can hash1 be a tree at shift_prefix in tree hash2? */
-	if (!get_tree_entry_mode(r, hash2, shift_prefix, &sub2, &mode2) &&
-	    S_ISDIR(mode2))
+	if (!get_tree_entry_mode(r, hash2, shift_prefix, &sub2, &tmp) &&
+	    S_ISDIR(tmp))
 		candidate |= 2;
 
 	if (candidate == 3) {