File tree Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Original file line number Diff line number Diff line change 92
92
93
93
if [ -n " $patchdir " ]; then
94
94
f=" $patchdir " " $( basename " $f " ) "
95
+ else
96
+ case " $f " in
97
+ /* ) : ;;
98
+ * ) f=" $topleveldir " /" $f " ;;
99
+ esac
95
100
fi
96
101
97
102
if [ -z " $f " ]; then
Original file line number Diff line number Diff line change 1
1
#! /bin/sh
2
2
3
- # Copyright (c) 2013 Michele Bini
3
+ # Copyright (c) 2013, 2014 Michele Bini
4
4
5
5
# This program is free software: you can redistribute it and/or modify
6
6
# it under the terms of the version 3 of the GNU General Public License
@@ -49,6 +49,28 @@ selectbranch() {
49
49
git symbolic-ref HEAD refs/heads/" $1 "
50
50
}
51
51
52
+ noerr () {
53
+ " $@ " 2> /dev/null
54
+ }
55
+
56
+ # Top level of the work tree, if possible relative to current directory
57
+ topleveldir=" $( noerr git rev-parse --show-cdup || noerr git rev-parse --show-toplevel) "
58
+
59
+ # Current directory, relative to top level of work tree
60
+ prefixdir=" $( noerr git rev-parse --show-prefix) "
61
+
62
+ withfinalslash () {
63
+ if [ -z " $1 " ]; then return ; fi
64
+ case " $1 " in
65
+ * /) println " $1 " ;;
66
+ * ) println " $1 " / ;;
67
+ esac
68
+ }
69
+
70
+ topleveldir=" $( withfinalslash " $topleveldir " ) "
71
+ prefixdir=" $( withfinalslash " $prefixdir " ) "
72
+
73
+
52
74
f=" $( namecommit HEAD) "
53
75
[ -z " f" ] && die " Internal error: Could not create patch name"
54
76
f=" $f " .patch
@@ -61,9 +83,11 @@ git format-patch --binary -M70% -C70% -N -1 --stdout >"$f"
61
83
62
84
b=" $( branchname) "
63
85
86
+ f=" $prefixdir$f "
87
+
64
88
git checkout --quiet --detach HEAD^
65
89
66
90
println " Uncommit: $f "
67
- println " Uncommit: $f " >> .uncommitted-patches
91
+ println " Uncommit: $f " >> " $topleveldir " .uncommitted-patches
68
92
69
93
[ -n " $b " ] && selectbranch " $b " && git reset --soft HEAD^
You can’t perform that action at this time.
0 commit comments