Re: [PATCH 29/30] create_dir_entry(): allow the flag value to be passed as an argument
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Apr 25, 2012, 18:31 UTC
- Message-ID
- <xmqqfwbrd5ny.fsf@junio.mtv.corp.google.com>
- In-Reply-To
- <1335307536-26914-30-git-send-email-mhagger@alum.mit.edu>
mhagger@alum.mit.edu writes:
Show 23 quoted lines
> diff --git a/refs.c b/refs.c
> index 4eca965..869c9a7 100644
> --- a/refs.c
> +++ b/refs.c
> @@ -231,18 +231,18 @@ static void clear_ref_dir(struct ref_dir *dir)
> }
>
> /*
> + * Create a struct ref_entry object for the specified dirname and flag.
> * dirname is the name of the directory with a trailing slash (e.g.,
> * "refs/heads/") or "" for the top-level directory.
> */
> static struct ref_entry *create_dir_entry(struct ref_cache *ref_cache,
> - const char *dirname)
> + const char *dirname, int flag)
> {
> struct ref_entry *direntry;
> int len = strlen(dirname);
> direntry = xcalloc(1, sizeof(struct ref_entry) + len + 1);
> memcpy(direntry->name, dirname, len + 1);
> - direntry->flag = REF_DIR;
> + direntry->flag = flag;
> direntry->u.subdir.ref_cache = ref_cache;As the returned structure will always represent a subdirectory and not a leaf node, i.e. you use u.subdir, I do not think it makes any sense to make it responsibility for the caller of this function to include REF_DIR in the value of the flag.
Also shouldn't flag be of type "unsigned", not "int"?