2

I have a long list of commits to make and, as such, would like to stagger the commits. So, when I do:

svn st | ack '^M'

I would like to commit these files only

Is this possible through the command line?

2
  • Just to clarify: you want to commit modified files only, and not those that were deleted, added, or replaced? Commented Apr 18, 2012 at 17:54
  • @malenkiy_scot Yes, I can confirm that I only want to commit modified files. Commented Apr 19, 2012 at 8:25

1 Answer 1

10

The xargs command is useful for this kind of thing.

Assuming you don't have any filenames containing space characters, you can do:

svn st | sed -n 's/^M//p' | xargs svn commit

If you do have space characters in filenames, the sed command becomes a little more complex, to add quotes around each filename:

svn st | sed -n 's/$/"/; s/^M */"/p' | xargs svn commit

(I'm not familiar with ack -- perhaps it could be also be used in place of sed in these examples)

Sign up to request clarification or add additional context in comments.

3 Comments

If not -u or -v options are specified, the number of characters before the start of filename is known (it's 8), so sed can be simplified: svn st | grep '^M' | sed 's/.\{8\}(.*)/\1/' | xargs svn ci
All depends on your definition of "simple", I suppose ;-)
Excellent, the first example with sed worked well. I tried using ack, which is my preferred tool of choice normally, but I couldn't get it working. Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.