What version are you running?
RBTools==1.0.2
What steps will reproduce the problem?
- Git clone from a repo and modify a file
- run git diff to get git_id_sha
- rbt diff --parent 'git_id_sha'
WARNING: Could not determine specific upstream remote to use for diffs. We recommend setting TRACKING_BRANCH in reviewboardrc to your nearest upstream remote branch.
CRITICAL: Failed to execute command: [u'git', u'rev-parse', u'5d727773ae7d199995590e777d786a39691ace4b^']What is the expected output? What do you see instead?
In RBTools 1.0.1, when you run "rbt diff --parent 'git_id_sha'", it gives the following ouput:
WARNING: Your working directory is not clean. Any changes which have not been committed to a branch will not be included in your review request.What operating system are you using?
Linux
Attach the debug out from the command.
Running: git rev-parse refs/heads/master
Running: git branch --remotes
Running: git config --get branch.6bc21db76d21841715217cde5b5da1f5889f06b0.remote
Command exited with rc 1: [u'git', u'config', u'--get', u'branch.6bc21db76d21841715217cde5b5da1f5889f06b0.remote']
Running: git remote
WARNING: Could not determine specific upstream remote to use for diffs. We recommend setting TRACKING_BRANCH in reviewboardrc to your nearest upstream remote branch.
Running: git rev-parse 6bc21db76d21841715217cde5b5da1f5889f06b0
Running: git rev-list 6bc21db76d21841715217cde5b5da1f5889f06b0 --not --remotes=originRunning: git rev-parse 5d727773ae7d199995590e777d786a39691ace4b^
Command exited with rc 128: [u'git', u'rev-parse', u'5d727773ae7d199995590e777d786a39691ace4b^']
fatal: ambiguous argument '5d727773ae7d199995590e777d786a39691ace4b^': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
5d727773ae7d199995590e777d786a39691ace4b^
Traceback (most recent call last):
File "/usr/local/bin/rbt", line 11, in <module>
sys.exit(main())
File "/usr/local/lib/python2.7/dist-packages/rbtools/commands/main.py", line 120, in main
command.run_from_argv([RB_MAIN, command_name] + args)
File "/usr/local/lib/python2.7/dist-packages/rbtools/commands/init.py", line 725, in run_from_argv
exit_code = self.main(args) or 0
File "/usr/local/lib/python2.7/dist-packages/rbtools/commands/diff.py", line 51, in main
revisions = tool.parse_revision_spec(args)
File "/usr/local/lib/python2.7/dist-packages/rbtools/clients/git.py", line 147, in parse_revision_spec
parent_ref, remote)
File "/usr/local/lib/python2.7/dist-packages/rbtools/clients/git.py", line 569, in _rev_list_youngest_remote_ancestor
youngest_remote_commit = self._rev_parse('%s^' % local_commit)[0]
File "/usr/local/lib/python2.7/dist-packages/rbtools/clients/git.py", line 537, in _rev_parse
revisions = self._execute([self.git, 'rev-parse'] + revisions)
File "/usr/local/lib/python2.7/dist-packages/rbtools/clients/git.py", line 1225, in _execute
return execute(cmdline, cwd=self._git_toplevel, args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/rbtools/utils/process.py", line 189, in execute
raise Exception('Failed to execute command: %s' % command)
Exception: Failed to execute command: [u'git', u'rev-parse', u'5d727773ae7d199995590e777d786a39691ace4b^']Please provide any additional information below.
In order to diagnose this, it would help to have the output of the following two commands (please upload the second as a file attachment):
git remote
git log --graph --pretty=oneline --all
-
- New + NeedInfo
PC:~/test_rbtools/rbtools$ git remote
originPC:~/test_rbtools/rbtools$ git log --graph --pretty=oneline --all
237829813e98f5ec993c66d84302546c4c46ea7d test
ecf67273a68199ff9e89d73884e3600dbcaedcf3 testing
6b9ccfb367c5f784ac120db2c7da9be26cfa1cc4 add testing file
523333759932242a161033bb8841fdf33661e3a0 Initial commitPC:~/test_rbtools/rbtools$ rbt diff --parent 237829813e98f5ec993c66d84302546c4c46ea7d
WARNING: Could not determine specific upstream remote to use for diffs. We recommend setting TRACKING_BRANCH in reviewboardrc to your nearest upstream remote branch.
CRITICAL: Failed to execute command: [u'git', u'rev-parse', u'523333759932242a161033bb8841fdf33661e3a0^']
I fixed an identical issue by modifying
_find_remote()
inclients/git.py
.The code eventually calls:
all_remotes = self._execute(['git', 'remote'], split_lines=True)
.split_lines=True
causesexecute()
to calldata.splitlines(True)
which preserves newlines. Then_find_remote()
runsif 'origin' in all_remotes:
. This fails (for me) because the contents ofall_remotes
is["origin\n"]
(note the trailing newline). Changing the if check to beif 'origin\n' in all_remotes:
fixes the issue for me. If that's the right way to fix this, then obviously the else block needs to returnall_remotes[0].strip()
to get rid of the newline if origin is not in the list.I didn't do anyting to figure out if there was something that should be changing upstream to prevent getting into this function in the first place. This code appears to be wrong, so I just stopped once this fixed the issue.