Re: [PATCH 2/3] sha1_name: get_sha1_with_context learns to follow symlinks
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- May 8, 2015, 19:45 UTC
- Message-ID
- <CAPig+cRzXQp_afDrOdKrUQ-=DD1P_UcDzs8aSZnTfesd7R20wQ@mail.gmail.com>
- In-Reply-To
- <1431108819-6831-2-git-send-email-dturner@twopensource.com>
On Fri, May 8, 2015 at 2:13 PM, <dturner@twopensource.com> wrote:
Show 30 quoted lines
> Wire up get_sha1_with_context to call get_tree_entry_follow_symlinks
> when GET_SHA1_FOLLOW_SYMLINKS is passed in flags. G_S_FOLLOW_SYMLINKS
> is incompatible with G_S_ONLY_TO_DIE because the diagnosis that
> ONLY_TO_DIE triggers does not consider symlinks.
>
> Signed-off-by: David Turner <dturner@twitter.com>
> ---
> diff --git a/sha1_name.c b/sha1_name.c
> index 6d10f05..23863f7 100644
> --- a/sha1_name.c
> +++ b/sha1_name.c
> @@ -1434,6 +1434,12 @@ static int get_sha1_with_context_1(const char *name,
> new_filename = resolve_relative_path(filename);
> if (new_filename)
> filename = new_filename;
> + if (flags & GET_SHA1_FOLLOW_SYMLINKS) {
> + ret = get_tree_enty_follow_symlinks(tree_sha1,
> + filename, sha1, oc->path, &oc->mode);
> + free(new_filename);
> + return ret;
> + }
> ret = get_tree_entry(tree_sha1, filename, sha1, &oc->mode);
> if (ret && only_to_die) {
> diagnose_invalid_sha1_path(prefix, filename,
> @@ -1469,5 +1475,7 @@ void maybe_die_on_misspelt_object_name(const char *name, const char *prefix)
>
> int get_sha1_with_context(const char *str, unsigned flags, unsigned char *sha1, struct object_context *orc)
> {
> + if (flags & GET_SHA1_FOLLOW_SYMLINKS && flags & GET_SHA1_ONLY_TO_DIE)
> + die(_("internal error: bad flags for get_sha1_with_context"));There may not be much value in marking an "internal error" string for translation.
> return get_sha1_with_context_1(str, flags, NULL, sha1, orc); > }