git cl format doesn't format files staged in gitk |
|||
Issue descriptionRepro: 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.
,
Oct 30
You ran `git add file.cc; git commit -m.` in step 1, yes?
,
Oct 30
I'm 99% sure I'd had it committed as a change.
,
Oct 30
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;
+}
,
Oct 30
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?
,
Oct 30
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.
,
Oct 30
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;
}
,
Oct 30
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.
,
Oct 30
I don't know anything about gitk. The workflow I usually use seems to work.
,
Nov 1
|
|||
►
Sign in to add a comment |
|||
Comment 1 by jpar...@google.com
, Oct 29Components: -Infra>Client Infra>Git