From: George Dunlap Date: Fri, 27 Jul 2018 10:16:31 +0000 (+0100) Subject: git: Add `-f` flag to all checkouts X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=f62b80c8fd7345ae388ff16faabb4015dba432d7;p=people%2Fgdunlap%2Fxsatool.git git: Add `-f` flag to all checkouts 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 --- diff --git a/README.md b/README.md index 0763580..7dd9ed6 100644 --- 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 3e09963..3cacf1b 100644 --- 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") }