Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Stash save should return undef if nothing was stashed #121

Merged
merged 1 commit into from

2 participants

Jacques Germishuys Coveralls
Jacques Germishuys
Owner

It's not an error to not have stashed changes, return undef.

Coveralls

Coverage Status

Coverage increased (+0.01%) when pulling 7c7e6fd on jacquesg/stash-save into 1fb161e on master.

Jacques Germishuys jacquesg merged commit 7c7e6fd into from
Jacques Germishuys jacquesg deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 17, 2014
This page is out of date. Refresh to see the latest.
Showing with 14 additions and 4 deletions.
  1. +2 −1  lib/Git/Raw/Stash.pm
  2. +3 −1 t/11-stash.t
  3. +9 −2 xs/Stash.xs
3  lib/Git/Raw/Stash.pm
View
@@ -21,7 +21,8 @@ B<WARNING>: The API of this module is unstable and may change without warning
=head2 save( $repo, $stasher, $msg [, \@opts] )
Save the local modifications to a new stash. Non-default options may be
-specified by providing the optional C<@opts> argument.
+specified by providing the optional C<@opts> argument. If files were stashed,
+this function will return a true value, otherwise C<undef>.
Valid fields for the C<@opts> array are:
4 t/11-stash.t
View
@@ -20,7 +20,7 @@ my $email = $config -> str('user.email');
my $me = Git::Raw::Signature -> now($name, $email);
-$repo -> stash($me, 'some stash');
+ok ($repo -> stash($me, 'some stash'));
Git::Raw::Stash -> foreach($repo, sub {
my ($i, $msg, $oid) = @_;
@@ -31,6 +31,8 @@ Git::Raw::Stash -> foreach($repo, sub {
0;
});
+is $repo -> stash($me, 'some stash'), undef;
+
Git::Raw::Stash -> drop($repo, 0);
Git::Raw::Stash -> foreach($repo, sub { die 'This should not be called' });
11 xs/Stash.xs
View
@@ -1,6 +1,6 @@
MODULE = Git::Raw PACKAGE = Git::Raw::Stash
-void
+SV *
save(class, repo, stasher, msg, ...)
SV *class
Repository repo
@@ -41,7 +41,14 @@ save(class, repo, stasher, msg, ...)
}
rc = git_stash_save(&oid, repo -> repository, stasher, git_ensure_pv(msg, "msg"), stash_flags);
- git_check_error(rc);
+ if (rc == GIT_ENOTFOUND) {
+ RETVAL = &PL_sv_undef;
+ } else {
+ git_check_error(rc);
+ RETVAL = newSViv(1);
+ }
+
+ OUTPUT: RETVAL
void
foreach(class, repo, cb)
Something went wrong with that request. Please try again.