From: JAYATHEERTH K Date: Tue, 03 Mar 2026 10:31:03 GMT Subject: Re: [PATCH 0/4] repo: add support for path-related fields Message-ID: In-Reply-To: <46c60949-87f1-426a-aeb9-706e97fd8e8a@gmail.com> > > I see. What you've written matches what you described — it essentially > replicates the functionality of ref-filter.c. While I understand this is > just a simple code implementation demo: > > > opts->path_format = PATH_FORMAT_ABSOLUTE; > > This implementation appears unable to support input like 'git repo-info > --keys=path.absolute.toplevel,path.relative.gitdir', meaning it cannot > handle multiple paths output from a single call as previously mentioned > by Brain. The 'opts' here should be a global shared state, right? > > I think it's better for the parser to allocate a separate memory for > each arg it encounters. But then we'd be back to implementing something > like struct used_atom, hahaha (ゝ∀・) > > Thank you again for your email. > > Yuchen We create a fresh local_opts copy from the global_opts defaults for every single key: for (int i = 0; i < argc; i++) { struct repo_info_opts local_opts = global_opts; /* Fresh reset */ char *base_key = normalize_key(argv[i], &local_opts); /* ... find_field and get_value logic ... */ } Since local_opts is local to the loop iteration, path.absolute.toplevel only modifies the state for that specific turn. When the loop moves to path.relative.gitdir, it gets a brand-new local_opts and starts over. It handles mixed formats in a single call perfectly, without any persistent _pollution_ or the need for complex heap allocations. > > (I feel like we've been on this topic for too long. If you don't want to > reply, you don't have to :-) > I agree we've covered a lot of ground here, so I'll leave it at that. Thanks for the great discussion ;) Regards, Jayatheerth