Re: [GSoC Patch v6 4/7] repo: add path.index with absolute and relative suffixes
- From
K Jayatheerth <jayatheerthkulkarni2005@gmail.com>
- Date
- Sep 23, 2026, 17:25 UTC
- Message-ID
- <CA+rGoLchSyDz9fcBuaS=M9t1q_Xp3KPsX5m_qKEfAHonQD6uTQ@mail.gmail.com>
- In-Reply-To
- <xmqqse3fbudk.fsf@gitster.g>
Show 15 quoted lines
> > + if (!index_file)
> > + return error(_("unable to get index file"));
>
> This is a dead code, as repo_get_index_file() calls BUG("") when it
> finds that the repo instance is not ready to return this information.
>
> Hence I am debating myself if this is a better alternative:
>
> const char *index_file = repo->index_file;
>
> if (!index_file)
> return error(...);
>
> I dunno.
>I think I am just gonna remove the if condition from get_path_index_relative() and let repo_get_index_file handle the bug instead of rewriting the logic.
Show 12 quoted lines
> > +static int get_path_index_relative(struct repository *repo, struct strbuf *buf)
> > +{
> > + const char *index_file = repo_get_index_file(repo);
> > +
> > + if (!index_file)
> > + return error(_("unable to get index file"));
> > +
> > + format_path(buf, index_file, repo->prefix, PATH_FORMAT_RELATIVE);
> > + return 0;
> > +}
>
> Ditto.Same for this.