ldap-git-backup icon indicating copy to clipboard operation
ldap-git-backup copied to clipboard

Don't list changed files on the command line

Open kasimon opened this issue 8 years ago • 5 comments

For very large change sets, listing them on the command line exceeds the maximum command line length. This change lets git pick up the changed files instead.

Fixes #4

kasimon avatar Oct 20 '17 09:10 kasimon

I think this does not remove deleted entries from the git repository.

rda0 avatar Dec 21 '17 17:12 rda0

man git-add:

This adds, modifies, and removes index entries to match the working tree.

kasimon avatar Dec 22 '17 09:12 kasimon

The script does the following:

  • git ls-files *.ldif -> @files_before (store all existing *.ldif files in array)
  • dump ldap database -> @filelist (store ldif files from dump in array)
  • @files_before = @files_before - @filelist (will now only contain the files not in the database anymore)
  • git add @filelist (stage new/changed ldifs)
  • git rm @files_before (remove all ldifs which do not exist in LDAP anymore)

The last part with git rm removes the ldif files which are still in the working tree but not in the LDAP database anymore. If you just use git add -A these files will not be touched, because they did not change and they will also not be removed. Another side effect would be, that any files in the repository's tree would be staged and committed.

rda0 avatar Dec 22 '17 11:12 rda0

@rda0 Got it, thanks for the detailed explanation. So an xargs-like solution would be needed that splits up the command invocations if the resulting string exceeds a certain length.

kasimon avatar Jan 02 '18 14:01 kasimon

@kasimon You are welcome. Yes this would be one solution. Another solution, which I propose in #6, is to add the files in multiple chunks. I did not test the xargs-solution, but it may be interesting to compare the performance.

rda0 avatar Jan 04 '18 15:01 rda0