]> xenbits.xensource.com Git - people/gdunlap/xsatool/commitdiff
git: Add `-f` flag to all checkouts
authorGeorge Dunlap <george.dunlap@citrix.com>
Fri, 27 Jul 2018 10:16:31 +0000 (11:16 +0100)
committerGeorge Dunlap <george.dunlap@citrix.com>
Fri, 27 Jul 2018 10:16:31 +0000 (11:16 +0100)
All the current instances of 'git checkout' are meant to be
destructive (several have `git clean -ffdx` afterwards).  In cases
where a file is generated and untracked in one version of Xen but tracked
in another version of Xen, `git checkout` will fail without the `-f` flag.

Since we're going to be destructive anyway, add `-f` to all `git
checkout` commands.

Signed-off-by: Georg Dunlap <george.dunlap@citrix.com>
README.md
git.go

index 07635804bd1a51b19027d17da08ec1616da87e9a..7dd9ed6c1a7bc9944001fbcabc3e5d1ce08c942a 100644 (file)
--- a/README.md
+++ b/README.md
@@ -109,9 +109,11 @@ other workflows.  You can, however, specify a path to existing
 repositories instead.  Be aware that `xsatool` may have any of the following
 effects on the tree:
 
-- Modify the working tree (including git clean -ffdx)
+- Modify the working tree (including `git clean -ffdx`)
 
-- Modify HEAD
+- Discard uncommited changes (e.g., `checkout -f`)
+
+- Modify `HEAD`
 
 - Create, delete, or modify branches matching `xsa/*`
 
diff --git a/git.go b/git.go
index 3e0996376ce77dbada1c5746588cb78c60673898..3cacf1b732d7b01e3d8c84da127bf5a747052e8a 100644 (file)
--- a/git.go
+++ b/git.go
@@ -108,7 +108,7 @@ func (r Repo) Fetch() (out []byte, err error) {
 }
 
 func (r Repo) MergeDefault(branch string) (out []byte, err error) {
-       out, err = r.gitCmd("checkout", branch)
+       out, err = r.gitCmd("checkout", "-f", branch)
 
        if err != nil {
                return
@@ -133,7 +133,7 @@ func (r Repo) MakeBranch(branch string, ref string) (err error) {
                        return
                }
        }
-       _, err = r.gitCmd("checkout", "-B", branch, ref)
+       _, err = r.gitCmd("checkout", "-f", "-B", branch, ref)
        if err == nil {
                _, err = r.gitCmd("clean", "-ffdx")
        }
@@ -148,7 +148,7 @@ func (r Repo) ResetBranch(branch string, ref string) (err error) {
 }
 
 func (r Repo) Checkout(branch string) (out []byte, err error) {
-       out, err = r.gitCmd("checkout", branch)
+       out, err = r.gitCmd("checkout", "-f", branch)
        if err == nil {
                _, err = r.gitCmd("clean", "-ffdx")
        }