fixes
make commit commit to the right branch when getting content from the branch, update first
This commit is contained in:
parent
5d20ac5800
commit
5e0adb2637
1 changed files with 10 additions and 10 deletions
16
Branch.hs
16
Branch.hs
|
@ -7,7 +7,9 @@
|
||||||
|
|
||||||
module Branch (
|
module Branch (
|
||||||
update,
|
update,
|
||||||
change
|
get,
|
||||||
|
change,
|
||||||
|
commit
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Control.Monad (unless)
|
import Control.Monad (unless)
|
||||||
|
@ -17,8 +19,8 @@ import System.Directory
|
||||||
import Data.String.Utils
|
import Data.String.Utils
|
||||||
import System.Cmd.Utils
|
import System.Cmd.Utils
|
||||||
|
|
||||||
import GitUnionMerge
|
|
||||||
import qualified GitRepo as Git
|
import qualified GitRepo as Git
|
||||||
|
import qualified GitUnionMerge
|
||||||
import qualified Annex
|
import qualified Annex
|
||||||
import Utility
|
import Utility
|
||||||
import Types
|
import Types
|
||||||
|
@ -91,7 +93,7 @@ updateRef ref
|
||||||
|
|
||||||
{- Stages the content of a file into the branch's index. -}
|
{- Stages the content of a file into the branch's index. -}
|
||||||
change :: FilePath -> String -> Annex ()
|
change :: FilePath -> String -> Annex ()
|
||||||
change file content = update >> do
|
change file content = do
|
||||||
g <- Annex.gitRepo
|
g <- Annex.gitRepo
|
||||||
sha <- liftIO $ Git.hashObject g content
|
sha <- liftIO $ Git.hashObject g content
|
||||||
withIndex $ liftIO $ Git.run g "update-index"
|
withIndex $ liftIO $ Git.run g "update-index"
|
||||||
|
@ -102,15 +104,13 @@ change file content = update >> do
|
||||||
commit :: String -> Annex ()
|
commit :: String -> Annex ()
|
||||||
commit message = withIndex $ do
|
commit message = withIndex $ do
|
||||||
g <- Annex.gitRepo
|
g <- Annex.gitRepo
|
||||||
-- It would be expensive to check if anything needs to be
|
liftIO $ GitUnionMerge.commit g message branch []
|
||||||
-- committed, so --allow-empty is used.
|
|
||||||
liftIO $ Git.run g "commit"
|
|
||||||
[Param "--allow-empty", Param "-m", Param message]
|
|
||||||
|
|
||||||
{- Gets the content of a file on the branch, or content staged in the index
|
{- Gets the content of a file on the branch, or content staged in the index
|
||||||
- if it's newer. Returns an empty string if the file didn't exist yet. -}
|
- if it's newer. Returns an empty string if the file didn't exist yet. -}
|
||||||
get :: FilePath -> Annex String
|
get :: FilePath -> Annex String
|
||||||
get file = withIndex $ do
|
get file = update >> do
|
||||||
|
withIndex $ do
|
||||||
g <- Annex.gitRepo
|
g <- Annex.gitRepo
|
||||||
liftIO $ catch (cat g) (const $ return "")
|
liftIO $ catch (cat g) (const $ return "")
|
||||||
where
|
where
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue