Re: [PATCH v3 2/5] diff: diff_aligned_abbrev: remove ellipsis after abbreviated SHA-1 value

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Nov 19, 2017 at 1:41 PM, Ann T Ropea <bedhanger@xxxxxx> wrote:
> Neither Git nor the user are in need of this (visual) aid anymore, but
> we must offer a transition period.
>
> Also, fix a typo: "abbbreviated" ---> "abbreviated".
>
> Signed-off-by: Ann T Ropea <bedhanger@xxxxxx>
> ---
> diff --git a/diff.c b/diff.c
> @@ -4901,15 +4901,22 @@ const char *diff_aligned_abbrev(const struct object_id *oid, int len)
>  {
>         int abblen;
>         const char *abbrev;
> +       const char *env_printsha1ellipsis = getenv("PRINT_SHA1_ELLIPSIS");

Can you move the getenv() call down to the point where the result is
actually used so we don't have to worry about its value going stale[1]
by some intervening call to getenv(), setenv(), unsetenv() or
putenv()? Alternately, move the check against "yes" up here and assign
it to a boolean (int) which you consult later.

Ditto for the other patches. Thanks.

[1]: http://pubs.opengroup.org/onlinepubs/9699919799/functions/getenv.html

> +       /* Do we want all 40 hex characters? */
>         if (len == GIT_SHA1_HEXSZ)
>                 return oid_to_hex(oid);
>
> +       /* An abbreviated value is fine, possibly followed by an ellipsis. */
>         abbrev = diff_abbrev_oid(oid, len);
> +
> +       if (!(env_printsha1ellipsis && !strcasecmp(env_printsha1ellipsis, "yes")))
> +               return abbrev;
> +
>         abblen = strlen(abbrev);



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux