Re: [PATCH 03/11] files-backend: add files_path()
- From
Ramsay Jones <ramsay@ramsayjones.plus.com>
- Date
- Feb 13, 2017, 20:43 UTC
- Message-ID
- <efab3ec2-e7c6-595a-8781-699bdc685a26@ramsayjones.plus.com>
- In-Reply-To
- <20170213152011.12050-4-pclouds@gmail.com>
On 13/02/17 15:20, Nguyễn Thái Ngọc Duy wrote:
Show 26 quoted lines
> This will be the replacement for both git_path() and git_path_submodule() > in this file. The idea is backend takes a git path and use that, > oblivious of submodule, linked worktrees and such. > > This is the middle step towards that. Eventually the "submodule" field > in 'struct files_ref_store' should be replace by "gitdir". And a > compound ref_store is created to combine two files backends together, > one represents the shared refs in $GIT_COMMON_DIR, one per-worktree. At > that point, files_path() becomes a wrapper of strbuf_vaddf(). > > Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> > --- > refs/files-backend.c | 20 ++++++++++++++++++++ > 1 file changed, 20 insertions(+) > > diff --git a/refs/files-backend.c b/refs/files-backend.c > index 6582c9b2d..39217a2ca 100644 > --- a/refs/files-backend.c > +++ b/refs/files-backend.c > @@ -169,6 +169,9 @@ static int files_log_ref_write(const char *refname, const unsigned char *old_sha > const unsigned char *new_sha1, const char *msg, > int flags, struct strbuf *err); > > +void files_path(struct files_ref_store *refs, struct strbuf *sb, > + const char *fmt, ...) __attribute__((format (printf, 3, 4))); > +
Why?
Show 28 quoted lines
> static struct ref_dir *get_ref_dir(struct ref_entry *entry)
> {
> struct ref_dir *dir;
> @@ -930,6 +933,23 @@ struct files_ref_store {
> /* Lock used for the main packed-refs file: */
> static struct lock_file packlock;
>
> +void files_path(struct files_ref_store *refs, struct strbuf *sb,
> + const char *fmt, ...)
> +{
> + struct strbuf tmp = STRBUF_INIT;
> + va_list vap;
> +
> + va_start(vap, fmt);
> + strbuf_vaddf(&tmp, fmt, vap);
> + va_end(vap);
> + if (refs->submodule)
> + strbuf_git_path_submodule(sb, refs->submodule,
> + "%s", tmp.buf);
> + else
> + strbuf_git_path(sb, "%s", tmp.buf);
> + strbuf_release(&tmp);
> +}
> +
> /*
> * Increment the reference count of *packed_refs.
> */
> ATB, Ramsay Jones