New issue
Advanced search Search tips

Issue 780540 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Nov 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 2
Type: Bug

Blocking:
issue 780055



Sign in to add a comment

`git cl upload` fails when the commit message is long, even if `--message-file` is used

Project Member Reported by robertma@chromium.org, Nov 1 2017

Issue description

What steps will reproduce the problem?
1. Save a long commit message to a text file.
2. `git cl upload --message-file=<PATH TO THAT FILE>`

What is the expected result?
CL created successfully with the given message.

What happens instead?
Command fails with error "Argument list too long" (see traceback at the end).


*nix systems usually have a limit on the maximum length of arguments, which is usually worked around by taking long arguments through files or stdin.

In the case of `git cl upload`. If a long commit message is given on command line via `-m`, the command fails unsurprisingly. However, the `--message-file` doesn't work around the issue as one would expect. Under the hood, depot_tools still loads the message from the file and puts the content in an argument. See code:

https://cs.chromium.org/chromium/tools/depot_tools/git_cl.py?l=4963&rcl=47b67c426b1d7120803e09f570e1cca312b34249
https://cs.chromium.org/chromium/tools/depot_tools/git_cl.py?l=3008&rcl=47b67c426b1d7120803e09f570e1cca312b34249


Appendix.
Traceback (most recent call last):
  File "/usr/local/google/home/robertma/tools/depot_tools/git_cl.py", line 6132, in <module>
    sys.exit(main(sys.argv[1:]))
  File "/usr/local/google/home/robertma/tools/depot_tools/git_cl.py", line 6114, in main
    return dispatcher.execute(OptionParser(), argv)
  File "/usr/local/google/home/robertma/tools/depot_tools/subcommand.py", line 252, in execute
    return command(parser, args[1:])
  File "/usr/local/google/home/robertma/tools/depot_tools/git_cl.py", line 4976, in CMDupload
    return cl.CMDUpload(options, args, orig_args)
  File "/usr/local/google/home/robertma/tools/depot_tools/git_cl.py", line 1665, in CMDUpload
    ret = self.CMDUploadChange(options, git_diff_args, custom_cl_base, change)
  File "/usr/local/google/home/robertma/tools/depot_tools/git_cl.py", line 3008, in CMDUploadChange
    '-m', change_desc.description]).strip()
  File "/usr/local/google/home/robertma/tools/depot_tools/git_cl.py", line 136, in RunGit
    return RunCommand(['git'] + args, **kwargs)
  File "/usr/local/google/home/robertma/tools/depot_tools/git_cl.py", line 124, in RunCommand
    return subprocess2.check_output(args, shell=shell, **kwargs)
  File "/usr/local/google/home/robertma/tools/depot_tools/subprocess2.py", line 524, in check_output
    return check_call_out(args, stdout=PIPE, **kwargs)[0]
  File "/usr/local/google/home/robertma/tools/depot_tools/subprocess2.py", line 484, in check_call_out
    out, returncode = communicate(args, **kwargs)
  File "/usr/local/google/home/robertma/tools/depot_tools/subprocess2.py", line 458, in communicate
    proc = Popen(args, **kwargs)
  File "/usr/local/google/home/robertma/tools/depot_tools/subprocess2.py", line 262, in __init__
    % (str(e), kwargs.get('cwd'), args[0]))
OSError: Execution failed with error: [Errno 7] Argument list too long.
Check that None or git exist and have execution permission.
 
Blocking: 780055
Cc: aga...@chromium.org tandrii@chromium.org
Status: Available (was: Untriaged)
Good catch. In all circumstances, we should write the message to a file (regardless of whether the original user passed --message-file or not, since we modify the message we shouldn't re-use the exact same file) and then use the -F flag to commit-tree instead of the -m flag.
Owner: aga...@chromium.org
Status: Started (was: Available)
https://canary-chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/754003

still need to fix the tests
Project Member

Comment 5 by bugdroid1@chromium.org, Nov 6 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/tools/depot_tools/+/9a03ae0833f72d40b51d8be1b7b38486050768c3

commit 9a03ae0833f72d40b51d8be1b7b38486050768c3
Author: Aaron Gable <agable@chromium.org>
Date: Mon Nov 06 19:41:49 2017

git-cl-upload: write commit description to file

Bug:  780540 
Change-Id: I85bf40d8faa482786589f9031e34f364342c06dd
Reviewed-on: https://chromium-review.googlesource.com/754003
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
Commit-Queue: Aaron Gable <agable@chromium.org>

[modify] https://crrev.com/9a03ae0833f72d40b51d8be1b7b38486050768c3/tests/git_cl_test.py
[modify] https://crrev.com/9a03ae0833f72d40b51d8be1b7b38486050768c3/git_cl.py

Status: Fixed (was: Started)

Sign in to add a comment