[attributes] Allow jiri update snapshot to override optional attrs

This change adds '-override-optional'  to 'jiri update' to allow
using local 'jiri init -fetch-optional' settings when checkout a
snapshot file. By default, when creating a snapshot file, jiri will
write its optional attributes settings to the snapshot file. When
another client is checking out this snapshot file, it will guarantee
the recreated workspace is identical to the one when snapshot is
created. When this new flag is set to true, jiri will ignore the
optional attributes from the snapshot file and use the local ones.

Bugs: VC-159
Tests: Local
Change-Id: Ic2ff086b826f06fba73177cef9a85558205d0885
diff --git a/cmd/jiri/update.go b/cmd/jiri/update.go
index 1bf997b..7eca408 100644
--- a/cmd/jiri/update.go
+++ b/cmd/jiri/update.go
@@ -29,6 +29,7 @@
 	rebaseTrackedFlag    bool
 	runHooksFlag         bool
 	fetchPkgsFlag        bool
+	overrideOptionalFlag bool
 )
 
 const (
@@ -50,6 +51,7 @@
 	cmdUpdate.Flags.BoolVar(&rebaseTrackedFlag, "rebase-tracked", false, "Rebase current tracked branches instead of fast-forwarding them.")
 	cmdUpdate.Flags.BoolVar(&runHooksFlag, "run-hooks", true, "Run hooks after updating sources.")
 	cmdUpdate.Flags.BoolVar(&fetchPkgsFlag, "fetch-packages", true, "Use cipd to fetch packages.")
+	cmdUpdate.Flags.BoolVar(&overrideOptionalFlag, "override-optional", false, "Override existing optional attributes in the snapshot file with current jiri settings")
 }
 
 // cmdUpdate represents the "jiri update" command.
@@ -92,6 +94,7 @@
 	}
 
 	if len(args) > 0 {
+		jirix.OverrideOptional = overrideOptionalFlag
 		if err := project.CheckoutSnapshot(jirix, args[0], gcFlag, runHooksFlag, fetchPkgsFlag, hookTimeoutFlag, fetchPkgsTimeoutFlag); err != nil {
 			return err
 		}
diff --git a/project/loader.go b/project/loader.go
index 2bc484a..92968d1 100644
--- a/project/loader.go
+++ b/project/loader.go
@@ -325,7 +325,7 @@
 		return err
 	}
 
-	if jirix.UsingSnapshot {
+	if jirix.UsingSnapshot && !jirix.OverrideOptional {
 		// using attributes defined in snapshot file instead of
 		// using predefined ones in jiri init.
 		jirix.FetchingAttrs = m.Attributes
diff --git a/x.go b/x.go
index daf9081..afd3ce2 100644
--- a/x.go
+++ b/x.go
@@ -112,6 +112,7 @@
 	PrebuiltJSON        string
 	FetchingAttrs       string
 	UsingSnapshot       bool
+	OverrideOptional    bool
 	IgnoreLockConflicts bool
 	Color               color.Color
 	Logger              *log.Logger