guilt patches, including git 1.8 support
cover guilt patches, including git 1.8 support
Hi Jeff and other guilty parties,
I collected all the guilt patches I could find on-list and added one of my own. Completely untested, except for running the regression tests. These are also available via git protocol from
git://repo.or.cz/guilt/mob.git mob
Thoughts?
Jonathan Nieder (1):
Drop unneeded git version check.
Per Cederqvist (6):
get rid of "cat: write error: Broken pipe" error message The tests should not fail if log.date or log.decorate are set.
Testsuite: get rid of "Broken pipe" errors from yes. Handle empty patches and patches with only a header. Fix fatal "guilt graph" error in sha1sum invocation. Change git branch when patches are applied.
Documentation/guilt.7 | 4 + guilt | 73 +++++--- guilt-branch | 12 +- guilt-commit | 7 + guilt-import-commit | 4 +- guilt-repair | 7 +- os.Darwin | 7 +- os.Linux | 7 +- os.SunOS | 7 +- regression/scaffold | 7 +- regression/t-029.sh | 6 +- regression/t-052.out | 24 +-- regression/t-052.sh | 7 +- regression/t-061.out | 468 ++++++++++++++++++++++++++++++++++++++++++++++++++ regression/t-061.sh | 148 ++++++++++++++++ 15 files changed, 743 insertions(+), 45 deletions(-) create mode 100644 regression/t-061.out create mode 100755 regression/t-061.sh
PATCH 1/7 get rid of "cat: write error: Broken pipe" error message
From: Per Cederqvist <[email protected]>
Date: Tue, 13 Mar 2012 14:39:44 +0100
In some circumstances (like running guilt in a M-x shell buffer in Emacs) cat may give the above error message when the reader of the output from cat exits without reading all input from cat. (In other circumstances cat is just silently terminated with SIGPIPE.)
Get rid of the error by removing the useless use of cat in do_get_header and do_get_full_header.
--- guilt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
guilt +4 -4
@@ -359,7 +359,7 @@ do_get_header() # 4th line skips any empty lines thereafter. # 5th line turns off empty line skip upon seeing a non-empty line. # 6th line terminates execution when we encounter the diff - cat "$1" | awk ' + awk ' BEGIN{body=0; subj=0} /^Subject:/ && (body == 0 && subj == 0){subj=1; print substr($0, 10) "\n"; next} /^(Subject:|From:|Author:|Date:|commit)/ && (body == 0){next}
@@ -369,7 +369,7 @@ BEGIN{body=0; subj=0} /^(diff |---$|--- )/{exit} {print $0} END{} -' +' < "$1" } # usage: do_get_full_header patchfile
@@ -377,12 +377,12 @@ do_get_full_header() { # 2nd line checks for the begining of a patch # 3rd line outputs the line if it didn't get pruned by the above rules - cat "$1" | awk ' + awk ' BEGIN{} /^(diff |---$|--- )/{exit} {print $0} END{} -' +' < "$1" } # usage: assert_head_check
Signature · 1 line
1.8.1
PATCH 2/7 The tests should not fail if log.date or log.decorate are set.
In reply to Jonathan NiederFrom: Per Cederqvist <[email protected]>
Date: Mon, 30 Apr 2012 12:25:49 +0200
Explicitly set log.date and log.decorate to their Git default values, so that git produces the expected output even if log.date and log.decorate are set by the user in his .gitconfig.
--- regression/scaffold | 4 ++++ 1 file changed, 4 insertions(+)
regression/scaffold +4 -0
@@ -82,6 +82,10 @@ function setup_git_repo git add def git commit -s -m "initial" 2> /dev/null > /dev/null # the commit should be d4850419ccc1146c7169f500725ce504b9774ed0 + + # Explicitly set config that the tests rely on. + git config log.date default + git config log.decorate no } function setup_guilt_repo
Signature · 1 line
1.8.1
PATCH 3/7 Testsuite: get rid of "Broken pipe" errors from yes.
In reply to Jonathan NiederFrom: Per Cederqvist <[email protected]>
Date: Mon, 30 Apr 2012 12:27:21 +0200
--- regression/t-029.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
regression/t-029.sh +3 -3
@@ -21,11 +21,11 @@ echo | shouldfail guilt repair --full cmd list_files -yes n | shouldfail guilt repair --full +yes n 2>/dev/null | shouldfail guilt repair --full cmd list_files -yes y | cmd guilt repair --full +yes y 2>/dev/null | cmd guilt repair --full cmd list_files
@@ -33,6 +33,6 @@ cmd guilt push -a cmd list_files -yes Y | cmd guilt repair --full +yes Y 2>/dev/null | cmd guilt repair --full cmd list_files
Signature · 1 line
1.8.1
PATCH 4/7 Handle empty patches and patches with only a header.
In reply to Jonathan NiederFrom: Per Cederqvist <[email protected]>
Date: Mon, 30 Apr 2012 12:29:55 +0200
"git apply --numstat" in Git 1.7.10 gives an error message unless the patch contains a diff, so don't attempt to apply it unless we find a '^diff'.
--- guilt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
guilt +1 -1
@@ -611,7 +611,7 @@ push_patch() cd_to_toplevel # apply the patch if and only if there is something to apply - if [ `git apply --numstat "$p" | wc -l` -gt 0 ]; then + if grep -q '^diff ' "$p" && [ `git apply --numstat "$p" | wc -l` -gt 0 ]; then if [ "$bail_action" = abort ]; then reject="" fi
Signature · 1 line
1.8.1
PATCH 5/7 Fix fatal "guilt graph" error in sha1sum invocation.
In reply to Jonathan NiederFrom: Per Cederqvist <[email protected]>
Date: Wed, 14 Mar 2012 14:34:38 +0100
Fix the compatibility function sha1 so that it reads from stdin (and not a file with a zero-length file name) when no argument is supplied.
[jn: adapted to also handle newer versions of OpenSSL,
based on reports from Andreas Schwab and John Szakmeister.
$ openssl dgst -sha1</dev/null da39a3ee5e6b4b0d3255bfef95601890afd80709 $ openssl version OpenSSL 0.9.8o 01 Jun 2010
$ openssl dgst -sha1 </dev/null (stdin)= da39a3ee5e6b4b0d3255bfef95601890afd80709 $ openssl version OpenSSL 1.0.0d 8 Feb 2011 ]
--- os.Darwin | 7 ++++++- os.Linux | 7 ++++++- os.SunOS | 7 ++++++- 3 files changed, 18 insertions(+), 3 deletions(-)
os.Darwin +6 -1
@@ -27,7 +27,12 @@ head_n() # usage: sha1 [file] sha1() { - openssl dgst -sha1 "$1" | sed "s,SHA1.\(.*\).= \(.*\),\2 \1," + if [ $# = 1 ] + then + openssl dgst -sha1 "$1" | sed "s,SHA1.\(.*\).= \(.*\),\2 \1," + else + openssl dgst -sha1 | sed 's,\(.*= \)*\(.*\),\2 -,' + fi } # usage: cp_a <src> <dst>
os.Linux +6 -1
@@ -30,7 +30,12 @@ head_n() # usage: sha1 [file] sha1() { - sha1sum "$1" + if [ $# = 1 ] + then + sha1sum "$1" + else + sha1sum + fi } # usage: cp_a <src> <dst>
os.SunOS +6 -1
@@ -30,7 +30,12 @@ head_n() # usage: sha1 [file] sha1() { - sha1sum "$1" + if [ $# = 1 ] + then + sha1sum "$1" + else + sha1sum + fi } # usage: cp_a <src> <dst>
Signature · 1 line
1.8.1
PATCH 6/7 Change git branch when patches are applied.
In reply to Jonathan NiederFrom: Per Cederqvist <[email protected]>
Date: Mon, 30 Apr 2012 12:24:06 +0200
Apply patches on a separate branch. The separate branch is automatically created when Guilt pushes something, and removed when no patches are applied. The name is formed by prepending "guilt/" to the original branch.
This breaks the "upstream" relationship, so a mistaken "git push" while patches are applied will no longer mess up your upstream repository.
Update the testsuite and documentation.
Thanks to Junio C Hamano for suggesting this solution to my problem.
---
This one was a bit experimental if I remember correctly, so you may want to skip it or make the feature optional.
Documentation/guilt.7 | 4 + guilt | 52 +++++- guilt-branch | 12 +- guilt-commit | 7 + guilt-import-commit | 4 +- guilt-repair | 7 +- regression/scaffold | 3 +- regression/t-052.out | 24 +-- regression/t-052.sh | 7 +- regression/t-061.out | 468 ++++++++++++++++++++++++++++++++++++++++++++++++++ regression/t-061.sh | 148 ++++++++++++++++ 11 files changed, 713 insertions(+), 23 deletions(-) create mode 100644 regression/t-061.out create mode 100755 regression/t-061.sh
Documentation/guilt.7 +4 -0
@@ -43,6 +43,10 @@ guards: This file contains any guards that should be applied to the series when series: This file contains a list of all the patch filenames relative to the per\-branch patch directory\&. Empty and commented out lines are ignored\&. status: This file contains the state of the stack\&. What patches are applied\&. +.SH "BRANCH USAGE" +When you have pushed a patch, Guilt automatically changes to a freshly created Git branch\&. The name of the new branch is formed by prepending \fBguilt/\fR to the name of the original branch\&. This is done so that you do not accidentally push a set of Guilt patches to a remote Git repository\&. Once you pop all patches Guilt automatically changes back to the original branch\&. + +This is mostly transparent\&. The only thing you need to remember is that if you use \fBgit checkout\fR to switch to a branch while you have Guilt patches applied, you should use \fBgit checkout guilt/BRANCH\fR instead of \fBgit checkout BRANCH\fR when you want to change back later. .SH "HOOKS" Any guilt operation may execute zero or more hook scripts which can be used to run any housekeeping commands or even abort the execution of the command\&. .SH "HOOKS DIRECTORY"
guilt +48 -4
87 lines not on this page · raw message
guilt-branch +10 -2
@@ -35,8 +35,16 @@ cat "$applied" | while read n; do `git rev-parse "refs/patches/$branch/$n"` "" done -git branch "$newbranch" -git checkout "$newbranch" +if $old_style_prefix || [ -z "`get_top 2>/dev/null`" ] +then + newgitbranch="$newbranch" +else + git update-ref "refs/heads/$newbranch" "refs/heads/$branch" "" + newgitbranch="$GUILT_PREFIX$newbranch" +fi + +git branch "$newgitbranch" +git checkout "$newgitbranch" mkdir -p "$GUILT_DIR/`dirname $newbranch`"
guilt-commit +7 -0
@@ -43,4 +43,11 @@ done sed -n -e "${pat_keep}" "$applied" > "$applied.tmp" mv "$applied.tmp" "$applied" +# if we removed the last patch, switch back to the base branch +if [ `wc -l < "$applied"` -eq 0 ] && [ "`git symbolic-ref HEAD`" = "refs/heads/$GUILT_PREFIX$branch" ] && ! $old_style_prefix +then + git update-ref refs/heads/$branch refs/heads/$GUILT_PREFIX$branch + git symbolic-ref HEAD refs/heads/$branch + git update-ref -d refs/heads/$GUILT_PREFIX$branch +fi }
guilt-import-commit +2 -2
@@ -23,7 +23,7 @@ if ! must_commit_first; then fi disp "About to begin conversion..." >&2 -disp "Current head: `cat $GIT_DIR/refs/heads/$branch`" >&2 +disp "Current head: `cat $GIT_DIR/refs/heads/\`git_branch\``" >&2 for rev in `git rev-list $rhash`; do s=`git log --pretty=oneline -1 $rev | cut -c 42-`
@@ -68,6 +68,6 @@ for rev in `git rev-list $rhash`; do done disp "Done." >&2 -disp "Current head: `cat $GIT_DIR/refs/heads/$branch`" >&2 +disp "Current head: `cat $GIT_DIR/refs/heads/\`git_branch\``" >&2 }
guilt-repair +6 -1
@@ -84,6 +84,11 @@ repair_pushed() # blow away any commits git reset --hard "$newrev" > /dev/null + if [ "`git symbolic-ref HEAD`" = "refs/heads/$GUILT_PREFIX$branch" ] && ! $old_style_prefix + then + git symbolic-ref HEAD refs/heads/$branch + git update-ref -d refs/heads/$GUILT_PREFIX$branch + fi # blow away the applied stack remove_patch_refs < "$applied"
@@ -112,7 +117,7 @@ case "$1" in ;; esac -oldrev=`git show-ref -s "refs/heads/$branch"` +oldrev=`git show-ref -s "refs/heads/\`git_branch\`"` case "$repair" in full)
regression/scaffold +2 -1
@@ -38,7 +38,8 @@ function replace_path -e "s,^Usage: guilt-,Usage: guilt ,g" \ -e "s,\.\.\. initial, initial,g" \ -e "s,^Already on\( branch\)\? [\"']\([^\"']*\)[\"']$,Already on \"\2\",g" \ - -e "s,^Switched to branch [\"']\([^\"']*\)[\"'],Switched to branch \"\1\",g" + -e "s,^Switched to branch [\"']\([^\"']*\)[\"'],Switched to branch \"\1\",g" \ + -e "\\,^Deleted branch guilt/.* (was .*).$,d" } function filter_dd
regression/t-052.out +12 -12
@@ -47,7 +47,7 @@ f da39a3ee5e6b4b0d3255bfef95601890afd80709 .git/patches/master/status Applying patch..modify Patch applied. % guilt branch br-modify -Switched to branch "br-modify" +Switched to branch "guilt/br-modify" % list_files d .git/patches d .git/patches/br-
@@ -76,8 +76,8 @@ f bc9ab2e0f5db99d483961e956e814d963f0309f8 .git/patches/master/modify f da39a3ee5e6b4b0d3255bfef95601890afd80709 .git/patches/br-/status r 33633e7a1aa31972f125878baf7807be57b1672d .git/refs/patches/br-modify/modify r 33633e7a1aa31972f125878baf7807be57b1672d .git/refs/patches/master/modify -% git checkout master -Switched to branch "master" +% git checkout guilt/master +Switched to branch "guilt/master" % list_files d .git/patches d .git/patches/br-
@@ -109,7 +109,7 @@ r 33633e7a1aa31972f125878baf7807be57b1672d .git/refs/patches/master/modify Applying patch..add Patch applied. % guilt branch br-add -Switched to branch "br-add" +Switched to branch "guilt/br-add" % list_files d .git/patches d .git/patches/br-
@@ -149,8 +149,8 @@ r 33633e7a1aa31972f125878baf7807be57b1672d .git/refs/patches/br-modify/modify r 33633e7a1aa31972f125878baf7807be57b1672d .git/refs/patches/master/modify r 37d588cc39848368810e88332bd03b083f2ce3ac .git/refs/patches/br-add/add r 37d588cc39848368810e88332bd03b083f2ce3ac .git/refs/patches/master/add -% git checkout master -Switched to branch "master" +% git checkout guilt/master +Switched to branch "guilt/master" % list_files d .git/patches d .git/patches/br-
@@ -193,7 +193,7 @@ r 37d588cc39848368810e88332bd03b083f2ce3ac .git/refs/patches/master/add Applying patch..remove Patch applied. % guilt branch br-remove -Switched to branch "br-remove" +Switched to branch "guilt/br-remove" % list_files d .git/patches d .git/patches/br-
@@ -245,8 +245,8 @@ r 37d588cc39848368810e88332bd03b083f2ce3ac .git/refs/patches/br-remove/add r 37d588cc39848368810e88332bd03b083f2ce3ac .git/refs/patches/master/add r ffb7faa126a6d91bcdd44a494f76b96dd860b8b9 .git/refs/patches/br-remove/remove r ffb7faa126a6d91bcdd44a494f76b96dd860b8b9 .git/refs/patches/master/remove -% git checkout master -Switched to branch "master" +% git checkout guilt/master +Switched to branch "guilt/master" % list_files d .git/patches d .git/patches/br-
@@ -301,7 +301,7 @@ r ffb7faa126a6d91bcdd44a494f76b96dd860b8b9 .git/refs/patches/master/remove Applying patch..mode Patch applied. % guilt branch br-mode -Switched to branch "br-mode" +Switched to branch "guilt/br-mode" % list_files d .git/patches d .git/patches/br-
@@ -366,5 +366,5 @@ r ccd56089d1b5305a9d35617cb7f6f4b06ffa68ba .git/refs/patches/master/mode r ffb7faa126a6d91bcdd44a494f76b96dd860b8b9 .git/refs/patches/br-mode/remove r ffb7faa126a6d91bcdd44a494f76b96dd860b8b9 .git/refs/patches/br-remove/remove r ffb7faa126a6d91bcdd44a494f76b96dd860b8b9 .git/refs/patches/master/remove -% git checkout master -Switched to branch "master" +% git checkout guilt/master +Switched to branch "guilt/master"
regression/t-052.sh +6 -1
@@ -12,5 +12,10 @@ for x in "" modify add remove mode ; do [ "$x" != "" ] && guilt push "$x" cmd guilt branch br-$x cmd list_files - cmd git checkout master + if [ "$x" != "" ] + then + cmd git checkout guilt/master + else + cmd git checkout master + fi done
regression/t-061.out new file +468 -0
468 lines not on this page · raw message
regression/t-061.sh new file +148 -0
148 lines not on this page · raw message
Signature · 1 line
1.8.1
PATCH 7/7 Drop unneeded git version check.
In reply to Jonathan NiederGit's compatibility record is pretty good, so there's no need to worry that newer versions of git will break the "git config" command.
Without this change, guilt errors out for git 1.8. With it, all tests pass.
---
Thanks for reading.
guilt | 11 ----------- 1 file changed, 11 deletions(-)
guilt +0 -11
@@ -26,17 +26,6 @@ SUBDIRECTORY_OK=1 . "$(git --exec-path)/git-sh-setup" # -# Git version check -# -gitver=`git --version | cut -d' ' -f3 | sed -e 's/^debian\.//'` -case "$gitver" in - 1.5.*) ;; # git config - 1.6.*) ;; # git config - 1.7.*) ;; # git config - *) die "Unsupported version of git ($gitver)" ;; -esac - -# # Shell library # usage()
Signature · 1 line
1.8.1
Quoted 7 lines · Jonathan Nieder
Hi Jeff and other guilty parties,
I collected all the guilt patches I could find on-list and added one of my own. Completely untested, except for running the regression tests. These are also available via git protocol from
git://repo.or.cz/guilt/mob.gitmob
Jonathan, thanks for collecting all of the guilt patches! Your repro was also very much really useful since I hadn't grabbed the latest patches from jeffpc's repo before it disappeared after the kernel.org security shutdown.
Jeff, do you need some help getting your repro on kernel.org re-established?
- Ted
Quoted 7 lines · Theodore Ts'o
Quoted 6 lines · Jonathan Nieder
Hi Jeff and other guilty parties,
I collected all the guilt patches I could find on-list and added one of my own. Completely untested, except for running the regression tests. These are also available via git protocol from
Quoted 6 lines
Quoted 1 line
git://repo.or.cz/guilt/mob.gitmobJonathan, thanks for collecting all of the guilt patches! Your repro was also very much really useful since I hadn't grabbed the latest patches from jeffpc's repo before it disappeared after the kernel.org security shutdown.
I had repo.or.cz mirroring all along. :)
Quoted 2 lines
Jeff, do you need some help getting your repro on kernel.org re-established?
Yes and no. I was hoping to find some time to restore all the web content on my server, and start using repo.or.cz as the public git repo. With that said, I have only two sigs for my gpg key. (Guilt isn't really related to linux...)
Thanks,
Jeff.
Signature · 3 lines
Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. - Albert Einstein
Quoted 9 lines · Jonathan Nieder
Hi Jeff and other guilty parties,
I collected all the guilt patches I could find on-list and added one of my own. Completely untested, except for running the regression tests. These are also available via git protocol from
git://repo.or.cz/guilt/mob.gitmobThoughts?
Regarding the "Change git branch when patches are applied" feature, it has saved me a number of times since I implemented it. I've been using it extensively, and have not had any problems with it.
Nevertheless, for backwards compatibility with the currently released guilt version I think it should be conditional, and disabled per default for one full release cycle. I've implemented this. My code is available from git://repo.or.cz/guilt/ceder.git
The following commits are not included in your list:
a194375 Added guilt.reusebranch configuration option. 1dd97bd Minor testsuite fix.
640caee The tests should not fail if guilt.diffstat is set.
I don't want Guilt to fork. Jeff, it would be really great if you could set up a public repo again!
/ceder
Quoted 30 lines
Jonathan Nieder (1):
Drop unneeded git version check.Per Cederqvist (6):
get rid of "cat: write error: Broken pipe" error message The tests should not fail if log.date or log.decorate are set.
Testsuite: get rid of "Broken pipe" errors from yes. Handle empty patches and patches with only a header. Fix fatal "guilt graph" error in sha1sum invocation. Change git branch when patches are applied.Documentation/guilt.7 | 4 + guilt | 73 +++++--- guilt-branch | 12 +- guilt-commit | 7 + guilt-import-commit | 4 +- guilt-repair | 7 +- os.Darwin | 7 +- os.Linux | 7 +- os.SunOS | 7 +- regression/scaffold | 7 +- regression/t-029.sh | 6 +- regression/t-052.out | 24 +-- regression/t-052.sh | 7 +- regression/t-061.out | 468 ++++++++++++++++++++++++++++++++++++++++++++++++++ regression/t-061.sh | 148 ++++++++++++++++ 15 files changed, 743 insertions(+), 45 deletions(-)create mode 100644 regression/t-061.out
create mode 100755regression/t-061.sh
Quoted 20 lines · Per Cederqvist
Quoted 9 lines · Jonathan Nieder
Hi Jeff and other guilty parties,
I collected all the guilt patches I could find on-list and added one of my own. Completely untested, except for running the regression tests. These are also available via git protocol from
git://repo.or.cz/guilt/mob.gitmobThoughts?
Regarding the "Change git branch when patches are applied" feature, it has saved me a number of times since I implemented it. I've been using it extensively, and have not had any problems with it.
Nevertheless, for backwards compatibility with the currently released guilt version I think it should be conditional, and disabled per default for one full release cycle. I've implemented this. My code is available from
git://repo.or.cz/guilt/ceder.git
Quoted 5 lines
The following commits are not included in your list:
a194375 Added guilt.reusebranch configuration option. 1dd97bd Minor testsuite fix.
640caee The tests should not fail if guilt.diffstat is set.
At $WORK, we started doing thorough reviews before committing. I'm kinda sold on this feature. I agree with the off-by-default config flag.
Quoted 2 lines
I don't want Guilt to fork. Jeff, it would be really great if you could set up a public repo again!
Yep. I'm trying to reclaim control of the repo.or.cz guilt repo... I no longer have access to [email protected] and I don't remember the password.
Jeff.
Signature · 1 line
NT is to UNIX what a doughnut is to a particle accelerator.
Quoted 9 lines · Jonathan Nieder
Hi Jeff and other guilty parties,
I collected all the guilt patches I could find on-list and added one of my own. Completely untested, except for running the regression tests. These are also available via git protocol from
git://repo.or.cz/guilt/mob.gitmobThoughts?
Sorry for taking so long. I finally reclaimed access togit://repo.or.cz/guilt.git. I pulled from mob, and merged it with what I had locally.
Thanks for collecting all these in one place!
Jeff.
Quoted 29 lines
Jonathan Nieder (1):
Drop unneeded git version check.Per Cederqvist (6):
get rid of "cat: write error: Broken pipe" error message The tests should not fail if log.date or log.decorate are set.
Testsuite: get rid of "Broken pipe" errors from yes. Handle empty patches and patches with only a header. Fix fatal "guilt graph" error in sha1sum invocation. Change git branch when patches are applied.Documentation/guilt.7 | 4 + guilt | 73 +++++--- guilt-branch | 12 +- guilt-commit | 7 + guilt-import-commit | 4 +- guilt-repair | 7 +- os.Darwin | 7 +- os.Linux | 7 +- os.SunOS | 7 +- regression/scaffold | 7 +- regression/t-029.sh | 6 +- regression/t-052.out | 24 +-- regression/t-052.sh | 7 +- regression/t-061.out | 468 ++++++++++++++++++++++++++++++++++++++++++++++++++ regression/t-061.sh | 148 ++++++++++++++++ 15 files changed, 743 insertions(+), 45 deletions(-) create mode 100644 regression/t-061.out create mode 100755 regression/t-061.sh
Signature · 4 lines
I have always wished for my computer to be as easy to use as my telephone; my wish has come true because I can no longer figure out how to use my telephone. - Bjarne Stroustrup