New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 899909 link

Starred by 1 user

Issue metadata

Status: Available
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 3
Type: Bug



Sign in to add a comment

git cl format doesn't format files staged in gitk

Project Member Reported by a...@chromium.org, Oct 29

Issue description

Repro:

1. Add a new file in your CL that has terrible formatting
2. Run "git cl format"

> Result: the new file isn't formatted

2.5. Run "git cl format --full"

> Result: the new file is formatted

git cl format tries to clean up the format of only the changed part of a file, but that seems to make it not try to format anything if the file is new.

Nico, do you know who to send this to? Or if this even the correct component? Julie, also sending to you as you might know.
 
Cc: ajp@chromium.org
Components: -Infra>Client Infra>Git
Moving to Infra-Git component for triage.
You ran `git add file.cc; git commit -m.` in step 1, yes?
I'm 99% sure I'd had it committed as a change.
Can't repro:

Nicos-MacBook-Pro:src thakis$ git checkout master
git checkout -b foo
mvim new.cc
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'.
Nicos-MacBook-Pro:src thakis$ git checkout -b foo
Switched to a new branch 'foo'
Nicos-MacBook-Pro:src thakis$ mvim new.cc
Nicos-MacBook-Pro:src thakis$ cat new.cc
#include <stdio.h>
int main() { printf("hello, avi\n"); return 1; }
Nicos-MacBook-Pro:src thakis$ git add new.cc
gitNicos-MacBook-Pro:src thakis$ git commit -m.
git cl format
git diff
[foo 95778ac3c3d0] .
 1 file changed, 2 insertions(+)
 create mode 100644 new.cc
Nicos-MacBook-Pro:src thakis$ git cl format
Nicos-MacBook-Pro:src thakis$ git diff
diff --git a/new.cc b/new.cc
index d6c61a9d7889..218dc2bf2b73 100644
--- a/new.cc
+++ b/new.cc
@@ -1,2 +1,5 @@
 #include <stdio.h>
-int main() { printf("hello, avi\n"); return 1; }
+int main() {
+  printf("hello, avi\n");
+  return 1;
+}

I also cannot reproduce after the files have been added to git (commit seems unnecessary).

Avi, can you provide specific steps to reproduce including the contents of a simple file? 
I don't use commandline tools, but my repro experience is:

$ git nb test
> create a new .cc file
> use gitk to stage it
$ git cl format  ## does not format the file
> click the commit button in gitk
$ git cl format  ## does not format the file
$ git cl format --full  ## does format the file

I'm afraid I don't know why gitk is special here but it's a part of my workflow.
Hmm. I still can't reproduce this.

$ git checkout -b foo
$ vi new.cc 
$ cat new.cc
#include <stdio.h> 
int main() { printf("hello, avi\n"); return 1; } 

$ gitk
// I see no way to stage files in gitk, but can launch git-gui from gitk
> Stage files in git-gui
$ git cl format
$ cat new.cc
#include <stdio.h>
int main() {
  printf("hello, avi\n");
  return 1;
}

I'd be curious to see the output of git status after you've staged files and before you've run git cl format. I wonder if it is doing something such that the current git state shows the new file as some smaller modification rather than an entirely new file.
Owner: ----
Summary: git cl format doesn't format files staged in gitk (was: git cl format doesn't format new files)
I don't know anything about gitk. The workflow I usually use seems to work.
Status: Available (was: Untriaged)

Sign in to add a comment