To make it harder to accidentally do "git push" with a guilt patch
applied, "guilt push" changes branch from e.g. "master" to
"guilt/master" starting with commit 67d3af63f422. This is a feature
which I use for ext4 development; I actually *do* want to be able to
push patches to the dev branch, which is a rewindable branch much like
git's "pu" branch.
Allow the use of the environment variable GUILT_FORCE_BARE_BRANCH
which disables the new behavior introduced by commit 67d3af63f422.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Cc: Per Cederqvist <redacted>
---
guilt | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
@@ -914,13 +914,22 @@ else die "Unsupported operating system: $UNAME_S" fi-if [ "$branch" = "$raw_git_branch" ] && [ -n "`get_top 2>/dev/null`" ]-then- # This is for compat with old repositories that still have a- # pushed patch without the new-style branch prefix.+if [ -n "`get_top 2>/dev/null`" ]; then+ #+ # If we have repositories patches pushed, then use whatever scheme+ # is currently in use+ #+ if [ "$branch" = "$raw_git_branch" ]; then old_style_prefix=true+ else+ old_style_prefix=false+ fi else+ if [ -n "$GUILT_FORCE_BARE_BRANCH" ]; then+ old_style_prefix=true+ else old_style_prefix=false+ fi fi _main "$@"
From: Josef 'Jeff' Sipek <hidden> Date: 2016-06-15 22:57:24
On Tue, May 21, 2013 at 10:55:57PM -0400, Theodore Ts'o wrote:
To make it harder to accidentally do "git push" with a guilt patch
applied, "guilt push" changes branch from e.g. "master" to
"guilt/master" starting with commit 67d3af63f422. This is a feature
which I use for ext4 development; I actually *do* want to be able to
push patches to the dev branch, which is a rewindable branch much like
git's "pu" branch.
Allow the use of the environment variable GUILT_FORCE_BARE_BRANCH
which disables the new behavior introduced by commit 67d3af63f422.
Would it make sense to make it git-config-able instead? As an added bonus,
one can then make the decision on per-repository basis.
Jeff.
@@ -914,13 +914,22 @@ else die "Unsupported operating system: $UNAME_S" fi-if [ "$branch" = "$raw_git_branch" ] && [ -n "`get_top 2>/dev/null`" ]-then- # This is for compat with old repositories that still have a- # pushed patch without the new-style branch prefix.+if [ -n "`get_top 2>/dev/null`" ]; then+ #+ # If we have repositories patches pushed, then use whatever scheme+ # is currently in use+ #+ if [ "$branch" = "$raw_git_branch" ]; then old_style_prefix=true+ else+ old_style_prefix=false+ fi else+ if [ -n "$GUILT_FORCE_BARE_BRANCH" ]; then+ old_style_prefix=true+ else old_style_prefix=false+ fi fi _main "$@"
--
1.7.12.rc0.22.gcdd159b
--
Linux, n.:
Generous programmers from around the world all join forces to help
you shoot yourself in the foot for free.
To make it harder to accidentally do "git push" with a guilt patch
applied, "guilt push" changes branch from e.g. "master" to
"guilt/master" starting with commit 67d3af63f422. This is a feature
which I use for ext4 development; I actually *do* want to be able to
push patches to the dev branch, which is a rewindable branch much like
git's "pu" branch.
Allow the use of the environment variable GUILT_FORCE_BARE_BRANCH
which disables the new behavior introduced by commit 67d3af63f422.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Cc: Per Cederqvist <redacted>
---
guilt | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
@@ -914,13 +914,22 @@ else die "Unsupported operating system: $UNAME_S" fi-if [ "$branch" = "$raw_git_branch" ] && [ -n "`get_top 2>/dev/null`" ]-then- # This is for compat with old repositories that still have a- # pushed patch without the new-style branch prefix.+if [ -n "`get_top 2>/dev/null`" ]; then+ #+ # If we have repositories patches pushed, then use whatever scheme+ # is currently in use+ #+ if [ "$branch" = "$raw_git_branch" ]; then old_style_prefix=true+ else+ old_style_prefix=false+ fi else+ if [ "$(git config --bool --get guilt.bareBranch)" = "true" ]; then+ old_style_prefix=true+ else old_style_prefix=false+ fi fi _main "$@"
From: Per Cederqvist <hidden> Date: 2016-06-15 22:57:24
On 05/22/13 14:11, Theodore Ts'o wrote:
To make it harder to accidentally do "git push" with a guilt patch
applied, "guilt push" changes branch from e.g. "master" to
"guilt/master" starting with commit 67d3af63f422. This is a feature
which I use for ext4 development; I actually *do* want to be able to
push patches to the dev branch, which is a rewindable branch much like
git's "pu" branch.
Allow the use of the environment variable GUILT_FORCE_BARE_BRANCH
which disables the new behavior introduced by commit 67d3af63f422.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Cc: Per Cederqvist <redacted>
I just posted an alternative patch that solves the same issue.
I forgot to add in-reply-to headers, and did change the subject
to "Added guilt.reusebranch configuration option". Sorry if I've
caused any confusion.
/ceder
@@ -914,13 +914,22 @@ else die "Unsupported operating system: $UNAME_S" fi-if [ "$branch" = "$raw_git_branch" ] && [ -n "`get_top 2>/dev/null`" ]-then- # This is for compat with old repositories that still have a- # pushed patch without the new-style branch prefix.+if [ -n "`get_top 2>/dev/null`" ]; then+ #+ # If we have repositories patches pushed, then use whatever scheme+ # is currently in use+ #+ if [ "$branch" = "$raw_git_branch" ]; then old_style_prefix=true+ else+ old_style_prefix=false+ fi else+ if [ "$(git config --bool --get guilt.bareBranch)" = "true" ]; then+ old_style_prefix=true+ else old_style_prefix=false+ fi fi _main "$@"
From: Per Cederqvist <hidden> Date: 2016-06-15 22:57:24
When the option is true (the default), Guilt does not create a new Git
branch when patches are applied. This way, you can switch between
Guilt 0.35 and the current version of Guilt with no issues.
At a future time, maybe a year after Guilt with guilt.reusebranch
support is released, the default should be changed to "false" to take
advantage of the ability to use a separate Git branch when patches are
applied.
Signed-off-by: Per Cederqvist <redacted>
---
This is an alternative solution to the same problem. I've been running
with this code for a while. I don't remember if I sent it to the list
before, but if I did it was apparently lost. Sorry if I never sent it.
This version includes some regression tests.
(I'm having mail problems. Apologies if you receive this patch twice.)
/ceder
guilt | 29 +++-
regression/scaffold | 1 +
regression/t-062.out | 457 +++++++++++++++++++++++++++++++++++++++++++++++++++
regression/t-062.sh | 150 +++++++++++++++++
4 files changed, 632 insertions(+), 5 deletions(-)
create mode 100644 regression/t-062.out
create mode 100755 regression/t-062.sh
@@ -836,6 +836,9 @@ guilt_push_diff_context=1 # default diffstat value: true or false DIFFSTAT_DEFAULT="false"+# default old_style_prefix value: true or false+REUSE_BRANCH_DEFAULT="true"+ # Prefix for guilt branches. GUILT_PREFIX=guilt/
@@ -847,6 +850,10 @@ GUILT_PREFIX=guilt/ diffstat=`git config --bool guilt.diffstat` [ -z "$diffstat" ] && diffstat=$DIFFSTAT_DEFAULT+# reuse Git branch?+reuse_branch=`git config --bool guilt.reusebranch`+[ -z "$reuse_branch" ] && reuse_branch=$REUSE_BRANCH_DEFAULT+ # # The following gets run every time this file is source'd #
@@ -911,13 +918,25 @@ else die "Unsupported operating system: $UNAME_S" fi-if [ "$branch" = "$raw_git_branch" ] && [ -n "`get_top 2>/dev/null`" ]+if [ -n "`get_top 2>/dev/null`" ] then- # This is for compat with old repositories that still have a- # pushed patch without the new-style branch prefix.- old_style_prefix=true+ # If there is at least one pushed patch, we set+ # old_style_prefix according to how it was pushed. It is only+ # possible to change the prefix style while no patches are+ # applied.+ if [ "$branch" = "$raw_git_branch" ]+ then+ old_style_prefix=true+ else+ old_style_prefix=false+ fi else- old_style_prefix=false+ if $reuse_branch+ then+ old_style_prefix=true+ else+ old_style_prefix=false+ fi fi _main "$@"
@@ -0,0 +1,150 @@+#!/bin/bash+#+# Test the branch-switching upgrade code+#++source$REG_DIR/scaffold++old_style_branch(){+# Modify the refs so that it looks as if the patch series was applied+# by an old version of guilt.+cmdgitupdate-refrefs/heads/$1refs/heads/guilt/$1+cmdgitsymbolic-refHEADrefs/heads/$1+cmdgitupdate-ref-drefs/heads/guilt/$1+}++remove_topic(){+cmdguiltpop-a+ifgitrev-parse--verify--quietguilt/master>/dev/null+then+cmdgitcheckoutguilt/master+else+cmdgitcheckoutmaster+fi+cmdguiltpop-a+cmdgitbranch-d$1+cmdrm-r.git/patches/$1+cmdgitfor-each-ref+cmdlist_files+}++functionfixup_time_info+{+touch-a-m-t"$TOUCH_DATE"".git/patches/master/$1"+}++cmdsetup_repo++cmdgitconfigguilt.reusebranchtrue++cmdguiltpush-a+cmdlist_files+cmdgitfor-each-ref++# Pop and push patches. Check that the repo is converted to new-style+# refs when no patches are applied and a patch is pushed.+old_style_branchmaster+cmdgitfor-each-ref++cmdlist_files++foriin`seq5`+do+cmdguiltpop+cmdgitfor-each-ref+cmdguiltpush+cmdgitfor-each-ref+cmdguiltpop+cmdgitfor-each-ref+done++# Check that "pop -a" does the right thing.+cmdguiltpush-a++old_style_branchmaster++cmdgitfor-each-ref++cmdguiltpop-a++cmdgitfor-each-ref++# Check that pushing two patches converts the repo to now-style (since+# it currently has no patches applied).+cmdguiltpushadd+cmdgitfor-each-ref++# Check guilt branch with a few patches applied.+old_style_branchmaster+cmdguiltbranchtopic+cmdgitfor-each-ref++# Check that the topic branch is converted to new-style.+cmdguiltpop-a+cmdguiltpush+cmdgitfor-each-ref++remove_topictopic++# Check guilt branch with the full patch series applied.+cmdguiltpush-a+old_style_branchmaster+cmdguiltbranchtopic+cmdgitfor-each-ref++remove_topictopic++# Check guilt branch with no patches applied.+# This gives us a new-style checkout.+cmdguiltbranchtopic+cmdgitfor-each-ref+cmdlist_files++remove_topictopic++# Check guilt branch in a new-style directory with all patches+# applied. (Strictly speaking, this test should probably move to a+# file devoted to testing "guilt branch".)+cmdguiltpush-a+cmdguiltbranchtopic+cmdgitfor-each-ref+cmdlist_files+cmdguiltpop-a+cmdgitfor-each-ref++remove_topictopic++# Check that "guilt new" does the right thing when no patches are+# applied. (Strictly speaking, this test should maybe move to+# t-025.sh).++cmdguiltnewnewpatch+cmdgitfor-each-ref'--format=%(refname)'+cmdguiltpop+fixup_time_infonewpatch+cmdguiltpush+cmdgitfor-each-ref++# Check that "guilt commit" does the right thing when committing all+# applied patches. (Strictly speaking, this test should maybe move to+# t-030.sh).+cmdgitbranch+cmdguiltapplied+cmdguiltcommit-a+cmdgitfor-each-ref+cmdgitbranch++# Check that "guilt commit" does the right thing when committing only+# a few of the applied patches. (Strictly speaking, this test should+# maybe move to t-030.sh).+cmdguiltpush-a+cmdguiltapplied+cmdgitbranch+cmdgitfor-each-ref+cmdguiltcommit-n2+cmdgitfor-each-ref+cmdgitbranch+cmdguiltcommit-n2+cmdgitfor-each-ref+cmdgitbranch+cmdguiltseries
From: Josef 'Jeff' Sipek <hidden> Date: 2016-06-15 22:57:24
On Wed, May 22, 2013 at 03:01:36PM +0200, Per Cederqvist wrote:
When the option is true (the default), Guilt does not create a new Git
branch when patches are applied. This way, you can switch between
Guilt 0.35 and the current version of Guilt with no issues.
At a future time, maybe a year after Guilt with guilt.reusebranch
support is released, the default should be changed to "false" to take
advantage of the ability to use a separate Git branch when patches are
applied.
So, I've been using the always-on prefix code and I do like it. It makes me
reasonably happy that other people that work on the same repo won't screw it
up. So, with that said, I'm tempted to actually make the default the
new-style prefix. If someone (there's at least Ted) wants the old behavior,
they'll have the config.
IOW, I'm tempted to apply this patch with a minor tweak: change the default
to new-style.
Signed-off-by: Per Cederqvist <redacted>
---
This is an alternative solution to the same problem. I've been running
with this code for a while. I don't remember if I sent it to the list
before, but if I did it was apparently lost. Sorry if I never sent it.
For all I know, I just dropped this patch on the floor by accident :/
Jeff.
quoted hunk
This version includes some regression tests.
(I'm having mail problems. Apologies if you receive this patch twice.)
/ceder
guilt | 29 +++-
regression/scaffold | 1 +
regression/t-062.out | 457 +++++++++++++++++++++++++++++++++++++++++++++++++++
regression/t-062.sh | 150 +++++++++++++++++
4 files changed, 632 insertions(+), 5 deletions(-)
create mode 100644 regression/t-062.out
create mode 100755 regression/t-062.sh
@@ -836,6 +836,9 @@ guilt_push_diff_context=1 # default diffstat value: true or false DIFFSTAT_DEFAULT="false"+# default old_style_prefix value: true or false+REUSE_BRANCH_DEFAULT="true"+ # Prefix for guilt branches. GUILT_PREFIX=guilt/
@@ -847,6 +850,10 @@ GUILT_PREFIX=guilt/ diffstat=`git config --bool guilt.diffstat` [ -z "$diffstat" ] && diffstat=$DIFFSTAT_DEFAULT+# reuse Git branch?+reuse_branch=`git config --bool guilt.reusebranch`+[ -z "$reuse_branch" ] && reuse_branch=$REUSE_BRANCH_DEFAULT+ # # The following gets run every time this file is source'd #
@@ -911,13 +918,25 @@ else die "Unsupported operating system: $UNAME_S" fi-if [ "$branch" = "$raw_git_branch" ] && [ -n "`get_top 2>/dev/null`" ]+if [ -n "`get_top 2>/dev/null`" ] then- # This is for compat with old repositories that still have a- # pushed patch without the new-style branch prefix.- old_style_prefix=true+ # If there is at least one pushed patch, we set+ # old_style_prefix according to how it was pushed. It is only+ # possible to change the prefix style while no patches are+ # applied.+ if [ "$branch" = "$raw_git_branch" ]+ then+ old_style_prefix=true+ else+ old_style_prefix=false+ fi else- old_style_prefix=false+ if $reuse_branch+ then+ old_style_prefix=true+ else+ old_style_prefix=false+ fi fi _main "$@"
@@ -0,0 +1,150 @@+#!/bin/bash+#+# Test the branch-switching upgrade code+#++source$REG_DIR/scaffold++old_style_branch(){+# Modify the refs so that it looks as if the patch series was applied+# by an old version of guilt.+cmdgitupdate-refrefs/heads/$1refs/heads/guilt/$1+cmdgitsymbolic-refHEADrefs/heads/$1+cmdgitupdate-ref-drefs/heads/guilt/$1+}++remove_topic(){+cmdguiltpop-a+ifgitrev-parse--verify--quietguilt/master>/dev/null+then+cmdgitcheckoutguilt/master+else+cmdgitcheckoutmaster+fi+cmdguiltpop-a+cmdgitbranch-d$1+cmdrm-r.git/patches/$1+cmdgitfor-each-ref+cmdlist_files+}++functionfixup_time_info+{+touch-a-m-t"$TOUCH_DATE"".git/patches/master/$1"+}++cmdsetup_repo++cmdgitconfigguilt.reusebranchtrue++cmdguiltpush-a+cmdlist_files+cmdgitfor-each-ref++# Pop and push patches. Check that the repo is converted to new-style+# refs when no patches are applied and a patch is pushed.+old_style_branchmaster+cmdgitfor-each-ref++cmdlist_files++foriin`seq5`+do+cmdguiltpop+cmdgitfor-each-ref+cmdguiltpush+cmdgitfor-each-ref+cmdguiltpop+cmdgitfor-each-ref+done++# Check that "pop -a" does the right thing.+cmdguiltpush-a++old_style_branchmaster++cmdgitfor-each-ref++cmdguiltpop-a++cmdgitfor-each-ref++# Check that pushing two patches converts the repo to now-style (since+# it currently has no patches applied).+cmdguiltpushadd+cmdgitfor-each-ref++# Check guilt branch with a few patches applied.+old_style_branchmaster+cmdguiltbranchtopic+cmdgitfor-each-ref++# Check that the topic branch is converted to new-style.+cmdguiltpop-a+cmdguiltpush+cmdgitfor-each-ref++remove_topictopic++# Check guilt branch with the full patch series applied.+cmdguiltpush-a+old_style_branchmaster+cmdguiltbranchtopic+cmdgitfor-each-ref++remove_topictopic++# Check guilt branch with no patches applied.+# This gives us a new-style checkout.+cmdguiltbranchtopic+cmdgitfor-each-ref+cmdlist_files++remove_topictopic++# Check guilt branch in a new-style directory with all patches+# applied. (Strictly speaking, this test should probably move to a+# file devoted to testing "guilt branch".)+cmdguiltpush-a+cmdguiltbranchtopic+cmdgitfor-each-ref+cmdlist_files+cmdguiltpop-a+cmdgitfor-each-ref++remove_topictopic++# Check that "guilt new" does the right thing when no patches are+# applied. (Strictly speaking, this test should maybe move to+# t-025.sh).++cmdguiltnewnewpatch+cmdgitfor-each-ref'--format=%(refname)'+cmdguiltpop+fixup_time_infonewpatch+cmdguiltpush+cmdgitfor-each-ref++# Check that "guilt commit" does the right thing when committing all+# applied patches. (Strictly speaking, this test should maybe move to+# t-030.sh).+cmdgitbranch+cmdguiltapplied+cmdguiltcommit-a+cmdgitfor-each-ref+cmdgitbranch++# Check that "guilt commit" does the right thing when committing only+# a few of the applied patches. (Strictly speaking, this test should+# maybe move to t-030.sh).+cmdguiltpush-a+cmdguiltapplied+cmdgitbranch+cmdgitfor-each-ref+cmdguiltcommit-n2+cmdgitfor-each-ref+cmdgitbranch+cmdguiltcommit-n2+cmdgitfor-each-ref+cmdgitbranch+cmdguiltseries
--
1.8.2
--
Once you have their hardware. Never give it back.
(The First Rule of Hardware Acquisition)
I just had another idea (although I haven't had a chance to code up
anything yet). Perhaps instead of, or in addition to, a global
setting (i.e., guilt.reusebranch), perhaps we should have a per-branch
setting, such as branch.<branch>.guiltReuseBranch?
I was actually thinking that it might be interesting to have a
branch.<branch>.rewindable, which would change the guilt defaults, and
could also key changes in key git behavior which makes it less likely
that a user shoots him or herself in the foot --- i.e., give warnings
if he or she has modified the branch in such a way that
remotes.origin.<branch> is no longer contained within the branch head.
- Ted
From: Josef 'Jeff' Sipek <hidden> Date: 2016-06-15 22:57:24
On Wed, May 22, 2013 at 10:45:31AM -0400, Theodore Ts'o wrote:
I just had another idea (although I haven't had a chance to code up
anything yet). Perhaps instead of, or in addition to, a global
setting (i.e., guilt.reusebranch), perhaps we should have a per-branch
setting, such as branch.<branch>.guiltReuseBranch?
I was actually thinking that it might be interesting to have a
branch.<branch>.rewindable, which would change the guilt defaults, and
could also key changes in key git behavior which makes it less likely
that a user shoots him or herself in the foot --- i.e., give warnings
if he or she has modified the branch in such a way that
remotes.origin.<branch> is no longer contained within the branch head.
Interesting! I wonder what git people have to say about this.
Jeff.
--
We have joy, we have fun, we have Linux on a Sun...