Commit 875471c
git-stash.sh: fix flawed fix of invalid ref handling (commit da65e7c)
The referenced commit tried to fix a flaw in stash's handling of a user
supplied invalid ref. i.e. 'git stash apply fake_ref@{0}' should fail
instead of applying stash@{0}. But, it did so in a naive way by avoiding the
use of the --default option of rev-parse, and instead manually supplied the
default revision if the user supplied an empty command line. This prevented
a common usage scenario of supplying flags on the stash command line (i.e.
non-empty command line) which would be parsed by lower level git commands,
without supplying a specific revision. This should fall back to the default
revision, but now it causes an error. e.g. 'git stash show -p'
The correct fix is to use the --verify option of rev-parse, which fails
properly if an invalid ref is supplied, and still allows falling back to a
default ref when one is not supplied.
Convert stash-drop to use --verify while we're at it, since specifying
multiple revisions for any of these commands is also an error and --verify
makes it so.
Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>1 parent 027b5a4 commit 875471c
1 file changed
+4
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
| 148 | + | |
| 149 | + | |
158 | 150 | | |
159 | 151 | | |
160 | 152 | | |
| |||
170 | 162 | | |
171 | 163 | | |
172 | 164 | | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | 165 | | |
180 | 166 | | |
181 | 167 | | |
182 | 168 | | |
183 | 169 | | |
184 | 170 | | |
185 | | - | |
| 171 | + | |
186 | 172 | | |
187 | 173 | | |
188 | 174 | | |
| |||
242 | 228 | | |
243 | 229 | | |
244 | 230 | | |
245 | | - | |
| 231 | + | |
246 | 232 | | |
247 | 233 | | |
248 | 234 | | |
| |||
0 commit comments