merge

git diff against previous

March 30, 2025 Linux No comments , , , ,

I’ve been using a simple home grown script (gitdiffc) to generate git diffs against the previous version for all files in a given commit.  It would run something like:

# git diff \
$(git log --pretty=format:%h -2 --reverse d86cc4b38db | tr "\n" " ")

The git log part, just gives two commit IDs. Example:

# git log --pretty=format:%h -2 --reverse d86cc4b38db
38aeb009b21
d86cc4b38db

I have a few files that I have to manually merge, as there are two many cherry-pick conflicts, so I was collecting information for that merge.  That included extracting the version that I would have wanted to cherry-pick, since :

git show d86cc4b38db:foo.cc > foo.cc.show

I also wanted a diff, of just that file, in the branch I am trying to pick from, but wasn’t sure how to get that easily without looking up the log, like I did in my ‘gitdiffc’ script that ran the log and diff command above.

I figured there had to be an easier way. Shout out to Grok, which pointed out that I can just use:

git diff d86cc4b38db^ d86cc4b38db -- foo.cc

This also means that I can simplify my ‘gitdiffc’ script so that it just runs:

# git diff d86cc4b38db^..d86cc4b38db

eliminating the nested git log command. That is simple enough that I don’t even need a script to remember how to do it. This should have been obvious, since I’ve used HEAD^ just like that so many times (i.e.: git reset HEAD^, to break up the last commit.)

Some random svn notes.

April 28, 2016 C/C++ development and debugging. , , , , , , , , ,

Pull

svn update

If there are conflicts, then an (e) edit option is available.  SVN isn’t smart enough to notice that resolving the conflict can be complete at edit completion, so you have to mark each such resolved change (r) resolved explicitly after invoking edit.

For unfathomable reasons, SVN (e)dit conflicts are shown in ‘diff -u’ output instead of ‘diff3 -m’.  I’m hoping that oddity can be confligured away.

svn status -u : if you mark a merge conflict as deferred, then this will show what all the contributors were.  In particular, you can construct a ‘diff3 -m’ command for such a deferred conflict, by running:

$ svn status -u | grep -A3 ^C
C            30427   lz_ios/lz_ios_srv/src/ios_config.c
?                    lz_ios/lz_ios_srv/src/ios_config.c.mine
?                    lz_ios/lz_ios_srv/src/ios_config.c.r30417
?                    lz_ios/lz_ios_srv/src/ios_config.c.r30427

From this you can run:

$ diff3 -m \
                    lz_ios/lz_ios_srv/src/ios_config.c.mine \
                    lz_ios/lz_ios_srv/src/ios_config.c.r30417 \
                    lz_ios/lz_ios_srv/src/ios_config.c.r30427 \
> lz_ios/lz_ios_srv/src/ios_config.c

After resolving the conflict, and updating the file, you must run:

svn resolve –accept=working foo.c # (say)

Merge branch

For a branch off of the project ‘foo’ :

svn up
svn merge --accept postpone ^/foo/trunk
svn commit 

Then resolve conflicts as above with ‘svn update’

Push (local branch, or local changes to trunk)

$ svn commit

Query stuff

svn diff, and svn log.

Cleanup state from failed update

When running over flaky wireless, my svn update’s failed a few times.  You have to run ‘svn cleanup’ to handle such a failure (but it tells you to do so).

Build tree root and repo info

‘svn info’ gives you useful information about the build tree you are in (the svn checkout).

List files and other info for a commit

svn log -v -r 30414

Commit selectively.

List the files:

svn ci -F ../../tools/svn-commit.tmp `cat c`