Re: [PATCHv3] rev-parse: add --show-superproject-working-tree

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

 



Stefan Beller <sbeller@xxxxxxxxxx> writes:

> +--show-superproject-working-tree
> +	Show the absolute path of the top-level directory of
> +	the superproject. A superproject is a repository that records
> +	this repository as a submodule.

The top-level directory of the superproject's working tree?

Describe error conditions, like "you get an error if there is no
such project"?

> diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
> index e08677e559..2549643267 100644
> --- a/builtin/rev-parse.c
> +++ b/builtin/rev-parse.c
> @@ -12,6 +12,7 @@
>  #include "diff.h"
>  #include "revision.h"
>  #include "split-index.h"
> +#include "submodule.h"
>  
>  #define DO_REVS		1
>  #define DO_NOREV	2
> @@ -779,6 +780,12 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
>  					puts(work_tree);
>  				continue;
>  			}
> +			if (!strcmp(arg, "--show-superproject-working-tree")) {
> +				const char *superproject = get_superproject_working_tree();
> +				if (superproject)
> +					puts(superproject);
> +				continue;

When is superproject NULL?  Shouldn't we die with "there is no
superproject that uses us as a submodule"?

I can accept "it is not an error to ask for the root of the
superproject's working tree when we do not have any---that is one
way to ask if we have a superproject or not".  But if that is the
case, the code can stay the same, but the documentation should say
so, something like...

	Show the absolute path of the root of the superproject's
	working tree (if exists) that uses the current repository as
	its submodule.  Outputs nothing if the current repository is
	not used as a submodule by any project.




[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]