ryan-williams/git-helpers

git-copy-diffs: `rm`ing files on remote server sometimes fails; "Argument list too long"

ryan-williams opened this issue · 1 comments

Getting a failure trying to rm files when running git-unpack-and-apply-diffs on the remote:

$ gcd
Got remote demeter at host demeter. Pushing..
Counting objects: 51, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (31/31), done.
Writing objects: 100% (51/51), 4.03 KiB | 0 bytes/s, done.
Total 51 (delta 19), reused 0 (delta 0)
To demeter:c/guacamole
   017b610..e37265d  1.2command -> 1.2command
   017b610..4ca31c6  command -> command
Pushed!
script to run remotely: /Users/ryan/c/git-helpers/git-unpack-and-apply-diffs
Got current branch: 1.2command
Found existing files: tmp.git-unpack-and-apply-diffs,diffs.tar.gz. Overwrite? [Y/n]:
scp'ing tar file: scp /var/folders/m0/mj2x82p1527349z6mn8btgtr0000gn/T/tmp4rzLwj/diffs.tar.gz demeter:c/guacamole
diffs.tar.gz                                                                                                                                     100%  184     0.2KB/s   00:00
scp'ing remote script: scp /Users/ryan/c/git-helpers/git-unpack-and-apply-diffs demeter:c/guacamole/tmp.git-unpack-and-apply-diffs
git-unpack-and-apply-diffs                                                                                                                       100% 2370     2.3KB/s   00:00
remote_cmd: cd c/guacamole && ./tmp.git-unpack-and-apply-diffs "1.2command"
ssh cmd:
ssh demeter cd c/guacamole && ./tmp.git-unpack-and-apply-diffs "1.2command"

remote.. git-unpack-and-apply-diffs!
HEAD is now at e37265d Merge branch 'command' into 1.2command
Switched to branch '1.2command'
./tmp.git-unpack-and-apply-diffs: line 24: /bin/rm: Argument list too long
Removing /var/folders/m0/mj2x82p1527349z6mn8btgtr0000gn/T/tmp4rzLwj
Traceback (most recent call last):
  File "/Users/ryan/c/git-helpers/aliases/git-cd", line 189, in <module>
    subprocess.check_call(ssh_cmd)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 540, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['ssh', 'demeter', 'cd c/guacamole && ./tmp.git-unpack-and-apply-diffs "1.2command"']' returned non-zero exit status 1

This is mostly mitigated by f748a79, which adds the --directory flag to its call to git ls-files --other ..., to not iterate over every file in whole directories that should be rm'd.