Skip to contentSkip to conversation

dim: Add apply and push shorthands for current branch

PATCH Superseded Thierry Reding 3 participants 6 messages Jul 31, 2017 – Aug 3, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dim: Add apply and push shorthands for current branch

From: Thierry Reding <[email protected]>

The new apply and push commands are shorthands for applying patches to and pushing the current branch, respectively.

---
 dim     | 27 +++++++++++++++++++++++++++
 dim.rst |  8 ++++++++
 2 files changed, 35 insertions(+)
dim +27 -0
index c0cbe352b165..036cb092557e 100755
@@ -326,6 +326,20 @@ function git_fetch_helper # remote
 	fi
 }
 
+function git_current_branch
+{
+	local line branch
+
+	git branch --list | while read line; do
+		branch="${line#* }"
+
+		if test "$branch" != "$line"; then
+			echo "$branch"
+			break
+		fi
+	done
+}
+
 function git_is_current_branch # branch
 {
 	git branch --list $1 | grep -q '\*'
@@ -739,6 +753,11 @@ function dim_push_fixes
 	dim_push_branch drm-intel-fixes "$@"
 }
 
+function dim_push
+{
+	dim_push_branch $(git_current_branch) "$@"
+}
+
 # ensure we're on branch $1, and apply patches. the rest of the arguments are
 # passed to git am.
 dim_alias_ab=apply-branch
@@ -930,6 +949,14 @@ function dim_apply_next_fixes
 	dim_apply_branch drm-intel-next-fixes "$@"
 }
 
+# apply patch to current branch, the rest of the arguments are passed to
+# git am
+dim_alias_am=apply
+function dim_apply
+{
+	dim_apply_branch $(git_current_branch) "$@"
+}
+
 function commit_list_references
 {
 	local commit remote log
dim.rst +8 -0
index c004c30ada17..fa9b587d73bb 100644
@@ -198,6 +198,10 @@ apply-queued [*git am arguments*]
 **apply-branch** shorthands for *drm-intel-fixes*, *drm-intel-next-fixes*, and
 *drm-intel-next-queued* branches respectively.
 
+apply [*git am arguments*]
+--------------------------
+**apply-branch** shorthand for the current branch.
+
 extract-tags *branch* [*git-rangeish*]
 --------------------------------------
 This extracts various tags (e.g. Reviewed-by:) from emails and applies them to the
@@ -232,6 +236,10 @@ push-queued [*git push arguments*]
 **push-branch** shorthands for *drm-intel-fixes*, *drm-intel-next-fixes*, and
 *drm-intel-next-queued* branches respectively.
 
+push [*git push arguments*]
+---------------------------
+**push** shorthand for the current branch.
+
 rebuild-tip
 -----------
 Rebuild and push the integration tree.
Signature · 6 lines
2.13.3

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw
Quoted 22 lines · Thierry Reding

From: Thierry Reding <[email protected]>

The new apply and push commands are shorthands for applying patches to and pushing the current branch, respectively.

---
 dim     | 27 +++++++++++++++++++++++++++
 dim.rst |  8 ++++++++
 2 files changed, 35 insertions(+)
dim +3 -0
index c0cbe352b165..036cb092557e 100755
@@ -326,6 +326,20 @@ function git_fetch_helper # remote
 	fi
 }
 
+function git_current_branch
+{
+	local line branch

dim function git_fetch_helper # remote · line 341

Quoted 10 lines
dim +10 -0
+
+	git branch --list | while read line; do
+		branch="${line#* }"
+
+		if test "$branch" != "$line"; then
+			echo "$branch"
+			break
+		fi
+	done
+}

git symbolic-ref -q --short HEAD

is a much shorter way to type this. Can you respin, maybe also updating the other helper right below here?

Otherwise I think this is perfect, I think I'll add this shorthand for some of the maintainer commands for handling pull requests too.

Thanks, Daniel

Quoted 64 lines
dim +14 -0
+
 function git_is_current_branch # branch
 {
 	git branch --list $1 | grep -q '\*'
@@ -739,6 +753,11 @@ function dim_push_fixes
 	dim_push_branch drm-intel-fixes "$@"
 }
 
+function dim_push
+{
+	dim_push_branch $(git_current_branch) "$@"
+}
+
 # ensure we're on branch $1, and apply patches. the rest of the arguments are
 # passed to git am.
 dim_alias_ab=apply-branch
@@ -930,6 +949,14 @@ function dim_apply_next_fixes
 	dim_apply_branch drm-intel-next-fixes "$@"
 }
 
+# apply patch to current branch, the rest of the arguments are passed to
+# git am
+dim_alias_am=apply
+function dim_apply
+{
+	dim_apply_branch $(git_current_branch) "$@"
+}
+
 function commit_list_references
 {
 	local commit remote log
dim.rst +8 -0
index c004c30ada17..fa9b587d73bb 100644
@@ -198,6 +198,10 @@ apply-queued [*git am arguments*]
 **apply-branch** shorthands for *drm-intel-fixes*, *drm-intel-next-fixes*, and
 *drm-intel-next-queued* branches respectively.
 
+apply [*git am arguments*]
+--------------------------
+**apply-branch** shorthand for the current branch.
+
 extract-tags *branch* [*git-rangeish*]
 --------------------------------------
 This extracts various tags (e.g. Reviewed-by:) from emails and applies them to the
@@ -232,6 +236,10 @@ push-queued [*git push arguments*]
 **push-branch** shorthands for *drm-intel-fixes*, *drm-intel-next-fixes*, and
 *drm-intel-next-queued* branches respectively.
 
+push [*git push arguments*]
+---------------------------
+**push** shorthand for the current branch.
+
 rebuild-tip
 -----------
 Rebuild and push the integration tree.
Signature · 6 lines
2.13.3

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw

PATCH v2 1/2 dim: Add apply and push shorthands for current branch

In reply to Thierry Reding

From: Thierry Reding <[email protected]>

The new apply and push commands are shorthands for applying patches to and pushing the current branch, respectively.

v2: use git symbolic-ref to find current branch (Daniel Vetter)

---
 dim     | 18 ++++++++++++++++++
 dim.rst |  8 ++++++++
 2 files changed, 26 insertions(+)
dim +18 -0
index c0cbe352b165..1422b35e2471 100755
@@ -326,6 +326,11 @@ function git_fetch_helper # remote
 	fi
 }
 
+function git_current_branch
+{
+	git symbolic-ref -q --short HEAD
+}
+
 function git_is_current_branch # branch
 {
 	git branch --list $1 | grep -q '\*'
@@ -739,6 +744,11 @@ function dim_push_fixes
 	dim_push_branch drm-intel-fixes "$@"
 }
 
+function dim_push
+{
+	dim_push_branch $(git_current_branch) "$@"
+}
+
 # ensure we're on branch $1, and apply patches. the rest of the arguments are
 # passed to git am.
 dim_alias_ab=apply-branch
@@ -930,6 +940,14 @@ function dim_apply_next_fixes
 	dim_apply_branch drm-intel-next-fixes "$@"
 }
 
+# apply patch to current branch, the rest of the arguments are passed to
+# git am
+dim_alias_am=apply
+function dim_apply
+{
+	dim_apply_branch $(git_current_branch) "$@"
+}
+
 function commit_list_references
 {
 	local commit remote log
dim.rst +8 -0
index c004c30ada17..fa9b587d73bb 100644
@@ -198,6 +198,10 @@ apply-queued [*git am arguments*]
 **apply-branch** shorthands for *drm-intel-fixes*, *drm-intel-next-fixes*, and
 *drm-intel-next-queued* branches respectively.
 
+apply [*git am arguments*]
+--------------------------
+**apply-branch** shorthand for the current branch.
+
 extract-tags *branch* [*git-rangeish*]
 --------------------------------------
 This extracts various tags (e.g. Reviewed-by:) from emails and applies them to the
@@ -232,6 +236,10 @@ push-queued [*git push arguments*]
 **push-branch** shorthands for *drm-intel-fixes*, *drm-intel-next-fixes*, and
 *drm-intel-next-queued* branches respectively.
 
+push [*git push arguments*]
+---------------------------
+**push** shorthand for the current branch.
+
 rebuild-tip
 -----------
 Rebuild and push the integration tree.
Signature · 6 lines
2.13.3

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#3 lore raw

PATCH 2/2 dim: Simplify test for current branch

From: Thierry Reding <[email protected]>

Instead of listing branches and grepping for the current branch, simply read the name of the current branch and compare.

---
 dim | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
dim +1 -1
index 1422b35e2471..ebb1da05662d 100755
@@ -333,7 +333,7 @@ function git_current_branch
 
 function git_is_current_branch # branch
 {
-	git branch --list $1 | grep -q '\*'
+	test "$(git_current_branch)" = "$1"
 }
 
 function git_branch_exists # branch
Signature · 6 lines
2.13.3

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#4 lore raw
In reply to Thierry Reding
Quoted 4 lines · Thierry Reding

From: Thierry Reding <[email protected]>

The new apply and push commands are shorthands for applying patches to and pushing the current branch, respectively.

There's been some talk about moving further in the direction of using the current branch and current directory, like git does. I think the historical reason for having to explicitly specify the branch is to avoid shooting oneself in the foot. To avoid that oops from a quick apply and push. The safety catch.

I'm not opposed, but this is the reason.

One comment below.

BR,
Jani.

Quoted 68 lines

v2: use git symbolic-ref to find current branch (Daniel Vetter)

---
 dim     | 18 ++++++++++++++++++
 dim.rst |  8 ++++++++
 2 files changed, 26 insertions(+)
dim +18 -0
index c0cbe352b165..1422b35e2471 100755
@@ -326,6 +326,11 @@ function git_fetch_helper # remote
 	fi
 }
 
+function git_current_branch
+{
+	git symbolic-ref -q --short HEAD
+}
+
 function git_is_current_branch # branch
 {
 	git branch --list $1 | grep -q '\*'
@@ -739,6 +744,11 @@ function dim_push_fixes
 	dim_push_branch drm-intel-fixes "$@"
 }
 
+function dim_push
+{
+	dim_push_branch $(git_current_branch) "$@"
+}
+
 # ensure we're on branch $1, and apply patches. the rest of the arguments are
 # passed to git am.
 dim_alias_ab=apply-branch
@@ -930,6 +940,14 @@ function dim_apply_next_fixes
 	dim_apply_branch drm-intel-next-fixes "$@"
 }
 
+# apply patch to current branch, the rest of the arguments are passed to
+# git am
+dim_alias_am=apply
+function dim_apply
+{
+	dim_apply_branch $(git_current_branch) "$@"
+}
+
 function commit_list_references
 {
 	local commit remote log
dim.rst +4 -0
index c004c30ada17..fa9b587d73bb 100644
@@ -198,6 +198,10 @@ apply-queued [*git am arguments*]
 **apply-branch** shorthands for *drm-intel-fixes*, *drm-intel-next-fixes*, and
 *drm-intel-next-queued* branches respectively.
 
+apply [*git am arguments*]
+--------------------------
+**apply-branch** shorthand for the current branch.
+
 extract-tags *branch* [*git-rangeish*]
 --------------------------------------
 This extracts various tags (e.g. Reviewed-by:) from emails and applies them to the

dim.rst push-queued [*git push arguments*] · line 241

Quoted 6 lines
dim.rst +3 -0
@@ -232,6 +236,10 @@ push-queued [*git push arguments*]
 **push-branch** shorthands for *drm-intel-fixes*, *drm-intel-next-fixes*, and
 *drm-intel-next-queued* branches respectively.
 
+push [*git push arguments*]
+---------------------------
+**push** shorthand for the current branch.

I think you mean **push-branch** shorthand.

Quoted 4 lines
dim.rst +1 -0
+
 rebuild-tip
 -----------
 Rebuild and push the integration tree.
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#5 lore raw
Quoted 6 lines · Jani Nikula
Quoted 4 lines · Thierry Reding

From: Thierry Reding <[email protected]>

The new apply and push commands are shorthands for applying patches to and pushing the current branch, respectively.

Quoted 7 lines

There's been some talk about moving further in the direction of using the current branch and current directory, like git does. I think the historical reason for having to explicitly specify the branch is to avoid shooting oneself in the foot. To avoid that oops from a quick apply and push. The safety catch.

I'm not opposed, but this is the reason.

Yeah, I think with all the new committer the common use-case has shifted a bit, where applying to the current branch is a reasonable thing to do. Also, worktrees help a bunch with that too.

If it causes more troubles than it helps we can always go back to forcing explicit branch names.

Quoted 77 lines

One comment below.

BR,
Jani.

Quoted 71 lines

v2: use git symbolic-ref to find current branch (Daniel Vetter)

---
 dim     | 18 ++++++++++++++++++
 dim.rst |  8 ++++++++
 2 files changed, 26 insertions(+)
dim +18 -0
index c0cbe352b165..1422b35e2471 100755
@@ -326,6 +326,11 @@ function git_fetch_helper # remote
 	fi
 }
 
+function git_current_branch
+{
+	git symbolic-ref -q --short HEAD
+}
+
 function git_is_current_branch # branch
 {
 	git branch --list $1 | grep -q '\*'
@@ -739,6 +744,11 @@ function dim_push_fixes
 	dim_push_branch drm-intel-fixes "$@"
 }
 
+function dim_push
+{
+	dim_push_branch $(git_current_branch) "$@"
+}
+
 # ensure we're on branch $1, and apply patches. the rest of the arguments are
 # passed to git am.
 dim_alias_ab=apply-branch
@@ -930,6 +940,14 @@ function dim_apply_next_fixes
 	dim_apply_branch drm-intel-next-fixes "$@"
 }
 
+# apply patch to current branch, the rest of the arguments are passed to
+# git am
+dim_alias_am=apply
+function dim_apply
+{
+	dim_apply_branch $(git_current_branch) "$@"
+}
+
 function commit_list_references
 {
 	local commit remote log
dim.rst +4 -0
index c004c30ada17..fa9b587d73bb 100644
@@ -198,6 +198,10 @@ apply-queued [*git am arguments*]
 **apply-branch** shorthands for *drm-intel-fixes*, *drm-intel-next-fixes*, and
 *drm-intel-next-queued* branches respectively.
 
+apply [*git am arguments*]
+--------------------------
+**apply-branch** shorthand for the current branch.
+
 extract-tags *branch* [*git-rangeish*]
 --------------------------------------
 This extracts various tags (e.g. Reviewed-by:) from emails and applies them to the
@@ -232,6 +236,10 @@ push-queued [*git push arguments*]
 **push-branch** shorthands for *drm-intel-fixes*, *drm-intel-next-fixes*, and
 *drm-intel-next-queued* branches respectively.
 
Quoted 5 lines

dim.rst push-queued [*git push arguments*] · line 241

Quoted 3 lines
dim.rst +3 -0
+push [*git push arguments*]
+---------------------------
+**push** shorthand for the current branch.

I think you mean **push-branch** shorthand.

I'll fix this while applying.
-Daniel

Quoted 12 lines
Quoted 5 lines
dim.rst +1 -0
+
 rebuild-tip
 -----------
 Rebuild and push the integration tree.
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx