Re: [PATCH v8 3/6] remote set-head: better output for --auto
- From
Bence Ferdinandy <bence@ferdinandy.com>
- Date
- Oct 15, 2024, 16:31 UTC
- Message-ID
- <D4WIUDMT92X8.31YFOS47V1B4E@ferdinandy.com>
- In-Reply-To
- <CAOLa=ZT_m=H8pW9qkoOf+b0bLnzvT-3taQYFu+J6WT3DRi=6sQ@mail.gmail.com>
On Tue Oct 15, 2024 at 09:47, karthik nayak <karthik.188@gmail.com> wrote:
Show 30 quoted lines
> Bence Ferdinandy <bence@ferdinandy.com> writes:
>
> [snip]
>
>> +static void report_set_head_auto(const char *remote, const char *head_name,
>> + struct strbuf *buf_prev) {
>> + struct strbuf buf_prefix = STRBUF_INIT;
>> + const char *prev_head = NULL;
>> +
>> + strbuf_addf(&buf_prefix, "refs/remotes/%s/", remote);
>> + skip_prefix(buf_prev->buf, buf_prefix.buf, &prev_head);
>> +
>> + if (prev_head && !strcmp(prev_head, head_name))
>> + printf("'%s/HEAD' is unchanged and points to '%s'\n",
>> + remote, head_name);
>> + else if (prev_head)
>> + printf("'%s/HEAD' has changed from '%s' and now points to '%s'\n",
>> + remote, prev_head, head_name);
>> + else if (!buf_prev->len)
>> + printf("'%s/HEAD' is now created and points to '%s'\n",
>> + remote, head_name);
>> + else
>> + printf("'%s/HEAD' used to point to '%s' "
>> + "(which is not a remote branch), but now points to '%s'\n",
>> + remote, buf_prev->buf, head_name);
>> + strbuf_release(&buf_prefix);
>> +}
>> +
>
> Shouldn't the messages above be marked for translation too? using `_()`?I guess it is unlikely to fall under the "should be machine readable" category. I'll fix that up as well.
Show 9 quoted lines
>
>> static int set_head(int argc, const char **argv, const char *prefix)
>> {
>> int i, opt_a = 0, opt_d = 0, result = 0;
>> - struct strbuf buf = STRBUF_INIT, buf2 = STRBUF_INIT;
>> + struct strbuf buf = STRBUF_INIT, buf2 = STRBUF_INIT,
>> + buf_prev = STRBUF_INIT;
>
> Nit: these names could definitely be better.Indeed ... The second patch is a refactor of remote set-head, I could include a variable rename refactor there as well, and use the same names I used in the last patch when adding the similar calls to fetch's set_head.