Re: [PATCH]: git-clang-format

2016-02-07 Thread Alexander Shukaev via cfe-commits

On 12/14/2015 10:03 PM, Alexander Shukaev wrote:

On 12/11/2015 04:40 PM, Daniel Jasper wrote:

Please submit patches to clang-format to reviews.llvm.org. Also, any
change
no matter how easy it is to deduce from the code itself deserves a proper
change description :-). Bullet points are fine.


Thanks for the quick reply.  I've submitted the patch for review [1] as
requested.  Just let me know if anything else is needed.

Regards,
Alexander

[1] http://reviews.llvm.org/D15465


Hello,

I am wondering whether I can expect this patch to be reviewed and 
included into the upcoming 3.8 release?  I didn't receive any feedback 
ever since it was submitted.  Apologies, I don't want to annoy anybody 
but seeing no reaction at all within a couple months feels rude.


Kind regards,
Alexander
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH]: git-clang-format

2016-02-08 Thread Alexander Shukaev via cfe-commits

On 02/08/2016 12:32 PM, Manuel Klimek wrote:

I believe you forgot to add cfe-commits as subscriber on the patch.

On Sun, Feb 7, 2016 at 12:51 PM Alexander Shukaev <
cl...@alexander.shukaev.name> wrote:


On 12/14/2015 10:03 PM, Alexander Shukaev wrote:

On 12/11/2015 04:40 PM, Daniel Jasper wrote:

Please submit patches to clang-format to reviews.llvm.org. Also, any
change
no matter how easy it is to deduce from the code itself deserves a

proper

change description :-). Bullet points are fine.


Thanks for the quick reply.  I've submitted the patch for review [1] as
requested.  Just let me know if anything else is needed.

Regards,
Alexander

[1] http://reviews.llvm.org/D15465


Hello,

I am wondering whether I can expect this patch to be reviewed and
included into the upcoming 3.8 release?  I didn't receive any feedback
ever since it was submitted.  Apologies, I don't want to annoy anybody
but seeing no reaction at all within a couple months feels rude.

Kind regards,
Alexander





Ah, I suspected something should be wrong with the submission...  Thanks 
for pointing this out.  Nevertheless, I'm sure that I've added key 
people as reviewers, so they should have had definitely received 
notifications about this patch...  I'm confused now.  Anyway, now I've 
added cfe-commits to subscribers.  I hope this patch still has a chance 
to hit 3.8.


Regards,
Alexander
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH]: git-clang-format

2015-12-11 Thread Alexander Shukaev via cfe-commits

Hello everyone,

Please, consider applying the attached patch or (at your option) a 
refined version of it upstream.  I'd be very excited to see it make into 
the upcoming 3.8 release.  The patch looks self-explanatory but in case 
any questions should arise, feel free to ask.  I can provide both 
rationale and use case examples to support it if needed.  In fact, we 
already use it extensively for Git 'pre-commit' hook to enforce code 
style conventions.


Looking forward to your response.  Thanks.

Kind regards,
Alexander
diff --git a/git-clang-format b/git-clang-format
index 0c45762..2ebd405 100755
--- a/git-clang-format
+++ b/git-clang-format
@@ -101,6 +101,8 @@ def main():
  help='allow changes to unstaged files')
   p.add_argument('-p', '--patch', action='store_true',
  help='select hunks interactively')
+  p.add_argument('-s', '--staged', action='store_true',
+ help='consider only staged lines')
   p.add_argument('-q', '--quiet', action='count', default=0,
  help='print less information')
   p.add_argument('--style',
@@ -141,7 +143,10 @@ def main():
   # The computed diff outputs absolute paths, so we must cd before accessing
   # those files.
   cd_to_toplevel()
-  old_tree = create_tree_from_workdir(changed_lines)
+  if opts.staged:
+old_tree = run_git_ls_files_and_save_to_tree(changed_lines)
+  else:
+old_tree = create_tree_from_workdir(changed_lines)
   new_tree = run_clang_format_and_save_to_tree(changed_lines,
binary=opts.binary,
style=opts.style)
@@ -260,7 +265,7 @@ def compute_diff(commit, files):
   The return value's `stdin` file object will produce a patch with the
   differences between the working directory and `commit`, filtered on `files`
   (if non-empty).  Zero context lines are used in the patch."""
-  cmd = ['git', 'diff-index', '-p', '-U0', commit, '--']
+  cmd = ['git', 'diff-index', '--cached', '-p', '-U0', commit, '--']
   cmd.extend(files)
   p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
   p.stdin.close()
@@ -317,6 +322,27 @@ def create_tree_from_workdir(filenames):
   return create_tree(filenames, '--stdin')
 
 
+def run_git_ls_files_and_save_to_tree(changed_lines):
+  """Run git ls-files and save the result to a git tree.
+
+  Returns the object ID (SHA-1) of the created tree."""
+  index_path = os.environ.get('GIT_INDEX_FILE')
+  def index_info_generator():
+for filename, line_ranges in changed_lines.iteritems():
+  old_index_path = os.environ.get('GIT_INDEX_FILE')
+  os.environ['GIT_INDEX_FILE'] = index_path
+  try:
+mode, id, stage, filename = run('git', 'ls-files', '--stage', '--',
+filename).split()
+yield '%s %s\t%s' % (mode, id, filename)
+  finally:
+if old_index_path is None:
+  del os.environ['GIT_INDEX_FILE']
+else:
+  os.environ['GIT_INDEX_FILE'] = old_index_path
+  return create_tree(index_info_generator(), '--index-info')
+
+
 def run_clang_format_and_save_to_tree(changed_lines, binary='clang-format',
   style=None):
   """Run clang-format on each file and save the result to a git tree.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH]: git-clang-format

2015-12-14 Thread Alexander Shukaev via cfe-commits

On 12/11/2015 04:40 PM, Daniel Jasper wrote:

Please submit patches to clang-format to reviews.llvm.org. Also, any change
no matter how easy it is to deduce from the code itself deserves a proper
change description :-). Bullet points are fine.


Thanks for the quick reply.  I've submitted the patch for review [1] as 
requested.  Just let me know if anything else is needed.


Regards,
Alexander

[1] http://reviews.llvm.org/D15465
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits