Skip to contentSkip to conversation

git.py: create a branch when checkout

PATCH In review Robert Yang 2 participants 5 messages Jul 9, 2015 – Jul 10, 2015

lore
Share & tools
lore
#0 lore raw

v2 cover git.py: create a branch when checkout

* V2:
- Use upstream name
- Track remote branch

* V1:
- Initial version

// Robert

The following changes since commit 0aaa67a790ab211b35eed58173efa115ceb6e243:

oeqa/bbtests: Fix to ensure DL_DIR is set (2015-07-08 13:09:28 +0100)

are available in the git repository at:

git://git.pokylinux.org/poky-contrib rbt/git
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=rbt/git

Robert Yang (1):
git.py: create a branch when checkout

 bitbake/lib/bb/fetch2/git.py |    7 +++++++
 1 file changed, 7 insertions(+)
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v2 1/1 git.py: create a branch when checkout

* Create a branch and named as upstream branch when checkout source
* Set the branch to track remote branch.

---
 bitbake/lib/bb/fetch2/git.py |    7 +++++++
 1 file changed, 7 insertions(+)
bitbake/lib/bb/fetch2/git.py +7 -0
index 2e53882..afa3d0a 100644
@@ -279,8 +279,15 @@ class Git(FetchMethod):
             if subdir != "":
                 runfetchcmd("%s read-tree %s%s" % (ud.basecmd, ud.revisions[ud.names[0]], readpathspec), d)
                 runfetchcmd("%s checkout-index -q -f -a" % ud.basecmd, d)
+            elif not ud.nobranch:
+                branchname =  ud.branches[ud.names[0]]
+                runfetchcmd("%s checkout -B %s %s" % (ud.basecmd, branchname, \
+                            ud.revisions[ud.names[0]]), d)
+                runfetchcmd("%s branch --set-upstream %s origin/%s" % (ud.basecmd, branchname, \
+                            branchname), d)
             else:
                 runfetchcmd("%s checkout %s" % (ud.basecmd, ud.revisions[ud.names[0]]), d)
+
         return True
 
     def clean(self, ud, d):
Signature · 1 line
1.7.9.5
#2 lore raw
Quoted 23 lines · On Thursday 09 July 2015 00:18:01 Robert Yang wrote:

* Create a branch and named as upstream branch when checkout source
* Set the branch to track remote branch.

---
 bitbake/lib/bb/fetch2/git.py |    7 +++++++
 1 file changed, 7 insertions(+)
bitbake/lib/bb/fetch2/git.py +0 -0
index 2e53882..afa3d0a 100644
@@ -279,8 +279,15 @@ class Git(FetchMethod):
             if subdir != "":
                 runfetchcmd("%s read-tree %s%s" % (ud.basecmd,

ud.revisions[ud.names[0]], readpathspec), d) runfetchcmd("%s checkout-index

bitbake/lib/bb/fetch2/git.py +3 -1
-q -f -a" % ud.basecmd, d) 
+            elif not ud.nobranch:
+                branchname =  ud.branches[ud.names[0]]
+                runfetchcmd("%s checkout -B %s %s" % (ud.basecmd,

branchname, \

bitbake/lib/bb/fetch2/git.py +2 -0
+                            ud.revisions[ud.names[0]]), d)
+                runfetchcmd("%s branch --set-upstream %s origin/%s" %
Quoted 2 lines

(ud.basecmd, branchname, \
+ branchname), d)

Doesn't git checkout support a --track option so we could do this in one command rather than two?

Cheers,
Paul

Signature · 2 lines
Paul Eggleton
Intel Open Source Technology Centre
#3 lore raw
Quoted 21 lines · Paul Eggleton
Quoted 20 lines · On Thursday 09 July 2015 00:18:01 Robert Yang wrote:

* Create a branch and named as upstream branch when checkout source
* Set the branch to track remote branch.

---
  bitbake/lib/bb/fetch2/git.py |    7 +++++++
  1 file changed, 7 insertions(+)
bitbake/lib/bb/fetch2/git.py +0 -0
index 2e53882..afa3d0a 100644
@@ -279,8 +279,15 @@ class Git(FetchMethod):
              if subdir != "":
                  runfetchcmd("%s read-tree %s%s" % (ud.basecmd,

ud.revisions[ud.names[0]], readpathspec), d) runfetchcmd("%s checkout-index

bitbake/lib/bb/fetch2/git.py +3 -1
-q -f -a" % ud.basecmd, d)
+            elif not ud.nobranch:
+                branchname =  ud.branches[ud.names[0]]
+                runfetchcmd("%s checkout -B %s %s" % (ud.basecmd,
Quoted 8 lines
Quoted 5 lines

branchname, \

bitbake/lib/bb/fetch2/git.py +2 -0
+                            ud.revisions[ud.names[0]]), d)
+                runfetchcmd("%s branch --set-upstream %s origin/%s" %

(ud.basecmd, branchname, \
+ branchname), d)

Doesn't git checkout support a --track option so we could do this in one command rather than two?

I'm afraid that we can use --track here, the supported commands are:
git checkout -b <branch> --track <remote>/<branch>
or
git checkout -b <branch> <start point>

What we need is something like:
git checkout -b <branch> --track <remote>/<branch> <start point> but git doesn't support this.

// Robert

Quoted 4 lines

Cheers,
Paul

#4 lore raw
Quoted 35 lines · On Friday 10 July 2015 08:00:35 Robert Yang wrote:
Quoted 19 lines · Paul Eggleton
Quoted 18 lines · On Thursday 09 July 2015 00:18:01 Robert Yang wrote:

* Create a branch and named as upstream branch when checkout source
* Set the branch to track remote branch.

---

  bitbake/lib/bb/fetch2/git.py |    7 +++++++
  1 file changed, 7 insertions(+)
bitbake/lib/bb/fetch2/git.py +0 -0
index 2e53882..afa3d0a 100644
@@ -279,8 +279,15 @@ class Git(FetchMethod):
              if subdir != "":
                  runfetchcmd("%s read-tree %s%s" % (ud.basecmd,
 
Quoted 14 lines
Quoted 11 lines

ud.revisions[ud.names[0]], readpathspec), d) runfetchcmd("%s checkout-index

bitbake/lib/bb/fetch2/git.py +3 -1
-q -f -a" % ud.basecmd, d)
+            elif not ud.nobranch:
+                branchname =  ud.branches[ud.names[0]]
+                runfetchcmd("%s checkout -B %s %s" % (ud.basecmd,

branchname, \

bitbake/lib/bb/fetch2/git.py +2 -0
+                            ud.revisions[ud.names[0]]), d)
+                runfetchcmd("%s branch --set-upstream %s origin/%s" %

(ud.basecmd, branchname, \
+ branchname), d)

Doesn't git checkout support a --track option so we could do this in one command rather than two?

Quoted 8 lines

I'm afraid that we can use --track here, the supported commands are:
git checkout -b <branch> --track <remote>/<branch>
or
git checkout -b <branch> <start point>

What we need is something like:
git checkout -b <branch> --track <remote>/<branch> <start point> but git doesn't support this.

Ah ok, fair enough - thanks for checking.

Cheers,
Paul

Signature · 2 lines
Paul Eggleton
Intel Open Source Technology Centre