sketch: fix diff view editing of gitignore'd files and forward more http errors to logs

Fixes https://github.com/boldsoftware/sketch/issues/213

We had "sketch" git ignored, so "git add sketch/cmd/sketch/main.go" was
failing when a user was editing it in diff view. The gitignore was
incorrectly specified. ("git ls-files -i -c --exclude-standard"
returning main.go should have tipped us off, but who knew!)

Anyway, fixed that, and improved the logging.

Co-Authored-By: sketch <hello@sketch.dev>
Change-ID: s3ed65211dd497f76k
diff --git a/git_tools/git_tools.go b/git_tools/git_tools.go
index d047710..a91071b 100644
--- a/git_tools/git_tools.go
+++ b/git_tools/git_tools.go
@@ -434,20 +434,15 @@
 	const expectedMsg = "User changes from diff view."
 	amend := err == nil && commitMsg == expectedMsg
 
-	// Add the file to git
-	cmd = exec.CommandContext(ctx, "git", "add", filePath)
-	cmd.Dir = repoDir
-	if out, err := cmd.CombinedOutput(); err != nil {
-		return fmt.Errorf("error adding file to git: %w - git output: %s", err, string(out))
-	}
-
 	// Commit the changes
+	// Instead of calling git add first, we call git commit with a filepsec, which works the same,
+	// but would fail if the file isn't tracked by git already.
 	if amend {
 		// Amend the previous commit
-		cmd = exec.CommandContext(ctx, "git", "commit", "--amend", "--no-edit")
+		cmd = exec.CommandContext(ctx, "git", "commit", "--amend", "--no-edit", "--", filePath)
 	} else {
 		// Create a new commit
-		cmd = exec.CommandContext(ctx, "git", "commit", "-m", expectedMsg, filePath)
+		cmd = exec.CommandContext(ctx, "git", "commit", "-m", expectedMsg, "--", filePath)
 	}
 	cmd.Dir = repoDir