1
0
mirror of https://github.com/danog/gift.git synced 2024-11-30 04:19:37 +01:00

Repo#sync restructured to make sure a 'stash pop' is never attempted if there was nothing to stash in the first place

This commit is contained in:
luke 2013-03-12 18:21:24 +00:00
parent 334417ea34
commit f9abf4b277

View File

@ -270,12 +270,17 @@ module.exports = class Repo
sync: (remote_name, branch, callback) -> sync: (remote_name, branch, callback) ->
[remote_name, callback, branch] = ['origin', branch, remote_name] if !callback [remote_name, callback, branch] = ['origin', branch, remote_name] if !callback
[remote_name, callback, branch] = ['origin', remote_name, []] if !branch [remote_name, callback, branch] = ['origin', remote_name, []] if !branch
@git "stash", {}, ["save"], (err) => @status (err, status) =>
return callback err if err return callback err if err
@git "pull", {}, [remote_name, branch], (err) => @git "stash", {}, ["save"], (err) =>
return callback err if err return callback err if err
@git "push", {}, [remote_name, branch], (err) => @git "pull", {}, [remote_name, branch], (err) =>
return callback err if err return callback err if err
@git "stash", {}, "pop", (err) => @git "push", {}, [remote_name, branch], (err) =>
return callback err if err return callback err if err
return callback null if not status?.clean
@git "stash", {}, ["pop"], (err) =>
return callback err if err
return callback null
else
return callback null