Re: [PATCH v7 5/6] branch: add --recurse-submodules option for branch creation

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

 



Glen Choo <chooglen@xxxxxxxxxx> writes:

> Jonathan Tan <jonathantanmy@xxxxxxxxxx> writes:
>
>>> +/*
>>> + * Creates a new branch in repository and its submodules (and its
>>> + * submodules, recursively). Besides these exceptions, the parameters
>>> + * function identically to create_branch():
>>> + *
>>> + * - start_name is the name of the ref, in repository r, that the new
>>> + *   branch should start from. In submodules, branches will start from
>>> + *   the respective gitlink commit ids in start_name's tree.
>>> + *
>>> + * - tracking_name is the name used of the ref that will be used to set
>>> + *   up tracking, e.g. origin/main. This is propagated to submodules so
>>> + *   that tracking information will appear as if the branch branched off
>>> + *   tracking_name instead of start_name (which is a plain commit id for
>>> + *   submodules). If omitted, start_name is used for tracking (just like
>>> + *   create_branch()).
>>> + *
>>> + */
>>> +void create_branches_recursively(struct repository *r, const char *name,
>>> +				 const char *start_name,
>>> +				 const char *tracking_name, int force,
>>> +				 int reflog, int quiet, enum branch_track track,
>>> +				 int dry_run);
>>
>> Instead of taking in "name", "start_name", and "tracking_name", could we
>> take in "name", "oid", and "tracking_name"? That way, it's clearer what
>> each parameter is used for.
>
> I used start_name to mirror create_branches(), but start_name makes less
> sense here because it's ambiguous.
>
> Since the start_name is always an oid or NULL, this makes sense. I'll do
> this.

Rereading the code, I realise that start_name isn't guaranteed to be an
oid or NULL. When create_branches_recursively() is called at the root
level i.e. cmd_branch(), start_name is a user-given revision which
may or may not be an object id. In that scenario, tracking_name is NULL
to indicate that we would like to track start_name.

I can still pass only oids, but that would require parsing the revision
in cmd_branch() itself, and that seems like a violation of the layering
we have set up.

Instead, I'll try to find an accurate, but more descriptive name than
start_name.



[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