Re: [PATCH rdma-core] cbuild: Make cbuild work with git worktrees

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

 



On Tue, Mar 27, 2018 at 03:33:39PM -0600, Jason Gunthorpe wrote:
> 'rev-parse --git-dir' does not do something useful when using worktrees.
> Instead use cdup which prints enough ../'s to get to the top of the tree.
>
> Signed-off-by: Jason Gunthorpe <jgg@xxxxxxxxxxxx>
> ---
>  buildlib/cbuild | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/buildlib/cbuild b/buildlib/cbuild
> index 6b6c5878bbd592..e1aecbaa0fdef5 100755
> --- a/buildlib/cbuild
> +++ b/buildlib/cbuild
> @@ -872,8 +872,8 @@ if __name__ == '__main__':
>
>      # This script must always run from the top of the git tree, and a git
>      # checkout is mandatory.
> -    git_top = subprocess.check_output(["git","rev-parse","--git-dir"]).strip();
> -    if git_top != ".git":
> -        os.chdir(os.path.dirname(git_top));
> +    cdup = subprocess.check_output(["git","rev-parse","--show-cdup"]).strip();

"--show-toplevel" is designed for this.

➜  kernel git:(rdma-rc) git rev-parse --show-toplevel
/images/src/kernel
➜  kernel git:(rdma-rc) git worktree add /tmp/tmp.aFE2bhK92u HEAD
Preparing /tmp/tmp.aFE2bhK92u (identifier tmp.aFE2bhK92u)
Checking out files: 100% (62901/62901), done.
HEAD is now at c0a99687bff7 RDMA/ucma: Don't copy data for unknown AF family
➜  kernel git:(rdma-rc) cd /tmp/tmp.aFE2bhK92u
➜  tmp.aFE2bhK92u git:(c0a99687bff7) git rev-parse --show-toplevel
/tmp/tmp.aFE2bhK92u

> +    if cdup:
> +        os.chdir(cdup);

and what will be if cdup is NULL?

>
>      args.func(args);
> --
> 2.16.2
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux