tags:

views:

47

answers:

2

Hi, I develope on Windows at home and send my changes to the customer. Customer do not want to have any SCM installed, so I need to send files I've changed from last iteration. Currently I'm using Subversion with some kind of the automation by self-written batch, that is a mix of windows and GNU/unix utilities. The script looks into the given revisions, list what files are changed, removes duplication and get at the end a file of list.

@echo off
if (%3) == () goto usage
set TO_REVISION=HEAD
set PUSHNAME=%3-%1

svn log -v -q -r %2 %3 |  sed "s/^[ ^t]*[AM] \/[[:alnum:]_]*\/[[:alnum:]_]*\/\(.*\.[[:alnum:]_]*\)/tar --append --file=%PUSHNAME%.tar \1/" | sed "s/ (.*//g" | sort | uniq | grep -v "config.xml" >> %PUSHNAME%.bat
IF ERRORLEVEL 1 goto error
echo bzip2 %PUSHNAME%.tar>> %PUSHNAME%.bat
echo :: SVN REVISIONS :: %2>> %PUSHNAME%.bat
echo ... %PUSHNAME%.bat generated.
goto done

:usage
echo USAGE: %~nx0 push-file-name from[:to]-revision relative-or-absolute-path
echo See svn log -v -q -r [REV] to view repository log.
goto done

:error
echo ERROR! Check (if exists) output file %PUSHNAME%.bat
goto done

:done

The batch is not perfect but for me is OK. Now i decide to move to the Git. I've converted the subversion repository to the Git repo. But show stopper to me I cannot find the replace command for svn -v -q -r log in Git manual :-( I'm sure it should be, but after a days of searching I'd like to ask about help more experienced Git-Gurus.

Thank in advance for your minutes spent for my problem,

Oleg

A: 
git show HEAD HEAD^

This will show the last two commits of the current branch. For more options, see git show --help

N 1.1
`HEAD^` refers to parent of `HEAD`
N 1.1
git --version => git version 1.7.2.3. If I try C:\dev\pim>git show HEAD HEAD^ I'm getting (two times Enter key) (German Mehr is More)Mehr?Mehr?fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.Use '--' to separate paths from revisions
olegtaranenko
@oleg: Do `git branch`. It will show which branch is the current (one with the asterisk). Then replace `HEAD` with `<current branch>`. Anyways, `HEAD` should work. what does `cat .git/HEAD` output?
N 1.1
C:\dev\reckitt\srcgit\pim2>git branch log4net* master productionC:\dev\reckitt\srcgit\pim2>git show master master^Mehr?Mehr?fatal: ambiguous argument 'master': unknown revision or path not in the working tree.Use '--' to separate paths from revisionsC:\dev\reckitt\srcgit\pim2>cat .git/HEADref: refs/heads/master Though, I guess this is a clutter on my workstation. I'm using different installation of UnxUtil / Msysgit and may be it call some wrong...
olegtaranenko
git show HEAD~2 does work!
olegtaranenko
@oleg: `HEAD~2` is same as `HEAD^^` or grandparent of `HEAD` commit.
N 1.1
indeed, git show HEAD^^ does work, but git show HEAD^ requires some more input...
olegtaranenko
+1  A: 

I guess you're trying to get a list of files changed since some commit:

git diff-index <commit> --name-only

Will list all files changed since <commit> and only their names.

--name-only will save you trouble of sed'ing the name of files. Using --name-status instead gets you more familiar looking

A   debian/control 
M   debian/rules

output.

Tuminoid
final command is git diff-index HEAD~2 --name-status
olegtaranenko